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": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain prompt caching in one sentence."
}
],
"stream": false,
"max_tokens": 1024,
"temperature": 0.7,
"top_p": 0.95,
"tools": [
{
"type": "function",
"function": {}
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain prompt caching in one sentence."
}
],
"stream": False,
"max_tokens": 1024,
"temperature": 0.7,
"top_p": 0.95,
"tools": [
{
"type": "function",
"function": {}
}
]
}
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: 'system', content: 'You are a concise assistant.'},
{role: 'user', content: 'Explain prompt caching in one sentence.'}
],
stream: false,
max_tokens: 1024,
temperature: 0.7,
top_p: 0.95,
tools: [{type: 'function', function: {}}]
})
};
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' => 'system',
'content' => 'You are a concise assistant.'
],
[
'role' => 'user',
'content' => 'Explain prompt caching in one sentence.'
]
],
'stream' => false,
'max_tokens' => 1024,
'temperature' => 0.7,
'top_p' => 0.95,
'tools' => [
[
'type' => 'function',
'function' => [
]
]
]
]),
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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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": "Prompt caching reuses previously processed prompt prefixes so repeated context is billed at a lower rate.",
"tool_calls": [
{}
]
},
"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": 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 전체 모델 인터페이스 - Chat Completions 전체 매개변수
- xAI Grok 텍스트 모델용 OpenAI 호환 Chat Completions 엔드포인트. 모델은
model매개변수로 선택 (전체 값은model매개변수의 대조표 참조) grok-4.5: 컨텍스트 윈도우 500K 토큰. 프롬프트가 200K 토큰 이상이면 모든 토큰 유형이 2배 요금으로 과금됩니다- 프롬프트 캐싱은 자동 적용: 캐시에 적중한 입력 토큰은 더 저렴한 캐시 입력 요금으로 과금됩니다
- 동기 및 스트리밍(SSE) 모드 지원
- 일반
function도구 호출 지원. xAI 서버 측 도구는 Responses API에서만 사용할 수 있습니다
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": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain prompt caching in one sentence."
}
],
"stream": false,
"max_tokens": 1024,
"temperature": 0.7,
"top_p": 0.95,
"tools": [
{
"type": "function",
"function": {}
}
]
}
'import requests
url = "https://direct.evolink.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain prompt caching in one sentence."
}
],
"stream": False,
"max_tokens": 1024,
"temperature": 0.7,
"top_p": 0.95,
"tools": [
{
"type": "function",
"function": {}
}
]
}
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: 'system', content: 'You are a concise assistant.'},
{role: 'user', content: 'Explain prompt caching in one sentence.'}
],
stream: false,
max_tokens: 1024,
temperature: 0.7,
top_p: 0.95,
tools: [{type: 'function', function: {}}]
})
};
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' => 'system',
'content' => 'You are a concise assistant.'
],
[
'role' => 'user',
'content' => 'Explain prompt caching in one sentence.'
]
],
'stream' => false,
'max_tokens' => 1024,
'temperature' => 0.7,
'top_p' => 0.95,
'tools' => [
[
'type' => 'function',
'function' => [
]
]
]
]),
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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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\": \"system\",\n \"content\": \"You are a concise assistant.\"\n },\n {\n \"role\": \"user\",\n \"content\": \"Explain prompt caching in one sentence.\"\n }\n ],\n \"stream\": false,\n \"max_tokens\": 1024,\n \"temperature\": 0.7,\n \"top_p\": 0.95,\n \"tools\": [\n {\n \"type\": \"function\",\n \"function\": {}\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": "Prompt caching reuses previously processed prompt prefixes so repeated context is billed at a lower rate.",
"tool_calls": [
{}
]
},
"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": 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이며, 텍스트 모델 지원이 더 우수하고 장시간 연결을 지원합니다. https://api.evolink.ai는 멀티모달 서비스의 주력 엔드포인트이며, 텍스트 모델에 대해서는 대체 주소로 사용됩니다.function 도구 호출만 지원합니다.인증
##모든 API는 Bearer Token 인증이 필요합니다##
API Key 받기:
API Key 관리 페이지를 방문하여 API Key를 받으세요
요청 헤더에 추가:
Authorization: Bearer YOUR_API_KEY
본문
호출할 모델:
| 모델 ID | 포지셔닝 |
|---|---|
grok-4.5 | xAI 추론 + 도구 호출 모델, 컨텍스트 윈도우 500K |
grok-4.5 "grok-4.5"
채팅 메시지 목록. system, user, assistant 역할을 지원합니다.
1Show child attributes
Show child attributes
[
{
"role": "system",
"content": "You are a concise assistant."
},
{
"role": "user",
"content": "Explain prompt caching in one sentence."
}
]
스트리밍으로 응답을 반환할지 여부 (SSE, chat.completion.chunk 이벤트). 기본값 false.
false
생성할 최대 토큰 수. 모델에 그대로 전달됩니다.
1024
샘플링 온도 (0-2). 값이 클수록 출력이 더 무작위해집니다.
0.7
Nucleus 샘플링 매개변수 (0-1).
0.95
일반 OpenAI function 도구 정의 (클라이언트 측 함수 호출, 호출당 추가 요금 없음). xAI 서버 측 도구는 Responses API에서만 사용할 수 있습니다.
Show child attributes
Show child attributes
함수 선택을 제어합니다: "auto" / "none" / "required", 또는 특정 함수를 지정하는 객체.
auto, none, required 응답
채팅 완성이 성공적으로 생성되었습니다 (JSON 객체, 또는 stream=true인 경우 chat.completion.chunk 이벤트의 SSE 스트림)
채팅 완성의 고유 식별자
"chatcmpl-20260812164515123456789AbCdEfGh"
실제 사용된 모델 이름
"grok-4.5"
응답 유형
chat.completion "chat.completion"
생성 타임스탬프
1786538000
채팅 완성 선택지 목록
Show child attributes
Show child attributes
토큰 사용 통계. 프롬프트가 200K 토큰 이상이면 모든 토큰 유형(입력, 캐시 입력, 출력)이 2배로 과금됩니다.
Show child attributes
Show child attributes