POST /v1/responses and POST /v1/chat/completions. Use model ID grok-4.7. The Responses API is the primary interface for reasoning, function calls, structured output, and image input.
The upstream xAI specification lists a 500,000-token context window, text and image input, and text output.
When to use Grok 4.7
- Long-running coding and agentic tasks
- Multi-step knowledge work and complex analysis
- Visual understanding with text and image inputs
- Function calling or schema-constrained JSON output
Quick example
- Responses API
- Chat Completions
Image input
Send image URLs through the Responses API multimodal message format:Reasoning behavior
Setreasoning.effort on Responses or reasoning_effort on Chat Completions:
Core request fields
Response and streaming
For non-streaming requests, read the final answer fromoutput[].content[].text on Responses or choices[0].message.content on Chat Completions. For Responses streaming, concatenate the text from response.output_text.delta events.
The reasoning-token count is available in usage.output_tokens_details.reasoning_tokens on Responses and usage.completion_tokens_details.reasoning_tokens on Chat Completions. For multi-turn Responses conversations, pass the reasoning item containing encrypted_content back unchanged.
API Reference
View the Grok 4.7 request and response schema.