创建聊天补全
curl --request POST \
--url https://www.anyfast.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "解释为什么二分查找的复杂度是 O(log n)。"
}
],
"reasoning_effort": "high",
"stream": false
}
'import requests
url = "https://www.anyfast.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "解释为什么二分查找的复杂度是 O(log n)。"
}
],
"reasoning_effort": "high",
"stream": False
}
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: '解释为什么二分查找的复杂度是 O(log n)。'}],
reasoning_effort: 'high',
stream: false
})
};
fetch('https://www.anyfast.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://www.anyfast.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' => '解释为什么二分查找的复杂度是 O(log n)。'
]
],
'reasoning_effort' => 'high',
'stream' => false
]),
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://www.anyfast.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\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://www.anyfast.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\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.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\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl_example",
"object": "chat.completion",
"created": 1790208000,
"model": "grok-4.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "二分查找每一步都会将剩余搜索空间缩小一半。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 55,
"total_tokens": 73,
"prompt_tokens_details": {
"text_tokens": 18,
"image_tokens": 0,
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 40
},
"num_sources_used": 0
}
}xAI
grok-4.5
Grok 4.5 聊天补全,适用于编程、智能体任务和图片理解。
POST
/
v1
/
chat
/
completions
创建聊天补全
curl --request POST \
--url https://www.anyfast.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "解释为什么二分查找的复杂度是 O(log n)。"
}
],
"reasoning_effort": "high",
"stream": false
}
'import requests
url = "https://www.anyfast.ai/v1/chat/completions"
payload = {
"model": "grok-4.5",
"messages": [
{
"role": "user",
"content": "解释为什么二分查找的复杂度是 O(log n)。"
}
],
"reasoning_effort": "high",
"stream": False
}
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: '解释为什么二分查找的复杂度是 O(log n)。'}],
reasoning_effort: 'high',
stream: false
})
};
fetch('https://www.anyfast.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://www.anyfast.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' => '解释为什么二分查找的复杂度是 O(log n)。'
]
],
'reasoning_effort' => 'high',
'stream' => false
]),
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://www.anyfast.ai/v1/chat/completions"
payload := strings.NewReader("{\n \"model\": \"grok-4.5\",\n \"messages\": [\n {\n \"role\": \"user\",\n \"content\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\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://www.anyfast.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\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://www.anyfast.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\": \"解释为什么二分查找的复杂度是 O(log n)。\"\n }\n ],\n \"reasoning_effort\": \"high\",\n \"stream\": false\n}"
response = http.request(request)
puts response.read_body{
"id": "chatcmpl_example",
"object": "chat.completion",
"created": 1790208000,
"model": "grok-4.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "二分查找每一步都会将剩余搜索空间缩小一半。"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 55,
"total_tokens": 73,
"prompt_tokens_details": {
"text_tokens": 18,
"image_tokens": 0,
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 40
},
"num_sources_used": 0
}
}授权
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
请求体
application/json
模型 ID。
可用选项:
grok-4.5 示例:
"grok-4.5"
对话消息。用户消息支持纯文本或由文本与图片 URL 组成的内容数组。
Minimum array length:
1Show child attributes
Show child attributes
推理强度。Grok 4.5 会将 xhigh 按 high 处理。
可用选项:
low, medium, high, xhigh 最大补全 Token 数。
必填范围:
x >= 1是否返回 SSE 增量。
此页面对您有帮助吗?