Mistral AI · Schema

Mistral AI Chat Completion

Schema for a Mistral AI chat completion request and response, including message structures, tool definitions, and function calling.

AgentsArtificial IntelligenceBatch ProcessingChatEmbeddingsFine-TuningLarge Language ModelsOCR

Properties

Name Type Description
id string Unique identifier for the chat completion.
object string The object type, always chat.completion.
created integer Unix timestamp when the completion was created.
model string The model used for the completion.
choices array The list of completion choices.
usage object
View JSON Schema on GitHub

JSON Schema

mistral-ai-chat-completion-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://mistral.ai/schemas/mistral-ai/chat-completion.json",
  "title": "Mistral AI Chat Completion",
  "description": "Schema for a Mistral AI chat completion request and response, including message structures, tool definitions, and function calling.",
  "type": "object",
  "$defs": {
    "ChatMessage": {
      "type": "object",
      "description": "A message in a chat conversation with role and content.",
      "required": ["role", "content"],
      "properties": {
        "role": {
          "type": "string",
          "description": "The role of the message author.",
          "enum": ["system", "user", "assistant", "tool"]
        },
        "content": {
          "oneOf": [
            { "type": "string" },
            {
              "type": "array",
              "items": {
                "$ref": "#/$defs/ContentPart"
              }
            }
          ],
          "description": "The content of the message, either a string or an array of content parts for multimodal input."
        },
        "tool_calls": {
          "type": "array",
          "description": "Tool calls generated by the model in this message.",
          "items": {
            "$ref": "#/$defs/ToolCall"
          }
        },
        "tool_call_id": {
          "type": "string",
          "description": "The ID of the tool call this message responds to, required for tool role."
        }
      }
    },
    "ContentPart": {
      "type": "object",
      "description": "A content part for multimodal inputs such as text or images.",
      "required": ["type"],
      "properties": {
        "type": {
          "type": "string",
          "description": "The type of content part.",
          "enum": ["text", "image_url"]
        },
        "text": {
          "type": "string",
          "description": "The text content, used when type is text."
        },
        "image_url": {
          "type": "object",
          "description": "The image URL object, used when type is image_url.",
          "properties": {
            "url": {
              "type": "string",
              "format": "uri",
              "description": "The URL of the image."
            }
          }
        }
      }
    },
    "Tool": {
      "type": "object",
      "description": "A tool that the model may call during completion.",
      "required": ["type", "function"],
      "properties": {
        "type": {
          "type": "string",
          "description": "The type of tool, currently only function is supported.",
          "enum": ["function"]
        },
        "function": {
          "$ref": "#/$defs/FunctionDefinition"
        }
      }
    },
    "FunctionDefinition": {
      "type": "object",
      "description": "Definition of a function that can be called by the model.",
      "required": ["name"],
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the function.",
          "pattern": "^[a-zA-Z0-9_-]+$",
          "maxLength": 64
        },
        "description": {
          "type": "string",
          "description": "A description of what the function does."
        },
        "parameters": {
          "type": "object",
          "description": "The parameters accepted by the function, as a JSON Schema object."
        }
      }
    },
    "ToolCall": {
      "type": "object",
      "description": "A tool call generated by the model.",
      "properties": {
        "id": {
          "type": "string",
          "description": "Unique identifier for the tool call."
        },
        "type": {
          "type": "string",
          "description": "The type of tool call.",
          "enum": ["function"]
        },
        "function": {
          "type": "object",
          "description": "The function call details.",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the function to call."
            },
            "arguments": {
              "type": "string",
              "description": "The arguments for the function call as a JSON string."
            }
          },
          "required": ["name", "arguments"]
        }
      }
    },
    "Usage": {
      "type": "object",
      "description": "Token usage statistics for the API request.",
      "properties": {
        "prompt_tokens": {
          "type": "integer",
          "description": "Number of tokens in the prompt.",
          "minimum": 0
        },
        "completion_tokens": {
          "type": "integer",
          "description": "Number of tokens in the completion.",
          "minimum": 0
        },
        "total_tokens": {
          "type": "integer",
          "description": "Total tokens used in the request.",
          "minimum": 0
        }
      }
    },
    "ChatCompletionChoice": {
      "type": "object",
      "description": "A choice in the chat completion response.",
      "properties": {
        "index": {
          "type": "integer",
          "description": "The index of this choice.",
          "minimum": 0
        },
        "message": {
          "$ref": "#/$defs/ChatMessage"
        },
        "finish_reason": {
          "type": "string",
          "description": "The reason the model stopped generating.",
          "enum": ["stop", "length", "tool_calls", "model_length"]
        }
      }
    }
  },
  "properties": {
    "id": {
      "type": "string",
      "description": "Unique identifier for the chat completion."
    },
    "object": {
      "type": "string",
      "description": "The object type, always chat.completion.",
      "const": "chat.completion"
    },
    "created": {
      "type": "integer",
      "description": "Unix timestamp when the completion was created."
    },
    "model": {
      "type": "string",
      "description": "The model used for the completion."
    },
    "choices": {
      "type": "array",
      "description": "The list of completion choices.",
      "items": {
        "$ref": "#/$defs/ChatCompletionChoice"
      }
    },
    "usage": {
      "$ref": "#/$defs/Usage"
    }
  },
  "required": ["id", "object", "created", "model", "choices", "usage"]
}