Create chat completion
Changed onStarting a new project? We recommend trying Responses to take advantage of the latest OpenAI platform features. Compare Chat Completions with Responses.
Creates a model response for the given chat conversation. Learn more in the text generation, vision, and audio guides.
Parameter support can differ depending on the model used to generate the response, particularly for newer reasoning models. Parameters that are only supported for reasoning models are noted below. For the current state of unsupported parameters in reasoning models, refer to the reasoning guide.
Returns a chat completion object, or a streamed sequence of chat completion chunk objects if the request is streamed.
Request
- Base URLhttps://api.openai.com/v1
- URLhttps://api.openai.com/v1/chat/completions
- AuthHTTP bearer
Request body
Example request
{
"temperature": 1,
"top_p": 1,
"user": "user-1234",
"safety_identifier": "safety-identifier-1234",
"prompt_cache_key": "prompt-cache-key-1234",
"audio": {
"voice": {
"id": "voice_1234"
}
},
"stop": "\n",
"n": 1
}Response
Returns a Chat Completion object for a non-streaming request.
If stream is true, returns server-sent events (text/event-stream). Successful chunk frames contain a JSON Chat Completion chunk matching CreateChatCompletionStreamResponse. On normal completion, the final frame is:
data: [DONE]
The final frame ends with a blank line. [DONE] is literal text, not a JSON chunk, and this frame has no event: done field.
If a failure occurs after streaming has started, a data frame may contain a JSON object with an error field instead of a completion chunk. The streaming schema describes successful JSON chunks, not error frames or the completion marker. An interrupted stream may end without the marker.
Changes
- info
added the new
gpt-6.1-terraenum value to the request property//
- info
- info
added the new optional request property
//////// - info
added the new optional request property
///////// - info
added the new optional request property
///////// - info
added the new optional request property
///////// - info
added the new optional request property
///////// - info
added the new optional request property
///////// - info
added the new optional request property
////////// - info
added the new optional request property
///////// - info
added the new optional request property
///////
- info