AI & LLM

OpenAI Chat Completion Response JSON Example

A complete JSON example of an OpenAI Chat Completions API response — includes choices, message content, finish_reason, and token usage. Copy-ready for building LLM apps and parsing model output.

{
  "id": "chatcmpl-Bf3kZq9X2nLp7TtVmWcR",
  "object": "chat.completion",
  "created": 1716902400,
  "model": "gpt-4o-2024-08-06",
  "choices": [
    {
      "index": 0,
      "message": {
        "role": "assistant",
        "content": "JSON (JavaScript Object Notation) is a lightweight, text-based format for storing and exchanging data. It uses key–value pairs and arrays, and is easy for both humans and machines to read.",
        "refusal": null
      },
      "logprobs": null,
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 24,
    "completion_tokens": 41,
    "total_tokens": 65,
    "prompt_tokens_details": {
      "cached_tokens": 0
    },
    "completion_tokens_details": {
      "reasoning_tokens": 0
    }
  },
  "system_fingerprint": "fp_6fc10e10eb"
}

Field Reference

idrequiredstringUnique identifier for the completion, prefixed with chatcmpl-
objectrequiredstringObject type — always 'chat.completion' for non-streamed responses
createdrequiredintegerUnix timestamp (seconds) of when the completion was created
modelrequiredstringThe exact model snapshot that produced the response
choicesrequiredarray<object>List of completion choices; usually one unless n > 1 was requested
choices[].message.contentrequiredstringThe assistant's generated text. May be null when a tool call is returned instead
choices[].finish_reasonrequiredstringWhy generation stopped: stop, length, tool_calls, or content_filter
usagerequiredobjectToken accounting for the request and response — used for billing

Variants

Request bodyThe chat request you POST to /v1/chat/completions.
{
  "model": "gpt-4o",
  "messages": [
    {
      "role": "system",
      "content": "You are a concise technical assistant."
    },
    {
      "role": "user",
      "content": "What is JSON in one sentence?"
    }
  ],
  "temperature": 0.7,
  "max_tokens": 256,
  "stream": false
}
Streaming chunk (SSE delta)A single chunk emitted when stream: true. Each chunk carries a partial delta.
Streaming chunk (SSE delta)
{
  "id": "chatcmpl-Bf3kZq9X2nLp7TtVmWcR",
  "object": "chat.completion.chunk",
  "created": 1716902400,
  "model": "gpt-4o-2024-08-06",
  "choices": [
    {
      "index": 0,
      "delta": {
        "content": "JSON "
      },
      "finish_reason": null
    }
  ]
}

Common Use Cases

  • Parsing assistant replies when integrating the OpenAI API into an app
  • Logging token usage per request for cost tracking and rate limiting
  • Mocking LLM responses in tests without calling the live API
openaillmchatgptchat completiongpt-4ai api

Validate or format this JSON

One click loads this exact example into the tool — no copy-paste needed. Format it, validate it, explore the tree, or generate TypeScript types instantly.

Frequently Asked Questions

It explains why generation stopped: 'stop' means the model finished naturally (or hit a stop sequence), 'length' means it hit max_tokens, 'tool_calls' means the model wants to call a function, and 'content_filter' means output was filtered. Always handle 'length' — it usually means the answer was truncated.

When the model decides to call a tool/function, it returns a tool_calls array instead of text, and content is null. Your code should check for tool_calls before assuming content is a string.

With stream: true the API sends Server-Sent Events. Each event's object is 'chat.completion.chunk' and carries a delta with a partial token or two. Concatenate the delta.content values to build the full message, and stop when you receive finish_reason or the [DONE] sentinel.

Related JSON Examples