curl --request POST \
--url https://api.poyo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.7",
"messages": [
{
"role": "user",
"content": "Explain vector databases in one sentence."
}
]
}
'{
"id": "chatcmpl-9876543210",
"object": "chat.completion",
"created": 1677652288,
"model": "grok-4.7",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A vector database stores embeddings and finds the most similar ones quickly."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 18,
"total_tokens": 30
}
}{
"code": 400,
"error": {
"message": "Invalid request parameters: messages: Field required",
"type": "validation_error",
"details": {}
}
}{
"code": 401,
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"error": {
"message": "Model not found: no-such-model",
"type": "invalid_request_error",
"code": "model_not_found"
}
}模型
xAI
通过 OpenAI 兼容的 Chat Completions 接口调用 xAI Grok 4.7 和 Grok 4.6。
POST
/
v1
/
chat
/
completions
curl --request POST \
--url https://api.poyo.ai/v1/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "grok-4.7",
"messages": [
{
"role": "user",
"content": "Explain vector databases in one sentence."
}
]
}
'{
"id": "chatcmpl-9876543210",
"object": "chat.completion",
"created": 1677652288,
"model": "grok-4.7",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "A vector database stores embeddings and finds the most similar ones quickly."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 12,
"completion_tokens": 18,
"total_tokens": 30
}
}{
"code": 400,
"error": {
"message": "Invalid request parameters: messages: Field required",
"type": "validation_error",
"details": {}
}
}{
"code": 401,
"error": {
"message": "Invalid API key",
"type": "authentication_error"
}
}{
"error": {
"message": "Model not found: no-such-model",
"type": "invalid_request_error",
"code": "model_not_found"
}
}xAI Grok 模型覆盖长时间运行的 Agent、编程、工程和知识工作。本页 Playground 使用 Chat Completions,所有 Grok 模型都支持该格式。
模型
- grok-4.7 — Grok 4.7。仅支持 Chat Completions。
- grok-4.6 — Grok 4.6,适用于长时间运行的 Agent、编程以及交互式或可视化项目。支持 Chat Completions 和 Responses。
示例
- 基础聊天补全 — 单条用户消息。
- 系统提示词 —
system消息加max_tokens。 - 流式输出 —
stream: true,以 SSE 返回。
grok-4.6,把相同的 model id 发送到 Responses。
注意事项
grok-4.7只接受/v1/chat/completions。- 全部模型及其支持的格式见 LLM 模型。
授权
所有 API 接口都需要 Bearer Token 认证。
创建 API Key:登录 PoYo,进入 仪表盘 → API 密钥(poyo.ai/zh/dashboard/api-key),点击创建 Key。
在请求头中添加:
Authorization: Bearer YOUR_API_KEY
请求体
application/json
xAI Grok 模型 ID。
可用选项:
grok-4.7, grok-4.6 对话消息列表。每条消息包含 role 和 content。system 用于定义模型行为,user 用于用户输入,assistant 用于多轮对话中模型之前的回复。
Show child attributes
Show child attributes
控制输出的随机性,范围 0-2。较低的值(如 0.2)使输出更确定,较高的值(如 1.8)使输出更随机。默认值:1.0。
必填范围:
0 <= x <= 2示例:
1
生成的最大 token 数。不同模型的上限不同。
必填范围:
x >= 1示例:
256
是否使用流式输出。true 以 SSE 格式返回流式响应,false 一次性返回完整响应。默认值:false。
示例:
false
核采样参数,范围 0-1。控制生成文本的多样性。建议只使用 top_p 或 temperature 其中之一,不要同时使用。默认值:1.0。
必填范围:
0 <= x <= 1示例:
1
频率惩罚,范围 -2.0 到 2.0。正值会降低重复相同词语的可能性。默认值:0。
必填范围:
-2 <= x <= 2示例:
0
存在惩罚,范围 -2.0 到 2.0。正值会提高谈论新话题的可能性。默认值:0。
必填范围:
-2 <= x <= 2示例:
0
停止序列。最多 4 个,遇到其中任一序列时停止生成。
示例:
"\n\nHuman:"
生成的补全数量。默认值:1。必须是普通数字,如 1,不要加引号。
必填范围:
x >= 1示例:
1