Anthropic · Schema

Message

LLMAnthropicArtificial IntelligenceClaudeFoundation ModelsMachine LearningMCPAgents

Properties

Name Type Description
id string Unique object identifier. The format and length of IDs may change over time.
type string Object type. For Messages, this is always `"message"`.
role string Conversational role of the generated message. This will always be `"assistant"`.
content array Content generated by the model. This is an array of content blocks, each of which has a `type` that determines its shape. Example: ```json [{"type": "text", "text": "Hi, I'm Claude."}] ``` If the requ
model object
stop_reason object The reason that we stopped. This may be one the following values: * `"end_turn"`: the model reached a natural stopping point * `"max_tokens"`: we exceeded the requested `max_tokens` or the model's max
stop_sequence object Which custom stop sequence was generated, if any. This value will be a non-null string if one of your custom stop sequences was generated.
stop_details object Structured information about why model output stopped. This is `null` when the `stop_reason` has no additional detail to report.
usage object Billing and rate-limit usage. Anthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems. Under the hood, the API transforms requests into a format s
diagnostics object Request-level diagnostics. Present only when `diagnostics` was supplied on the request; `null` when no prompt-cache divergence was detected.
context_management object Context management response. Information about context management strategies applied during the request.
container object Information about the container used in this request. This will be non-null if a container tool (e.g. code execution) was used.
View JSON Schema on GitHub

JSON Schema

