{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-openai/json-schema/microsoft-azure-openai-create-completion-response-schema.json",
  "title": "createCompletionResponse",
  "description": "Represents a completion response from the API. Note: both the streamed and non-streamed response objects share the same shape (unlike the chat endpoint).\n",
  "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/createCompletionResponse",
  "type": "object",
  "properties": {
    "id": {
      "type": "string",
      "description": "A unique identifier for the completion."
    },
    "choices": {
      "type": "array",
      "description": "The list of completion choices the model generated for the input prompt.",
      "items": {
        "type": "object",
        "required": [
          "finish_reason",
          "index",
          "logprobs",
          "text"
        ],
        "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,\nor `content_filter` if content was omitted due to a flag from our content filters.\n",
            "enum": [
              "stop",
              "length",
              "content_filter"
            ]
          },
          "index": {
            "type": "integer"
          },
          "logprobs": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "text_offset": {
                "type": "array",
                "items": {
                  "type": "integer"
                }
              },
              "token_logprobs": {
                "type": "array",
                "items": {
                  "type": "number"
                }
              },
              "tokens": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "top_logprobs": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "text": {
            "type": "string"
          },
          "content_filter_results": {
            "$ref": "#/$defs/contentFilterChoiceResults"
          }
        }
      }
    },
    "created": {
      "type": "integer",
      "description": "The Unix timestamp (in seconds) of when the completion was created."
    },
    "model": {
      "type": "string",
      "description": "The model used for completion."
    },
    "prompt_filter_results": {
      "$ref": "#/$defs/promptFilterResults"
    },
    "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 \"text_completion\"",
      "enum": [
        "text_completion"
      ]
    },
    "usage": {
      "$ref": "#/$defs/completionUsage"
    }
  },
  "required": [
    "id",
    "object",
    "created",
    "model",
    "choices"
  ],
  "$defs": {
    "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"
      }
    }
  }
}