Create chat completion
POST
/chat/completions
const url = 'https://example.com/chat/completions';const options = { method: 'POST', headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'}, body: '{"messages":[{"content":"Hello!","role":"user"}],"model":"gpt-5.5","stream":false}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}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).
Authorizations
Заголовок раздела «Authorizations»Request Bodyrequired
Заголовок раздела «Request Bodyrequired»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>
_Msgobject
role
required
Role
string
content
Content
stream
Stream
If true, stream tokens as SSE (text/event-stream).
boolean
Example
{ "messages": [ { "content": "Hello!", "role": "user" } ], "model": "gpt-5.5", "stream": false}Responses
Заголовок раздела «Responses»Successful Response
Media typeapplication/json
Examplegenerated
exampleValidation Error
Media typeapplication/json
HTTPValidationError
object
detail
Detail
Array<object>
ValidationErrorobject
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": {} } ]}