Skip to content
English

Grok 4.6 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.6
ProviderxAI
Input / outputText / text
EndpointPOST /v1/chat/completions
PricingLive HiAPI token rates

Grok 4.6 from xAI is available through HiAPI Chat Completions for text input and text output, streaming, tools, JSON objects, and four verified reasoning efforts.

Production guidance

Verified contract
  • Use model=grok-4.6 with POST /v1/chat/completions. The same HiAPI API key works across enabled models; media models use POST /v1/tasks with a different request shape.
  • Reasoning efforts are low, medium, high, and xhigh; high is the default. Reasoning tokens are billed as output.
  • The initial public contract does not promise Responses, image input, parallel tools, or full structured outputs. Context above 200K is subject to the live model page and completed long-context verification.

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.6 enum: grok-4.6
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.6",
  "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.6",
  "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.6",
  "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.6",
  "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.6.

Which reasoning efforts are supported?

Use reasoning_effort=low, medium, high, or xhigh. The default is high. Reasoning tokens count as output tokens.

Does it support streaming, JSON objects, and tools?

Yes. Set stream=true for SSE, response_format.type=json_object for JSON objects, and use tools/tool_choice for function calls. Tool continuation must replay the assistant tool call and matching tool result.

Are image input and Responses available?

They are not part of the initial HiAPI public contract. Use text messages with Chat Completions.

How are tokens billed and what about long context?

Input, output, and cached input use the live rates on the model and pricing pages; reasoning tokens count as output. Although the provider documents 500K context, the initial HiAPI release does not promise use above 200K until the live model page records completed verification.

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