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 wire

Key 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.delta arrives as .reasoningDelta).
  • URL citations surface as StreamPart.source and source-url parts in chat UIs.
  • usage.cachedInputTokens reports prompt-cache hits.
  • Built-in Responses tools have typed builders under OpenAIModel.Tools: webSearch, webSearchPreview, fileSearch(vectorStoreIds:), codeInterpreter, and computerUse(displayWidth:displayHeight:environment:). Drop them in tools:; 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_logprobs via providerOptions) collect on result.providerMetadata["openai"]["logprobs"], on both the Responses and chat wires.
  • Other Responses knobs (store, instructions, include, previous_response_id, max_turns) pass through providerOptions, merged at the top level (nested objects like text and reasoning merge rather than clobber, so text.verbosity coexists 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 modelso1*, o3*, o4-mini*, and gpt-5* (except gpt-5-chat*): the reasoning parameter maps to reasoning.effort with an automatic detailed summary, and sampling knobs are dropped where those models reject them.
  • gpt-5.1 through gpt-5.6 — accept temperature/topP again when reasoning effort is none.

Current lineup

Snapshot from July 2026; new ids work the day OpenAI ships them.

ModelNotes
gpt-5.6-sol / gpt-5.6-terra / gpt-5.6-lunaNewest family (July 2026): Sol is the flagship, Terra the balanced tier, Luna the fast one
gpt-5.5, gpt-5.5-proApril 2026
gpt-5.4, -mini, -nano, -proMarch 2026 workhorses
gpt-5.3-codex, gpt-5.2-codexCode-tuned
gpt-5.3-chat, gpt-5.2-chatNon-reasoning chat variants
gpt-5.2, gpt-5.1-thinking, gpt-5.1-instantLate 2025
gpt-realtime-2.1, gpt-realtime-miniRealtime voice
gpt-image-2, gpt-image-1.5, gpt-image-1-miniImage generation and edits
text-embedding-3-large, text-embedding-3-smallEmbeddings
whisper-1, gpt-4o-mini-ttsTranscription and speech

Beyond text

SurfaceEntry point
EmbeddingsOpenAIEmbeddingModel("text-embedding-3-small")
Images (generate + edit)OpenAIImageModel("gpt-image-2")
SpeechOpenAISpeechModel("gpt-4o-mini-tts")
TranscriptionOpenAITranscriptionModel("whisper-1")
Realtime voiceOpenAIRealtimeModel("gpt-realtime")
FilesOpenAIFiles().upload(...)
VideoOpenAIVideoModel("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 of file_search: create with expiry, attach and detach files, and search(_:query:) with filters and query rewriting.
  • OpenAIBatchClient, OpenAIContainersClient, and OpenAIModerationsClient (returns flagged plus the flagged category names).