Skip to main content
Use openai(modelId, config?) from @agentium/core. For a native speech session, see OpenAI voice adapters.

Setup

Factory

Save as openai-agent.ts and run with npx tsx openai-agent.ts. Model calls require account access and incur provider usage.

Supported models

The examples use gpt-6.1-sol for general work and gpt-6-luna for focused tasks. gpt-6-astra is the heavier reasoning/coding option. These choices were checked on October 4, 2026; see Example models and the OpenAI catalog. Agentium accepts a model ID string; acceptance by the constructor does not prove that the provider supports it or that your account has access.

Config

apiKey overrides OPENAI_API_KEY; baseURL points the SDK to an explicitly configured endpoint. A compatible gateway must support the API shape selected for that model, including Responses for GPT-6 tools.

Per-request API key override

The model execution configuration supports an apiKey override. Resolve per-user credentials through authenticated host configuration before passing them to execution. Do not expose unrestricted credential/endpoint selection through an unauthenticated route.

Reasoning

GPT-6 function-tool calls use Responses even if reasoning is disabled. For supported GPT-5 tool/reasoning combinations, v4 also selects Responses as needed. Other requests can use Chat Completions. The adapter preserves provider continuation items across tool rounds. The adapter omits unsupported temperature, topP, and stop fields for reasoning families. Select an effort supported by the model; the type’s full union is not a guarantee that every model accepts every value. See reasoning.

Structured outputs

Use an Agent output schema as shown in structured output. Tool argument schemas and final answer schemas serve different purposes. Validate application constraints after the result is parsed.

Multi-modal support

Image input uses the multimodal message contract. Audio, files, and image generation depend on the selected model and endpoint; a text-model change does not enable a specialized endpoint automatically.

Realtime / voice

Use OpenAIRealtimeProvider or OpenAIStreamingRecognizer for native voice or transcription. A GPT-6 text model is not a substitute for a realtime model.

Full example

Research harness supplies a real tool loop, evidence, explicit grants, budgets, and cleanup. Model recipes compare provider configurations.