{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/letta/json-schema/letta-chat-completion-request-schema.json",
  "title": "ChatCompletionRequest",
  "description": "OpenAI-compatible chat completion request - exactly matching OpenAI's schema.",
  "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/ChatCompletionRequest",
  "properties": {
    "model": {
      "type": "string",
      "title": "Model",
      "description": "ID of the model to use"
    },
    "messages": {
      "items": {
        "anyOf": [
          {
            "$ref": "#/$defs/ChatCompletionDeveloperMessageParam"
          },
          {
            "$ref": "#/$defs/ChatCompletionSystemMessageParam"
          },
          {
            "$ref": "#/$defs/ChatCompletionUserMessageParam"
          },
          {
            "$ref": "#/$defs/ChatCompletionAssistantMessageParam"
          },
          {
            "$ref": "#/$defs/ChatCompletionToolMessageParam"
          },
          {
            "$ref": "#/$defs/ChatCompletionFunctionMessageParam"
          }
        ]
      },
      "type": "array",
      "title": "Messages",
      "description": "Messages comprising the conversation so far"
    },
    "temperature": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 2,
          "minimum": 0
        },
        {
          "type": "null"
        }
      ],
      "title": "Temperature",
      "description": "Sampling temperature"
    },
    "top_p": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1,
          "minimum": 0
        },
        {
          "type": "null"
        }
      ],
      "title": "Top P",
      "description": "Nucleus sampling parameter"
    },
    "n": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1
        },
        {
          "type": "null"
        }
      ],
      "title": "N",
      "description": "Number of chat completion choices to generate",
      "default": 1
    },
    "stream": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stream",
      "description": "Whether to stream back partial progress",
      "default": false
    },
    "stop": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stop",
      "description": "Sequences where the API will stop generating"
    },
    "max_tokens": {
      "anyOf": [
        {
          "type": "integer"
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Tokens",
      "description": "Maximum number of tokens to generate"
    },
    "presence_penalty": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 2,
          "minimum": -2
        },
        {
          "type": "null"
        }
      ],
      "title": "Presence Penalty",
      "description": "Presence penalty"
    },
    "frequency_penalty": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 2,
          "minimum": -2
        },
        {
          "type": "null"
        }
      ],
      "title": "Frequency Penalty",
      "description": "Frequency penalty"
    },
    "user": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "User",
      "description": "A unique identifier representing your end-user"
    }
  },
  "type": "object",
  "required": [
    "model",
    "messages"
  ],
  "$defs": {
    "Audio": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        }
      },
      "type": "object",
      "required": [
        "id"
      ],
      "title": "Audio",
      "description": "Data about a previous audio response from the model.\n[Learn more](https://platform.openai.com/docs/guides/audio)."
    },
    "ChatCompletionAssistantMessageParam": {
      "properties": {
        "role": {
          "type": "string",
          "const": "assistant",
          "title": "Role"
        },
        "audio": {
          "anyOf": [
            {
              "$ref": "#/$defs/Audio"
            },
            {
              "type": "null"
            }
          ]
        },
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/ChatCompletionContentPartTextParam"
                  },
                  {
                    "$ref": "#/$defs/ChatCompletionContentPartRefusalParam"
                  }
                ]
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "function_call": {
          "anyOf": [
            {
              "$ref": "#/$defs/FunctionCall-Input"
            },
            {
              "type": "null"
            }
          ]
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "refusal": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Refusal"
        },
        "tool_calls": {
          "items": {
            "anyOf": [
              {
                "$ref": "#/$defs/ChatCompletionMessageFunctionToolCallParam"
              },
              {
                "$ref": "#/$defs/ChatCompletionMessageCustomToolCallParam"
              }
            ]
          },
          "type": "array",
          "title": "Tool Calls"
        }
      },
      "type": "object",
      "required": [
        "role"
      ],
      "title": "ChatCompletionAssistantMessageParam",
      "description": "Messages sent by the model in response to user messages."
    },
    "ChatCompletionContentPartImageParam": {
      "properties": {
        "image_url": {
          "$ref": "#/$defs/ImageURL"
        },
        "type": {
          "type": "string",
          "const": "image_url",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "image_url",
        "type"
      ],
      "title": "ChatCompletionContentPartImageParam",
      "description": "Learn about [image inputs](https://platform.openai.com/docs/guides/vision)."
    },
    "ChatCompletionContentPartInputAudioParam": {
      "properties": {
        "input_audio": {
          "$ref": "#/$defs/InputAudio"
        },
        "type": {
          "type": "string",
          "const": "input_audio",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "input_audio",
        "type"
      ],
      "title": "ChatCompletionContentPartInputAudioParam",
      "description": "Learn about [audio inputs](https://platform.openai.com/docs/guides/audio)."
    },
    "ChatCompletionContentPartRefusalParam": {
      "properties": {
        "refusal": {
          "type": "string",
          "title": "Refusal"
        },
        "type": {
          "type": "string",
          "const": "refusal",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "refusal",
        "type"
      ],
      "title": "ChatCompletionContentPartRefusalParam"
    },
    "ChatCompletionContentPartTextParam": {
      "properties": {
        "text": {
          "type": "string",
          "title": "Text"
        },
        "type": {
          "type": "string",
          "const": "text",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "text",
        "type"
      ],
      "title": "ChatCompletionContentPartTextParam",
      "description": "Learn about [text inputs](https://platform.openai.com/docs/guides/text-generation)."
    },
    "ChatCompletionDeveloperMessageParam": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionContentPartTextParam"
              },
              "type": "array"
            }
          ],
          "title": "Content"
        },
        "role": {
          "type": "string",
          "const": "developer",
          "title": "Role"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "content",
        "role"
      ],
      "title": "ChatCompletionDeveloperMessageParam",
      "description": "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, `developer` messages\nreplace the previous `system` messages."
    },
    "ChatCompletionFunctionMessageParam": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "title": "Content"
        },
        "name": {
          "type": "string",
          "title": "Name"
        },
        "role": {
          "type": "string",
          "const": "function",
          "title": "Role"
        }
      },
      "type": "object",
      "required": [
        "content",
        "name",
        "role"
      ],
      "title": "ChatCompletionFunctionMessageParam"
    },
    "ChatCompletionMessageCustomToolCallParam": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "custom": {
          "$ref": "#/$defs/Custom-Input"
        },
        "type": {
          "type": "string",
          "const": "custom",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "id",
        "custom",
        "type"
      ],
      "title": "ChatCompletionMessageCustomToolCallParam",
      "description": "A call to a custom tool created by the model."
    },
    "ChatCompletionMessageFunctionToolCallParam": {
      "properties": {
        "id": {
          "type": "string",
          "title": "Id"
        },
        "function": {
          "$ref": "#/$defs/openai__types__chat__chat_completion_message_function_tool_call_param__Function"
        },
        "type": {
          "type": "string",
          "const": "function",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "id",
        "function",
        "type"
      ],
      "title": "ChatCompletionMessageFunctionToolCallParam",
      "description": "A call to a function tool created by the model."
    },
    "ChatCompletionSystemMessageParam": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionContentPartTextParam"
              },
              "type": "array"
            }
          ],
          "title": "Content"
        },
        "role": {
          "type": "string",
          "const": "system",
          "title": "Role"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "content",
        "role"
      ],
      "title": "ChatCompletionSystemMessageParam",
      "description": "Developer-provided instructions that the model should follow, regardless of\nmessages sent by the user. With o1 models and newer, use `developer` messages\nfor this purpose instead."
    },
    "ChatCompletionToolMessageParam": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "$ref": "#/$defs/ChatCompletionContentPartTextParam"
              },
              "type": "array"
            }
          ],
          "title": "Content"
        },
        "role": {
          "type": "string",
          "const": "tool",
          "title": "Role"
        },
        "tool_call_id": {
          "type": "string",
          "title": "Tool Call Id"
        }
      },
      "type": "object",
      "required": [
        "content",
        "role",
        "tool_call_id"
      ],
      "title": "ChatCompletionToolMessageParam"
    },
    "ChatCompletionUserMessageParam": {
      "properties": {
        "content": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "items": {
                "anyOf": [
                  {
                    "$ref": "#/$defs/ChatCompletionContentPartTextParam"
                  },
                  {
                    "$ref": "#/$defs/ChatCompletionContentPartImageParam"
                  },
                  {
                    "$ref": "#/$defs/ChatCompletionContentPartInputAudioParam"
                  },
                  {
                    "$ref": "#/$defs/File"
                  }
                ]
              },
              "type": "array"
            }
          ],
          "title": "Content"
        },
        "role": {
          "type": "string",
          "const": "user",
          "title": "Role"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "content",
        "role"
      ],
      "title": "ChatCompletionUserMessageParam",
      "description": "Messages sent by an end user, containing prompts or additional context\ninformation."
    },
    "Custom-Input": {
      "properties": {
        "input": {
          "type": "string",
          "title": "Input"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "input",
        "name"
      ],
      "title": "Custom",
      "description": "The custom tool that the model called."
    },
    "File": {
      "properties": {
        "file": {
          "$ref": "#/$defs/FileFile"
        },
        "type": {
          "type": "string",
          "const": "file",
          "title": "Type"
        }
      },
      "type": "object",
      "required": [
        "file",
        "type"
      ],
      "title": "File",
      "description": "Learn about [file inputs](https://platform.openai.com/docs/guides/text) for text generation."
    },
    "FileFile": {
      "properties": {
        "file_data": {
          "type": "string",
          "title": "File Data"
        },
        "file_id": {
          "type": "string",
          "title": "File Id"
        },
        "filename": {
          "type": "string",
          "title": "Filename"
        }
      },
      "type": "object",
      "title": "FileFile"
    },
    "FunctionCall-Input": {
      "properties": {
        "arguments": {
          "type": "string",
          "title": "Arguments"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "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."
    },
    "ImageURL": {
      "properties": {
        "url": {
          "type": "string",
          "title": "Url"
        },
        "detail": {
          "type": "string",
          "enum": [
            "auto",
            "low",
            "high"
          ],
          "title": "Detail"
        }
      },
      "type": "object",
      "required": [
        "url"
      ],
      "title": "ImageURL"
    },
    "InputAudio": {
      "properties": {
        "data": {
          "type": "string",
          "title": "Data"
        },
        "format": {
          "type": "string",
          "enum": [
            "wav",
            "mp3"
          ],
          "title": "Format"
        }
      },
      "type": "object",
      "required": [
        "data",
        "format"
      ],
      "title": "InputAudio"
    },
    "openai__types__chat__chat_completion_message_function_tool_call_param__Function": {
      "properties": {
        "arguments": {
          "type": "string",
          "title": "Arguments"
        },
        "name": {
          "type": "string",
          "title": "Name"
        }
      },
      "type": "object",
      "required": [
        "arguments",
        "name"
      ],
      "title": "Function",
      "description": "The function that the model called."
    }
  }
}