{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-openai/json-schema/microsoft-azure-openai-create-chat-completion-response-schema.json",
  "title": "createChatCompletionResponse",
  "description": "Represents a chat completion response returned by model, based on the provided input.",
  "x-generated": "2026-11-12",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-openai-deployments-api-openapi.yml#/components/schemas/createChatCompletionResponse",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "A unique identifier for the chat completion."
    },
    "prompt_filter_results": {
      "$ref": "#/$defs/promptFilterResults"
    },
    "choices": {
      "type": "array",
      "description": "A list of chat completion choices. Can be more than one if `n` is greater than 1.",
      "items": {
        "type": "object",
        "required": [
          "finish_reason",
          "index",
          "message",
          "logprobs"
        ],
        "properties": {
          "finish_reason": {
            "type": "string",
            "description": "The reason the model stopped generating tokens. This will be `stop` if the model hit a natural stop point or a provided stop sequence,\n`length` if the maximum number of tokens specified in the request was reached,\n`content_filter` if content was omitted due to a flag from our content filters,\n`tool_calls` if the model called a tool, or `function_call` (deprecated) if the model called a function.\n",
            "enum": [
              "stop",
              "length",
              "tool_calls",
              "content_filter",
              "function_call"
            ]
          },
          "index": {
            "type": "integer",
            "description": "The index of the choice in the list of choices."
          },
          "message": {
            "$ref": "#/$defs/chatCompletionResponseMessage"
          },
          "content_filter_results": {
            "$ref": "#/$defs/contentFilterChoiceResults"
          },
          "logprobs": {
            "description": "Log probability information for the choice.",
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "content": {
                "description": "A list of message content tokens with log probability information.",
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/$defs/chatCompletionTokenLogprob"
                }
              },
              "refusal": {
                "description": "A list of message refusal tokens with log probability information.",
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "$ref": "#/$defs/chatCompletionTokenLogprob"
                }
              }
            },
            "required": [
              "content",
              "refusal"
            ]
          }
        }
      }
    },
    "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."
    },
    "system_fingerprint": {
      "type": "string",
      "description": "This fingerprint represents the backend configuration that the model runs with.\n\nCan be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism.\n"
    },
    "object": {
      "type": "string",
      "description": "The object type, which is always `chat.completion`.",
      "enum": [
        "chat.completion"
      ]
    },
    "usage": {
      "$ref": "#/$defs/completionUsage"
    }
  },
  "required": [
    "choices",
    "created",
    "id",
    "model",
    "object"
  ],
  "$defs": {
    "azureChatExtensionsMessageContext": {
      "type": "object",
      "properties": {
        "citations": {
          "type": "array",
          "description": "The data source retrieval result, used to generate the assistant message in the response.",
          "items": {
            "$ref": "#/$defs/citation"
          },
          "x-ms-identifiers": []
        },
        "intent": {
          "type": "string",
          "description": "The detected intent from the chat history, used to pass to the next turn to carry over the context."
        }
      },
      "description": "  A representation of the additional context information available when Azure OpenAI chat extensions are involved\n  in the generation of a corresponding chat completions response. This context information is only populated when\n  using an Azure OpenAI request configured to use a matching extension."
    },
    "chatCompletionFunctionCall": {
      "type": "object",
      "description": "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model.",
      "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, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."
        }
      },
      "required": [
        "name",
        "arguments"
      ]
    },
    "chatCompletionMessageToolCall": {
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the tool call."
        },
        "type": {
          "$ref": "#/$defs/toolCallType"
        },
        "function": {
          "type": "object",
          "description": "The function that the model called.",
          "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, and may hallucinate parameters not defined by your function schema. Validate the arguments in your code before calling your function."
            }
          },
          "required": [
            "name",
            "arguments"
          ]
        }
      },
      "required": [
        "id",
        "type",
        "function"
      ]
    },
    "chatCompletionResponseMessage": {
      "type": "object",
      "description": "A chat completion message generated by the model.",
      "properties": {
        "role": {
          "$ref": "#/$defs/chatCompletionResponseMessageRole"
        },
        "refusal": {
          "type": [
            "string",
            "null"
          ],
          "description": "The refusal message generated by the model."
        },
        "content": {
          "type": [
            "string",
            "null"
          ],
          "description": "The contents of the message."
        },
        "tool_calls": {
          "type": "array",
          "description": "The tool calls generated by the model, such as function calls.",
          "items": {
            "$ref": "#/$defs/chatCompletionMessageToolCall"
          }
        },
        "function_call": {
          "$ref": "#/$defs/chatCompletionFunctionCall"
        },
        "context": {
          "$ref": "#/$defs/azureChatExtensionsMessageContext"
        }
      },
      "required": [
        "role",
        "content",
        "refusal"
      ]
    },
    "chatCompletionResponseMessageRole": {
      "type": "string",
      "enum": [
        "assistant"
      ],
      "description": "The role of the author of the response message."
    },
    "chatCompletionTokenLogprob": {
      "type": "object",
      "properties": {
        "token": {
          "description": "The token.",
          "type": "string"
        },
        "logprob": {
          "description": "The log probability of this token.",
          "type": "number"
        },
        "bytes": {
          "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.",
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": "integer"
          }
        },
        "top_logprobs": {
          "description": "List of the most likely tokens and their log probability, at this token position. In rare cases, there may be fewer than the number of requested `top_logprobs` returned.",
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "token": {
                "description": "The token.",
                "type": "string"
              },
              "logprob": {
                "description": "The log probability of this token.",
                "type": "number"
              },
              "bytes": {
                "description": "A list of integers representing the UTF-8 bytes representation of the token. Useful in instances where characters are represented by multiple tokens and their byte representations must be combined to generate the correct text representation. Can be `null` if there is no bytes representation for the token.",
                "type": [
                  "array",
                  "null"
                ],
                "items": {
                  "type": "integer"
                }
              }
            },
            "required": [
              "token",
              "logprob",
              "bytes"
            ]
          }
        }
      },
      "required": [
        "token",
        "logprob",
        "bytes",
        "top_logprobs"
      ]
    },
    "citation": {
      "required": [
        "content"
      ],
      "type": "object",
      "properties": {
        "content": {
          "type": "string",
          "description": "The content of the citation."
        },
        "title": {
          "type": "string",
          "description": "The title of the citation."
        },
        "url": {
          "type": "string",
          "description": "The URL of the citation."
        },
        "filepath": {
          "type": "string",
          "description": "The file path of the citation."
        },
        "chunk_id": {
          "type": "string",
          "description": "The chunk ID of the citation."
        }
      },
      "description": "citation information for a chat completions response message."
    },
    "completionUsage": {
      "type": "object",
      "description": "Usage statistics for the completion request.",
      "properties": {
        "prompt_tokens": {
          "type": "integer",
          "description": "Number of tokens in the prompt."
        },
        "completion_tokens": {
          "type": "integer",
          "description": "Number of tokens in the generated completion."
        },
        "total_tokens": {
          "type": "integer",
          "description": "Total number of tokens used in the request (prompt + completion)."
        },
        "completion_tokens_details": {
          "type": "object",
          "description": "Breakdown of tokens used in a completion.",
          "properties": {
            "reasoning_tokens": {
              "type": "integer",
              "description": "Tokens generated by the model for reasoning."
            }
          }
        }
      },
      "required": [
        "prompt_tokens",
        "completion_tokens",
        "total_tokens"
      ]
    },
    "contentFilterChoiceResults": {
      "type": "object",
      "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about third party text and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id.",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultsBase"
        },
        {
          "properties": {
            "protected_material_text": {
              "$ref": "#/$defs/contentFilterDetectedResult"
            }
          }
        },
        {
          "properties": {
            "protected_material_code": {
              "$ref": "#/$defs/contentFilterDetectedWithCitationResult"
            }
          }
        }
      ]
    },
    "contentFilterDetectedResult": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultBase"
        },
        {
          "properties": {
            "detected": {
              "type": "boolean"
            }
          }
        }
      ],
      "required": [
        "detected",
        "filtered"
      ]
    },
    "contentFilterDetectedWithCitationResult": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterDetectedResult"
        },
        {
          "properties": {
            "citation": {
              "type": "object",
              "properties": {
                "URL": {
                  "type": "string"
                },
                "license": {
                  "type": "string"
                }
              }
            }
          }
        }
      ],
      "required": [
        "detected",
        "filtered"
      ]
    },
    "contentFilterPromptResults": {
      "type": "object",
      "description": "Information about the content filtering category (hate, sexual, violence, self_harm), if it has been detected, as well as the severity level (very_low, low, medium, high-scale that determines the intensity and risk level of harmful content) and if it has been filtered or not. Information about jailbreak content and profanity, if it has been detected, and if it has been filtered or not. And information about customer block list, if it has been filtered and its id.",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultsBase"
        },
        {
          "properties": {
            "jailbreak": {
              "$ref": "#/$defs/contentFilterDetectedResult"
            }
          }
        }
      ]
    },
    "contentFilterResultBase": {
      "type": "object",
      "properties": {
        "filtered": {
          "type": "boolean"
        }
      },
      "required": [
        "filtered"
      ]
    },
    "contentFilterResultsBase": {
      "type": "object",
      "description": "Information about the content filtering results.",
      "properties": {
        "sexual": {
          "$ref": "#/$defs/contentFilterSeverityResult"
        },
        "violence": {
          "$ref": "#/$defs/contentFilterSeverityResult"
        },
        "hate": {
          "$ref": "#/$defs/contentFilterSeverityResult"
        },
        "self_harm": {
          "$ref": "#/$defs/contentFilterSeverityResult"
        },
        "profanity": {
          "$ref": "#/$defs/contentFilterDetectedResult"
        },
        "error": {
          "$ref": "#/$defs/errorBase"
        }
      }
    },
    "contentFilterSeverityResult": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultBase"
        },
        {
          "properties": {
            "severity": {
              "type": "string",
              "enum": [
                "safe",
                "low",
                "medium",
                "high"
              ],
              "x-ms-enum": {
                "name": "ContentFilterSeverity",
                "modelAsString": true,
                "values": [
                  {
                    "value": "safe",
                    "description": "General content or related content in generic or non-harmful contexts."
                  },
                  {
                    "value": "low",
                    "description": "Harmful content at a low intensity and risk level."
                  },
                  {
                    "value": "medium",
                    "description": "Harmful content at a medium intensity and risk level."
                  },
                  {
                    "value": "high",
                    "description": "Harmful content at a high intensity and risk level."
                  }
                ]
              }
            }
          }
        }
      ],
      "required": [
        "severity",
        "filtered"
      ]
    },
    "errorBase": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "promptFilterResult": {
      "type": "object",
      "description": "Content filtering results for a single prompt in the request.",
      "properties": {
        "prompt_index": {
          "type": "integer"
        },
        "content_filter_results": {
          "$ref": "#/$defs/contentFilterPromptResults"
        }
      }
    },
    "promptFilterResults": {
      "type": "array",
      "description": "Content filtering results for zero or more prompts in the request. In a streaming request, results for different prompts may arrive at different times or in different orders.",
      "items": {
        "$ref": "#/$defs/promptFilterResult"
      }
    },
    "toolCallType": {
      "type": "string",
      "enum": [
        "function"
      ],
      "description": "The type of the tool call, in this case `function`.",
      "x-ms-enum": {
        "name": "ToolCallType",
        "modelAsString": true,
        "values": [
          {
            "value": "function",
            "description": "The tool call type is function."
          }
        ]
      }
    }
  }
}