跳转到主要内容
POST
/
v1
/
chat
/
completions
创建对话补全
curl --request POST \
  --url https://api.apiany.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gpt-5.4",
  "messages": [
    {
      "role": "user",
      "content": "Write a concise product tagline for APIAny.AI."
    }
  ],
  "temperature": 0.7
}
'
{
  "id": "<string>",
  "object": "chat.completion",
  "created": 123,
  "model": "<string>",
  "choices": [
    {}
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123,
    "input_tokens": 123,
    "output_tokens": 123,
    "cached_input_tokens": 123
  }
}

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求体

application/json
model
string
必填
示例:

"gpt-5.4"

messages
object[]
必填
temperature
number

采样温度。

必填范围: 0 <= x <= 2
top_p
number

核采样累计概率。

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

响应中最大 token 数。

必填范围: x >= 1
stop

最多 4 个停止序列。

n
integer

生成候选条数。

必填范围: x >= 1
frequency_penalty
number
必填范围: -2 <= x <= 2
presence_penalty
number
必填范围: -2 <= x <= 2
seed
integer

尽量可复现的采样种子。

response_format
object

强制 JSON 对象或 JSON Schema 输出,如 { "type": "json_object" }。

tools
object[]

模型可调用的工具/函数声明。

tool_choice

工具选择:'auto' | 'none' | 'required' | { type: 'function', function: { name } }。

logprobs
boolean
top_logprobs
integer
必填范围: 0 <= x <= 20
logit_bias
object
user
string

终端用户标识,用于风险审计。

stream
boolean

为 true 时通过 SSE 流式返回增量(OpenAI chat.completion.chunk),以 'data: [DONE]' 结束。

响应

OpenAI 兼容的对话补全响应。

id
string
必填
object
string
必填
示例:

"chat.completion"

created
integer
必填
model
string
必填
choices
object[]
必填
usage
object