Mojentic.LLM.Gateways.OpenAI (Mojentic v1.2.0)

Copy Markdown View Source

Gateway for OpenAI LLM service.

This gateway provides access to OpenAI's API, supporting text generation, structured output, tool calling, streaming, and embeddings.

Configuration

Set environment variables to configure the gateway:

export OPENAI_API_KEY=sk-...
export OPENAI_API_ENDPOINT=https://api.openai.com/v1  # optional

Examples

alias Mojentic.LLM.{Broker, Message}
alias Mojentic.LLM.Gateways.OpenAI

broker = Broker.new("gpt-4", OpenAI)
messages = [Message.user("Hello!")]
{:ok, response} = Broker.generate(broker, messages)