Grok 4.7 API
https://api.hiapi.ai /v1/chat/completions This model uses an OpenAI-compatible Chat Completions endpoint. The same HiAPI API key can call enabled models in your account group; image, video, and audio models use /v1/tasks and a different request shape.
Model overview
| Model name | Grok 4.7 |
|---|---|
| Provider | xAI |
| Model page | HiAPI model details |
| Input / output | Text / text |
| Endpoint | POST /v1/chat/completions |
| Pricing | Live HiAPI token rates |
xAI Grok 4.7 is built for coding, agentic tasks, and knowledge work, and is available through HiAPI Chat Completions.
Production guidance
- According to xAI documentation, Grok 4.7 supports low, medium, high, and xhigh reasoning effort, with high as the default. HiAPI supports these efforts through Chat Completions.
- Use model=grok-4.7 with POST /v1/chat/completions. Media models use POST /v1/tasks with a different request shape.
- Responses, image input, and provider-specific search tools are outside the current HiAPI contract.
Best suited for
Use Chat Completions for text agents, streamed answers, JSON objects, and function tools.
messagesreasoning_efforttoolsRequest parameters
model string required Use this exact public model ID.
messages array required Ordered system, user, assistant, and tool messages.
stream boolean optional Set true for Server-Sent Events.
reasoning_effort enum optional Reasoning effort. Reasoning tokens count as output tokens.
response_format object optional Use type=json_object for JSON object output.
tools array optional OpenAI-compatible function definitions.
tool_choice string | object optional Use auto or required when applicable.
API examples
Request examples
Read content and reasoning_content deltas until [DONE].
{
"model": "grok-4.7",
"messages": [
{
"role": "user",
"content": "Explain HTTP caching in three short paragraphs."
}
],
"stream": true,
"reasoning_effort": "high"
}Use response_format.type=json_object and parse message.content.
{
"model": "grok-4.7",
"messages": [
{
"role": "user",
"content": "Return a JSON object with an answer field."
}
],
"stream": false,
"reasoning_effort": "medium",
"response_format": {
"type": "json_object"
}
}Execute the returned call, then continue with the assistant tool call and matching role=tool result.
{
"model": "grok-4.7",
"messages": [
{
"role": "user",
"content": "Check order A-123."
}
],
"stream": false,
"reasoning_effort": "low",
"tools": [
{
"type": "function",
"function": {
"name": "get_order_status",
"description": "Look up an order.",
"parameters": {
"type": "object",
"properties": {
"order_id": {
"type": "string"
}
},
"required": [
"order_id"
],
"additionalProperties": false
}
}
}
],
"tool_choice": "auto"
}Response schema
Non-streaming responses follow the Chat Completions schema. Thinking mode also returns reasoning_content; usage is the billing detail source.
{
"id": "chatcmpl_example",
"object": "chat.completion",
"model": "grok-4.7",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Caching can reduce repeated transfer cost.",
"reasoning_content": "First identify cache hit conditions."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 18,
"total_tokens": 42
}
} - Read choices[0].message.content for text and reasoning_content when needed.
- For streams, accumulate choices[0].delta.content and reasoning_content until [DONE].
- Read prompt, completion, and total token usage; reasoning is included in completion tokens.
FAQ
Which endpoint and model ID should I use?
Use POST /v1/chat/completions with model=grok-4.7.
Which reasoning efforts are supported?
Use reasoning_effort=low, medium, high, or xhigh. The default is high. Reasoning tokens count as output tokens.
Which capabilities are supported?
The HiAPI surface includes streaming, JSON objects, and function tools. Invalid reasoning_effort values return HTTP 400 before upstream dispatch.
How are tokens billed?
Input, output, and cached input use the live rates on the model and pricing pages; reasoning tokens count as output.
Can I reuse an OpenAI SDK client?
Yes. Set base_url to https://api.hiapi.ai/v1, use a HiAPI API key, and call chat.completions.create with messages.