Grok Quick Chat (All Models)
curl --request POST \
--url https://direct.evolink.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
]
}
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.5',
messages: [{role: 'user', content: 'Hello, introduce yourself'}]
})
};
fetch('https://direct.evolink.ai/v1/chat/completions', 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/chat/completions",
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.5',
'messages' => [
[
'role' => 'user',
'content' => 'Hello, introduce yourself'
]
]
]),
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/chat/completions"
payload := strings.NewReader("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\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/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://direct.evolink.ai/v1/chat/completions")
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.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl-20260812164515123456789AbCdEfGh",
"model": "grok-4.5",
"object": "chat.completion",
"created": 1786538000,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm Grok 4.5, a reasoning model built by xAI..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 504,
"completion_tokens": 2,
"total_tokens": 526,
"prompt_tokens_details": {
"cached_tokens": 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": 403,
"message": "Access denied for this model",
"type": "permission_error",
"param": "model"
}
}{
"error": {
"code": 404,
"message": "Specified model not found",
"type": "not_found_error",
"param": "model",
"fallback_suggestion": "grok-4.5"
}
}{
"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": 502,
"message": "Upstream AI service unavailable",
"type": "upstream_error",
"fallback_suggestion": "try again later"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"type": "service_unavailable_error",
"fallback_suggestion": "retry after 30 seconds"
}
}Chat Completions API
Grok All-Model API - Chat Completions Quickstart
- Call xAI Grok text models using the OpenAI SDK format (pick the model via the
modelparameter) - Reasoning + tool-use models;
grok-4.5has a 500K-token context window - Synchronous processing mode, minimal parameters, quick to get started
- 💡 Need more features? See the full parameter documentation
- 💡 Server-side tools (web search, X search, code execution, …) are available on the Responses API
POST
/
v1
/
chat
/
completions
Grok Quick Chat (All Models)
curl --request POST \
--url https://direct.evolink.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "Hello, introduce yourself"
}
]
}
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.5',
messages: [{role: 'user', content: 'Hello, introduce yourself'}]
})
};
fetch('https://direct.evolink.ai/v1/chat/completions', 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/chat/completions",
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.5',
'messages' => [
[
'role' => 'user',
'content' => 'Hello, introduce yourself'
]
]
]),
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/chat/completions"
payload := strings.NewReader("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\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/chat/completions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://direct.evolink.ai/v1/chat/completions")
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.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"Hello, introduce yourself\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl-20260812164515123456789AbCdEfGh",
"model": "grok-4.5",
"object": "chat.completion",
"created": 1786538000,
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! I'm Grok 4.5, a reasoning model built by xAI..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 504,
"completion_tokens": 2,
"total_tokens": 526,
"prompt_tokens_details": {
"cached_tokens": 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": 403,
"message": "Access denied for this model",
"type": "permission_error",
"param": "model"
}
}{
"error": {
"code": 404,
"message": "Specified model not found",
"type": "not_found_error",
"param": "model",
"fallback_suggestion": "grok-4.5"
}
}{
"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": 502,
"message": "Upstream AI service unavailable",
"type": "upstream_error",
"fallback_suggestion": "try again later"
}
}{
"error": {
"code": 503,
"message": "Service temporarily unavailable",
"type": "service_unavailable_error",
"fallback_suggestion": "retry after 30 seconds"
}
}BaseURL: The default BaseURL is
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.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
application/json
Model to call:
| Model ID | Positioning |
|---|---|
grok-4.5 | xAI reasoning + tool-use model, 500K context window |
Available options:
grok-4.5 Example:
"grok-4.5"
List of chat messages
Minimum array length:
1Show child attributes
Show child attributes
Example:
[
{
"role": "user",
"content": "Hello, introduce yourself"
}
]
Response
Chat completion generated successfully
Unique identifier for the chat completion
Example:
"chatcmpl-20260812164515123456789AbCdEfGh"
Model name actually used
Example:
"grok-4.5"
Response type
Available options:
chat.completion Example:
"chat.completion"
Creation timestamp
Example:
1786538000
List of chat completion choices
Show child attributes
Show child attributes
Token usage statistics. Prompts of 200K tokens or more are billed at 2x for all token types.
Show child attributes
Show child attributes
⌘I