Providers

First-class model packs, custom compatible endpoints, the registry, and reasoning translation.

Every provider implements one protocol:

public protocol LanguageModel: Sendable {
  var provider: String { get }
  var modelID: String { get }
  func stream(_ request: LanguageModelRequest) async throws
    -> AsyncThrowingStream<StreamPart, Error>
}

Higher-level functions are built on this spec, so a provider swap never touches your feature code.

Native packs

Each pack speaks its provider's real wire, mirroring the @ai-sdk/* package family. Where upstream is native, the port is native too; no lowest-common-denominator shims.

ProviderNotes
OpenAIModelResponses API by default, .chat for chat completions; reasoning-model rules
AnthropicModelMessages API; thinking, tool use, forced-tool JSON mode
GoogleModelNative Gemini wire; thinking levels and budgets
GoogleVertexModelExpress-mode keys or bearer tokens
AzureOpenAIProviderDeployment-based routing
BedrockModelConverse over AWS event stream binary framing; API-key auth
XaiModelResponses API default, typed SearchParameters, .chat legacy
GroqModelReasoning deltas, x_groq usage envelope, cached tokens
DeepSeekModelreasoning_content, cache-hit accounting
MistralModel, PerplexityModel, CohereModelNative wires, citations as sources
FoundationModelsModelOn-device models; no upstream analog

Keys come from each provider's conventional environment variable (OPENAI_API_KEY, ANTHROPIC_API_KEY, XAI_API_KEY, ...) or an explicit apiKey: argument. baseURL includes the version path, matching the AI SDK's URL semantics, so gateways and proxies drop in cleanly.

First-class compatible providers

Providers that share the OpenAI chat-completions wire still have their own model types with the right URLs and environment keys:

let together = TogetherAIModel("MiniMaxAI/MiniMax-M3")
let local = OllamaModel("gemma4")

Together, Fireworks, Cerebras, OpenRouter, DeepInfra, Baseten, Vercel (v0), Gateway, Ollama, LM Studio, and Sarvam (Indic chat) are first-class model packs. OpenAICompatibleProvider is the general initializer for custom gateways and anything else that speaks the chat-completions wire. The compatibility page has every endpoint and environment variable.

Media and retrieval models

Non-chat capabilities have their own focused protocols and first-class model types. They do not need to be wrapped as language providers:

CapabilityProtocolProviders
EmbeddingsEmbeddingModelOpenAI, Cohere, compatible endpoints
RerankingRerankingModelCohere
ImagesImageModelOpenAI, fal, Luma, Replicate
SpeechSpeechModelOpenAI, ElevenLabs, LMNT, Hume, Deepgram, Sarvam
TranscriptionTranscriptionModelOpenAI, ElevenLabs, Deepgram, AssemblyAI, Rev.ai, Gladia, Sarvam
VideoVideoModelxAI, Luma
RealtimeRealtimeModelOpenAI, Google, xAI

The media provider index links every dedicated provider page.

The registry and custom providers

ProviderRegistry resolves "provider:model-id" strings; customProvider publishes friendly aliases with settings baked in and falls back to a wrapped provider for unknown ids:

let openai = ProviderRegistry.Provider { OpenAIModel($0) }
let custom = customProvider(
  languageModels: [
    "fast": OpenAIModel("gpt-5.6-luna"),
    "smart": wrapLanguageModel(model: OpenAIModel("gpt-5.6-sol"), middleware: [.extractReasoning()])
  ],
  fallback: openai
)
let registry = ProviderRegistry(providers: ["openai": custom])
let model = try registry.languageModel("openai:fast")

Live search on xAI

Grok's server-side search is a typed option, not a raw JSON blob:

let search = XaiModel.SearchParameters(
  mode: .auto,
  returnCitations: true,
  sources: [.web(), .x(), .news()]
)

let result = try await generateText(
  model: XaiModel("grok-4.5"),
  prompt: "What happened in AI this week?",
  providerOptions: search.providerOptions
)
print(result.sources)   // citations from the search

The full surface: mode (.auto, .on, .off), returnCitations, a fromDate/toDate window (YYYY-MM-DD), maxSearchResults, and per-source filters — .web(country:excludedWebsites:allowedWebsites:safeSearch:), .x(includedHandles:excludedHandles:postFavoriteCount:postViewCount:), .news(country:excludedWebsites:safeSearch:). It serializes to xAI's search_parameters body field exactly.

Sources and citations

Search-backed providers (Perplexity and Cohere citations, OpenAI and xAI url annotations) surface as StreamPart.source and collect on result.sources.

Per-provider pages

Setup, features, and the models each pack special-cases — plus the compatibility matrix for the cross-provider view.

OpenAI

Responses + chat, embeddings, images, speech, realtime.

Anthropic

Adaptive thinking tiers, files and skills, caching.

Google

Gemini, Vertex routing, Gemini Live.

Azure OpenAI

Deployment-based routing.

Amazon Bedrock

Converse over event streams, API-key auth.

xAI

Grok, typed live search, video, realtime.

Groq

Fast open models, reasoning deltas.

DeepSeek

reasoning_content streaming.

Mistral

Chat wire plus a binary reasoning knob.

Perplexity

Search-grounded answers with citations.

Cohere

Command models, embeddings, reranking.

Together AI

Hosted open models through a dedicated pack.

Fireworks

Fast inference with reasoning support.

Cerebras

Dedicated Cerebras inference pack.

OpenRouter

One model type for OpenRouter's catalog.

DeepInfra

Chat completions at DeepInfra's OpenAI endpoint.

Baseten

Call hosted model deployments.

Vercel

Generate through the v0 endpoint.

AI Gateway

Route provider-qualified models through AI Gateway.

Sarvam

Indic chat, speech, and transcription.

fal

Image generation across fal-hosted models.

Luma

Dream Machine image and video generation.

Replicate

Image generation with Replicate-hosted models.

ElevenLabs

Speech synthesis and transcription.

LMNT

Text-to-speech with LMNT voices.

Hume

Expressive text-to-speech.

Deepgram

Aura speech and Nova transcription.

AssemblyAI

Asynchronous transcription behind one await.

Rev.ai

Asynchronous speech-to-text jobs.

Gladia

Prerecorded-audio transcription.

Ollama

Run local Ollama models.

LM Studio

Connect to LM Studio's local server.

Custom compatible

Configure a custom chat-completions endpoint.

Media provider index

Compare every image, speech, transcription, and video pack.