Skip to main content

Chat Completion Object

The Chat Completions API returns two object types: non-streaming responses return a ChatCompletion object, and streaming responses return ChatCompletionChunk objects.

Chat Completion Object

The complete response object returned by non-streaming requests.
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion",
  "created": 1709123456,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "Hello! How can I help you?"
      },
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 12,
    "completion_tokens": 15,
    "total_tokens": 27
  },
  "system_fingerprint": "fp_abc123"
}

Field Descriptions

FieldTypeDescription
idstringUnique identifier for this completion
objectstringAlways chat.completion
createdintegerUnix timestamp of creation time
modelstringThe model name actually used
choicesarrayList of completion results, length determined by the n request parameter
choices[].indexintegerIndex of the result in the list
choices[].messageobjectThe message generated by the model
choices[].message.rolestringAlways assistant
choices[].message.contentstring|nullText content of the message
choices[].message.tool_callsarray|nullList of tools the model requests to call
choices[].finish_reasonstringStop reason: stop, length, tool_calls, content_filter
usageobjectToken usage statistics
usage.prompt_tokensintegerNumber of input tokens
usage.completion_tokensintegerNumber of output tokens
usage.total_tokensintegerTotal number of tokens
system_fingerprintstring|nullSystem fingerprint

Chat Completion Chunk Object (Streaming)

During streaming requests, the server returns ChatCompletionChunk objects in SSE (Server-Sent Events) format, chunk by chunk.
{
  "id": "chatcmpl-abc123",
  "object": "chat.completion.chunk",
  "created": 1709123456,
  "model": "gpt-4o",
  "choices": [
    {
      "index": 0,
      "delta": {
        "role": "assistant",
        "content": "Hello"
      },
      "finish_reason": null
    }
  ]
}

Field Descriptions

FieldTypeDescription
idstringUnique identifier for this completion, shared across all chunks
objectstringAlways chat.completion.chunk
createdintegerUnix timestamp of creation time
modelstringThe model name actually used
choicesarrayList of incremental results
choices[].indexintegerIndex of the result in the list
choices[].deltaobjectIncremental message content
choices[].delta.rolestringOnly appears in the first chunk, value is assistant
choices[].delta.contentstringIncremental text content
choices[].delta.tool_callsarrayIncremental tool calls
choices[].finish_reasonstring|nullStop reason in the last chunk, null for all others
usageobject|nullOnly included in the last chunk when stream_options.include_usage is true

Streaming Format

Streaming responses follow the SSE protocol. Each event is prefixed with data: , and the stream ends with data: [DONE]:
data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1709123456,"model":"gpt-4o","choices":[{"index":0,"delta":{"role":"assistant","content":""},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1709123456,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"Hello"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1709123456,"model":"gpt-4o","choices":[{"index":0,"delta":{"content":"!"},"finish_reason":null}]}

data: {"id":"chatcmpl-abc123","object":"chat.completion.chunk","created":1709123456,"model":"gpt-4o","choices":[{"index":0,"delta":{},"finish_reason":"stop"}]}

data: [DONE]
Crazyrouter is fully compatible with the OpenAI Chat Completion object format and supports all standard fields. Additional fields returned by upstream models are also passed through to the client.