{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/letta/json-schema/letta-chat-completion-schema.json",
  "title": "ChatCompletion",
  "description": "Represents a chat completion response returned by model, based on the provided input.",
  "x-generated": "2026-11-10",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/letta-chat-completions-api-openapi.yml#/components/schemas/ChatCompletion",
  "properties": {
    "id": {
      "type": "string",
      "title": "Id"
    },
    "choices": {
      "items": {
        "$ref": "#/$defs/Choice"
      },
      "type": "array",
      "title": "Choices"
    },
    "created": {
      "type": "integer",
      "title": "Created"
    },
    "model": {
      "type": "string",
      "title": "Model"
    },
    "object": {
      "type": "string",
      "const": "chat.completion",
      "title": "Object"
    },
    "service_tier": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "auto",
            "default",
            "flex",
            "scale",
            "priority"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Service Tier"
    },
    "system_fingerprint": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "System Fingerprint"
    },
    "usage": {
      "anyOf": [
        {
          "$ref": "#/$defs/CompletionUsage"
        },
        {
          "type": "null"
        }
      ]
    }
  },
  "additionalProperties": true,
  "type": "object",
  "required": [
    "id",
    "choices",
    "created",
    "model",
    "object"
  ],
  "$defs": {
    "Annotation": {
      "properties": {
        "type": {
          "type": "string",
          "const": "url_citation",
          "title": "Type"
        },
        "url_citation": {
          "$ref": "#/$defs/AnnotationURLCitation"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "type",
        "url_citation"
      ],
      "title": "Annotation",
      "description": "A URL citation when using web search."
    },
    "AnnotationURLCitation": {
      "properties": {
        "end_index": {
          "type": "integer",
          "title": "End Index"
        },
        "start_index": {
          "type": "integer",
          "title": "Start Index"
        },
        "title": {
          "type": "string",
          "title": "Title"
        },
        "url": {
          "type": "string",
          "title": "Url"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "end_index",
        "start_index",
        "title",
        "url"
      ],
      "title": "AnnotationURLCitation",
      "description": "A URL citation when using web search."
    },
    "ChatCompletionAudio": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "data": {
          "type": "string",
          "title": "Data"
        },
        "expires_at": {
          "type": "integer",
          "title": "Expires At"
        },
        "transcript": {
          "type": "string",
          "title": "Transcript"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "id",
        "data",
        "expires_at",
        "transcript"
      ],
      "title": "ChatCompletionAudio",
      "description": "If the audio output modality is requested, this object contains data\nabout the audio response from the model. [Learn more](https://platform.openai.com/docs/guides/audio)."
    },
    "ChatCompletionMessage": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Refusal"
        },
        "role": {
          "type": "string",
          "const": "assistant",
          "title": "Role"
        },
        "annotations": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/Annotation"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Annotations"
        },
        "audio": {
          "anyOf": [
            {
              "$ref": "#/$defs/ChatCompletionAudio"
            },
            {
              "type": "null"
            }
          ]
        },
        "function_call": {
          "anyOf": [
            {
              "$ref": "#/$defs/FunctionCall-Output"
            },
            {
              "type": "null"
            }
          ]
        },
        "tool_calls": {
          "anyOf": [
            {
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/ChatCompletionMessageFunctionToolCall-Output"
                  },
                  {
                    "$ref": "#/$defs/ChatCompletionMessageCustomToolCall"
                  }
                ]
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Tool Calls"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "role"
      ],
      "title": "ChatCompletionMessage",
      "description": "A chat completion message generated by the model."
    },
    "ChatCompletionMessageCustomToolCall": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "custom": {
          "$ref": "#/$defs/Custom-Output"
        },
        "type": {
          "type": "string",
          "const": "custom",
          "title": "Type"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "id",
        "custom",
        "type"
      ],
      "title": "ChatCompletionMessageCustomToolCall",
      "description": "A call to a custom tool created by the model."
    },
    "ChatCompletionMessageFunctionToolCall-Output": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "function": {
          "$ref": "#/$defs/Function-Output"
        },
        "type": {
          "type": "string",
          "const": "function",
          "title": "Type"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "id",
        "function",
        "type"
      ],
      "title": "ChatCompletionMessageFunctionToolCall",
      "description": "A call to a function tool created by the model."
    },
    "Choice": {
      "properties": {
        "finish_reason": {
          "type": "string",
          "enum": [
            "stop",
            "length",
            "tool_calls",
            "content_filter",
            "function_call"
          ],
          "title": "Finish Reason"
        },
        "index": {
          "type": "integer",
          "title": "Index"
        },
        "logprobs": {
          "anyOf": [
            {
              "$ref": "#/$defs/openai__types__chat__chat_completion__ChoiceLogprobs"
            },
            {
              "type": "null"
            }
          ]
        },
        "message": {
          "$ref": "#/$defs/ChatCompletionMessage"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "finish_reason",
        "index",
        "message"
      ],
      "title": "Choice"
    },
    "CompletionTokensDetails": {
      "properties": {
        "accepted_prediction_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Accepted Prediction Tokens"
        },
        "audio_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Audio Tokens"
        },
        "reasoning_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Reasoning Tokens"
        },
        "rejected_prediction_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Rejected Prediction Tokens"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "CompletionTokensDetails",
      "description": "Breakdown of tokens used in a completion."
    },
    "CompletionUsage": {
      "properties": {
        "completion_tokens": {
          "type": "integer",
          "title": "Completion Tokens"
        },
        "prompt_tokens": {
          "type": "integer",
          "title": "Prompt Tokens"
        },
        "total_tokens": {
          "type": "integer",
          "title": "Total Tokens"
        },
        "completion_tokens_details": {
          "anyOf": [
            {
              "$ref": "#/$defs/CompletionTokensDetails"
            },
            {
              "type": "null"
            }
          ]
        },
        "prompt_tokens_details": {
          "anyOf": [
            {
              "$ref": "#/$defs/PromptTokensDetails"
            },
            {
              "type": "null"
            }
          ]
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "completion_tokens",
        "prompt_tokens",
        "total_tokens"
      ],
      "title": "CompletionUsage",
      "description": "Usage statistics for the completion request."
    },
    "Custom-Output": {
      "properties": {
        "input": {
          "type": "string",
          "title": "Input"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "input",
        "name"
      ],
      "title": "Custom",
      "description": "The custom tool that the model called."
    },
    "Function-Output": {
      "properties": {
        "arguments": {
          "type": "string",
          "title": "Arguments"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "arguments",
        "name"
      ],
      "title": "Function",
      "description": "The function that the model called."
    },
    "FunctionCall-Output": {
      "properties": {
        "arguments": {
          "type": "string",
          "title": "Arguments"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "arguments",
        "name"
      ],
      "title": "FunctionCall",
      "description": "Deprecated and replaced by `tool_calls`.\n\nThe name and arguments of a function that should be called, as generated by the model."
    },
    "PromptTokensDetails": {
      "properties": {
        "audio_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Audio Tokens"
        },
        "cached_tokens": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "title": "Cached Tokens"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "PromptTokensDetails",
      "description": "Breakdown of tokens used in the prompt."
    },
    "openai__types__chat__chat_completion__ChoiceLogprobs": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/openai__types__chat__chat_completion_token_logprob__ChatCompletionTokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "refusal": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/openai__types__chat__chat_completion_token_logprob__ChatCompletionTokenLogprob"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Refusal"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "title": "ChoiceLogprobs",
      "description": "Log probability information for the choice."
    },
    "openai__types__chat__chat_completion_token_logprob__ChatCompletionTokenLogprob": {
      "properties": {
        "token": {
          "type": "string",
          "title": "Token"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bytes"
        },
        "logprob": {
          "type": "number",
          "title": "Logprob"
        },
        "top_logprobs": {
          "items": {
            "$ref": "#/$defs/openai__types__chat__chat_completion_token_logprob__TopLogprob"
          },
          "type": "array",
          "title": "Top Logprobs"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "token",
        "logprob",
        "top_logprobs"
      ],
      "title": "ChatCompletionTokenLogprob"
    },
    "openai__types__chat__chat_completion_token_logprob__TopLogprob": {
      "properties": {
        "token": {
          "type": "string",
          "title": "Token"
        },
        "bytes": {
          "anyOf": [
            {
              "items": {
                "type": "integer"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Bytes"
        },
        "logprob": {
          "type": "number",
          "title": "Logprob"
        }
      },
      "additionalProperties": true,
      "type": "object",
      "required": [
        "token",
        "logprob"
      ],
      "title": "TopLogprob"
    }
  }
}