Complete API reference for the Grok 4.7 LLM model powered by xAI.
Model Variants
This API supports one model variant:
Quick Comparison
Grok 4.7
Endpoint
POST /api/v1/chat/completions
Request Parameters
Required
Message Support
Optional
Example Request
const response = await fetch('https://api.flaq.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_API_KEY',
'Accept': 'text/event-stream',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'grok-4.7',
messages: [
{
role: 'user',
content: 'Explain how a browser caches an image in two sentences.'
}
],
stream: true,
max_tokens: 2048,
reasoning_effort: 'medium'
})
});
Grok 4.7 returns OpenAI-compatible completion responses. With stream: true, the response is Server-Sent Events. With stream: false or when stream is omitted, the response is a single JSON object.
Successful Response
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"grok-4.7","choices":[{"index":0,"delta":{"role":"assistant"},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"grok-4.7","choices":[{"index":0,"delta":{"reasoning_content":"Explain cache reuse."},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"grok-4.7","choices":[{"index":0,"delta":{"content":"The browser saves a copy of the image. It reuses the copy while it is fresh."},"finish_reason":null}]}
data: {"id":"chatcmpl-...","object":"chat.completion.chunk","created":1710000000,"model":"grok-4.7","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}
data: [DONE]
Error Response
data: {"error":{"message":"API requests too frequent, exceeding rate limit","type":"rate_limit_error","code":"1302","param":null}}
Best Practices
- Use structured messages to send conversation history through
messages[].
- Attach images in message content by adding an
image_url block to messages[].content.
- Consume SSE events by appending
choices[0].delta.content and treating data: [DONE] as the end of the stream.