{"id":18000134,"url":"https://github.com/dvcrn/ex_openai","last_synced_at":"2025-10-05T19:56:45.096Z","repository":{"id":106630126,"uuid":"609519256","full_name":"dvcrn/ex_openai","owner":"dvcrn","description":"Auto-generated Elixir SDK for OpenAI APIs with full typespecs, docs and streaming support","archived":false,"fork":false,"pushed_at":"2025-05-06T06:32:53.000Z","size":4479,"stargazers_count":93,"open_issues_count":2,"forks_count":30,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-23T13:18:13.172Z","etag":null,"topics":["elixir","openai"],"latest_commit_sha":null,"homepage":"","language":"Elixir","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dvcrn.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-04T12:29:04.000Z","updated_at":"2025-05-12T18:04:29.000Z","dependencies_parsed_at":"2024-04-02T01:28:14.409Z","dependency_job_id":"7c8f3f30-e4f5-47e8-a65e-b92b53123cc1","html_url":"https://github.com/dvcrn/ex_openai","commit_stats":{"total_commits":76,"total_committers":2,"mean_commits":38.0,"dds":"0.13157894736842102","last_synced_commit":"5765cdf8b3dd6404b49a99ab24eab5489a86439e"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"purl":"pkg:github/dvcrn/ex_openai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcrn%2Fex_openai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcrn%2Fex_openai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcrn%2Fex_openai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcrn%2Fex_openai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dvcrn","download_url":"https://codeload.github.com/dvcrn/ex_openai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dvcrn%2Fex_openai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278510918,"owners_count":25998997,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-05T02:00:06.059Z","response_time":54,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["elixir","openai"],"created_at":"2024-10-29T23:09:46.782Z","updated_at":"2025-10-05T19:56:45.084Z","avatar_url":"https://github.com/dvcrn.png","language":"Elixir","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Elixir SDK for OpenAI APIs\n\n[![Hex.pm Version](https://img.shields.io/hexpm/v/ex_openai)](https://hex.pm/packages/ex_openai)\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/ex_openai)\n[![Hex.pm Download Total](https://img.shields.io/hexpm/dt/ex_openai)](https://hex.pm/packages/ex_openai)\n\nExOpenAI is an (unofficial) Elixir SDK for interacting with the [OpenAI APIs](https://platform.openai.com/docs/api-reference/introduction). This SDK is fully auto-generated using [metaprogramming](https://elixirschool.com/en/lessons/advanced/metaprogramming/) and always reflects the latest state of the OpenAI API.\n\n## Features\n\n- Complete implementation of all OpenAI API endpoints\n- Auto-generated with strict typing and documentation\n- Elixir-style API with required arguments as function parameters and optional arguments as keyword lists\n- Support for streaming responses with SSE\n- Editor features: autocompletion, typechecking, and inline documentation\n- Support with OpenAI-compatible APIs (like OpenRouter)\n\n\u003cimg src=\"images/functiondocs.png\" width=\"500\" /\u003e\n\n\u003cimg src=\"images/diagnostics.png\" width=\"500\" /\u003e\n\n## Installation\n\nAdd **_:ex_openai_** as a dependency in your mix.exs file:\n\n```elixir\ndef deps do\n  [\n    {:ex_openai, \"~\u003e 1.8.0\"}\n  ]\nend\n```\n\n## Quick Start\n\n### Configuration\n\n```elixir\nimport Config\n\nconfig :ex_openai,\n  api_key: System.get_env(\"OPENAI_API_KEY\"),\n  organization_key: System.get_env(\"OPENAI_ORGANIZATION_KEY\"),\n  # Optional settings\n  base_url: System.get_env(\"OPENAI_API_URL\"),\n  http_options: [recv_timeout: 50_000],\n  http_headers: [{\"OpenAI-Beta\", \"assistants=v2\"}]\n```\n\n### Basic Usage\n\n```elixir\n# List available models\n{:ok, models} = ExOpenAI.Models.list_models()\n\n# Create a completion\n{:ok, completion} = ExOpenAI.Completions.create_completion(\"gpt-3.5-turbo-instruct\", \"The sky is\")\n\n# Chat completion\nmessages = [\n  %ExOpenAI.Components.ChatCompletionRequestUserMessage{role: :user, content: \"What is the capital of France?\"}\n]\n{:ok, response} = ExOpenAI.Chat.create_chat_completion(messages, \"gpt-4\")\n\n# Responses\n{:ok, response} = ExOpenAI.Responses.create_response(\n  \"Tell me a joke about programming\",\n  \"gpt-4o-mini\"\n)\n\n# Continue the conversation\n{:ok, follow_up} = ExOpenAI.Responses.create_response(\n  \"Explain why that joke is funny\",\n  \"gpt-4o-mini\",\n  previous_response_id: response.id\n)\n```\n\nMore examples in [Examples](docs/examples.md)\n\n## API Overview\n\nExOpenAI supports all OpenAI API endpoints, organized into logical modules:\n\n- **Assistants** - Create and manage assistants\n- **Audio** - Speech, transcription, and translation\n- **Chat** - Chat completions API\n- **Completions** - Text completion API\n- **Embeddings** - Vector embeddings\n- **Files** - File management\n- **Images** - Image generation and editing\n- **Models** - Model management\n- **Responses** - Stateful conversation API\n- **Threads** - Thread-based conversations\n- **Vector Stores** - Vector database operations\n\nFor detailed documentation on each module, see the [API Documentation](https://hexdocs.pm/ex_openai).\n\n## Advanced Usage\n\n### Streaming Responses\n\n```elixir\n# Using a callback function\ncallback = fn\n  :finish -\u003e IO.puts \"Done\"\n  {:data, data} -\u003e IO.puts \"Data: #{inspect(data)}\"\n  {:error, err} -\u003e IO.puts \"Error: #{inspect(err)}\"\nend\n\nExOpenAI.Completions.create_completion(\n  \"gpt-3.5-turbo-instruct\",\n  \"Tell me a story\",\n  stream: true,\n  stream_to: callback\n)\n```\n\nFor more advanced streaming options, see the [Streaming Guide](docs/streaming.md).\n\n### File Uploads\n\n```elixir\n# Simple file upload\nimage_data = File.read!(\"path/to/image.png\")\n{:ok, result} = ExOpenAI.Images.create_image_variation(image_data)\n\n# With filename information\naudio_data = File.read!(\"path/to/audio.wav\")\n{:ok, transcript} = ExOpenAI.Audio.create_transcription({\"audio.wav\", audio_data}, \"whisper-1\")\n```\n\n## Documentation\n\n- [Complete API Reference](https://hexdocs.pm/ex_openai)\n- [Explanation on codegen](docs/codegen.md)\n- [Streaming Guide](docs/streaming.md)\n- [Configuration Options](docs/configuration.md)\n- [Examples](docs/examples.md)\n\n## Contributing\n\nContributions are welcome! If you find a bug or want to add a feature, please open an issue or submit a PR.\n\nTo update the SDK when OpenAI changes their API:\n\n```bash\nmix update_openai_docs\n```\n\n## Projects Using ExOpenAI\n\n- [Elixir ChatGPT](https://github.com/dvcrn/elixir-chatgpt)\n- [FixMyJP](https://fixmyjp.d.sh)\n- [GPT Slack Bot](https://github.com/dvcrn/gpt-slack-bot)\n\n_Add yours with a PR!_\n\n## License\n\nAvailable as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvcrn%2Fex_openai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdvcrn%2Fex_openai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdvcrn%2Fex_openai/lists"}