API compatibility - 8 documented limits
xAI (Grok) API compatibility
xAI documents an OpenAI-compatible API at https://api.x.ai/v1 (responses, chat/completions, images/generations, models, files and batches). Its Anthropic SDK compatibility is deprecated. The docs list 8 limitations: 7 for the OpenAI-compatible layer and 1 for the Anthropic-compatible layer.
Verified against xAI's own documentation. Not documented means the docs read that day do not say; it never means No.
Compare every provider in the API compatibility matrix.
OpenAI-compatible API
Supportedhttps://api.x.ai/v1- Endpoints
- responses
- chat/completions
- images/generations
- models
- files
- batches
- Auth
- Authorization: Bearer $XAI_API_KEY
- Regional and alternate URLs
- Global
https:// api. x. ai/ v1 - US
https:// us. api. x. ai/ v1
- Global
- Notes
- Docs now brand the API as SpaceXSI; the host is still api.x.ai. Responses is the primary endpoint; Chat Completions is documented as legacy. The US regional endpoint (https://us.api.x.ai/v1) currently serves only grok-4.7 and grok-4.6, no image/video/voice APIs, and costs 10% more.
From the docs
client = OpenAI( api_key="<YOUR_XAI_API_KEY_HERE>", base_url="https://api.x.ai/v1", )
Anthropic-compatible API
DeprecatedDeprecated. xAI still lists the endpoint under its legacy APIs, but its docs say the Anthropic SDK compatibility is fully deprecated.
- Notes
- POST /v1/messages (and legacy POST /v1/complete) are still listed under Legacy & Deprecated, described as compatible with the Anthropic API, but the docs say the Anthropic SDK compatibility is fully deprecated and point to the Responses API or gRPC.
From the docs
Deprecated: The Anthropic SDK compatibility is fully deprecated. Please migrate to the Responses API or the gRPC API.
Documented limitations
Parameters, content types and features xAI (Grok)'s docs say its compatibility layers ignore, reject or change, each with the line it comes from. A layer with nothing listed may still differ in ways the docs do not spell out.
OpenAI-compatible layer7
Chat Completions is legacy
Chat Completions is offered as a legacy endpoint.
docs.x.ai/developers/model-capabilities/legacy/chat-completions.md logit_bias unsupported
logit_bias: "(Unsupported) A JSON object that maps tokens (specified by their token ID in the tokenizer) to an associated bias value from -100 to 100."
docs.x.ai/developers/rest-api-reference/inference/chat-completions.md logprobs / top_logprobs silently ignored on grok-4.20 and newer
Not supported by models
grok-4.20and newer; the field will be silently ignored if set.docs.x.ai/developers/rest-api-reference/inference/chat-completions.md frequency_penalty, stop not supported by reasoning models
stop: "(Not supported by reasoning models) Up to 4 sequences where the API will stop generating further tokens."; frequency_penalty: "(Not supported by reasoning models) Number between -2.0 and 2.0."
docs.x.ai/developers/rest-api-reference/inference/chat-completions.md presence_penalty not supported by grok-3 and reasoning models
presence_penalty: "(Not supported by
grok-3and reasoning models) Number between -2.0 and 2.0."docs.x.ai/developers/rest-api-reference/inference/chat-completions.md max_tokens deprecated in favor of max_completion_tokens
max_tokens: "[DEPRECATED] The maximum number of tokens that can be generated in the chat completion. Deprecated in favor of
max_completion_tokens."docs.x.ai/developers/rest-api-reference/inference/chat-completions.md only function tools on chat completions
Currently, only functions are supported as a tool.
docs.x.ai/developers/rest-api-reference/inference/chat-completions.md
Anthropic-compatible layer1
top_k unsupported on deprecated /v1/messages
top_k: "(Unsupported) When generating next tokens, randomly selecting the next token from the k most likely options."
docs.x.ai/developers/rest-api-reference/inference/legacy.md
Example from xAI (Grok)'s docs
Copied verbatim from the provider's documentation, placeholders included.
from openai import OpenAI
client = OpenAI(
api_key="<YOUR_XAI_API_KEY_HERE>",
base_url="https://api.x.ai/v1",
)
response = client.responses.create(
model="grok-4.7",
input="Fix this function and explain the bug: function median(a){a.sort();return a[a.length/2]}",
)More on xAI (Grok)
Newsletter
Know when a provider changes its API
One email per week. New models, new endpoints and the compatibility changes that break a base URL, and what they mean for your stack.