curl --request POST \
--url https://direct.evolink.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.6",
"input": "Search the web for the latest SpaceX launch and summarize it in one sentence.",
"stream": false,
"max_output_tokens": 2048,
"reasoning": {
"effort": "high"
},
"tools": [
{
"type": "web_search"
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/responses"
payload = {
"model": "grok-4.6",
"input": "Search the web for the latest SpaceX launch and summarize it in one sentence.",
"stream": False,
"max_output_tokens": 2048,
"reasoning": { "effort": "high" },
"tools": [{ "type": "web_search" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'grok-4.6',
input: 'Search the web for the latest SpaceX launch and summarize it in one sentence.',
stream: false,
max_output_tokens: 2048,
reasoning: {effort: 'high'},
tools: [{type: 'web_search'}]
})
};
fetch('https://direct.evolink.ai/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://direct.evolink.ai/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'grok-4.6',
'input' => 'Search the web for the latest SpaceX launch and summarize it in one sentence.',
'stream' => false,
'max_output_tokens' => 2048,
'reasoning' => [
'effort' => 'high'
],
'tools' => [
[
'type' => 'web_search'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://direct.evolink.ai/v1/responses"
payload := strings.NewReader("{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://direct.evolink.ai/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://direct.evolink.ai/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "55d44212-8d5e-90cc-975f-36d341ce21f5",
"object": "response",
"status": "completed",
"model": "grok-4.6",
"created_at": 1786538000,
"output": [
{
"id": "<string>",
"type": "web_search_call",
"status": "completed",
"content": [
{}
]
}
],
"usage": {
"input_tokens": 10329,
"output_tokens": 299,
"total_tokens": 10628,
"input_tokens_details": {
"cached_tokens": 6016
},
"output_tokens_details": {
"reasoning_tokens": 128
},
"num_server_side_tools_used": 2,
"server_side_tool_usage_details": {
"web_search_calls": 2,
"x_search_calls": 0,
"code_interpreter_calls": 0,
"document_search_calls": 0,
"file_search_calls": 0,
"mcp_calls": 0
}
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"code": 401,
"message": "Invalid or expired token",
"type": "authentication_error"
}
}{
"error": {
"code": 402,
"message": "Insufficient quota",
"type": "insufficient_quota_error",
"fallback_suggestion": "https://evolink.ai/dashboard/billing"
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"fallback_suggestion": "retry after 60 seconds"
}
}{
"error": {
"code": 500,
"message": "Internal server error",
"type": "internal_server_error",
"fallback_suggestion": "try again later"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"type": "service_unavailable_error",
"fallback_suggestion": "retry after 30 seconds"
}
}Grok All-Model API - Responses Reference
- OpenAI-compatible Responses endpoint for xAI Grok text models; pick the model via the
modelparameter (see the table on themodelparameter for all values) - 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
- xAI server-side tools run on xAI infrastructure and are billed per successful call:
web_search,x_search,code_execution,attachment_search,collections_search - Regular
functiontools (client-side function calling) are also supported and carry no per-call fee
curl --request POST \
--url https://direct.evolink.ai/v1/responses \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.6",
"input": "Search the web for the latest SpaceX launch and summarize it in one sentence.",
"stream": false,
"max_output_tokens": 2048,
"reasoning": {
"effort": "high"
},
"tools": [
{
"type": "web_search"
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/responses"
payload = {
"model": "grok-4.6",
"input": "Search the web for the latest SpaceX launch and summarize it in one sentence.",
"stream": False,
"max_output_tokens": 2048,
"reasoning": { "effort": "high" },
"tools": [{ "type": "web_search" }]
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
model: 'grok-4.6',
input: 'Search the web for the latest SpaceX launch and summarize it in one sentence.',
stream: false,
max_output_tokens: 2048,
reasoning: {effort: 'high'},
tools: [{type: 'web_search'}]
})
};
fetch('https://direct.evolink.ai/v1/responses', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://direct.evolink.ai/v1/responses",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'model' => 'grok-4.6',
'input' => 'Search the web for the latest SpaceX launch and summarize it in one sentence.',
'stream' => false,
'max_output_tokens' => 2048,
'reasoning' => [
'effort' => 'high'
],
'tools' => [
[
'type' => 'web_search'
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://direct.evolink.ai/v1/responses"
payload := strings.NewReader("{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://direct.evolink.ai/v1/responses")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://direct.evolink.ai/v1/responses")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"model\": \"grok-4.6\",\n \"input\": \"Search the web for the latest SpaceX launch and summarize it in one sentence.\",\n \"stream\": false,\n \"max_output_tokens\": 2048,\n \"reasoning\": {\n \"effort\": \"high\"\n },\n \"tools\": [\n {\n \"type\": \"web_search\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "55d44212-8d5e-90cc-975f-36d341ce21f5",
"object": "response",
"status": "completed",
"model": "grok-4.6",
"created_at": 1786538000,
"output": [
{
"id": "<string>",
"type": "web_search_call",
"status": "completed",
"content": [
{}
]
}
],
"usage": {
"input_tokens": 10329,
"output_tokens": 299,
"total_tokens": 10628,
"input_tokens_details": {
"cached_tokens": 6016
},
"output_tokens_details": {
"reasoning_tokens": 128
},
"num_server_side_tools_used": 2,
"server_side_tool_usage_details": {
"web_search_calls": 2,
"x_search_calls": 0,
"code_interpreter_calls": 0,
"document_search_calls": 0,
"file_search_calls": 0,
"mcp_calls": 0
}
}
}{
"error": {
"code": 400,
"message": "Invalid request parameters",
"type": "invalid_request_error"
}
}{
"error": {
"code": 401,
"message": "Invalid or expired token",
"type": "authentication_error"
}
}{
"error": {
"code": 402,
"message": "Insufficient quota",
"type": "insufficient_quota_error",
"fallback_suggestion": "https://evolink.ai/dashboard/billing"
}
}{
"error": {
"code": 429,
"message": "Rate limit exceeded",
"type": "rate_limit_error",
"fallback_suggestion": "retry after 60 seconds"
}
}{
"error": {
"code": 500,
"message": "Internal server error",
"type": "internal_server_error",
"fallback_suggestion": "try again later"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"type": "service_unavailable_error",
"fallback_suggestion": "retry after 30 seconds"
}
}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.image_generation is currently not available on Grok 4.5 or Grok 4.6: declaring it is accepted for compatibility but the tool is removed before the request reaches the model. Unrecognized tools[].type values are rejected with 400.Authorizations
##All APIs require Bearer Token authentication##
Get API Key:
Visit API Key Management Page to get your API Key
Add to request header:
Authorization: Bearer YOUR_API_KEY
Body
Model to call:
| Model ID | Positioning |
|---|---|
grok-4.6 | xAI reasoning + tool-use model, 500K context window; adds the xhigh reasoning level; knowledge cutoff 2026-02-01 |
grok-4.5 | xAI reasoning + tool-use model, 500K context window; reasoning levels up to high (xhigh is accepted but downgraded to high) |
grok-4.6, grok-4.5 "grok-4.6"
Input for the model: a plain string, or an array of OpenAI Responses input items (e.g. {"role":"user","content":[...]}).
"Search the web for the latest SpaceX launch and summarize it in one sentence."
Whether to return a streaming response (SSE events, ending with response.completed). Default false.
false
Maximum number of tokens to generate (reasoning tokens included).
2048
Reasoning depth control, object form: {"effort": "low" | "medium" | "high" | "xhigh"}. Defaults to high; reasoning cannot be disabled. xhigh is supported by grok-4.6 only — grok-4.5 accepts the value but downgrades it to high. Reasoning tokens are billed as output tokens and reported in usage.output_tokens_details.reasoning_tokens.
Show child attributes
Show child attributes
Tool declarations. xAI server-side tools (billed per successful call, fees not affected by the long-context multiplier):
| Tool type | What it does | Price per call |
|---|---|---|
web_search | Search the internet and browse web pages | $0.005 |
x_search | Search X posts, profiles, and threads | $0.005 |
code_execution | Run Python in a sandbox (code_interpreter accepted as alias) | $0.005 |
attachment_search | Search files attached to the conversation (may be auto-enabled when the input contains files) | $0.01 |
collections_search | Query uploaded document collections (file_search accepted as alias) | $0.0025 |
Regular function tools (client-side function calling) are also supported and carry no per-call fee.
image_generation is currently not available: declaring it is accepted for compatibility but removed before the request reaches the model. Unrecognized tool types are rejected with 400.
Show child attributes
Show child attributes
[{ "type": "web_search" }]
Controls tool selection: "auto" (default) / "none" / "required", or an object pinning a specific tool, e.g. {"type": "web_search"}.
auto, none, required Response
Response generated successfully (JSON object, or an SSE event stream ending with response.completed when stream=true)
Unique identifier for the response
"55d44212-8d5e-90cc-975f-36d341ce21f5"
Response type
response "response"
Response status
completed, incomplete, failed "completed"
Model name actually used
"grok-4.6"
Creation timestamp
1786538000
Output items in generation order: reasoning items (summarized thinking), server-side tool call items such as web_search_call / code_interpreter_call (status completed marks a successful, billable call), and a final message item with output_text content.
Show child attributes
Show child attributes
Token and tool usage statistics. Prompts of 200K tokens or more are billed at 2x for all token types; tool fees are unaffected by the multiplier.
Show child attributes
Show child attributes