{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/nielseniq/main/json-schema/nielseniq-create-chat-completion-response-schema.json",
  "title": "createChatCompletionResponse",
  "x-generated": "2026-10-18",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/nielseniq-docusearch-us-azure-openai-service-api-openapi.yml#/components/schemas/createChatCompletionResponse",
  "required": [
    "id",
    "object",
    "created",
    "model",
    "choices"
  ],
  "type": "object",
  "allOf": [
    {
      "$ref": "#/$defs/chatCompletionsResponseCommon"
    },
    {
      "properties": {
        "prompt_filter_results": {
          "$ref": "#/$defs/promptFilterResults"
        },
        "choices": {
          "type": "array",
          "items": {
            "type": "object",
            "allOf": [
              {
                "$ref": "#/$defs/chatCompletionChoiceCommon"
              },
              {
                "properties": {
                  "message": {
                    "$ref": "#/$defs/chatCompletionResponseMessage"
                  },
                  "content_filter_results": {
                    "$ref": "#/$defs/contentFilterChoiceResults"
                  }
                }
              }
            ]
          }
        }
      }
    }
  ],
  "$defs": {
    "azureChatExtensionsMessageContext": {
      "type": "object",
      "properties": {
        "citations": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/citation"
          },
          "description": "The data source retrieval result, used to generate the assistant message in the response.",
          "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."
    },
    "chatCompletionChoiceCommon": {
      "type": "object",
      "properties": {
        "index": {
          "type": "integer"
        },
        "finish_reason": {
          "type": "string"
        }
      }
    },
    "chatCompletionFunctionCall": {
      "required": [
        "name",
        "arguments"
      ],
      "type": "object",
      "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."
        }
      },
      "description": "Deprecated and replaced by `tool_calls`. The name and arguments of a function that should be called, as generated by the model."
    },
    "chatCompletionMessageToolCall": {
      "required": [
        "id",
        "type",
        "function"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "The ID of the tool call."
        },
        "type": {
          "$ref": "#/$defs/toolCallType"
        },
        "function": {
          "required": [
            "name",
            "arguments"
          ],
          "type": "object",
          "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."
            }
          },
          "description": "The function that the model called."
        }
      }
    },
    "chatCompletionResponseMessage": {
      "type": "object",
      "properties": {
        "role": {
          "$ref": "#/$defs/chatCompletionResponseMessageRole"
        },
        "content": {
          "type": [
            "string",
            "null"
          ],
          "description": "The contents of the message."
        },
        "tool_calls": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/chatCompletionMessageToolCall"
          },
          "description": "The tool calls generated by the model, such as function calls."
        },
        "function_call": {
          "$ref": "#/$defs/chatCompletionFunctionCall"
        },
        "context": {
          "$ref": "#/$defs/azureChatExtensionsMessageContext"
        }
      },
      "description": "A chat completion message generated by the model."
    },
    "chatCompletionResponseMessageRole": {
      "enum": [
        "assistant"
      ],
      "type": "string",
      "description": "The role of the author of the response message."
    },
    "chatCompletionResponseObject": {
      "enum": [
        "chat.completion"
      ],
      "type": "string",
      "description": "The object type.",
      "x-ms-enum": {
        "name": "ChatCompletionResponseObject",
        "modelAsString": true,
        "values": [
          {
            "value": "chat.completion",
            "description": "The object type is chat completion."
          }
        ]
      }
    },
    "chatCompletionsResponseCommon": {
      "required": [
        "id",
        "object",
        "created",
        "model"
      ],
      "type": "object",
      "properties": {
        "id": {
          "type": "string",
          "description": "A unique identifier for the chat completion."
        },
        "object": {
          "$ref": "#/$defs/chatCompletionResponseObject"
        },
        "created": {
          "type": "integer",
          "description": "The Unix timestamp (in seconds) of when the chat completion was created.",
          "format": "unixtime"
        },
        "model": {
          "type": "string",
          "description": "The model used for the chat completion."
        },
        "usage": {
          "$ref": "#/$defs/completionUsage"
        },
        "system_fingerprint": {
          "type": "string",
          "description": "Can be used in conjunction with the `seed` request parameter to understand when backend changes have been made that might impact determinism."
        }
      }
    },
    "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": {
      "required": [
        "prompt_tokens",
        "completion_tokens",
        "total_tokens"
      ],
      "type": "object",
      "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)."
        }
      },
      "description": "Usage statistics for the completion request."
    },
    "contentFilterChoiceResults": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultsBase"
        },
        {
          "properties": {
            "protected_material_text": {
              "$ref": "#/$defs/contentFilterDetectedResult"
            }
          }
        },
        {
          "properties": {
            "protected_material_code": {
              "$ref": "#/$defs/contentFilterDetectedWithCitationResult"
            }
          }
        }
      ],
      "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."
    },
    "contentFilterDetectedResult": {
      "required": [
        "detected",
        "filtered"
      ],
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultBase"
        },
        {
          "properties": {
            "detected": {
              "type": "boolean"
            }
          }
        }
      ]
    },
    "contentFilterDetectedWithCitationResult": {
      "required": [
        "detected",
        "filtered"
      ],
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterDetectedResult"
        },
        {
          "properties": {
            "citation": {
              "type": "object",
              "properties": {
                "URL": {
                  "type": "string"
                },
                "license": {
                  "type": "string"
                }
              }
            }
          }
        }
      ]
    },
    "contentFilterPromptResults": {
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultsBase"
        },
        {
          "properties": {
            "jailbreak": {
              "$ref": "#/$defs/contentFilterDetectedResult"
            }
          }
        }
      ],
      "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."
    },
    "contentFilterResultBase": {
      "required": [
        "filtered"
      ],
      "type": "object",
      "properties": {
        "filtered": {
          "type": "boolean"
        }
      }
    },
    "contentFilterResultsBase": {
      "type": "object",
      "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"
        }
      },
      "description": "Information about the content filtering results."
    },
    "contentFilterSeverityResult": {
      "required": [
        "severity",
        "filtered"
      ],
      "type": "object",
      "allOf": [
        {
          "$ref": "#/$defs/contentFilterResultBase"
        },
        {
          "properties": {
            "severity": {
              "enum": [
                "safe",
                "low",
                "medium",
                "high"
              ],
              "type": "string",
              "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."
                  }
                ]
              }
            }
          }
        }
      ]
    },
    "errorBase": {
      "type": "object",
      "properties": {
        "code": {
          "type": "string"
        },
        "message": {
          "type": "string"
        }
      }
    },
    "promptFilterResult": {
      "type": "object",
      "properties": {
        "prompt_index": {
          "type": "integer"
        },
        "content_filter_results": {
          "$ref": "#/$defs/contentFilterPromptResults"
        }
      },
      "description": "Content filtering results for a single prompt in the request."
    },
    "promptFilterResults": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/promptFilterResult"
      },
      "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."
    },
    "toolCallType": {
      "enum": [
        "function"
      ],
      "type": "string",
      "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."
          }
        ]
      }
    }
  }
}