Skip to main content

Maximum
xai/grok-4.7/chat

Grok 4.7 is xAI's chat model behind an OpenAI-compatible call with SSE streaming. It takes a 500,000-token context and replies up to 450,000 tokens, with reasoning effort from low to xhigh; no filter is added on this platform.

Input $2Output $6per 1 million tokensCached input $0.50Prompts of 200K tokens or moreInput $4Cached input $1Output $12

Workbench

Send a request

Quickstart

Examples use the selected endpoint’s public parameter definitions. Replace the API key and example media, then send the request from your server.

SDKs & integrations
POSThttps://api.spicyapi.ai/v1/chat/completions

API authentication

Keep the API key in the server environment variable SPICY_API_KEY. Use Bearer authentication and Content-Type: application/json for JSON requests.

Authorization: Bearer $SPICY_API_KEY
curl --fail-with-body -sN https://api.spicyapi.ai/v1/chat/completions \
  -H "Authorization: Bearer $SPICY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
  "model": "xai/grok-4.7/chat",
  "messages": [
    {
      "role": "user",
      "content": "Summarise the following release notes into three bullet points."
    }
  ],
  "stream": true
}' \
  | jq --unbuffered -Rrj 'select(startswith("data: ")) | .[6:] | select(. != "[DONE]") | fromjson | if .error then "\n[error] \(.error.message)\n" else (.choices[0].delta.content? // empty) end'

Generated from this model’s input schema — the same one the API validates every request against.

Keep one Idempotency-Key for each logical request. After a network interruption, do not automatically resend with a new key; retain request_id to investigate the accepted request. Idempotency does not replay an earlier chat stream.

Input parameters

Place the model parameters directly in the JSON request body alongside model. This endpoint does not use an input wrapper.

messagesarray<object>Required

Keep character instructions in the system message and the unfolding Grok 4.7 dialogue in message order. A user turn may contain text and image_url; the array accepts at most 256 messages.

Default
Not specified
Constraints
minItems:1
maxItems:256
response_formatobjectOptional

Choose JSON object output for Grok 4.7 character sheets or continuity records; leave ordinary dialogue in text form.

Default
Not specified
tool_choicestring | objectOptional

When Grok 4.7 writes dialogue, none avoids function requests. For continuity lookups, auto allows a call, required insists on one, and an object identifies the function to use.

Default
Not specified
parallel_tool_callsbooleanOptional

Grok 4.7 can request several tools per turn with the default true. For a story application that must read a character record before updating it, select false so each turn requests at most one function.

Default
true
toolsarray<object>Optional

Grok 4.7 accepts up to 128 definitions for functions such as reading a character record. Check the returned arguments before your application performs an operation.

Default
Not specified
Constraints
maxItems:128
top_pnumberOptional

For Grok 4.7 prose, top_p can be set from 0.01 to 1. Adjust it separately from temperature when comparing dialogue samples.

Default
1
Constraints
minimum:0.01
maximum:1
temperaturenumberOptional

Use Grok 4.7 temperature to explore prose variation within 0–2; the default is 0.7. Keep the setting fixed when assessing a change to character instructions.

Default
0.7
Constraints
minimum:0
maximum:2
max_tokensintegerOptional

Caps the visible reply at 450,000; the default of 4,096 truncates a long answer silently. Reasoning tokens are billed as output but are NOT bound by this cap. For Grok 4.7 dialogue, compare low or medium effort with the high default when controlling the total output budget.

Default
4096
Constraints
minimum:1
maximum:450000
reasoning_effortstringOptional

low, medium, high or xhigh; the default is high. For dialogue and roleplay use low or medium: high spends output tokens deliberating and reads as hesitation. Effort is billed as output, so the careful setting is also the expensive one.

Default
"high"
Allowed values
"low""medium""high""xhigh"

Read the result

With stream set to false, the request returns the completed chat response directly. Read choices[].message; no task polling is needed. Set stream to true when your client supports Server-Sent Events.

Completed response example
{
  "id": "chatcmpl_example",
  "object": "chat.completion",
  "created": 1788652800,
  "model": "xai/grok-4.7/chat",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Here is a concise summary of the release notes."
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 32,
    "completion_tokens": 14,
    "total_tokens": 46
  }
}

The response example is illustrative. usage reports token counts; token counts and charges depend on your actual request.

SDKs & integrations

Use SpicyAPI in your app, terminal, AI assistant or visual workflow. Choose a setup guide below.

Use it in SillyTavern and roleplay apps

In SillyTavern, RisuAI, Agnai or any app with an OpenAI-compatible setting, paste the base URL below and your API key, then pick xai/grok-4.7/chat as the model. Browser calls are allowed, and sliders this model does not take are ignored instead of rejected.

Base URL: https://api.spicyapi.ai/v1
Model: xai/grok-4.7/chat

Use it in ComfyUI

Install the SpicyAPI nodes from ComfyUI Manager or with the command below, then pick xai/grok-4.7/chat in the SpicyAPI Chat node to use this model inside a ComfyUI graph.

cd ComfyUI/custom_nodes
git clone https://github.com/spicyapi-ai/comfyui-spicyapi