{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://api.cohere.com/schemas/cohere/chat-message.json",
  "title": "Cohere Chat Message",
  "description": "Represents a message in a Cohere Chat API conversation, including user prompts, assistant responses, system instructions, and tool results.",
  "type": "object",
  "required": ["role"],
  "properties": {
    "role": {
      "type": "string",
      "enum": ["user", "assistant", "system", "tool"],
      "description": "The role of the message author in the conversation. User messages are prompts, assistant messages are model responses, system messages set behavior, and tool messages return function results."
    },
    "content": {
      "type": "string",
      "description": "The text content of the message."
    },
    "tool_call_id": {
      "type": "string",
      "description": "The ID of the tool call this message is responding to. Required when role is tool."
    },
    "tool_calls": {
      "type": "array",
      "description": "Tool calls generated by the model when it decides to invoke available functions.",
      "items": {
        "$ref": "#/$defs/ToolCall"
      }
    },
    "citations": {
      "type": "array",
      "description": "Citations referencing source documents used in retrieval-augmented generation.",
      "items": {
        "$ref": "#/$defs/Citation"
      }
    }
  },
  "$defs": {
    "ToolCall": {
      "type": "object",
      "description": "A tool call generated by the model requesting execution of a specified function.",
      "required": ["id", "type", "function"],
      "properties": {
        "id": {
          "type": "string",
          "description": "The unique identifier for this tool call."
        },
        "type": {
          "type": "string",
          "enum": ["function"],
          "description": "The type of tool call. Currently only function is supported."
        },
        "function": {
          "type": "object",
          "description": "The function to call with its arguments.",
          "required": ["name", "arguments"],
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the function to call."
            },
            "arguments": {
              "type": "string",
              "description": "The arguments to pass to the function, serialized as a JSON string."
            }
          }
        }
      }
    },
    "Citation": {
      "type": "object",
      "description": "A citation referencing source content used in generating a response.",
      "properties": {
        "start": {
          "type": "integer",
          "description": "The start index of the cited text span in the response.",
          "minimum": 0
        },
        "end": {
          "type": "integer",
          "description": "The end index of the cited text span in the response.",
          "minimum": 0
        },
        "text": {
          "type": "string",
          "description": "The cited text from the response."
        },
        "document_ids": {
          "type": "array",
          "description": "The IDs of the source documents referenced by this citation.",
          "items": {
            "type": "string"
          }
        }
      }
    }
  }
}