Skip to Content
ModelsGrok

Grok family

xAI’s Grok models, including the reasoning models Grok 4.7, 4.6, 4.5, and 4.3, and the non-reasoning models Grok 4.1 Fast and 4.20. Called through the OpenAI-compatible API.

Common tasks

Models

For the full model list and live prices, see the models page . Model IDs have the prefix x-ai/, which can be omitted.

Common model IDs (copy them exactly)
Grok 4.7x-ai/grok-4.7Reasoning model, 500K context
Grok 4.1 Fastx-ai/grok-4.1-fastNon-reasoning, 2M context, image support
TypeModelsDescription
Reasoning modelsGrok 4.7, 4.6, 4.5Always reason and take longer; 500K context, text only
Reasoning modelGrok 4.31M context, supports image input
Non-reasoning modelsGrok 4.1 Fast, 4.20Fast responses; 2M context, supports image input

Endpoint support

EndpointSupported models
Chat Completions /v1/chat/completionsAll
Responses /v1/responsesGrok 4.3, 4.20, 4.1 Fast
Anthropic native APIGrok 4.3 only; others return protocol_not_supported

Grok models are provided by xAI directly (grok), and some models also have Azure AI Foundry as a provider.

Examples

grok_basic.py
import os from openai import OpenAI client = OpenAI(base_url="https://api.ofox.ai/v1", api_key=os.environ["OFOX_API_KEY"]) resp = client.chat.completions.create( model="x-ai/grok-4.7", reasoning_effort="low", messages=[{"role": "user", "content": "Explain idempotency in one sentence."}], ) print(resp.choices[0].message.content) print("Reasoning tokens:", resp.usage.completion_tokens_details.reasoning_tokens)

Reasoning

Key pointGrok 4.7, 4.6, and 4.5 always reason, and complex questions may take several minutes. Use reasoning_effort: low to reduce the amount of reasoning, or switch to the non-reasoning Grok 4.1 Fast.
ModelReasoningreasoning_effort
Grok 4.7, 4.6, 4.5Always reasonlow significantly reduces reasoning
Grok 4.3Always reasons; reasoning content is not returnedAccepted
Grok 4.1 Fast, 4.20No reasoningReturns 400 on Grok 4.1 Fast

Measured on the same math problem: by default Grok 4.7 used about 15,000 reasoning tokens and took about 4 minutes; with reasoning_effort: "low", it used about 4,200 tokens and took about 1 minute. Reasoning tokens are billed at the output rate, and their count is in usage.completion_tokens_details.reasoning_tokens; reasoning content is in delta.reasoning_content of the streaming response.

Other features

  • Image input: supported by Grok 4.3, 4.20, and 4.1 Fast, using standard image_url content blocks; see Vision for the format.
  • Structured output and tool calling: response_format supports json_schema; tool calling uses the standard tools parameter.
  • Caching: repeated request prefixes are cached automatically; the hit count is in usage.prompt_tokens_details.cached_tokens.

Common errors

HTTP · typeError messageCauseFix
400 invalid_request_errorContains This model does not support and reasoningreasoning_effort was sent to the non-reasoning model Grok 4.1 FastRemove the parameter
400 protocol_not_supportedModel 'x-ai/grok-4.7' does not support the 'anthropic' protocol on this platform.The model does not support the Anthropic APIUse the OpenAI-compatible API
400 endpoint_not_supportedModel 'x-ai/grok-4.7' does not support the /v1/responses endpoint on this platform.The model does not support the Responses APIUse /v1/chat/completions
404 model_not_foundModel 'xai/grok-4.7' not foundThe prefix was written as xai/The prefix is x-ai/
Request timeout—Reasoning takes too longPass reasoning_effort: "low", use streaming, or set the client timeout to 600 seconds or more

For other general errors, see Error handling.

Official docs

FAQ

How do I write Grok model IDs?

The standard form is x-ai/grok-4.7; you can also omit the prefix and write grok-4.7. Writing xai/grok-4.7 returns 404.

Why is Grok 4.7 so slow?

Grok 4.7, 4.6, and 4.5 always reason, and complex questions may use more than ten thousand reasoning tokens and take several minutes. Passing reasoning_effort: "low" shortens this significantly, or switch to the non-reasoning Grok 4.1 Fast.

Can reasoning be turned off for Grok?

Reasoning cannot be turned off for Grok 4.7, 4.6, 4.5, or 4.3; you can only reduce it with reasoning_effort. For fast responses, use Grok 4.1 Fast.

Can Claude Code use Grok?

Only Grok 4.3 supports the Anthropic API; calls to other Grok models return protocol_not_supported.

How long a context does Grok support?

Grok 4.1 Fast and 4.20 support 2M tokens, Grok 4.3 supports 1M, and Grok 4.7, 4.6, and 4.5 support 500K.

Last updated on