Skip to main content
POST
Chat Completions

Authorizations

Authorization
string
header
required

API Key obtained from the APIYI Console

Body

application/json
model
string
required

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

Examples:

"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[]
required

Array of conversation messages, supports multi-turn dialogue

Example:
temperature
number
default:1

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

Required range: 0 <= x <= 2
max_tokens
integer

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

Required range: x >= 1
top_p
number
default:1

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

Required range: 0 <= x <= 1
n
integer
default:1

Number of completions to generate for each message.

Required range: x >= 1
stream
boolean
default: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
default:0

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

Required range: -2 <= x <= 2
frequency_penalty
number
default:0

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

Required range: -2 <= x <= 2
user
string

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

Response

Successfully returned chat completion result

id
string

Unique identifier for the request

Example:

"chatcmpl-abc123"

object
enum<string>
Available options:
chat.completion
Example:

"chat.completion"

created
integer

Creation timestamp (Unix seconds)

Example:

1702855400

model
string

The model actually used

Example:

"gpt-4o"

choices
object[]
usage
object

Token usage statistics