{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/Chat",
  "title": "Chat",
  "type": "object",
  "properties": {
    "assistantId": {
      "type": "string",
      "description": "This is the assistant that will be used for the chat. To use an existing assistant, use `assistantId` instead."
    },
    "assistant": {
      "description": "This is the assistant that will be used for the chat. To use an existing assistant, use `assistantId` instead.",
      "allOf": [
        {
          "$ref": "#/components/schemas/CreateAssistantDTO"
        }
      ]
    },
    "assistantOverrides": {
      "description": "These are the variable values that will be used to replace template variables in the assistant messages.\nOnly variable substitution is supported in chat contexts - other assistant properties cannot be overridden.",
      "allOf": [
        {
          "$ref": "#/components/schemas/AssistantOverrides"
        }
      ]
    },
    "squadId": {
      "type": "string",
      "description": "This is the squad that will be used for the chat. To use a transient squad, use `squad` instead."
    },
    "squad": {
      "description": "This is the squad that will be used for the chat. To use an existing squad, use `squadId` instead.",
      "allOf": [
        {
          "$ref": "#/components/schemas/CreateSquadDTO"
        }
      ]
    },
    "name": {
      "type": "string",
      "description": "This is the name of the chat. This is just for your own reference.",
      "maxLength": 40
    },
    "sessionId": {
      "type": "string",
      "description": "This is the ID of the session that will be used for the chat.\nMutually exclusive with previousChatId."
    },
    "input": {
      "description": "This is the input text for the chat.\nCan be a string or an array of chat messages.",
      "oneOf": [
        {
          "type": "string",
          "title": "String"
        },
        {
          "type": "array",
          "items": {
            "oneOf": [
              {
                "$ref": "#/components/schemas/SystemMessage",
                "title": "SystemMessage"
              },
              {
                "$ref": "#/components/schemas/UserMessage",
                "title": "UserMessage"
              },
              {
                "$ref": "#/components/schemas/AssistantMessage",
                "title": "AssistantMessage"
              },
              {
                "$ref": "#/components/schemas/ToolMessage",
                "title": "ToolMessage"
              },
              {
                "$ref": "#/components/schemas/DeveloperMessage",
                "title": "DeveloperMessage"
              }
            ]
          },
          "title": "MessageArray"
        }
      ],
      "examples": [
        "Hello, how can you help me?",
        [
          {
            "role": "user",
            "content": "Hello, how can you help me?"
          }
        ]
      ]
    },
    "stream": {
      "type": "boolean",
      "description": "This is a flag that determines whether the response should be streamed.\nWhen true, the response will be sent as chunks of text.",
      "default": false
    },
    "previousChatId": {
      "type": "string",
      "description": "This is the ID of the chat that will be used as context for the new chat.\nThe messages from the previous chat will be used as context.\nMutually exclusive with sessionId."
    },
    "id": {
      "type": "string",
      "description": "This is the unique identifier for the chat."
    },
    "orgId": {
      "type": "string",
      "description": "This is the unique identifier for the org that this chat belongs to."
    },
    "messages": {
      "type": "array",
      "description": "This is an array of messages used as context for the chat.\nUsed to provide message history for multi-turn conversations.",
      "items": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/SystemMessage",
            "title": "SystemMessage"
          },
          {
            "$ref": "#/components/schemas/UserMessage",
            "title": "UserMessage"
          },
          {
            "$ref": "#/components/schemas/AssistantMessage",
            "title": "AssistantMessage"
          },
          {
            "$ref": "#/components/schemas/ToolMessage",
            "title": "ToolMessage"
          },
          {
            "$ref": "#/components/schemas/DeveloperMessage",
            "title": "DeveloperMessage"
          }
        ]
      }
    },
    "output": {
      "type": "array",
      "description": "This is the output messages generated by the system in response to the input.",
      "items": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/SystemMessage",
            "title": "SystemMessage"
          },
          {
            "$ref": "#/components/schemas/UserMessage",
            "title": "UserMessage"
          },
          {
            "$ref": "#/components/schemas/AssistantMessage",
            "title": "AssistantMessage"
          },
          {
            "$ref": "#/components/schemas/ToolMessage",
            "title": "ToolMessage"
          },
          {
            "$ref": "#/components/schemas/DeveloperMessage",
            "title": "DeveloperMessage"
          }
        ]
      }
    },
    "createdAt": {
      "format": "date-time",
      "type": "string",
      "description": "This is the ISO 8601 date-time string of when the chat was created."
    },
    "updatedAt": {
      "format": "date-time",
      "type": "string",
      "description": "This is the ISO 8601 date-time string of when the chat was last updated."
    },
    "costs": {
      "type": "array",
      "description": "These are the costs of individual components of the chat in USD.",
      "items": {
        "oneOf": [
          {
            "$ref": "#/components/schemas/ModelCost",
            "title": "ModelCost"
          },
          {
            "$ref": "#/components/schemas/ChatCost",
            "title": "ChatCost"
          }
        ]
      }
    },
    "cost": {
      "type": "number",
      "description": "This is the cost of the chat in USD."
    }
  },
  "required": [
    "id",
    "orgId",
    "createdAt",
    "updatedAt"
  ]
}