创建对话请求 (OpenAI)

使用标准 OpenAI 兼容协议访问 AccessAPI 上的各厂商模型,支持 GPT、Qwen、DeepSeek、Gemini、Doubao 等系列。

POST /v1/chat/completions

📌 并发限制

并发限制基于账号维度,同一账号下所有 API Key 共享并发配额,默认最大并发请求数为 200。超出后返回错误码 4296,需等待已有请求完成后再重试。如需提升并发上限,请联系管理员。

Header 参数

Authorization string Required
Bearer Token。格式:Bearer YOUR_API_KEY

Body 参数

model string Required

使用的模型 ID。可用模型完整列表请查看

✅ 模型名称不区分大小写,例如 GPT-5-Minigpt-5-mini 效果相同。

"gpt-5-mini" "qwen3-max" "deepseek-v3.2"

示例: "gpt-5-mini"

messages object[] Required

迄今为止构成对话的消息列表。支持 systemuserassistant 三种角色,需按照 user/assistant 交替顺序排列。

stream boolean

如果设置,将发送部分消息增量,就像 ChatGPT 一样。Token 将作为 data-only server-sent events 在可用时发送,流由 data: [DONE] 消息终止。

示例: false

max_tokens integer

生成的补全的最大 token 数量。请确保 input tokens + max_tokens 不超过模型的上下文窗口。

注意:部分较新模型(如 gpt-5 系列)仅支持 max_completion_tokens 参数,不支持 max_tokens,传入后会返回错误。请根据模型文档选择正确参数。

示例: 4096

max_completion_tokens integer

生成的补全的最大 token 数量(新版参数名)。推理模型中该数量包含思考 token,建议优先使用此参数替代 max_tokens

示例: 4096

enable_thinking boolean

在思考模式和非思考模式之间切换。仅适用于支持思考链的推理模型(如 deepseek-r1、qwen3 系列等),普通模型传入此参数会被忽略。

示例: false

thinking_budget integer

Chain-of-thought 输出的最大 token 数量。仅适用于支持思考链的推理模型,需配合 enable_thinking: true 使用。

范围:128 <= x <= 32768 | 默认:4096 | 示例:4096

min_p number<float>

基于 token 概率的自适应动态过滤阈值。此字段仅适用于 Qwen3。

范围:0 <= x <= 1 | 示例:0.05

stop string | string[]

模型终止生成的自定义文本序列(最多 4 个)。结果文本将不包含停止序列。

示例: null

temperature number<float>

决定响应的随机性。值越高输出越随机,值越低输出越确定。建议不要同时修改 temperature 和 top_p。

范围:0 <= x <= 2 | 默认:1 | 示例:0.7

top_p number<float>

核采样参数,基于累积概率动态调整候选 token 范围。建议不要同时修改 temperature 和 top_p。

范围:0 < x <= 1 | 默认:0.7 | 示例:0.7

top_k number<float>

每步仅从概率最高的 top_k 个 token 中采样。值越小输出越保守,值越大越多样。并非所有模型支持此参数。

范围:0 <= x <= 50 | 示例:50

frequency_penalty number<float>

频率惩罚。正值根据到目前为止文本中的现有频率对 token 进行惩罚,从而降低模型逐字重复同一行的可能性。

示例: 0.5

n integer

要生成的补全数量。

Example: 1

response_format object

指定模型必须输出的格式的对象。

显示子属性

response_format.type string

响应格式的类型。

Example: "text"

tools object[]

函数功能的描述,模型用于选择何时以及如何调用该函数。

显示子属性

tools.type enum<string> Required

工具的类型。目前仅支持 function

function
tools.function object Required

函数定义。

Response

id string
choices object[]

显示子属性

choices.message object

显示子属性

choices.message.role string

示例: "assistant"

choices.message.content string
choices.message.reasoning_content string

模型生成的推理内容。

choices.message.tool_calls object[]

模型生成的工具调用(如果相关)。

显示子属性

choices.message.tool_calls.id string Required

工具调用的 ID。

choices.message.tool_calls.type enum<string> Required

要调用的函数名称。必须包含 a-z, A-Z, 0-9, 或包含下划线和破折号,最大长度为 64。

function
choices.message.tool_calls.function object Required

函数接受的参数,描述为 JSON Schema 对象。

显示子属性

choices.message.tool_calls.function.name string Required

要调用的函数名称。

choices.message.tool_calls.function.arguments string Required

模型生成的用于调用该函数的参数,为 JSON 格式。请注意,模型生成的内容并不总是有效的 JSON,且可能会幻觉出函数定义中未提供的参数。在调用函数前,请在您的代码中验证这些参数。

usage object

显示子属性

prompt_tokens integer Required

提示 (prompt) 中的 token 数量。

completion_tokens integer Required

生成的补全 (completion) 中的 token 数量。

total_tokens integer Required

请求中使用的总 token 数量 (提示 + 补全)。

prompt_cache_hit_tokens integer

本次请求输入中命中缓存的 token 数量。

prompt_cache_miss_tokens integer

本次请求输入中未命中缓存的 token 数量。

completion_tokens_details object

生成的补全 token 的详细信息。

Show properties

reasoning_tokens integer

模型生成的推理 token 数量。

Default: []

prompt_tokens_details object

提示 token 的详细信息。

Show properties

cached_tokens integer

提示中存在的已缓存 token 数量。

默认值: 0

created integer
model string
object enum<string>
chat.completion
curl -X POST https://api.AccessAPI.com/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
  "model": "deepseek-v3",
  "messages": [
    {
      "role": "user",
      "content": "Hello world!"
    }
  ],
  "stream": false
}'
Response Example
{
  "id": "chatcmpl-6v78924892489248",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "deepseek-v3",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello world!"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  }
}