ExAgent.Providers.OpenAI (ExAgent v0.2.0)

Copy Markdown View Source

OpenAI LLM provider.

Wraps the OpenAI chat completions API with automatic Req client configuration, Bearer token auth, and JSON encoding.

Example

provider = ExAgent.Providers.OpenAI.new(api_key: "sk-...")
ExAgent.Provider.chat(provider, messages)

Summary

Functions

Creates a new OpenAI provider with validated options and initialized Req client.

Types

t()

@type t() :: %ExAgent.Providers.OpenAI{
  api_key: String.t(),
  base_url: String.t(),
  max_tokens: integer() | nil,
  model: String.t(),
  req: Req.Request.t() | nil,
  system_prompt: String.t() | nil,
  temperature: float() | nil,
  tools: [ExAgent.Tool.t()]
}

Functions

new(opts)

@spec new(keyword()) :: t()

Creates a new OpenAI provider with validated options and initialized Req client.

Options

  • :api_key (required) - OpenAI API key
  • :model - Model name (default: "gpt-4o")
  • :base_url - API base URL (default: "https://api.openai.com/v1")
  • :system_prompt - System prompt to prepend to messages
  • :tools - List of ExAgent.Tool structs