Create Chat Completion
Given a list of messages comprising a conversation, the provided model returns an appropriate response.
For more details, see Create chat documentation in the OpenAI API reference and the related Chat Completions API guide.
Input
| Field | Definition | Type | Required |
|---|---|---|---|
|
Model |
The identifier of the model to use. See the Model endpoint compatibility table for details on which models work with the Chat API. |
Dropdown | TRUE |
|
Messages |
A list of the messages that comprise the conversation. |
List of Objects | TRUE |
|
Temperature |
The sampling temperature to use in the output. Values can be from Higher values like Okta generally recommends altering this input or Top P, but not both. |
Number | FALSE |
|
Top P |
An alternative to sampling with temperature, this is called nucleus sampling. The model considers the results of the tokens with Top P probability mass. A value of Okta generally recommends altering this input or Temperature but not both. |
Number | FALSE |
|
N |
How many chat completion choices to generate for each input message. The default is |
Number | FALSE |
|
Stop |
You can specify up to four text sequences that tell the API to stop generating further tokens. See How do I use Stop Sequences? The returned chat completion doesn't contain the |
Text |
FALSE |
|
Max Tokens |
The maximum number of tokens to generate in the chat completion. See Tokenizer. |
Number | FALSE |
|
Presence Penalty |
A number from Positive values penalize new tokens based on whether they already appear in the text, thus increasing the likelihood of the model to talk about new topics. |
Number | FALSE |
|
Frequency Penalty |
A number from Positive values penalize new tokens based on whether they already appear in the text, thus decreasing the likelihood of the model to repeat the same line. |
Number | FALSE |
|
User |
A unique identifier representing your end user. OpenAI can use this ID to monitor and detect abuse. See Safety Best Practices. |
Text |
FALSE |
Output
| Field | Definition | Type |
|---|---|---|
|
Model |
The model used in the chat completion. |
Text |
|
ID |
A unique identifier for the chat completion chunk |
Text |
|
Object |
The object type. This is always |
Text |
|
Created |
The Unix timestamp when OpenAI created the chat completion. The value is in seconds. |
Number |
|
Choices |
A list of the chat completion choices:
This result can be more than one, if N is greater than |
List of Objects |
|
Usage |
The usage statistics for the completion request:
|
Object |
|
Raw Output |
The raw output returned by the chat. |
Object |
Example
The following is an example of the Raw Output result returned by the card:
{
"id": "chatcmpl-123",
"object": "chat.completion",
"created": 1677652288,
"model": "gpt-3.5-turbo-0613",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "\n\nHello there, how may I assist you today?"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 9,
"completion_tokens": 12,
"total_tokens": 21
}
}