xai
Package
Section titled “Package”@ai-sdk/xai
Factories
Section titled “Factories”AIProviders.xAI
Capabilities
Section titled “Capabilities”- Language
- Image
- Transcription
- Speech
- Video
- Files
Streaming transcription and current image options
Section titled “Streaming transcription and current image options”streamingTranscriptionModel(_:webSocketTransport:) uses an injectable WebSocket transport. Audio format, sample rate, VAD, partial/final utterances, multi-channel input, finish metadata and producer cancellation follow the published xAI streaming contract. opus is also accepted for batch transcription. The requested model ID is retained by transcription factories.
Image capabilities recognize grok-imagine-image-2.0; options add 1.5k resolution and auto quality. X Search permits up to 20 allowed/excluded handles. Portable reasoning max maps to the provider’s highest effort. Existing realtime sessions and Responses calls keep their separate native APIs.
xAI mirrors upstream 5.0.30: XAI_API_KEY, custom base URL and headers, versioned user-agent suffix, callable/language Responses default, chat/responses/image/video/files aliases, no-argument speech/speechModel and transcription/transcriptionModel aliases, Responses provider options and hosted tools with blocked-domain filters and complete unsupported-sampling warnings, Grok 4.6 xhigh reasoning and priority service-tier metadata, streamed/generated Responses image-generation calls with prompt and failure results, image generation/editing, Imagine Video 1.5 generation/edit/extend/reference modes with 1080p, reference voices, resilient polling, and terminal moderation/missing-URL errors, /tts speech generation with voice/language/output_format, timestamps, pronunciation replacements, trace/usage metadata, and provider options, /stt multipart batch transcription with options and word segments, Files API provider references, response metadata, and xAI error schema. Responses Batch uploads requests, forwards callback URLs, paginates durable results, preserves full content/counts, and isolates provider errors or cancellations per item; current parity also preserves complete raw usage, web-search action data, encoded follow-up identifiers, dot-segment-safe IDs, and typed stream failures. The provider-neutral Realtime V4 contract and duplex session are implemented with xAI ephemeral-secret creation, expiry metadata, authenticated WebSocket configuration, session/audio/text/tool/custom event serialization and parsing, pre-open queuing, health replies, cancellation, and close metadata. Google realtime adapters, browser WebRTC, ProviderV4 type names, ESM-only packaging, Node 22 engines, and workflow serialization helpers remain deferred or JS-only concerns. The 4.0.54 pass adds complete Files V4 metadata/download/delete and cancellable streaming uploads with expiry validation, plus Batch tool content, input-file expiry/metadata, final-assistant finish data, and raw provider finish reasons. The 2026-09-20 pass aligns Responses schema and batch behavior to xAI 5 while retaining chat as a legacy source-compatible Swift shim; new code should use Responses. The 2026-09-27 pass adds current Responses options and Imagine Video 1.5 storage, keyframe, last-frame, and audio controls; image or audio references select reference-to-video even alongside frame images, with a combined three-item voice and audio-reference limit. File/mask image capabilities are now exposed as async Bool? getters; unrecognized models remain unknown. The 2026-10-11 pass: Streaming transcription supports model selection, Opus/VAD controls, interim/final multi-channel reconstruction and producer cleanup over native duplex WebSockets. Imagine Image 2.0 accepts files, 1.5k resolution and auto quality; X search allows 20 handles.
Factory argument requirements are defined by the public Swift factory signatures. Use Public symbols when you need the exact initializer or factory declaration.
Return to the provider matrix.