Represents a chat completion response returned by the model, based on the provided input.

Object Fields

id
string
A unique identifier for the chat completion.
choices
array
A list of chat completion choices. Can be more than one if n is greater than 1.Each choice object contains:
  • index (integer): The index of the choice in the list
  • message (object): The message generated by the model
    • role (string): The role of the message author (assistant)
    • content (string): The content of the message
  • finish_reason (string): The reason the model stopped generating (stop, length, content_filter, tool_calls)
created
integer
The Unix timestamp (in seconds) of when the chat completion was created.
model
string
The model used for the chat completion.
system_fingerprint
string
This fingerprint represents the backend configuration that the model runs with.
object
string
The object type, which is always chat.completion.
usage
object
Usage statistics for the completion request.
  • completion_tokens (integer): Number of tokens in the generated completion
  • prompt_tokens (integer): Number of tokens in the prompt
  • total_tokens (integer): Total number of tokens used in the request (prompt + completion)

Example

{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 9,
    "completion_tokens": 12,
    "total_tokens": 21
  },
  "system_fingerprint": "fp_44709d6fcb"
}