Get chat completion
Get a stored chat completion. Only Chat Completions that have been created
with the store parameter set to true will be returned.
ReturnsExpand Collapse
ChatCompletion object { id, choices, created, 7 more } Represents a chat completion response returned by model, based on the provided input.
Represents a chat completion response returned by model, based on the provided input.
choices: array of object { finish_reason, index, logprobs, message } A list of chat completion choices. Can be more than one if n is greater than 1.
A list of chat completion choices. Can be more than one if n is greater than 1.
finish_reason: "stop" or "length" or "tool_calls" or 2 moreThe reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
content_filter if content was omitted due to a flag from our content filters,
tool_calls if the model called a tool, or function_call (deprecated) if the model called a function.
Read the Model Spec for more.
The reason the model stopped generating tokens. This will be stop if the model hit a natural stop point or a provided stop sequence,
length if the maximum number of tokens specified in the request was reached,
content_filter if content was omitted due to a flag from our content filters,
tool_calls if the model called a tool, or function_call (deprecated) if the model called a function.
Read the Model Spec for more.
logprobs: object { content, refusal } or nullLog probability information for the choice.
Log probability information for the choice.
A list of message content tokens with log probability information.
A list of message content tokens with log probability information.
A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.
top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.
List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.
A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
A list of message refusal tokens with log probability information.
A list of message refusal tokens with log probability information.
A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
The log probability of this token, if it is within the top 20 most likely tokens. Otherwise, the value -9999.0 is used to signify that the token is very unlikely.
top_logprobs: array of object { token, bytes, logprob } List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.
List of the most likely tokens and their log probability, at this token position. The number of entries may be fewer than the requested top_logprobs.
A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be null if there is no bytes representation for the token.
A chat completion message generated by the model.
A chat completion message generated by the model.
annotations: optional array of object { type, url_citation } Annotations for the message, when applicable, as when using the
web search tool.
Annotations for the message, when applicable, as when using the web search tool.
If the audio output modality is requested, this object contains data
about the audio response from the model. Learn more.
If the audio output modality is requested, this object contains data about the audio response from the model. Learn more.
Deprecatedfunction_call: optional object { arguments, name } Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.
Deprecated and replaced by tool_calls. The name and arguments of a function that should be called, as generated by the model.
The tool calls generated by the model, such as function calls.
The tool calls generated by the model, such as function calls.
ChatCompletionMessageFunctionToolCall object { id, function, type } A call to a function tool created by the model.
A call to a function tool created by the model.
function: object { arguments, name } The function that the model called.
The function that the model called.
The Unix timestamp (in seconds) of when the chat completion was created.
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
moderation: optional object { input, output } or nullModeration results for the request input and generated output, if moderated
completions were requested.
Moderation results for the request input and generated output, if moderated completions were requested.
input: object { model, results, type } or object { code, message, type } Moderation for the request input.
Moderation for the request input.
ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.
Successful moderation results for the request input or generated output.
results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.
A list of moderation results.
output: object { model, results, type } or object { code, message, type } Moderation for the generated output.
Moderation for the generated output.
ModerationResults object { model, results, type } Successful moderation results for the request input or generated output.
Successful moderation results for the request input or generated output.
results: array of object { categories, category_applied_input_types, category_scores, 3 more } A list of moderation results.
A list of moderation results.
service_tier: optional "auto" or "default" or "flex" or 3 more or nullSpecifies the processing type used for serving the request.
- If set to ‘auto’, then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use ‘default’.
- If set to ‘default’, then the request will be processed with the standard pricing and performance for the selected model.
- If set to ‘flex’, then the request will be processed with the Flex Processing service tier.
- To opt-in to Fast mode at the request level, include the
service_tier=fast or service_tier=priority parameter for Responses or Chat Completions. The response will show service_tier=priority regardless of if you specify service_tier=fast or priority in your request.
- When not set, the default behavior is ‘auto’.
When the service_tier parameter is set, the response body will include the service_tier value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
Specifies the processing type used for serving the request.
- If set to ‘auto’, then the request will be processed with the service tier configured in the Project settings. Unless otherwise configured, the Project will use ‘default’.
- If set to ‘default’, then the request will be processed with the standard pricing and performance for the selected model.
- If set to ‘flex’, then the request will be processed with the Flex Processing service tier.
- To opt-in to Fast mode at the request level, include the
service_tier=fastorservice_tier=priorityparameter for Responses or Chat Completions. The response will showservice_tier=priorityregardless of if you specifyservice_tier=fastorpriorityin your request. - When not set, the default behavior is ‘auto’.
When the service_tier parameter is set, the response body will include the service_tier value based on the processing mode actually used to serve the request. This response value may be different from the value set in the parameter.
This fingerprint represents the backend configuration that the model runs with.
Can be used in conjunction with the seed request parameter to understand when backend changes have been made that might impact determinism.
Usage statistics for the completion request.
Usage statistics for the completion request.
completion_tokens_details: optional object { accepted_prediction_tokens, audio_tokens, reasoning_tokens, 2 more } Breakdown of tokens used in a completion.
Breakdown of tokens used in a completion.
When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion.
When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion. However, like reasoning tokens, these tokens are still counted in the total completion tokens for purposes of billing, output, and context window limits.
Get chat completion
curl https://api.openai.com/v1/chat/completions/chatcmpl-abc123 \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-H "Content-Type: application/json"
{
"object": "chat.completion",
"id": "chatcmpl-abc123",
"model": "gpt-4o-2024-08-06",
"created": 1738960610,
"request_id": "req_ded8ab984ec4bf840f37566c1011c417",
"tool_choice": null,
"usage": {
"total_tokens": 31,
"completion_tokens": 18,
"prompt_tokens": 13
},
"seed": 4944116822809979520,
"top_p": 1.0,
"temperature": 1.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0,
"system_fingerprint": "fp_50cad350e4",
"input_user": null,
"service_tier": "default",
"tools": null,
"metadata": {},
"choices": [
{
"index": 0,
"message": {
"content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
"role": "assistant",
"tool_calls": null,
"function_call": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"response_format": null
}
Returns Examples
{
"object": "chat.completion",
"id": "chatcmpl-abc123",
"model": "gpt-4o-2024-08-06",
"created": 1738960610,
"request_id": "req_ded8ab984ec4bf840f37566c1011c417",
"tool_choice": null,
"usage": {
"total_tokens": 31,
"completion_tokens": 18,
"prompt_tokens": 13
},
"seed": 4944116822809979520,
"top_p": 1.0,
"temperature": 1.0,
"presence_penalty": 0.0,
"frequency_penalty": 0.0,
"system_fingerprint": "fp_50cad350e4",
"input_user": null,
"service_tier": "default",
"tools": null,
"metadata": {},
"choices": [
{
"index": 0,
"message": {
"content": "Mind of circuits hum, \nLearning patterns in silence— \nFuture's quiet spark.",
"role": "assistant",
"tool_calls": null,
"function_call": null
},
"finish_reason": "stop",
"logprobs": null
}
],
"response_format": null
}