Skip to content
English

Grok 4.7 API

POST Base URL: 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 nameGrok 4.7
ProviderxAI
Model pageHiAPI model details
Input / outputText / text
EndpointPOST /v1/chat/completions
PricingLive 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

Verified contract
  • 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

Reasoning and tool workflows

Use Chat Completions for text agents, streamed answers, JSON objects, and function tools.

messagesreasoning_efforttools

Request parameters

model string required

Use this exact public model ID.

example grok-4.7 enum: grok-4.7
messages array required

Ordered system, user, assistant, and tool messages.

stream boolean optional

Set true for Server-Sent Events.

default false
reasoning_effort enum optional

Reasoning effort. Reasoning tokens count as output tokens.

default high enum: lowmediumhighxhigh
response_format object optional

Use type=json_object for JSON object output.

example {"type":"json_object"}
tools array optional

OpenAI-compatible function definitions.

tool_choice string | object optional

Use auto or required when applicable.

API examples

Request examples

Streaming

Read content and reasoning_content deltas until [DONE].

Request body
{
  "model": "grok-4.7",
  "messages": [
    {
      "role": "user",
      "content": "Explain HTTP caching in three short paragraphs."
    }
  ],
  "stream": true,
  "reasoning_effort": "high"
}
JSON object

Use response_format.type=json_object and parse message.content.

Request body
{
  "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"
  }
}
Function tool

Execute the returned call, then continue with the assistant tool call and matching role=tool result.

Request body
{
  "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
  }
}
  1. Read choices[0].message.content for text and reasoning_content when needed.
  2. For streams, accumulate choices[0].delta.content and reasoning_content until [DONE].
  3. 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.

Next steps