跳转到主要内容
POST
/
v1
/
chat
/
completions
对话补全
curl --request POST \
  --url https://www.anyfast.ai/v1/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "gemini-2.5-pro",
  "messages": [
    {
      "role": "user",
      "content": "你好!"
    }
  ],
  "max_tokens": 2,
  "temperature": 1,
  "top_p": 0.5,
  "frequency_penalty": 0,
  "presence_penalty": 0,
  "stream": false,
  "stop": "<string>",
  "n": 1,
  "response_format": {
    "type": "text"
  }
}
'
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 123,
  "model": "gemini-2.5-pro",
  "choices": [
    {
      "index": 123,
      "message": {
        "role": "assistant",
        "content": "你好!有什么我可以帮助你的吗?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 123,
    "completion_tokens": 123,
    "total_tokens": 123
  }
}

授权

Authorization
string
header
必填

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

请求体

application/json
model
enum<string>
必填

用于补全的 Gemini 模型 ID。

可用选项:
gemini-3.1-pro-preview,
gemini-3.1-flash-image-preview,
gemini-3.1-flash-lite-preview,
gemini-3-pro-preview,
gemini-3-pro-image-preview,
gemini-3-flash-preview,
gemini-2.5-pro,
gemini-2.5-flash,
gemini-2.5-flash-lite,
gemini-2.0-flash
示例:

"gemini-2.5-pro"

messages
object[]
必填

组成当前对话的消息列表。

Minimum array length: 1
示例:
[{ "role": "user", "content": "你好!" }]
max_tokens
integer

对话补全中生成的最大 token 数。

必填范围: x >= 1
temperature
number
默认值:1

采样温度,范围 0 到 2。

必填范围: 0 <= x <= 2
示例:

1

top_p
number

核采样阈值。

必填范围: 0 <= x <= 1
frequency_penalty
number
默认值:0

根据新 token 在文本中的现有频率进行惩罚。

必填范围: -2 <= x <= 2
presence_penalty
number
默认值:0

根据新 token 是否已出现在文本中进行惩罚。

必填范围: -2 <= x <= 2
stream
boolean
默认值:false

如果为 true,将通过 SSE 流式发送部分消息。

stop

API 将在生成这些序列时停止继续生成。

n
integer
默认值:1

为每条输入消息生成多少个补全选项。

必填范围: x >= 1
response_format
object

指定模型必须输出的格式。设置为 {"type": "json_object"} 可启用 JSON 模式。

响应

补全生成成功

id
string
必填
示例:

"chatcmpl-abc123"

object
string
必填
示例:

"chat.completion"

created
integer
必填

补全创建时的 Unix 时间戳。

model
string
必填
示例:

"gemini-2.5-pro"

choices
object[]
必填
usage
object