OpenAI
Responses API by default, chat completions when you ask, plus embeddings, images, speech, transcription, and realtime.
let model = OpenAIModel("gpt-5.6-sol") // Responses API
let chat = OpenAIModel.chat("gpt-5.6-terra") // chat completions wireKey from OPENAI_API_KEY; base URL from OPENAI_BASE_URL or
https://api.openai.com/v1. organization: and project: become the
matching request headers.
Features
- Tools, structured output (JSON schema mode), vision, and streamed
reasoning summaries (
response.reasoning_summary_text.deltaarrives as.reasoningDelta). - URL citations surface as
StreamPart.sourceand source-url parts in chat UIs. usage.cachedInputTokensreports prompt-cache hits.- Built-in Responses tools have typed builders under
OpenAIModel.Tools:webSearch,webSearchPreview,fileSearch(vectorStoreIds:),codeInterpreter, andcomputerUse(displayWidth:displayHeight:environment:). Drop them intools:; the calls and results stream back as provider-executed parts and citations as.source:
let result = try await generateText(
model: OpenAIModel("gpt-5.6-sol"),
prompt: "What happened in tech today?",
tools: [OpenAIModel.Tools.webSearch()]
)
print(result.sources.map(\.url))code_interpreter, image_generation, and mcp calls added through
providerOptions surface the same way — each as a provider-executed
.toolCall plus its .toolResult. A model refusal arrives as text and
finishes on .contentFilter.
- Token logprobs (request them with
logprobs/top_logprobsviaproviderOptions) collect onresult.providerMetadata["openai"]["logprobs"], on both the Responses and chat wires. - Other Responses knobs (
store,instructions,include,previous_response_id,max_turns) pass throughproviderOptions, merged at the top level (nested objects liketextandreasoningmerge rather than clobber, sotext.verbositycoexists with a structured-output format).
Response lifecycle
store: true and background: true responses are managed with
OpenAIResponsesClient:
let client = OpenAIResponsesClient()
let tokens = try await client.countInputTokens(
for: LanguageModelRequest(messages: [.user("How many tokens is this?")]),
modelID: "gpt-5.6-sol"
) // POST /v1/responses/input_tokens
let response = try await client.retrieve("resp_123", include: ["reasoning.encrypted_content"])
let items = try await client.listInputItems("resp_123", limit: 20)
try await client.cancel("resp_123") // background responses
try await client.compact("resp_123") // shrink stored context
try await client.delete("resp_123")Models
Any id the API serves works. The library special-cases:
- Reasoning models —
o1*,o3*,o4-mini*, andgpt-5*(exceptgpt-5-chat*): thereasoningparameter maps toreasoning.effortwith an automatic detailed summary, and sampling knobs are dropped where those models reject them. gpt-5.1throughgpt-5.6— accepttemperature/topPagain when reasoning effort isnone.
Current lineup
Snapshot from July 2026; new ids work the day OpenAI ships them.
| Model | Notes |
|---|---|
gpt-5.6-sol / gpt-5.6-terra / gpt-5.6-luna | Newest family (July 2026): Sol is the flagship, Terra the balanced tier, Luna the fast one |
gpt-5.5, gpt-5.5-pro | April 2026 |
gpt-5.4, -mini, -nano, -pro | March 2026 workhorses |
gpt-5.3-codex, gpt-5.2-codex | Code-tuned |
gpt-5.3-chat, gpt-5.2-chat | Non-reasoning chat variants |
gpt-5.2, gpt-5.1-thinking, gpt-5.1-instant | Late 2025 |
gpt-realtime-2.1, gpt-realtime-mini | Realtime voice |
gpt-image-2, gpt-image-1.5, gpt-image-1-mini | Image generation and edits |
text-embedding-3-large, text-embedding-3-small | Embeddings |
whisper-1, gpt-4o-mini-tts | Transcription and speech |
Beyond text
| Surface | Entry point |
|---|---|
| Embeddings | OpenAIEmbeddingModel("text-embedding-3-small") |
| Images (generate + edit) | OpenAIImageModel("gpt-image-2") |
| Speech | OpenAISpeechModel("gpt-4o-mini-tts") |
| Transcription | OpenAITranscriptionModel("whisper-1") |
| Realtime voice | OpenAIRealtimeModel("gpt-realtime") |
| Files | OpenAIFiles().upload(...) |
| Video | OpenAIVideoModel("sora-2") — create, poll, download, remix |
Multi-agent
GPT-5.6 models can spawn and coordinate their own subagent tree inside a single Responses call:
let model = OpenAIModel(
"gpt-5.6-sol",
multiAgent: OpenAIModel.MultiAgent(maxConcurrentSubagents: 3)
)
let review = try await generateText(
model: model,
prompt: "Review this diff with three agents: correctness, security, and missing tests.",
tools: [readFile]
)Setting multiAgent: adds multi_agent to the request and the
responses_multi_agent=v1 beta header. The root agent (/root) spawns
subagents (/root/reviewer, /root/reviewer/tester, …) and synthesizes the
final answer; maxConcurrentSubagents caps active turns across the whole
tree, and defaults to OpenAI's 3.
The six hosted coordination actions — spawn, send message, follow-up task,
wait, interrupt, and list — arrive as multi_agent_call items. Your app
must not execute them, so they surface as provider metadata
(result.providerMetadata["openai"]["multiAgentCall"]) rather than tool
calls. Ordinary function calls from any agent in the tree still run through
the normal tool loop.
Platform APIs
OpenAIConversationsClient— the Conversations API: create (from[Message]or raw items), get, update metadata, list/add/delete items.OpenAIVectorStoresClient— the store side offile_search: create with expiry, attach and detach files, andsearch(_:query:)with filters and query rewriting.OpenAIBatchClient,OpenAIContainersClient, andOpenAIModerationsClient(returnsflaggedplus the flagged category names).