{ "$schema": "https://json-schema.org/draft/2020-12/schema", "$id": "https://platform.openai.com/schemas/openai/chat-completion.json", "title": "OpenAI Chat Completion", "description": "A chat completion response object returned by the OpenAI Chat Completions API. Represents a model-generated message in response to a conversation comprising a list of messages.", "type": "object", "required": ["id", "object", "created", "model", "choices"], "properties": { "id": { "type": "string", "description": "A unique identifier for the chat completion. Prefixed with chatcmpl-.", "pattern": "^chatcmpl-" }, "object": { "type": "string", "const": "chat.completion", "description": "The object type, which is always chat.completion." }, "created": { "type": "integer", "description": "The Unix timestamp (in seconds) of when the chat completion was created." }, "model": { "type": "string", "description": "The model used for the chat completion (e.g., gpt-5, gpt-4.1, o4-mini)." }, "system_fingerprint": { "type": ["string", "null"], "description": "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." }, "service_tier": { "type": ["string", "null"], "description": "The service tier used for processing the request. This field is only included if the service_tier parameter is specified in the request." }, "choices": { "type": "array", "description": "A list of chat completion choices. Can be more than one if n is greater than 1.", "items": { "$ref": "#/$defs/Choice" } }, "usage": { "$ref": "#/$defs/Usage" } }, "$defs": { "Choice": { "type": "object", "description": "A chat completion choice containing the model's generated message and metadata.", "required": ["index", "message", "finish_reason"], "properties": { "index": { "type": "integer", "minimum": 0, "description": "The index of the choice in the list of choices." }, "message": { "$ref": "#/$defs/AssistantMessage" }, "finish_reason": { "type": "string", "enum": ["stop", "length", "tool_calls", "content_filter"], "description": "The reason the model stopped generating tokens. stop indicates a natural stop point or provided stop sequence was reached. length indicates max_tokens was reached. tool_calls indicates the model called a tool. content_filter indicates content was omitted due to a content filter flag." }, "logprobs": { "type": ["object", "null"], "description": "Log probability information for the choice, if requested.", "properties": { "content": { "type": ["array", "null"], "description": "A list of message content tokens with log probability information.", "items": { "$ref": "#/$defs/TokenLogprob" } }, "refusal": { "type": ["array", "null"], "description": "A list of refusal message content tokens with log probability information.", "items": { "$ref": "#/$defs/TokenLogprob" } } } } } }, "AssistantMessage": { "type": "object", "description": "A chat completion message generated by the model.", "required": ["role", "content"], "properties": { "role": { "type": "string", "const": "assistant", "description": "The role of the author of this message, always assistant." }, "content": { "type": ["string", "null"], "description": "The contents of the message. Can be null if the model called a tool." }, "refusal": { "type": ["string", "null"], "description": "The refusal message generated by the model, if applicable." }, "tool_calls": { "type": "array", "description": "The tool calls generated by the model, such as function calls.", "items": { "$ref": "#/$defs/ToolCall" } } } }, "ToolCall": { "type": "object", "description": "A tool call generated by the model.", "required": ["id", "type", "function"], "properties": { "id": { "type": "string", "description": "The ID of the tool call." }, "type": { "type": "string", "const": "function", "description": "The type of the tool call, currently always function." }, "function": { "type": "object", "description": "The function that the model called.", "required": ["name", "arguments"], "properties": { "name": { "type": "string", "description": "The name of the function to call." }, "arguments": { "type": "string", "description": "The arguments to call the function with, as generated by the model in JSON format. Note that the model does not always generate valid JSON." } } } } }, "TokenLogprob": { "type": "object", "description": "Log probability information for a single token.", "required": ["token", "logprob", "bytes", "top_logprobs"], "properties": { "token": { "type": "string", "description": "The token string." }, "logprob": { "type": "number", "description": "The log probability of this token. -9999.0 represents very low probability." }, "bytes": { "type": ["array", "null"], "description": "A list of integers representing the UTF-8 bytes representation of the token.", "items": { "type": "integer" } }, "top_logprobs": { "type": "array", "description": "List of the most likely tokens and their log probability, at this token position.", "items": { "type": "object", "required": ["token", "logprob", "bytes"], "properties": { "token": { "type": "string" }, "logprob": { "type": "number" }, "bytes": { "type": ["array", "null"], "items": { "type": "integer" } } } } } } }, "Usage": { "type": "object", "description": "Usage statistics for the completion request.", "required": ["prompt_tokens", "completion_tokens", "total_tokens"], "properties": { "prompt_tokens": { "type": "integer", "minimum": 0, "description": "Number of tokens in the prompt." }, "completion_tokens": { "type": "integer", "minimum": 0, "description": "Number of tokens in the generated completion." }, "total_tokens": { "type": "integer", "minimum": 0, "description": "Total number of tokens used in the request (prompt + completion)." }, "completion_tokens_details": { "type": "object", "description": "Breakdown of tokens used in the completion.", "properties": { "reasoning_tokens": { "type": "integer", "minimum": 0, "description": "Tokens generated by the model for internal reasoning (used by o-series models)." }, "accepted_prediction_tokens": { "type": "integer", "minimum": 0, "description": "When using Predicted Outputs, the number of tokens in the prediction that appeared in the completion." }, "rejected_prediction_tokens": { "type": "integer", "minimum": 0, "description": "When using Predicted Outputs, the number of tokens in the prediction that did not appear in the completion." } } }, "prompt_tokens_details": { "type": "object", "description": "Breakdown of tokens used in the prompt.", "properties": { "cached_tokens": { "type": "integer", "minimum": 0, "description": "The number of prompt tokens that were served from cache." } } } } } } }