x-ai/grok-code-fast-1-free
专业代码助手,生成效率极高
接口详情
POST
https://api123.codenews.cc/v1/chat/completions请求参数
| 参数名 | 类型 | 必填 | 默认值 | 描述 |
|---|---|---|---|---|
| model | string | 是 | gpt-4o | 模型 ID,固定为 gpt-4o |
| messages | array | 是 | - | 消息列表,包含 role 和 content |
| temperature | number | 否 | 1.0 | 采样温度,介于 0 和 2 之间 |
| stream | boolean | 否 | false | 是否流式输出 |
代码示例
请将 $API_KEY 替换为您在控制台申请的真实 API Key。
curl https://api123.codenews.cc/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $API_KEY" \
-d '{
"model": "x-ai/grok-code-fast-1-free",
"messages": [{"role": "user", "content": "你好"}]
}'响应示例
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-4o",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "你好!我是 GPT-4o,有什么我可以帮你的吗?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}错误码
| 状态码 | 说明 |
|---|---|
| 401 | API Key 无效或缺失 |
| 429 | 请求过于频繁,触发限流 |
| 500 | 服务器内部错误 |