跳转到主要内容
POST
/
v1
/
chat
/
completions
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "你好,请介绍一下你自己"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!我是 Claude,由 Anthropic 开发的 AI 助手。我可以帮助你回答问题、分析信息、编写代码、创作内容等。有什么我可以帮你的吗?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 42,
    "total_tokens": 57
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.toapis.com/llms.txt

Use this file to discover all available pages before exploring further.

  • 兼容 OpenAI Chat Completions API 格式
  • 通过 model 参数指定模型,所有支持的模型请参阅 模型一览
  • 支持流式输出(SSE)
  • 支持多轮对话、系统提示词
  • 部分模型支持视觉输入(图片)和深度思考模式

Authorizations

Authorization
string
必填
所有接口均需要使用 Bearer Token 进行认证获取 API Key:访问 API Key 管理页面 获取您的 API Key使用时在请求头中添加:
Authorization: Bearer YOUR_API_KEY

Body

model
string
必填
模型名称,所有支持的模型请参阅 模型一览示例:"claude-sonnet-4-6""gpt-5""qwen3-max"
messages
object[]
必填
对话消息列表,按时间顺序排列
stream
boolean
默认值:false
是否启用流式输出(Server-Sent Events)
  • true:逐 token 流式返回
  • false:等待完整响应后一次性返回
max_tokens
integer
生成内容的最大 token 数量不设置时使用模型默认上限
temperature
number
默认值:1
采样温度,控制输出随机性
  • 范围:0 ~ 2
  • 值越低输出越稳定,值越高输出越随机
top_p
number
默认值:1
核采样概率阈值范围:0 ~ 1,建议不要同时修改 temperaturetop_p
stop
string | string[]
停止序列,遇到指定字符串时停止生成最多 4 个停止序列

Response

id
string
本次请求的唯一标识符
object
string
对象类型,固定为 chat.completion
created
integer
请求创建时间(Unix 时间戳)
model
string
实际使用的模型名称
choices
object[]
生成结果列表
  • choices[].message.role:消息角色,固定为 assistant
  • choices[].message.content:生成的文本内容
  • choices[].finish_reason:结束原因,stop / length / content_filter
  • choices[].index:结果索引
usage
object
本次请求的 token 消耗统计
  • usage.prompt_tokens:输入 token 数
  • usage.completion_tokens:输出 token 数
  • usage.total_tokens:总 token 数
curl --request POST \
  --url https://toapis.com/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "claude-sonnet-4-6",
    "messages": [
      {
        "role": "user",
        "content": "你好,请介绍一下你自己"
      }
    ]
  }'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1703884800,
  "model": "claude-sonnet-4-6",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "你好!我是 Claude,由 Anthropic 开发的 AI 助手。我可以帮助你回答问题、分析信息、编写代码、创作内容等。有什么我可以帮你的吗?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 15,
    "completion_tokens": 42,
    "total_tokens": 57
  }
}