Skip to main content
POST
Creates a chat conversation.

Body

application/json
messages
(System message · object | User message · object | Assistant message · object | Tool message · object)[]
required

A list of messages comprising the conversation so far. Depending on the model you use, different message types (modalities) are supported, like text, images, and audio.

Minimum array length: 1
Example:
model
string
required

Model ID used to generate the response.

Example:

"qwen2.5-vl-3b"

frequency_penalty
number | null
default:0

Number between -2.0 and 2.0. Positive values penalize new tokens based on their existing frequency in the text so far, decreasing the model's likelihood to repeat the same line verbatim.

Required range: -2 <= x <= 2
max_completion_tokens
integer | null

An upper bound for the number of tokens that can be generated for a completion, including visible output tokens and reasoning tokens.

presence_penalty
number | null
default:0

Number between -2.0 and 2.0. Positive values penalize new tokens based on whether they appear in the text so far, increasing the model's likelihood to talk about new topics.

Required range: -2 <= x <= 2
safety_identifier
string | null

A stable identifier used to help detect users of your application that may be violating OpenAI's usage policies. The IDs should be a string that uniquely identifies each user.

seed
integer | null

If specified, our system will make a best effort to sample deterministically, such that repeated requests with the same seed and parameters should return the same result.

Required range: -9223372036854776000 <= x <= 9223372036854776000
Example:

42

stream
boolean | null
default:false

If set to true, the model response data will be streamed to the client as it is generated using server-sent events.

temperature
number | null
default:1

What sampling temperature to use, between 0 and 2. Higher values like 0.8 will make the output more random, while lower values like 0.2 will make it more focused and deterministic.

Required range: 0 <= x <= 2
top_p
number | null
default:1

An alternative to sampling with temperature, called nucleus sampling, where the model considers the results of the tokens with top_p probability mass. So 0.1 means only the tokens comprising the top 10% probability mass are considered.

Required range: 0 <= x <= 1
top_k
integer | null
default:40

Top-k sampling parameter. If specified, the sampler considers only the k most likely next tokens at each step. If omitted, the model's configured sampler defaults are used.

Required range: x >= 1

Response

200 - application/json

OK

Represents a chat completion response returned by model, based on the provided input.

id
string
required

A unique identifier for the chat completion.

choices
object[]
required

A list of chat completion choices. Can be more than one if n is greater than 1.

created
integer
required

The Unix timestamp (in seconds) of when the chat completion was created.

object
enum<string>
required

The object type, which is always chat.completion.

Available options:
chat.completion
model
string

The model used for the chat completion.

usage
object

Usage statistics for the completion request.