openai.ex  by mgallo

Elixir SDK for OpenAI API

created 4 years ago
349 stars

Top 80.8% on sourcepulse

GitHubView on GitHub
1 Expert Loves This Project
Project Summary

This Elixir library provides a community-maintained wrapper for the OpenAI REST APIs, targeting Elixir developers who want to integrate OpenAI's language models and services into their applications. It offers a comprehensive interface to various OpenAI functionalities, including text generation, image manipulation, audio processing, and the newer Assistants API.

How It Works

The library leverages Elixir's concurrency and fault-tolerance features, built on top of the HTTPoison HTTP client. It maps OpenAI's REST endpoints to Elixir functions, handling request formatting, authentication, and response parsing. Configuration is managed via mix.exs or config.exs, allowing for API key management and custom HTTP options. Runtime configuration overrides are also supported for dynamic adjustments.

Quick Start & Requirements

  • Installation: Add :openai to your mix.exs dependencies.
  • Prerequisites: Elixir, OpenAI API key.
  • Configuration: Set api_key and optionally organization_key and beta parameters in config.exs.
  • Usage: Call functions like OpenAI.chat_completion/1 or OpenAI.images_generations/2.
  • Docs: https://github.com/mgallo/openai.ex

Highlighted Details

  • Supports a wide range of OpenAI APIs, including the latest Assistants API.
  • Allows runtime configuration overrides for flexibility.
  • Includes examples for streaming chat completions and handling image generation timeouts.
  • Provides aliases for deprecated OpenAI API endpoints for backward compatibility.

Maintenance & Community

The project is community-maintained, with a disclaimer about potential delays in addressing issues or pull requests due to the maintainer's other commitments. Alternative libraries are linked for users seeking more active development.

Licensing & Compatibility

  • License: MIT License.
  • Compatibility: Permissive MIT license allows for commercial use and integration into closed-source projects.

Limitations & Caveats

The README explicitly states that issue and PR response times may be delayed, and the library may not always reflect the latest API specifications. Some newer functionalities, like threads() and threads(params), are noted as undocumented by OpenAI at the time of writing.

Health Check
Last commit

1 year ago

Responsiveness

1 week

Pull Requests (30d)
0
Issues (30d)
0
Star History
10 stars in the last 90 days

Explore Similar Projects

Feedback? Help us improve.