Represents a chat completion response returned by Claude models using the OpenAI-compatible format.

Object Fields

id
string
A unique identifier for the chat completion.
choices
array
A list of chat completion choices.Each choice object contains:
  • index (integer): The index of the choice
  • message (object): The message generated by the model
    • role (string): The role (assistant)
    • content (string): The content of the message
  • finish_reason (string): The reason the model stopped (stop, length)
created
integer
The Unix timestamp (in seconds) of when the completion was created.
model
string
The model used for the chat completion.
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

Example

{
  "id": "chatcmpl-claude-123",
  "object": "chat.completion",
  "created": 1677652288,
  "model": "claude-sonnet-4-20250514",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you today?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 20,
    "completion_tokens": 10,
    "total_tokens": 30
  }
}