Skip to main content
POST
Chat Completions

授权

Authorization
string
header
必填

API Key obtained from the APIYI Console

请求体

application/json
model
string
必填

Model name. APIYI supports 400+ models — just change the model name to switch between providers.

示例:

"gpt-4o"

"gpt-4o-mini"

"gpt-5-chat-latest"

"claude-sonnet-4-20250514"

"claude-opus-4-1-20250805"

"claude-3-5-haiku-20241022"

"gemini-2.5-pro"

"gemini-2.5-flash"

"gemini-2.0-flash"

"deepseek-r1"

"deepseek-v3-0324"

"grok-4-0709"

"grok-3"

"o4-mini"

"o3"

"qwen-max"

"glm-4-plus"

messages
object[]
必填

Array of conversation messages, supports multi-turn dialogue

示例:
temperature
number
默认值:1

Sampling temperature. Higher values (e.g., 0.8) make output more random, lower values (e.g., 0.2) make it more deterministic.

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

Maximum number of tokens to generate. Different models have different limits.

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

Nucleus sampling parameter. It is generally recommended not to modify both temperature and top_p.

必填范围: 0 <= x <= 1
n
integer
默认值:1

Number of completions to generate for each message.

必填范围: x >= 1
stream
boolean
默认值:false

Whether to stream results. The Playground does not support streaming preview — use an SDK to test.

stop

Stop sequence(s). Generation stops when this sequence is encountered. Up to 4.

presence_penalty
number
默认值:0

Presence penalty. Positive values increase the likelihood of talking about new topics.

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

Frequency penalty. Positive values decrease the likelihood of repeating the same text verbatim.

必填范围: -2 <= x <= 2
user
string

A unique identifier for the end user, used for monitoring and abuse detection.

响应

Successfully returned chat completion result

id
string

Unique identifier for the request

示例:

"chatcmpl-abc123"

object
enum<string>
可用选项:
chat.completion
示例:

"chat.completion"

created
integer

Creation timestamp (Unix seconds)

示例:

1702855400

model
string

The model actually used

示例:

"gpt-4o"

choices
object[]
usage
object

Token usage statistics