# Grok API: model IDs, reasoning effort, 2M context, and errors Source: https://ofox.ai/docs/develop/models/grok 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 - [Reduce reasoning time](#reasoning) — What reasoning_effort does and its measured effect. - [Endpoint support](#endpoints) — Chat Completions, Responses, and Anthropic endpoints. - [Troubleshooting errors](#errors) — Reasoning parameter not supported, protocol not supported, request timeouts. ## Models For the full model list and live prices, see the [models page](https://ofox.ai/models?provider=x-ai). Model IDs have the prefix `x-ai/`, which can be omitted. **Common model IDs (copy them exactly)** - Grok 4.7: `x-ai/grok-4.7` — Reasoning model, 500K context - Grok 4.1 Fast: `x-ai/grok-4.1-fast` — Non-reasoning, 2M context, image support | Type | Models | Description | |---|---|---| | Reasoning models | Grok 4.7, 4.6, 4.5 | Always reason and take longer; 500K context, text only | | Reasoning model | Grok 4.3 | 1M context, supports image input | | Non-reasoning models | Grok 4.1 Fast, 4.20 | Fast responses; 2M context, supports image input | ## Endpoint support | Endpoint | Supported models | |---|---| | Chat Completions `/v1/chat/completions` | All | | Responses `/v1/responses` | Grok 4.3, 4.20, 4.1 Fast | | Anthropic native API | Grok 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 **Python** ```python filename="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) ``` **cURL** ```bash filename="Terminal" curl https://api.ofox.ai/v1/chat/completions \ -H "Authorization: Bearer $OFOX_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "model": "x-ai/grok-4.7", "reasoning_effort": "low", "messages": [{"role": "user", "content": "Explain idempotency in one sentence."}] }' ``` ## Reasoning **Key point**:Grok 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. | Model | Reasoning | `reasoning_effort` | |---|---|---| | Grok 4.7, 4.6, 4.5 | Always reason | `low` significantly reduces reasoning | | Grok 4.3 | Always reasons; reasoning content is not returned | Accepted | | Grok 4.1 Fast, 4.20 | No reasoning | Returns 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](https://ofox.ai/docs/develop/guides/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 · type | Error message | Cause | Fix | |---|---|---|---| | 400 `invalid_request_error` | Contains `This model does not support` and `reasoning` | `reasoning_effort` was sent to the non-reasoning model Grok 4.1 Fast | Remove the parameter | | 400 `protocol_not_supported` | `Model 'x-ai/grok-4.7' does not support the 'anthropic' protocol on this platform.` | The model does not support the Anthropic API | Use the OpenAI-compatible API | | 400 `endpoint_not_supported` | `Model 'x-ai/grok-4.7' does not support the /v1/responses endpoint on this platform.` | The model does not support the Responses API | Use `/v1/chat/completions` | | 404 `model_not_found` | `Model 'xai/grok-4.7' not found` | The prefix was written as `xai/` | The prefix is `x-ai/` | | Request timeout | — | Reasoning takes too long | Pass `reasoning_effort: "low"`, use streaming, or set the client timeout to 600 seconds or more | For other general errors, see [Error handling](https://ofox.ai/docs/develop/guides/error-handling). ## Official docs - [xAI · Documentation](https://docs.x.ai/) ## 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.