OpenAI
Use OpenAI’s GPT-4o, GPT-4o-mini, GPT-4-turbo, and o1 models with Agentium through the unifiedModelProvider interface.
Setup
- Install
- Environment
Install the OpenAI SDK (required by Agentium for OpenAI support):
Factory
string
required
The OpenAI model identifier.
object
Optional configuration. See Config below.
Supported Models
Using a different OpenAI model
Using a different OpenAI model
Pass any valid OpenAI model ID to the factory. New models are supported as soon as the OpenAI API supports them.
Config
string
OpenAI API key. If omitted, uses
OPENAI_API_KEY environment variable.string
Custom API base URL. Use for Azure OpenAI, proxies, or self-hosted endpoints.
Example
Per-Request API Key Override
Override the API key for individual requests (e.g., multi-tenant apps):apiKey in RunOpts is passed through to the model’s generate() and stream() calls.
Realtime / Voice
For real-time voice agents, useopenaiRealtime() to create an OpenAI Realtime provider:
openaiRealtime() is a shorthand for new OpenAIRealtimeProvider(). It accepts the same config:
npm install ws
See the Voice Agents docs for full details.
Multi-Modal Support
OpenAI GPT-4o models support images, audio, and files as input.Images
Audio
Files
Files are sent using OpenAI’s native file input type. Both URLs and base64 data are supported:data: URIs for the API.
Reasoning Models (o-series)
OpenAI’s o-series models (o1, o3) have built-in chain-of-thought reasoning. Configure them via thereasoning config:
effort parameter controls how much computation the model spends on reasoning:
"low"— Quick answers, minimal reasoning"medium"— Balanced reasoning"high"— Maximum reasoning depth, best for complex problems
Reasoning models may not support system prompts or streaming depending on the version. Agentium handles these constraints automatically.
Structured Outputs
OpenAI supports strict structured output via JSON mode. When usingdefineTool with Zod schemas, Agentium automatically uses OpenAI’s strict mode for more reliable function calling:
strict: true, ensuring the model always returns valid, well-typed arguments.