Перейти к содержимому

Create chat completion

POST
/chat/completions
curl --request POST \
--url https://example.com/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "messages": [ { "content": "Hello!", "role": "user" } ], "model": "gpt-5.5", "stream": false }'

OpenAI-compatible chat completion. Set stream=true for SSE token streaming; otherwise returns a single chat.completion object. Charged per-token from balance. Supports vision (image_url data: parts on vision models) and Perplexity Sonar (category=search models) — web results return as message.annotations (url_citation).

Media typeapplication/json
ChatCompletionRequest
object
model
required
Model

Model id from GET /models, or a common OpenAI/Claude/Gemini alias.

string
messages
required
Messages

Conversation so far; the last user message is the prompt.

Array<object>
_Msg
object
role
required
Role
string
content
Content
stream
Stream

If true, stream tokens as SSE (text/event-stream).

boolean
stream_options
Any of:
object
key
additional properties
any
temperature
Any of:
number
max_tokens
Any of:
integer
max_completion_tokens
Any of:
integer
reasoning_effort
Any of:
string
Allowed values: off low medium high xhigh max
Example
{
"messages": [
{
"content": "Hello!",
"role": "user"
}
],
"model": "gpt-5.5",
"stream": false
}

Successful Response

Media typeapplication/json
Examplegenerated
example

Validation Error

Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationError
object
loc
required
Location
Array
msg
required
Message
string
type
required
Error Type
string
input
Input
ctx
Context
object
Examplegenerated
{
"detail": [
{
"loc": [
"example"
],
"msg": "example",
"type": "example",
"input": "example",
"ctx": {}
}
]
}