Try Bifrost Enterprise free for 14 days.
Request access

[ Provider Guide ]

xAI Grok Provider on Bifrost

Bifrost routes xAI Grok models with OpenAI-compatible chat completions, text generation, and image generation. Vision-capable models support image URLs and base64-encoded images.

xAI Grok provider summary

xAI powers the Grok family of models. Bifrost delegates to the OpenAI implementation with standard parameter filtering, vision support, and reasoning on select models.

Key features:

  • Full OpenAI compatibility — chat, text completion, and responses
  • Vision support — image URLs and base64 for multimodal models
  • Streaming — Server-Sent Events with delta-based updates
  • Reasoning — extended thinking on grok-3-mini via reasoning_effort
  • Tool calling — function definitions and execution

Common xAI Grok model IDs used in Bifrost routes:

  • grok-3-20250415 (Latest)
  • grok-3-mini-20250415 (Efficient, reasoning enabled)
  • grok-2-vision-1212 (Vision)
PropertyDetails
DescriptionxAI's Grok models for chat, reasoning, vision, and image generation.
Provider route on Bifrostxai/<model>
Provider docxAI
API endpoint for providerhttps://api.x.ai
Supported endpoints/v1/chat/completions, /v1/responses, /v1/completions, /v1/images/generations, /v1/models

Supported operations

Embeddings, Speech, Transcriptions, Files, and Batch return UnsupportedOperationError. See Supported operations in Bifrost docs.

OperationNon-streamingStreamingUpstream endpoint
Chat CompletionsYesYes/v1/chat/completions
Responses APIYesYes/v1/responses
Text CompletionsYesYes/v1/completions
Image GenerationYes/v1/images/generations
List ModelsYes/v1/models
EmbeddingsNoNo-
Speech (TTS)NoNo-
Transcriptions (STT)NoNo-
FilesNoNo-
BatchNoNo-

Supported OpenAI parameters

Quick reference of OpenAI parameters accepted when routing through xAI Grok via Bifrost.

[
  "stream",
  "temperature",
  "top_p",
  "max_tokens",
  "max_completion_tokens",
  "stop",
  "tools",
  "tool_choice",
  "user",
  "reasoning",
  "response_format"
]

Supported xAI Grok models

Use the provider prefix xai/ in Bifrost model routes for deterministic provider targeting.

FamilyModel IDBifrost routeTypical usage
Grok 3grok-3-20250415xai/grok-3-20250415Latest model
Grok 3 Minigrok-3-mini-20250415xai/grok-3-mini-20250415Efficient variant
Grok 2 Visiongrok-2-vision-1212xai/grok-2-vision-1212Vision capabilities

API reference

OpenAI-compatible endpoints routed to xAI via Bifrost.

1) Chat Completions

Primary path at /v1/chat/completions. xAI supports standard OpenAI chat parameters. See Chat Completions in Bifrost docs and OpenAI Chat Completions.

Filtered parameters

ParameterReasonNotes
prompt_cache_keyNot supportedRemoved for xAI compatibility
verbosityAnthropic-specificRemoved for xAI compatibility
storeNot supportedRemoved for xAI compatibility
service_tierNot supportedRemoved for xAI compatibility

Reasoning support

grok-3-mini supports extended reasoning via reasoning_effort (e.g. high). Other Grok-3 and Grok-4 models error if this parameter is set. Bifrost converts the internal Reasoning structure to xAI's string format.

Vision support

Vision models accept image URLs, base64-encoded images, and multiple images per message.

curl -X POST http://localhost:8080/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "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://example.com/image.jpg"}}
      ]
    }]
  }'
{
  "model": "xai/grok-3-mini",
  "messages": [{"role": "user", "content": "Solve this step by step"}],
  "reasoning_effort": "high"
}

2) Responses API

Forwarded directly to /v1/responses (not chat fallback). Same parameters and message handling as Chat Completions. Full streaming support. See Responses API in Bifrost docs.

