Grok All-Model API - Chat Completions Reference
- OpenAI-compatible Chat Completions endpoint for xAI Grok text models; pick the model via the
modelparameter (see the table on themodelparameter for all values) grok-4.5: 500K-token context window; prompts of 200K tokens or more are billed at 2x for all token types- Prompt caching is automatic: cached prompt tokens are billed at the lower cached-input rate
- Synchronous and streaming (SSE) modes
- Regular
functiontool calling is supported; xAI server-side tools are available on the Responses API only
https://direct.evolink.ai, which has better support for text models and long-lived connections. https://api.evolink.ai is the primary endpoint for multimodal services and serves as a fallback address for text models.function tool calling only.Authorizations
##All APIs require Bearer Token authentication##
Get API Key:
Visit API Key Management Page to get your API Key
Add to request header:
Body
Model to call:
grok-4.5 "grok-4.5"
List of chat messages. Supports system, user, and assistant roles.
1Whether to return a streaming response (SSE, chat.completion.chunk events). Default false.
false
Maximum number of tokens to generate. Passed through to the model as-is.
1024
Sampling temperature (0-2). Higher values produce more random output.
0.7
Nucleus sampling parameter (0-1).
0.95
Regular OpenAI function tool definitions (client-side function calling, no extra per-call fee). xAI server-side tools are only available on the Responses API.
Controls function selection: "auto" / "none" / "required", or an object pinning a specific function.
auto, none, required Response
Chat completion generated successfully (JSON object, or an SSE stream of chat.completion.chunk events when stream=true)
Unique identifier for the chat completion
"chatcmpl-20260812164515123456789AbCdEfGh"
Model name actually used
"grok-4.5"
Response type
chat.completion "chat.completion"
Creation timestamp
1786538000
List of chat completion choices
Token usage statistics. Prompts of 200K tokens or more are billed at 2x for all token types (input, cached input, output).