Skip to main content

Overview

xAI is an OpenAI-compatible provider powering the Grok family of models. Bifrost delegates to the OpenAI implementation with standard parameter filtering. Key features:
  • Full OpenAI compatibility - Chat, text completion, and responses
  • Vision support - Image URLs and base64 encoding for multimodal models
  • Streaming support - Server-Sent Events with delta-based updates
  • Reasoning support - Extended thinking for Grok reasoning models
  • Tool calling - Complete function definition and execution
  • Parameter filtering - Removes unsupported OpenAI-specific fields

Supported Operations

OperationNon-StreamingStreamingEndpoint
Chat Completions/v1/chat/completions
Responses API/v1/responses
Text Completions/v1/completions
List Models-/v1/models
Embeddings-
Speech (TTS)-
Transcriptions (STT)-
Files-
Batch-
Unsupported Operations (❌): Embeddings, Speech, Transcriptions, Files, and Batch are not supported by the upstream xAI API. These return UnsupportedOperationError.

1. Chat Completions

Request Parameters

xAI supports all standard OpenAI chat completion parameters. For full parameter reference and behavior, see OpenAI Chat Completions.

Filtered Parameters

Removed for xAI compatibility:
  • prompt_cache_key - Not supported
  • verbosity - Anthropic-specific
  • store - Not supported
  • service_tier - Not supported

Reasoning Support

xAI’s grok-3-mini model supports extended reasoning via the standard reasoning_effort field:
{
  "model": "xai/grok-3-mini",
  "messages": [...],
  "reasoning_effort": "high"
}
Model-Specific Feature: The reasoning_effort parameter is only supported by grok-3-mini. Other Grok-3 and Grok-4 models will return an error if this parameter is specified.
Bifrost converts from the internal Reasoning structure to xAI’s reasoning_effort string format.

Vision Support

xAI vision models support both image URLs and base64-encoded images:
{
  "model": "xai/grok-2-vision-1212",
  "messages": [{
    "role": "user",
    "content": [
      {"type": "text", "text": "What is in this image?"},
      {"type": "image_url", "image_url": {"url": "https://..."}}
    ]
  }]
}
Supported Image Formats:
  • ✅ Image URLs
  • ✅ Base64-encoded images
  • ✅ Multiple images per message
xAI supports all standard OpenAI message types, tools, responses, and streaming formats. For details on message handling, tool conversion, responses, and streaming, refer to OpenAI Chat Completions.

2. Responses API

xAI’s Responses API is forwarded directly to /v1/responses:
ResponsesRequest → /v1/responses → ResponsesResponse
Same parameter support and message handling as Chat Completions. Full streaming support available.

3. Text Completions

xAI supports legacy text completion format:
ParameterMapping
promptDirect pass-through
max_tokensmax_tokens
temperature, top_pDirect pass-through
stopStop sequences
frequency_penalty, presence_penaltyPenalty parameters
Streaming support available via stream: true.

4. List Models

Lists available xAI models with their capabilities and context lengths.

Unsupported Features

FeatureReason
EmbeddingNot offered by xAI API
Speech/TTSNot offered by xAI API
Transcription/STTNot offered by xAI API
Batch OperationsNot offered by xAI API
File ManagementNot offered by xAI API