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 0 through 2. The default is 1.

Higher values like 0.8 make the output more random, while lower values like 0.2 make it more focused and deterministic.

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 0.1 means only the tokens comprising the top 10% of the probability mass are considered. The default is 1.

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 1.

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 stop sequence.

Text

FALSE

Max Tokens

The maximum number of tokens to generate in the chat completion.

See Tokenizer.

Number

FALSE

Presence Penalty

A number from -2.0 through 2.0.

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 -2.0 through 2.0.

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 chat.completion.

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:

  • index: The index of the choice in the list of choices.

  • message: A chat completion message generated by the model.

    • role: The role of the author of the message.

    • content: The contents of the message.

  • finish reason: The reason that the model stopped generating tokens.

    See the chat completion API for a complete description of these fields.

This result can be more than one, if N is greater than 1.

List of Objects

Usage

The usage statistics for the completion request:

  • prompt tokens: Number of tokens in the prompt.

  • completion tokens: Number of tokens in the generated completion.

  • total tokens: Total number of tokens used in the request. This is the sum of the previous two values.

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:

Copy
{
"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
}
}

Related topics

OpenAI connector

Workflow elements

OpenAI API Reference