ResponsesRequest → /v1/responses → ResponsesResponse
curl -X POST http://localhost:8080/v1/responses \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-3-20250415",
    "input": "Hello",
    "max_output_tokens": 1024
  }'

3) Text Completions

Legacy format at /v1/completions. Supports streaming via stream: true. See Text Completions in Bifrost docs.

ParameterMappingNotes
promptDirect pass-through
max_tokensmax_tokens
temperatureDirect pass-through
top_pDirect pass-through
stopStop sequences
frequency_penaltyPenalty parameters
presence_penaltyPenalty parameters
curl -X POST http://localhost:8080/v1/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-3-20250415",
    "prompt": "Hello, my name is",
    "max_tokens": 50
  }'

4) Image Generation

OpenAI-compatible format at /v1/images/generations. Conversion matches OpenAI Image Generation. Responses unmarshal into BifrostImageGenerationResponse. Streaming not supported. See Image Generation in Bifrost docs.

quality, size, and style are not supported by xAI at this time.

curl -X POST http://localhost:8080/v1/images/generations \
  -H "Content-Type: application/json" \
  -d '{
    "model": "xai/grok-2-image",
    "prompt": "A serene mountain landscape at sunset",
    "n": 1
  }'

5) List Models

GET /v1/models — lists available xAI models with capabilities and context lengths. No request parameters required. See List Models in Bifrost docs.

curl http://localhost:8080/v1/models

Unsupported features

These operations are not offered by the upstream xAI API. Bifrost returns UnsupportedOperationError.

FeatureReason
EmbeddingsNot 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

Implementation caveats

CaveatImpactSeverity
Reasoning model-specificOnly grok-3-mini supports reasoning_effort; other Grok models errorHigh
Image generation parametersquality, size, style parameters not supportedLow
Vision limited to specific modelsOnly vision-capable models accept image contentMedium
Embeddings unsupportedEmbeddings operation returns UnsupportedOperationErrorLow

Authoritative references

[ BIFROST FEATURES ]

Open Source & Enterprise

Everything you need to run AI in production, from free open source to enterprise-grade features.

01 Governance

SAML support for SSO and Role-based access control and policy enforcement for team collaboration.

02 Adaptive Load Balancing

Automatically optimizes traffic distribution across provider keys and models based on real-time performance metrics.

03 Cluster Mode

High availability deployment with automatic failover and load balancing. Peer-to-peer clustering where every instance is equal.

04 Alerts

Real-time notifications for budget limits, failures, and performance issues on Email, Slack, PagerDuty, Teams, Webhook and more.

05 Log Exports

Export and analyze request logs, traces, and telemetry data from Bifrost with enterprise-grade data export capabilities for compliance, monitoring, and analytics.

06 Audit Logs

Comprehensive logging and audit trails for compliance and debugging.

07 Vault Support

Secure API key management with HashiCorp Vault, AWS Secrets Manager, Google Secret Manager, and Azure Key Vault integration.

08 VPC Deployment

Deploy Bifrost within your private cloud infrastructure with VPC isolation, custom networking, and enhanced security controls.

09 Guardrails

Automatically detect and block unsafe model outputs with real-time policy enforcement and content moderation across all agents.

[ SHIP RELIABLE AI ]

Try Bifrost Enterprise with a 14-day Free Trial

[quick setup]

Drop-in replacement for any AI SDK

Change just one line of code. Works with OpenAI, Anthropic, Vercel AI SDK, LangChain, and more.

1import os
2from anthropic import Anthropic
3
4anthropic = Anthropic(
5 api_key=os.environ.get("ANTHROPIC_API_KEY"),
6 base_url="https://<bifrost_url>/anthropic",
7)
8
9message = anthropic.messages.create(
10 model="claude-3-5-sonnet-20241022",
11 max_tokens=1024,
12 messages=[
13 {"role": "user", "content": "Hello, Claude"}
14 ]
15)
Drop in once, run everywhere.