POST
/
v1
/
chat
/
completions

The chat endpoint is used to generate chat completions using the OpenAI API. This endpoint is designed to assist with generating responses to messages in a chat application. The model is fine-tuned on a mixture of conversations from the internet, as well as a small number of conversations created in-house. The model is able to generate responses to messages in a conversational style, and can also generate messages in a specific persona.

Body

application/json
max_tokens
integer
default: inf

The maximum number of tokens allowed for the generated answer. By default, the number of tokens the model can return will be (4096 - prompt tokens).

messages
object[]
required

The messages to generate chat completions for, in the chat format.

model
string
default: gpt-3.5-turborequired

The model to use for generating completions.

stream
boolean | null
default: false

If set, partial message deltas will be sent, like in ChatGPT. Tokens will be sent as data-only server-sent events as they become available, with the stream terminated by a data: [DONE] message. #magic___^_^___line

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.

We generally recommend altering this or top_p but not both.

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.

We generally recommend altering this or temperature but not both.

Response

200 - application/json
id
string
required

The ID of the completion.

model
string
required

The model used for generating the completion.

object
string
required

The type of the completion object.

created
integer
required

The timestamp of the completion creation, in unix epoch time.

choices
object[]
required

The generated completions.

usage
object
required

The usage statistics for the completion.

system_fingerprint
string

The system fingerprint of the completion.