{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/mensageiro-ai/json-schema/mensageiro-ai-messages-request-schema.json",
  "title": "MessagesRequest",
  "description": "Anthropic Messages request. Anything Anthropic accepts passes through unchanged.",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/mensageiro-ai-openapi.json#/components/schemas/MessagesRequest",
  "type": "object",
  "required": [
    "messages"
  ],
  "properties": {
    "model": {
      "$ref": "#/$defs/ModelId"
    },
    "models": {
      "$ref": "#/$defs/FallbackModels"
    },
    "preset": {
      "type": "string",
      "description": "`@preset/<name>`: one of your presets, merged under this request with `model` in place of the preset's."
    },
    "max_tokens": {
      "type": "integer",
      "description": "Required by Anthropic unless a preset sets it. Caps the output and sizes the balance hold."
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "additionalProperties": true
      }
    },
    "system": {
      "type": [
        "string",
        "array"
      ]
    },
    "stream": {
      "type": "boolean",
      "description": "Stream the answer as server-sent events."
    },
    "auto": {
      "type": "object",
      "description": "With `model: \"auto\"`: `tier_max` caps the tier the auto router may pick (fast < balanced < frontier). The router picks from the tiers in GET /v1/catalog `auto_router`, classifying the request locally (no extra model call): a reasoning ask or a high reasoning effort, or tools with code, goes to frontier; tools, code blocks, images, a json_schema answer or a prompt over 16,000 tokens to balanced; the rest to fast. The answer's `model` and x-uplink-model name the model chosen, x-uplink-auto-tier its tier, and it bills at that model's price. With an `x-session-id` header the same model answers that session for 30 minutes from its last request.",
      "properties": {
        "tier_max": {
          "type": "string",
          "enum": [
            "fast",
            "balanced",
            "frontier"
          ]
        }
      }
    },
    "routing": {
      "oneOf": [
        {
          "type": "string",
          "enum": [
            "price",
            "latency",
            "throughput",
            "cheapest",
            "fastest"
          ]
        },
        {
          "type": "object",
          "properties": {
            "sort": {
              "type": "string",
              "enum": [
                "price",
                "latency",
                "throughput"
              ]
            }
          }
        }
      ],
      "description": "The order this request tries the model's routes in, over the key's own setting: price (cheapest for us first, the default), latency (quickest first token lately) or throughput (most output tokens per second lately). The price you pay is the same whichever route answers."
    },
    "provider": {
      "type": "object",
      "description": "OpenRouter-style `{\"sort\": \"price\" | \"latency\" | \"throughput\"}`, read as `routing`. Other members are ignored.",
      "additionalProperties": true
    },
    "transforms": {
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "middle-out"
        ]
      },
      "description": "`[\"middle-out\"]`: when the prompt plus room for the answer is longer than the model's context window, whole messages are dropped from the middle until it fits. Kept: system messages, the first user message and the latest turn; a tool call and its results go together. x-uplink-compressed says how many were dropped. `[]` turns a key's context_overflow default off for this request. The field is never sent on to the model."
    }
  },
  "additionalProperties": true,
  "$defs": {
    "FallbackModels": {
      "type": "array",
      "maxItems": 5,
      "items": {
        "type": "string"
      },
      "description": "Up to 5 model ids or aliases tried in order after `model` once every route of the one before has failed before a byte was sent. Each is billed at its own price when it answers; the key's allowlist applies to each."
    },
    "ModelId": {
      "type": "string",
      "description": "A model id from GET /v1/catalog, one of your organization's aliases, `@preset/<name>` for one of its presets, or `auto` (also `uplink/auto` or `<brand>/auto`) to let the auto router pick; `auto/uncensored`, `auto/abliterated`, `auto/security` (also `auto/cyber`) and `auto/roleplay` pick only from that profile's lists in GET /v1/catalog `auto_router.profiles`. Not enumerated here."
    }
  }
}