跳转到主要内容
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://api.foxapi.cc/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "user",
      "content": "用一句话解释什么是量子计算"
    }
  ]
}
'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1757165031,
  "model": "<string>",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 10,
    "completion_tokens": 50,
    "total_tokens": 60
  }
}

授权

Authorization
string
header
必填

所有接口均需要使用Bearer Token进行认证

使用时在请求头中添加:

Authorization: Bearer YOUR_API_KEY

请求体

application/json
model
string
必填

模型名称,如 gpt-4o、deepseek-chat、claude-sonnet-4-20250514 等

示例:

"gpt-4o"

messages
object[]
必填

对话消息列表

stream
boolean
默认值:false

是否流式返回响应

temperature
number

采样温度 (0-2)

必填范围: 0 <= x <= 2
max_tokens
integer

最大生成token数

top_p
number

核采样参数 (0-1)

必填范围: 0 <= x <= 1

响应

对话补全响应

id
string

唯一补全ID

示例:

"chatcmpl-abc123"

object
enum<string>

对象类型

可用选项:
chat.completion
created
integer

创建时间戳

示例:

1757165031

model
string

使用的模型

choices
object[]
usage
object

用量统计