anthropic-beta-message-schema.json Raw ↑
{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/anthropic/main/json-schema/anthropic-beta-message-schema.json",
  "title": "Message",
  "x-generated": "2026-09-23",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/anthropic-messages-beta-true-api-openapi.yml#/components/schemas/BetaMessage",
  "properties": {
    "id": {
      "description": "Unique object identifier.\n\nThe format and length of IDs may change over time.",
      "title": "Id",
      "type": "string"
    },
    "type": {
      "const": "message",
      "default": "message",
      "description": "Object type.\n\nFor Messages, this is always `\"message\"`.",
      "title": "Type",
      "type": "string"
    },
    "role": {
      "const": "assistant",
      "default": "assistant",
      "description": "Conversational role of the generated message.\n\nThis will always be `\"assistant\"`.",
      "title": "Role",
      "type": "string"
    },
    "content": {
      "description": "Content generated by the model.\n\nThis is an array of content blocks, each of which has a `type` that determines its shape.\n\nExample:\n\n```json\n[{\"type\": \"text\", \"text\": \"Hi, I'm Claude.\"}]\n```\n\nIf the request input `messages` ended with an `assistant` turn, then the response `content` will continue directly from that last turn. You can use this to constrain the model's output.\n\nFor example, if the input `messages` were:\n```json\n[\n  {\"role\": \"user\", \"content\": \"What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun\"},\n  {\"role\": \"assistant\", \"content\": \"The best answer is (\"}\n]\n```\n\nThen the response `content` might be:\n\n```json\n[{\"type\": \"text\", \"text\": \"B)\"}]\n```",
      "items": {
        "$ref": "#/$defs/BetaContentBlock"
      },
      "title": "Content",
      "type": "array"
    },
    "model": {
      "$ref": "#/$defs/Model"
    },
    "stop_reason": {
      "anyOf": [
        {
          "$ref": "#/$defs/BetaStopReason"
        },
        {
          "type": "null"
        }
      ],
      "description": "The reason that we stopped.\n\nThis may be one the following values:\n* `\"end_turn\"`: the model reached a natural stopping point\n* `\"max_tokens\"`: we exceeded the requested `max_tokens` or the model's maximum\n* `\"stop_sequence\"`: one of your provided custom `stop_sequences` was generated\n* `\"tool_use\"`: the model invoked one or more tools\n* `\"pause_turn\"`: we paused a long-running turn. You may provide the response back as-is in a subsequent request to let the model continue.\n* `\"refusal\"`: when streaming classifiers intervene to handle potential policy violations\n* `\"model_context_window_exceeded\"`: we exceeded the model's context window\n\nIn non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.",
      "title": "Stop Reason"
    },
    "stop_sequence": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Which custom stop sequence was generated, if any.\n\nThis value will be a non-null string if one of your custom stop sequences was generated.",
      "title": "Stop Sequence"
    },
    "stop_details": {
      "anyOf": [
        {
          "$ref": "#/$defs/BetaRefusalStopDetails"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Structured information about why model output stopped.\n\nThis is `null` when the `stop_reason` has no additional detail to report."
    },
    "usage": {
      "$ref": "#/$defs/BetaUsage",
      "description": "Billing and rate-limit usage.\n\nAnthropic's API bills and rate-limits by token counts, as tokens represent the underlying cost to our systems.\n\nUnder the hood, the API transforms requests into a format suitable for the model. The model's output then goes through a parsing stage before becoming an API response. As a result, the token counts in `usage` will not match one-to-one with the exact visible content of an API request or response.\n\nFor example, `output_tokens` will be non-zero, even for an empty string response from Claude.\n\nTotal input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`."
    },
    "diagnostics": {
      "anyOf": [
        {
          "$ref": "#/$defs/BetaDiagnostics"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Request-level diagnostics. Present only when `diagnostics` was supplied on the request; `null` when no prompt-cache divergence was detected.",
      "x-anthropic-beta-required": [
        "cache-diagnosis-2026-04-07"
      ]
    },
    "context_management": {
      "anyOf": [
        {
          "$ref": "#/$defs/BetaResponseContextManagement"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Context management response.\n\nInformation about context management strategies applied during the request.",
      "x-anthropic-beta-required": [
        "context-management-2025-06-27",
        "compact-2026-01-12"
      ]
    },
    "container": {
      "anyOf": [
        {
          "$ref": "#/$defs/BetaContainer"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Information about the container used in this request.\n\nThis will be non-null if a container tool (e.g. code execution) was used."
    }
  },
  "required": [
    "id",
    "type",
    "role",
    "content",
    "model",
    "stop_reason",
    "stop_sequence",
    "stop_details",
    "usage",
    "diagnostics",
    "context_management",
    "container"
  ],
  "type": "object",
  "x-stainless-python-custom-imports": [
    "from .beta_content_block import BetaContentBlock as BetaContentBlock"
  ],
  "$defs": {
    "BetaAdvisorMessageIterationUsage": {
      "description": "Token usage for an advisor sub-inference iteration.",
      "properties": {
        "cache_creation": {
          "anyOf": [
            {
              "$ref": "#/$defs/BetaCacheCreation"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Breakdown of cached tokens by TTL"
        },
        "cache_creation_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the cache entry.",
          "minimum": 0,
          "title": "Cache Creation Input Tokens",
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "default": 0,
          "description": "The number of input tokens read from the cache.",
          "minimum": 0,
          "title": "Cache Read Input Tokens",
          "type": "integer"
        },
        "input_tokens": {
          "description": "The number of input tokens which were used.",
          "minimum": 0,
          "title": "Input Tokens",
          "type": "integer"
        },
        "model": {
          "$ref": "#/$defs/Model"
        },
        "output_tokens": {
          "description": "The number of output tokens which were used.",
          "minimum": 0,
          "title": "Output Tokens",
          "type": "integer"
        },
        "type": {
          "const": "advisor_message",
          "default": "advisor_message",
          "description": "Usage for an advisor sub-inference iteration",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_creation",
        "cache_creation_input_tokens",
        "cache_read_input_tokens",
        "input_tokens",
        "model",
        "output_tokens",
        "type"
      ],
      "title": "AdvisorMessageIterationUsage",
      "type": "object"
    },
    "BetaAdvisorToolResultErrorCode": {
      "enum": [
        "max_uses_exceeded",
        "prompt_too_long",
        "too_many_requests",
        "overloaded",
        "unavailable",
        "execution_time_exceeded",
        "model_not_found"
      ],
      "title": "AdvisorToolResultErrorCode",
      "type": "string"
    },
    "BetaBase64PDFSource": {
      "additionalProperties": false,
      "properties": {
        "data": {
          "format": "byte",
          "title": "Data",
          "type": "string"
        },
        "media_type": {
          "const": "application/pdf",
          "title": "Media Type",
          "type": "string"
        },
        "type": {
          "const": "base64",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "data",
        "media_type",
        "type"
      ],
      "title": "Base64PDFSource",
      "type": "object"
    },
    "BetaBashCodeExecutionToolResultErrorCode": {
      "enum": [
        "invalid_tool_input",
        "unavailable",
        "too_many_requests",
        "execution_time_exceeded",
        "output_file_too_large"
      ],
      "title": "BashCodeExecutionToolResultErrorCode",
      "type": "string"
    },
    "BetaCacheCreation": {
      "properties": {
        "ephemeral_1h_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the 1 hour cache entry.",
          "minimum": 0,
          "title": "Ephemeral 1H Input Tokens",
          "type": "integer"
        },
        "ephemeral_5m_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the 5 minute cache entry.",
          "minimum": 0,
          "title": "Ephemeral 5M Input Tokens",
          "type": "integer"
        }
      },
      "required": [
        "ephemeral_1h_input_tokens",
        "ephemeral_5m_input_tokens"
      ],
      "title": "CacheCreation",
      "type": "object"
    },
    "BetaCacheMissMessagesChanged": {
      "properties": {
        "cache_missed_input_tokens": {
          "description": "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.",
          "title": "Cache Missed Input Tokens",
          "type": "integer"
        },
        "type": {
          "const": "messages_changed",
          "default": "messages_changed",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_missed_input_tokens",
        "type"
      ],
      "title": "CacheMissMessagesChanged",
      "type": "object"
    },
    "BetaCacheMissModelChanged": {
      "properties": {
        "cache_missed_input_tokens": {
          "description": "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.",
          "title": "Cache Missed Input Tokens",
          "type": "integer"
        },
        "type": {
          "const": "model_changed",
          "default": "model_changed",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_missed_input_tokens",
        "type"
      ],
      "title": "CacheMissModelChanged",
      "type": "object"
    },
    "BetaCacheMissPreviousMessageNotFound": {
      "properties": {
        "type": {
          "const": "previous_message_not_found",
          "default": "previous_message_not_found",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "CacheMissPreviousMessageNotFound",
      "type": "object"
    },
    "BetaCacheMissSystemChanged": {
      "properties": {
        "cache_missed_input_tokens": {
          "description": "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.",
          "title": "Cache Missed Input Tokens",
          "type": "integer"
        },
        "type": {
          "const": "system_changed",
          "default": "system_changed",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_missed_input_tokens",
        "type"
      ],
      "title": "CacheMissSystemChanged",
      "type": "object"
    },
    "BetaCacheMissToolsChanged": {
      "properties": {
        "cache_missed_input_tokens": {
          "description": "Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.",
          "title": "Cache Missed Input Tokens",
          "type": "integer"
        },
        "type": {
          "const": "tools_changed",
          "default": "tools_changed",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_missed_input_tokens",
        "type"
      ],
      "title": "CacheMissToolsChanged",
      "type": "object"
    },
    "BetaCacheMissUnavailable": {
      "properties": {
        "type": {
          "const": "unavailable",
          "default": "unavailable",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "CacheMissUnavailable",
      "type": "object"
    },
    "BetaCodeExecutionToolResultErrorCode": {
      "enum": [
        "invalid_tool_input",
        "unavailable",
        "too_many_requests",
        "execution_time_exceeded"
      ],
      "title": "CodeExecutionToolResultErrorCode",
      "type": "string"
    },
    "BetaCompactionIterationUsage": {
      "description": "Token usage for a compaction iteration.",
      "properties": {
        "cache_creation": {
          "anyOf": [
            {
              "$ref": "#/$defs/BetaCacheCreation"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Breakdown of cached tokens by TTL"
        },
        "cache_creation_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the cache entry.",
          "minimum": 0,
          "title": "Cache Creation Input Tokens",
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "default": 0,
          "description": "The number of input tokens read from the cache.",
          "minimum": 0,
          "title": "Cache Read Input Tokens",
          "type": "integer"
        },
        "input_tokens": {
          "description": "The number of input tokens which were used.",
          "minimum": 0,
          "title": "Input Tokens",
          "type": "integer"
        },
        "output_tokens": {
          "description": "The number of output tokens which were used.",
          "minimum": 0,
          "title": "Output Tokens",
          "type": "integer"
        },
        "type": {
          "const": "compaction",
          "default": "compaction",
          "description": "Usage for a compaction iteration",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_creation",
        "cache_creation_input_tokens",
        "cache_read_input_tokens",
        "input_tokens",
        "output_tokens",
        "type"
      ],
      "title": "CompactionIterationUsage",
      "type": "object"
    },
    "BetaContainer": {
      "description": "Information about the container used in the request (for the code execution tool)",
      "properties": {
        "expires_at": {
          "description": "The time at which the container will expire.",
          "format": "date-time",
          "title": "Expires At",
          "type": "string"
        },
        "id": {
          "description": "Identifier for the container used in this request",
          "title": "Id",
          "type": "string"
        },
        "skills": {
          "anyOf": [
            {
              "items": {
                "$ref": "#/$defs/BetaSkill"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Skills loaded in the container",
          "title": "Skills"
        }
      },
      "required": [
        "expires_at",
        "id",
        "skills"
      ],
      "title": "Container",
      "type": "object"
    },
    "BetaContentBlock": {
      "oneOf": [
        {
          "$ref": "#/$defs/BetaResponseTextBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseThinkingBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseRedactedThinkingBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseToolUseBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseServerToolUseBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseWebSearchToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseWebFetchToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseAdvisorToolResultBlock",
          "x-anthropic-beta-required": [
            "advisor-tool-2026-03-01"
          ]
        },
        {
          "$ref": "#/$defs/BetaResponseCodeExecutionToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseBashCodeExecutionToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseTextEditorCodeExecutionToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseToolSearchToolResultBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseMCPToolUseBlock",
          "x-anthropic-beta-required": [
            "mcp-client-2025-04-04",
            "mcp-client-2025-11-20"
          ]
        },
        {
          "$ref": "#/$defs/BetaResponseMCPToolResultBlock",
          "x-anthropic-beta-required": [
            "mcp-client-2025-04-04",
            "mcp-client-2025-11-20"
          ]
        },
        {
          "$ref": "#/$defs/BetaResponseContainerUploadBlock"
        },
        {
          "$ref": "#/$defs/BetaResponseCompactionBlock",
          "x-anthropic-beta-required": [
            "compact-2026-01-12"
          ]
        },
        {
          "$ref": "#/$defs/BetaResponseFallbackBlock",
          "x-anthropic-beta-required": [
            "server-side-fallback-2026-06-01",
            "server-side-fallback-2026-07-01"
          ]
        }
      ]
    },
    "BetaDiagnostics": {
      "description": "Response envelope for request-level diagnostics. Present (possibly\nnull) whenever the caller supplied `diagnostics` on the request.",
      "properties": {
        "cache_miss_reason": {
          "anyOf": [
            {
              "oneOf": [
                {
                  "$ref": "#/$defs/BetaCacheMissModelChanged"
                },
                {
                  "$ref": "#/$defs/BetaCacheMissSystemChanged"
                },
                {
                  "$ref": "#/$defs/BetaCacheMissToolsChanged"
                },
                {
                  "$ref": "#/$defs/BetaCacheMissMessagesChanged"
                },
                {
                  "$ref": "#/$defs/BetaCacheMissPreviousMessageNotFound"
                },
                {
                  "$ref": "#/$defs/BetaCacheMissUnavailable"
                }
              ]
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Explains why the prompt cache could not fully reuse the prefix from the request identified by `diagnostics.previous_message_id`. `null` means diagnosis is still pending — the response was serialized before the background comparison completed.",
          "title": "Cache Miss Reason"
        }
      },
      "required": [
        "cache_miss_reason"
      ],
      "title": "Diagnostics",
      "type": "object"
    },
    "BetaDirectCaller": {
      "additionalProperties": false,
      "description": "Tool invocation directly from the model.",
      "properties": {
        "type": {
          "const": "direct",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "DirectCaller",
      "type": "object"
    },
    "BetaFallbackCreditNotApplied": {
      "description": "No reprice was applied; ``reason`` says why.",
      "properties": {
        "reason": {
          "description": "Why the reprice was not applied.\n\nA closed enum; additions to the redemption-check vocabulary arrive as\ndeliberate schema updates.",
          "enum": [
            "body_mismatch",
            "continuation_excluded",
            "continuation_only",
            "expired",
            "invalid_target_model",
            "not_enabled",
            "reprice_unavailable",
            "temporarily_unavailable",
            "variant_fields_present",
            "wrong_organization",
            "wrong_platform",
            "wrong_workspace"
          ],
          "title": "Reason",
          "type": "string"
        },
        "remove_to_redeem": {
          "anyOf": [
            {
              "items": {
                "type": "string"
              },
              "type": "array"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Request fields to remove before retrying, so the retry can redeem this\ntoken.\n\nPresent exactly when `reason` is `variant_fields_present` — never null,\nnever an empty array; absent otherwise. Fields are named only from your own request, and only after\nthe sealed variant hash matched. A served best-effort retry has already\nbeen billed at normal price; nothing redeems retroactively, but a corrected\nre-send inside the token's five-minute window can still redeem.",
          "title": "Remove To Redeem"
        },
        "type": {
          "const": "not_applied",
          "default": "not_applied",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "reason",
        "type"
      ],
      "title": "FallbackCreditNotApplied",
      "type": "object"
    },
    "BetaFallbackCreditRedeemed": {
      "description": "The reprice was applied: the retry is billed as if the conversation\nhad been on the retry model all along.",
      "properties": {
        "type": {
          "const": "redeemed",
          "default": "redeemed",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "type"
      ],
      "title": "FallbackCreditRedeemed",
      "type": "object"
    },
    "BetaFallbackCreditUsage": {
      "description": "Outcome of the ``fallback_credit_token`` presented on this request.",
      "properties": {
        "status": {
          "description": "Whether the fallback-credit reprice was applied to this response's billing.\n\nA union discriminated on `type`. `redeemed`: the retry is billed as if\nthe conversation had been on the retry model all along — including when the\nresulting shift is zero because there was nothing to move. `not_applied`:\nno reprice was applied; the arm's `reason` says why.",
          "oneOf": [
            {
              "$ref": "#/$defs/BetaFallbackCreditRedeemed"
            },
            {
              "$ref": "#/$defs/BetaFallbackCreditNotApplied"
            }
          ],
          "title": "Status"
        }
      },
      "required": [
        "status"
      ],
      "title": "FallbackCreditUsage",
      "type": "object"
    },
    "BetaFallbackMessageIterationUsage": {
      "description": "Token usage for the fallback-model attempt of a server-side fallback request.\n\nProduced in place of a `message` entry for whichever hop served the\nresponse. A declined hop produces the existing `message` entry. Whether\na fallback model served the response is signalled by the presence of this\nentry in `usage.iterations`.",
      "properties": {
        "cache_creation": {
          "anyOf": [
            {
              "$ref": "#/$defs/BetaCacheCreation"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Breakdown of cached tokens by TTL"
        },
        "cache_creation_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the cache entry.",
          "minimum": 0,
          "title": "Cache Creation Input Tokens",
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "default": 0,
          "description": "The number of input tokens read from the cache.",
          "minimum": 0,
          "title": "Cache Read Input Tokens",
          "type": "integer"
        },
        "input_tokens": {
          "description": "The number of input tokens which were used.",
          "minimum": 0,
          "title": "Input Tokens",
          "type": "integer"
        },
        "model": {
          "$ref": "#/$defs/Model"
        },
        "output_tokens": {
          "description": "The number of output tokens which were used.",
          "minimum": 0,
          "title": "Output Tokens",
          "type": "integer"
        },
        "type": {
          "const": "fallback_message",
          "default": "fallback_message",
          "description": "Usage for the fallback-model attempt that served the response",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_creation",
        "cache_creation_input_tokens",
        "cache_read_input_tokens",
        "input_tokens",
        "model",
        "output_tokens",
        "type"
      ],
      "title": "FallbackMessageIterationUsage",
      "type": "object"
    },
    "BetaFallbackRefusalTrigger": {
      "description": "The `from` model declined for policy reasons.",
      "properties": {
        "category": {
          "anyOf": [
            {
              "$ref": "#/$defs/BetaRefusalCategory"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "The policy category that triggered the `from` model's refusal at this hop. `null` when the refusal doesn't map to a named category. Same vocabulary as `stop_details.category`.",
          "x-stainless-naming": {
            "csharp": {
              "type_name": "BetaFallbackRefusalTriggerCategory"
            }
          }
        },
        "type": {
          "const": "refusal",
          "default": "refusal",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "category",
        "type"
      ],
      "title": "FallbackRefusalTrigger",
      "type": "object"
    },
    "BetaIterationsUsage": {
      "anyOf": [
        {
          "items": {
            "oneOf": [
              {
                "$ref": "#/$defs/BetaMessageIterationUsage"
              },
              {
                "$ref": "#/$defs/BetaCompactionIterationUsage"
              },
              {
                "$ref": "#/$defs/BetaAdvisorMessageIterationUsage",
                "x-anthropic-beta-required": [
                  "advisor-tool-2026-03-01"
                ]
              },
              {
                "$ref": "#/$defs/BetaFallbackMessageIterationUsage",
                "x-anthropic-beta-required": [
                  "server-side-fallback-2026-06-01",
                  "server-side-fallback-2026-07-01"
                ]
              }
            ],
            "x-stainless-naming": {
              "java": {
                "type_name": "BetaIterationsUsageItems"
              },
              "csharp": {
                "type_name": "BetaIterationsUsageItems"
              }
            }
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "default": null,
      "description": "Per-iteration token usage breakdown.\n\nEach entry represents one sampling iteration, with its own input/output token counts and cache statistics, discriminated by `type`. For `message` entries (model sampling iterations, such as the turns of a server-side tool use loop), this allows you to:\n- Determine which iterations exceeded long context thresholds (>=200k tokens)\n- Calculate the context window size from the last `message` entry\n- Understand token accumulation across server-side tool use loops\n\nA `compaction` entry reports the token usage of the compaction operation itself — the server-side request that summarizes the context being closed — NOT the size of the context that was compacted away, and its token counts can be much smaller than that closed context (for example, a compaction that closes a ~200k-token context can report only a few thousand tokens). Do not derive the context window size from a `compaction` entry, even when it is the last entry. A `compaction` entry's tokens are not included in the top-level `usage` fields. When an input-token trigger is in effect (the default — 150,000 tokens unless configured otherwise), each `compaction` entry closes a context that had reached at least that threshold, though the context can exceed it by the final iteration's output and tool results.",
      "title": "Iterations",
      "x-anthropic-beta-required": [
        "compact-2026-01-12",
        "advisor-tool-2026-03-01",
        "task-budgets-2026-03-13",
        "server-side-fallback-2026-06-01",
        "server-side-fallback-2026-07-01"
      ]
    },
    "BetaMessageIterationUsage": {
      "description": "Token usage for a sampling iteration.",
      "properties": {
        "cache_creation": {
          "anyOf": [
            {
              "$ref": "#/$defs/BetaCacheCreation"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "description": "Breakdown of cached tokens by TTL"
        },
        "cache_creation_input_tokens": {
          "default": 0,
          "description": "The number of input tokens used to create the cache entry.",
          "minimum": 0,
          "title": "Cache Creation Input Tokens",
          "type": "integer"
        },
        "cache_read_input_tokens": {
          "default": 0,
          "description": "The number of input tokens read from the cache.",
          "minimum": 0,
          "title": "Cache Read Input Tokens",
          "type": "integer"
        },
        "input_tokens": {
          "description": "The number of input tokens which were used.",
          "minimum": 0,
          "title": "Input Tokens",
          "type": "integer"
        },
        "model": {
          "$ref": "#/$defs/Model"
        },
        "output_tokens": {
          "description": "The number of output tokens which were used.",
          "minimum": 0,
          "title": "Output Tokens",
          "type": "integer"
        },
        "type": {
          "const": "message",
          "default": "message",
          "description": "Usage for a sampling iteration",
          "title": "Type",
          "type": "string"
        }
      },
      "required": [
        "cache_creation",
        "cache_creation_input_tokens",
        "cache_read_input_tokens",
        "input_tokens",
        "model",
        "output_tokens",
        "type"
      ],
      "title": "MessageIterationUsage",
      "type": "object"
    },
    "BetaOutputTokensDetails": {
      "properties": {
        "thinking_tokens": {
          "default": 0,
          "description": "Number of output tokens the model generated as internal reasoning, including\nthe thinking-block delimiter tokens.\n\nReflects the raw reasoning the model produced, not the (possibly shorter)\nsummarized thinking text returned in the response body. Computed by\nre-tokenizing the raw reasoning text, so it may differ from the model's exact\ngeneration count by a small number of tokens. Always ≤ `output_tokens`;\n`output_tokens - thinking_tokens` approximates the non-reasoning output.",
          "minimum": 0,
          "title": "Thinking Tokens",
          "type": "integer"
        }
      },
      "required": [
        "thinking_tokens"
      ],
      "title": "OutputTokensDetails",
      "type": "object"
    },
    "BetaPlainTextSource": {
      "additionalProperties": false,
      "properties": {
        "data": {
          "title": "Data",
          "type": "string"
        },
        "media_type": {
          "const": "text/plain",
          "title": "Media Type",
          "type": "string"
        },
        "type": {
          "const": "text",
          "title": "Type",
          "type"

# --- truncated at 32 KB (99 KB total) ---
# Full source: https://raw.githubusercontent.com/api-evangelist/anthropic/refs/heads/main/json-schema/anthropic-beta-message-schema.json

Work with this as data

Every JSON Schema here is available over the APIs.io API and to AI agents over MCP.

MCP server

One button, every client — Claude, Cursor, VS Code and the rest.

https://apis.io/mcp

Tools for schemas

4 MCP tools reach this
  • find_json_schemasBrowse and filter every JSON Schema in the catalog.
  • apis_io_searchSTART HERE — APIs, providers and tags for one query, each with its total.
  • resolveTurn a domain, URL or GitHub org into the provider it belongs to.
  • find_cohortsEvery scored population of providers in the catalog.
All 92 tools →

Call it yourself

curl for this page
This JSON Schema
curl "https://apis.io/api/v1/json-schemas/anthropic-beta-message"
All schemas
curl "https://apis.io/api/v1/json-schemas?limit=25"

Discovery needs no key. Ratings and market analysis are Pro.

Get an API key

Free tier, no form to fill in. Signing in shares your email address with us — we store it to create your key and to recognise you if you sign in with another provider. See our Privacy Policy and Terms.

A second provider on the same verified email joins the account you already have.