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"
}
}Interfaz de todos los modelos Grok - Referencia completa de Responses
- Endpoint Responses compatible con OpenAI para los modelos de texto xAI Grok; selecciona el modelo con el parámetro
model(todos los valores están en la tabla del parámetromodel) - Ventana de contexto de 500K tokens; a partir de 200K tokens en el prompt, todos los tipos de token se facturan al doble
- El almacenamiento en caché del prompt es automático: los tokens de entrada servidos desde la caché se facturan a la tarifa de caché, más baja
- Modos sincrónico y streaming (SSE)
- Las herramientas del lado del servidor de xAI se ejecutan en la infraestructura de xAI y se facturan por llamada exitosa:
web_search,x_search,code_execution,attachment_search,collections_search - También se admiten las herramientas
functionnormales (llamadas a funciones del lado del cliente), que no generan coste por llamada
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, que ofrece mejor compatibilidad con modelos de texto y admite conexiones persistentes. https://api.evolink.ai es el endpoint principal para servicios multimodales y actúa como dirección de respaldo para los modelos de texto.image_generation no está disponible actualmente en Grok 4.5 ni en Grok 4.6: su declaración se acepta por compatibilidad, pero la herramienta se elimina antes de que la solicitud llegue al modelo. Los valores tools[].type no reconocidos se rechazan con 400.Autorizaciones
##Todas las APIs requieren autenticación Bearer Token##
Obtener API Key:
Visita la Página de gestión de API Key para obtener tu API Key
Agregar al encabezado de la solicitud:
Authorization: Bearer YOUR_API_KEY
Cuerpo
Modelo a invocar:
| ID del modelo | Posicionamiento |
|---|---|
grok-4.6 | Modelo xAI de razonamiento y uso de herramientas, ventana de contexto de 500K; añade el nivel de razonamiento xhigh; corte de conocimiento 2026-02-01 |
grok-4.5 | Modelo xAI de razonamiento y uso de herramientas, ventana de contexto de 500K; niveles de razonamiento hasta high (xhigh se acepta pero se degrada a high) |
grok-4.6, grok-4.5 "grok-4.6"
Entrada para el modelo: una cadena simple, o un arreglo de elementos de entrada de OpenAI Responses (p. ej. {"role":"user","content":[...]}).
"Search the web for the latest SpaceX launch and summarize it in one sentence."
Indica si se devuelve una respuesta en streaming (eventos SSE que terminan con response.completed). Predeterminado false.
false
Número máximo de tokens a generar (incluidos los tokens de razonamiento).
2048
Control de la profundidad de razonamiento, forma de objeto: {"effort": "low" | "medium" | "high" | "xhigh"}. Por defecto high; el razonamiento no se puede desactivar. xhigh solo lo admite grok-4.6: grok-4.5 acepta el valor pero lo degrada a high. Los tokens de razonamiento se facturan como tokens de salida y se informan en usage.output_tokens_details.reasoning_tokens.
Show child attributes
Show child attributes
Declaraciones de herramientas. Herramientas del lado del servidor de xAI (facturadas por llamada exitosa; las tarifas no se ven afectadas por el multiplicador de contexto largo):
| Tipo de herramienta | Función | Precio por llamada |
|---|---|---|
web_search | Buscar en Internet y consultar páginas web | $0.005 |
x_search | Buscar publicaciones, perfiles e hilos de X | $0.005 |
code_execution | Ejecutar Python en un entorno aislado (code_interpreter se acepta como alias) | $0.005 |
attachment_search | Buscar en los archivos adjuntos a la conversación (puede activarse automáticamente cuando la entrada contiene archivos) | $0.01 |
collections_search | Consultar colecciones de documentos subidas (file_search se acepta como alias) | $0.0025 |
También se admiten las herramientas function normales (llamadas a funciones del lado del cliente), que no generan coste por llamada.
image_generation no está disponible actualmente: su declaración se acepta por compatibilidad, pero la herramienta se elimina antes de que la solicitud llegue al modelo. Los tipos de herramienta no reconocidos se rechazan con 400.
Show child attributes
Show child attributes
[{ "type": "web_search" }]
Controla la selección de la herramienta: "auto" (predeterminado) / "none" / "required", o un objeto que fija una herramienta concreta, p. ej. {"type": "web_search"}.
auto, none, required Respuesta
Respuesta generada con éxito (objeto JSON, o un flujo de eventos SSE que termina con response.completed cuando stream=true)
Identificador único de la respuesta
"55d44212-8d5e-90cc-975f-36d341ce21f5"
Tipo de respuesta
response "response"
Estado de la respuesta
completed, incomplete, failed "completed"
Nombre del modelo realmente utilizado
"grok-4.6"
Marca de tiempo de creación
1786538000
Elementos de salida en orden de generación: elementos reasoning (resumen del razonamiento), elementos de llamada a herramientas del lado del servidor como web_search_call / code_interpreter_call (el estado completed indica una llamada exitosa y facturable) y, por último, un elemento message con contenido output_text.
Show child attributes
Show child attributes
Estadísticas de uso de tokens y herramientas. Los prompts de 200K tokens o más se facturan al doble en todos los tipos de token; las tarifas de herramientas no se ven afectadas por el multiplicador.
Show child attributes
Show child attributes