# Beta

## Domain Types

### Anthropic Beta

- `Union[str, Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]]`

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Beta API Error

- `class BetaAPIError: …`

  - `message: str`

  - `type: Literal["api_error"]`

    - `"api_error"`

### Beta Authentication Error

- `class BetaAuthenticationError: …`

  - `message: str`

  - `type: Literal["authentication_error"]`

    - `"authentication_error"`

### Beta Billing Error

- `class BetaBillingError: …`

  - `message: str`

  - `type: Literal["billing_error"]`

    - `"billing_error"`

### Beta Error

- `BetaError`

  - `class BetaInvalidRequestError: …`

    - `message: str`

    - `type: Literal["invalid_request_error"]`

      - `"invalid_request_error"`

  - `class BetaAuthenticationError: …`

    - `message: str`

    - `type: Literal["authentication_error"]`

      - `"authentication_error"`

  - `class BetaBillingError: …`

    - `message: str`

    - `type: Literal["billing_error"]`

      - `"billing_error"`

  - `class BetaPermissionError: …`

    - `message: str`

    - `type: Literal["permission_error"]`

      - `"permission_error"`

  - `class BetaNotFoundError: …`

    - `message: str`

    - `type: Literal["not_found_error"]`

      - `"not_found_error"`

  - `class BetaRateLimitError: …`

    - `message: str`

    - `type: Literal["rate_limit_error"]`

      - `"rate_limit_error"`

  - `class BetaGatewayTimeoutError: …`

    - `message: str`

    - `type: Literal["timeout_error"]`

      - `"timeout_error"`

  - `class BetaAPIError: …`

    - `message: str`

    - `type: Literal["api_error"]`

      - `"api_error"`

  - `class BetaOverloadedError: …`

    - `message: str`

    - `type: Literal["overloaded_error"]`

      - `"overloaded_error"`

### Beta Error Response

- `class BetaErrorResponse: …`

  - `error: BetaError`

    - `class BetaInvalidRequestError: …`

      - `message: str`

      - `type: Literal["invalid_request_error"]`

        - `"invalid_request_error"`

    - `class BetaAuthenticationError: …`

      - `message: str`

      - `type: Literal["authentication_error"]`

        - `"authentication_error"`

    - `class BetaBillingError: …`

      - `message: str`

      - `type: Literal["billing_error"]`

        - `"billing_error"`

    - `class BetaPermissionError: …`

      - `message: str`

      - `type: Literal["permission_error"]`

        - `"permission_error"`

    - `class BetaNotFoundError: …`

      - `message: str`

      - `type: Literal["not_found_error"]`

        - `"not_found_error"`

    - `class BetaRateLimitError: …`

      - `message: str`

      - `type: Literal["rate_limit_error"]`

        - `"rate_limit_error"`

    - `class BetaGatewayTimeoutError: …`

      - `message: str`

      - `type: Literal["timeout_error"]`

        - `"timeout_error"`

    - `class BetaAPIError: …`

      - `message: str`

      - `type: Literal["api_error"]`

        - `"api_error"`

    - `class BetaOverloadedError: …`

      - `message: str`

      - `type: Literal["overloaded_error"]`

        - `"overloaded_error"`

  - `request_id: Optional[str]`

  - `type: Literal["error"]`

    - `"error"`

### Beta Gateway Timeout Error

- `class BetaGatewayTimeoutError: …`

  - `message: str`

  - `type: Literal["timeout_error"]`

    - `"timeout_error"`

### Beta Invalid Request Error

- `class BetaInvalidRequestError: …`

  - `message: str`

  - `type: Literal["invalid_request_error"]`

    - `"invalid_request_error"`

### Beta Not Found Error

- `class BetaNotFoundError: …`

  - `message: str`

  - `type: Literal["not_found_error"]`

    - `"not_found_error"`

### Beta Overloaded Error

- `class BetaOverloadedError: …`

  - `message: str`

  - `type: Literal["overloaded_error"]`

    - `"overloaded_error"`

### Beta Permission Error

- `class BetaPermissionError: …`

  - `message: str`

  - `type: Literal["permission_error"]`

    - `"permission_error"`

### Beta Rate Limit Error

- `class BetaRateLimitError: …`

  - `message: str`

  - `type: Literal["rate_limit_error"]`

    - `"rate_limit_error"`

# Models

## List Models

`beta.models.list(ModelListParams**kwargs)  -> SyncPage[BetaModelInfo]`

**get** `/v1/models`

List available models.

The Models API response can be used to determine which models are available for use in the API. More recently released models are listed first.

### Parameters

- `after_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object.

- `before_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object.

- `limit: Optional[int]`

  Number of items to return per page.

  Defaults to `20`. Ranges from `1` to `1000`.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaModelInfo: …`

  - `id: str`

    Unique model identifier.

  - `capabilities: Optional[BetaModelCapabilities]`

    Model capability information.

    - `batch: BetaCapabilitySupport`

      Whether the model supports the Batch API.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `citations: BetaCapabilitySupport`

      Whether the model supports citation generation.

    - `code_execution: BetaCapabilitySupport`

      Whether the model supports code execution tools.

    - `context_management: BetaContextManagementCapability`

      Context management support and available strategies.

      - `clear_thinking_20251015: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `clear_tool_uses_20250919: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `compact_20260112: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `effort: BetaEffortCapability`

      Effort (reasoning_effort) support and available levels.

      - `high: BetaCapabilitySupport`

        Whether the model supports high effort level.

      - `low: BetaCapabilitySupport`

        Whether the model supports low effort level.

      - `max: BetaCapabilitySupport`

        Whether the model supports max effort level.

      - `medium: BetaCapabilitySupport`

        Whether the model supports medium effort level.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `xhigh: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

    - `image_input: BetaCapabilitySupport`

      Whether the model accepts image content blocks.

    - `pdf_input: BetaCapabilitySupport`

      Whether the model accepts PDF content blocks.

    - `structured_outputs: BetaCapabilitySupport`

      Whether the model supports structured output / JSON mode / strict tool schemas.

    - `thinking: BetaThinkingCapability`

      Thinking capability and supported type configurations.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `types: BetaThinkingTypes`

        Supported thinking type configurations.

        - `adaptive: BetaCapabilitySupport`

          Whether the model supports thinking with type 'adaptive' (auto).

        - `enabled: BetaCapabilitySupport`

          Whether the model supports thinking with type 'enabled'.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.

  - `display_name: str`

    A human-readable name for the model.

  - `max_input_tokens: Optional[int]`

    Maximum input context window size in tokens for this model.

  - `max_tokens: Optional[int]`

    Maximum value for the `max_tokens` parameter when using this model.

  - `type: Literal["model"]`

    Object type.

    For Models, this is always `"model"`.

    - `"model"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.models.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "claude-opus-4-6",
      "capabilities": {
        "batch": {
          "supported": true
        },
        "citations": {
          "supported": true
        },
        "code_execution": {
          "supported": true
        },
        "context_management": {
          "clear_thinking_20251015": {
            "supported": true
          },
          "clear_tool_uses_20250919": {
            "supported": true
          },
          "compact_20260112": {
            "supported": true
          },
          "supported": true
        },
        "effort": {
          "high": {
            "supported": true
          },
          "low": {
            "supported": true
          },
          "max": {
            "supported": true
          },
          "medium": {
            "supported": true
          },
          "supported": true,
          "xhigh": {
            "supported": true
          }
        },
        "image_input": {
          "supported": true
        },
        "pdf_input": {
          "supported": true
        },
        "structured_outputs": {
          "supported": true
        },
        "thinking": {
          "supported": true,
          "types": {
            "adaptive": {
              "supported": true
            },
            "enabled": {
              "supported": true
            }
          }
        }
      },
      "created_at": "2026-02-04T00:00:00Z",
      "display_name": "Claude Opus 4.6",
      "max_input_tokens": 0,
      "max_tokens": 0,
      "type": "model"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id"
}
```

## Get a Model

`beta.models.retrieve(strmodel_id, ModelRetrieveParams**kwargs)  -> BetaModelInfo`

**get** `/v1/models/{model_id}`

Get a specific model.

The Models API response can be used to determine information about a specific model or resolve a model alias to a model ID.

### Parameters

- `model_id: str`

  Model identifier or alias.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaModelInfo: …`

  - `id: str`

    Unique model identifier.

  - `capabilities: Optional[BetaModelCapabilities]`

    Model capability information.

    - `batch: BetaCapabilitySupport`

      Whether the model supports the Batch API.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `citations: BetaCapabilitySupport`

      Whether the model supports citation generation.

    - `code_execution: BetaCapabilitySupport`

      Whether the model supports code execution tools.

    - `context_management: BetaContextManagementCapability`

      Context management support and available strategies.

      - `clear_thinking_20251015: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `clear_tool_uses_20250919: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `compact_20260112: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `effort: BetaEffortCapability`

      Effort (reasoning_effort) support and available levels.

      - `high: BetaCapabilitySupport`

        Whether the model supports high effort level.

      - `low: BetaCapabilitySupport`

        Whether the model supports low effort level.

      - `max: BetaCapabilitySupport`

        Whether the model supports max effort level.

      - `medium: BetaCapabilitySupport`

        Whether the model supports medium effort level.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `xhigh: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

    - `image_input: BetaCapabilitySupport`

      Whether the model accepts image content blocks.

    - `pdf_input: BetaCapabilitySupport`

      Whether the model accepts PDF content blocks.

    - `structured_outputs: BetaCapabilitySupport`

      Whether the model supports structured output / JSON mode / strict tool schemas.

    - `thinking: BetaThinkingCapability`

      Thinking capability and supported type configurations.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `types: BetaThinkingTypes`

        Supported thinking type configurations.

        - `adaptive: BetaCapabilitySupport`

          Whether the model supports thinking with type 'adaptive' (auto).

        - `enabled: BetaCapabilitySupport`

          Whether the model supports thinking with type 'enabled'.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.

  - `display_name: str`

    A human-readable name for the model.

  - `max_input_tokens: Optional[int]`

    Maximum input context window size in tokens for this model.

  - `max_tokens: Optional[int]`

    Maximum value for the `max_tokens` parameter when using this model.

  - `type: Literal["model"]`

    Object type.

    For Models, this is always `"model"`.

    - `"model"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_model_info = client.beta.models.retrieve(
    model_id="model_id",
)
print(beta_model_info.id)
```

#### Response

```json
{
  "id": "claude-opus-4-6",
  "capabilities": {
    "batch": {
      "supported": true
    },
    "citations": {
      "supported": true
    },
    "code_execution": {
      "supported": true
    },
    "context_management": {
      "clear_thinking_20251015": {
        "supported": true
      },
      "clear_tool_uses_20250919": {
        "supported": true
      },
      "compact_20260112": {
        "supported": true
      },
      "supported": true
    },
    "effort": {
      "high": {
        "supported": true
      },
      "low": {
        "supported": true
      },
      "max": {
        "supported": true
      },
      "medium": {
        "supported": true
      },
      "supported": true,
      "xhigh": {
        "supported": true
      }
    },
    "image_input": {
      "supported": true
    },
    "pdf_input": {
      "supported": true
    },
    "structured_outputs": {
      "supported": true
    },
    "thinking": {
      "supported": true,
      "types": {
        "adaptive": {
          "supported": true
        },
        "enabled": {
          "supported": true
        }
      }
    }
  },
  "created_at": "2026-02-04T00:00:00Z",
  "display_name": "Claude Opus 4.6",
  "max_input_tokens": 0,
  "max_tokens": 0,
  "type": "model"
}
```

## Domain Types

### Beta Capability Support

- `class BetaCapabilitySupport: …`

  Indicates whether a capability is supported.

  - `supported: bool`

    Whether this capability is supported by the model.

### Beta Context Management Capability

- `class BetaContextManagementCapability: …`

  Context management capability details.

  - `clear_thinking_20251015: Optional[BetaCapabilitySupport]`

    Indicates whether a capability is supported.

    - `supported: bool`

      Whether this capability is supported by the model.

  - `clear_tool_uses_20250919: Optional[BetaCapabilitySupport]`

    Indicates whether a capability is supported.

  - `compact_20260112: Optional[BetaCapabilitySupport]`

    Indicates whether a capability is supported.

  - `supported: bool`

    Whether this capability is supported by the model.

### Beta Effort Capability

- `class BetaEffortCapability: …`

  Effort (reasoning_effort) capability details.

  - `high: BetaCapabilitySupport`

    Whether the model supports high effort level.

    - `supported: bool`

      Whether this capability is supported by the model.

  - `low: BetaCapabilitySupport`

    Whether the model supports low effort level.

  - `max: BetaCapabilitySupport`

    Whether the model supports max effort level.

  - `medium: BetaCapabilitySupport`

    Whether the model supports medium effort level.

  - `supported: bool`

    Whether this capability is supported by the model.

  - `xhigh: Optional[BetaCapabilitySupport]`

    Indicates whether a capability is supported.

### Beta Model Capabilities

- `class BetaModelCapabilities: …`

  Model capability information.

  - `batch: BetaCapabilitySupport`

    Whether the model supports the Batch API.

    - `supported: bool`

      Whether this capability is supported by the model.

  - `citations: BetaCapabilitySupport`

    Whether the model supports citation generation.

  - `code_execution: BetaCapabilitySupport`

    Whether the model supports code execution tools.

  - `context_management: BetaContextManagementCapability`

    Context management support and available strategies.

    - `clear_thinking_20251015: Optional[BetaCapabilitySupport]`

      Indicates whether a capability is supported.

    - `clear_tool_uses_20250919: Optional[BetaCapabilitySupport]`

      Indicates whether a capability is supported.

    - `compact_20260112: Optional[BetaCapabilitySupport]`

      Indicates whether a capability is supported.

    - `supported: bool`

      Whether this capability is supported by the model.

  - `effort: BetaEffortCapability`

    Effort (reasoning_effort) support and available levels.

    - `high: BetaCapabilitySupport`

      Whether the model supports high effort level.

    - `low: BetaCapabilitySupport`

      Whether the model supports low effort level.

    - `max: BetaCapabilitySupport`

      Whether the model supports max effort level.

    - `medium: BetaCapabilitySupport`

      Whether the model supports medium effort level.

    - `supported: bool`

      Whether this capability is supported by the model.

    - `xhigh: Optional[BetaCapabilitySupport]`

      Indicates whether a capability is supported.

  - `image_input: BetaCapabilitySupport`

    Whether the model accepts image content blocks.

  - `pdf_input: BetaCapabilitySupport`

    Whether the model accepts PDF content blocks.

  - `structured_outputs: BetaCapabilitySupport`

    Whether the model supports structured output / JSON mode / strict tool schemas.

  - `thinking: BetaThinkingCapability`

    Thinking capability and supported type configurations.

    - `supported: bool`

      Whether this capability is supported by the model.

    - `types: BetaThinkingTypes`

      Supported thinking type configurations.

      - `adaptive: BetaCapabilitySupport`

        Whether the model supports thinking with type 'adaptive' (auto).

      - `enabled: BetaCapabilitySupport`

        Whether the model supports thinking with type 'enabled'.

### Beta Model Info

- `class BetaModelInfo: …`

  - `id: str`

    Unique model identifier.

  - `capabilities: Optional[BetaModelCapabilities]`

    Model capability information.

    - `batch: BetaCapabilitySupport`

      Whether the model supports the Batch API.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `citations: BetaCapabilitySupport`

      Whether the model supports citation generation.

    - `code_execution: BetaCapabilitySupport`

      Whether the model supports code execution tools.

    - `context_management: BetaContextManagementCapability`

      Context management support and available strategies.

      - `clear_thinking_20251015: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `clear_tool_uses_20250919: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `compact_20260112: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

      - `supported: bool`

        Whether this capability is supported by the model.

    - `effort: BetaEffortCapability`

      Effort (reasoning_effort) support and available levels.

      - `high: BetaCapabilitySupport`

        Whether the model supports high effort level.

      - `low: BetaCapabilitySupport`

        Whether the model supports low effort level.

      - `max: BetaCapabilitySupport`

        Whether the model supports max effort level.

      - `medium: BetaCapabilitySupport`

        Whether the model supports medium effort level.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `xhigh: Optional[BetaCapabilitySupport]`

        Indicates whether a capability is supported.

    - `image_input: BetaCapabilitySupport`

      Whether the model accepts image content blocks.

    - `pdf_input: BetaCapabilitySupport`

      Whether the model accepts PDF content blocks.

    - `structured_outputs: BetaCapabilitySupport`

      Whether the model supports structured output / JSON mode / strict tool schemas.

    - `thinking: BetaThinkingCapability`

      Thinking capability and supported type configurations.

      - `supported: bool`

        Whether this capability is supported by the model.

      - `types: BetaThinkingTypes`

        Supported thinking type configurations.

        - `adaptive: BetaCapabilitySupport`

          Whether the model supports thinking with type 'adaptive' (auto).

        - `enabled: BetaCapabilitySupport`

          Whether the model supports thinking with type 'enabled'.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the model was released. May be set to an epoch value if the release date is unknown.

  - `display_name: str`

    A human-readable name for the model.

  - `max_input_tokens: Optional[int]`

    Maximum input context window size in tokens for this model.

  - `max_tokens: Optional[int]`

    Maximum value for the `max_tokens` parameter when using this model.

  - `type: Literal["model"]`

    Object type.

    For Models, this is always `"model"`.

    - `"model"`

### Beta Thinking Capability

- `class BetaThinkingCapability: …`

  Thinking capability details.

  - `supported: bool`

    Whether this capability is supported by the model.

  - `types: BetaThinkingTypes`

    Supported thinking type configurations.

    - `adaptive: BetaCapabilitySupport`

      Whether the model supports thinking with type 'adaptive' (auto).

      - `supported: bool`

        Whether this capability is supported by the model.

    - `enabled: BetaCapabilitySupport`

      Whether the model supports thinking with type 'enabled'.

### Beta Thinking Types

- `class BetaThinkingTypes: …`

  Supported thinking type configurations.

  - `adaptive: BetaCapabilitySupport`

    Whether the model supports thinking with type 'adaptive' (auto).

    - `supported: bool`

      Whether this capability is supported by the model.

  - `enabled: BetaCapabilitySupport`

    Whether the model supports thinking with type 'enabled'.

# Messages

## Create a Message

`beta.messages.create(MessageCreateParams**kwargs)  -> BetaMessage`

**post** `/v1/messages`

Send a structured list of input messages with text and/or image content, and the model will generate the next message in the conversation.

The Messages API can be used for either single queries or stateless multi-turn conversations.

Learn more about the Messages API in our [user guide](https://docs.claude.com/en/docs/initial-setup)

### Parameters

- `max_tokens: int`

  The maximum number of tokens to generate before stopping.

  Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.

  Set to `0` to populate the [prompt cache](https://docs.claude.com/en/docs/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response.

  Different models have different maximum values for this parameter.  See [models](https://docs.claude.com/en/docs/models-overview) for details.

- `messages: Iterable[BetaMessageParam]`

  Input messages.

  Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.

  Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.

  If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.

  Example with a single `user` message:

  ```json
  [{"role": "user", "content": "Hello, Claude"}]
  ```

  Example with multiple conversational turns:

  ```json
  [
    {"role": "user", "content": "Hello there."},
    {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},
    {"role": "user", "content": "Can you explain LLMs in plain English?"},
  ]
  ```

  Example with a partially-filled response from Claude:

  ```json
  [
    {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
    {"role": "assistant", "content": "The best answer is ("},
  ]
  ```

  Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent:

  ```json
  {"role": "user", "content": "Hello, Claude"}
  ```

  ```json
  {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}
  ```

  See [input examples](https://docs.claude.com/en/api/messages-examples).

  Note that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API.

  There is a limit of 100,000 messages in a single request.

  - `content: Union[str, List[BetaContentBlockParam]]`

    - `str`

    - `List[BetaContentBlockParam]`

      - `class BetaTextBlockParam: …`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

          - `type: Literal["ephemeral"]`

            - `"ephemeral"`

          - `ttl: Optional[Literal["5m", "1h"]]`

            The time-to-live for the cache control breakpoint.

            This may be one the following values:

            - `5m`: 5 minutes
            - `1h`: 1 hour

            Defaults to `5m`.

            - `"5m"`

            - `"1h"`

        - `citations: Optional[List[BetaTextCitationParam]]`

          - `class BetaCitationCharLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationWebSearchResultLocationParam: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

      - `class BetaImageBlockParam: …`

        - `source: Source`

          - `class BetaBase64ImageSource: …`

            - `data: str`

            - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

              - `"image/jpeg"`

              - `"image/png"`

              - `"image/gif"`

              - `"image/webp"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaURLImageSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileImageSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestDocumentBlock: …`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaContentBlockSource: …`

            - `content: Union[str, List[BetaContentBlockSourceContent]]`

              - `str`

              - `List[BetaContentBlockSourceContent]`

                - `class BetaTextBlockParam: …`

                - `class BetaImageBlockParam: …`

            - `type: Literal["content"]`

              - `"content"`

          - `class BetaURLPDFSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileDocumentSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          - `enabled: Optional[bool]`

        - `context: Optional[str]`

        - `title: Optional[str]`

      - `class BetaSearchResultBlockParam: …`

        - `content: List[BetaTextBlockParam]`

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `source: str`

        - `title: str`

        - `type: Literal["search_result"]`

          - `"search_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

      - `class BetaThinkingBlockParam: …`

        - `signature: str`

        - `thinking: str`

        - `type: Literal["thinking"]`

          - `"thinking"`

      - `class BetaRedactedThinkingBlockParam: …`

        - `data: str`

        - `type: Literal["redacted_thinking"]`

          - `"redacted_thinking"`

      - `class BetaToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `type: Literal["tool_use"]`

          - `"tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

            - `type: Literal["direct"]`

              - `"direct"`

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

            - `tool_id: str`

            - `type: Literal["code_execution_20250825"]`

              - `"code_execution_20250825"`

          - `class BetaServerToolCaller20260120: …`

            - `tool_id: str`

            - `type: Literal["code_execution_20260120"]`

              - `"code_execution_20260120"`

      - `class BetaToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["tool_result"]`

          - `"tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[Content], null]]`

          - `str`

          - `List[Content]`

            - `class BetaTextBlockParam: …`

            - `class BetaImageBlockParam: …`

            - `class BetaSearchResultBlockParam: …`

            - `class BetaRequestDocumentBlock: …`

            - `class BetaToolReferenceBlockParam: …`

              Tool reference block that can be included in tool_result content.

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

                - `"tool_reference"`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

        - `is_error: Optional[bool]`

      - `class BetaServerToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

          - `"advisor"`

          - `"web_search"`

          - `"web_fetch"`

          - `"code_execution"`

          - `"bash_code_execution"`

          - `"text_editor_code_execution"`

          - `"tool_search_tool_regex"`

          - `"tool_search_tool_bm25"`

        - `type: Literal["server_tool_use"]`

          - `"server_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebSearchToolResultBlockParam: …`

        - `content: BetaWebSearchToolResultBlockParamContent`

          - `List[BetaWebSearchResultBlockParam]`

            - `encrypted_content: str`

            - `title: str`

            - `type: Literal["web_search_result"]`

              - `"web_search_result"`

            - `url: str`

            - `page_age: Optional[str]`

          - `class BetaWebSearchToolRequestError: …`

            - `error_code: BetaWebSearchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"max_uses_exceeded"`

              - `"too_many_requests"`

              - `"query_too_long"`

              - `"request_too_large"`

            - `type: Literal["web_search_tool_result_error"]`

              - `"web_search_tool_result_error"`

        - `tool_use_id: str`

        - `type: Literal["web_search_tool_result"]`

          - `"web_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebFetchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaWebFetchToolResultErrorBlockParam: …`

            - `error_code: BetaWebFetchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"url_too_long"`

              - `"url_not_allowed"`

              - `"url_not_in_prior_context"`

              - `"url_not_accessible"`

              - `"unsupported_content_type"`

              - `"too_many_requests"`

              - `"max_uses_exceeded"`

              - `"unavailable"`

            - `type: Literal["web_fetch_tool_result_error"]`

              - `"web_fetch_tool_result_error"`

          - `class BetaWebFetchBlockParam: …`

            - `content: BetaRequestDocumentBlock`

            - `type: Literal["web_fetch_result"]`

              - `"web_fetch_result"`

            - `url: str`

              Fetched content URL

            - `retrieved_at: Optional[str]`

              ISO 8601 timestamp when the content was retrieved

        - `tool_use_id: str`

        - `type: Literal["web_fetch_tool_result"]`

          - `"web_fetch_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaAdvisorToolResultBlockParam: …`

        - `content: Content`

          - `class BetaAdvisorToolResultErrorParam: …`

            - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

              - `"max_uses_exceeded"`

              - `"prompt_too_long"`

              - `"too_many_requests"`

              - `"overloaded"`

              - `"unavailable"`

              - `"execution_time_exceeded"`

            - `type: Literal["advisor_tool_result_error"]`

              - `"advisor_tool_result_error"`

          - `class BetaAdvisorResultBlockParam: …`

            - `text: str`

            - `type: Literal["advisor_result"]`

              - `"advisor_result"`

            - `stop_reason: Optional[str]`

          - `class BetaAdvisorRedactedResultBlockParam: …`

            - `encrypted_content: str`

              Opaque blob produced by a prior response; must be round-tripped verbatim.

            - `type: Literal["advisor_redacted_result"]`

              - `"advisor_redacted_result"`

            - `stop_reason: Optional[str]`

        - `tool_use_id: str`

        - `type: Literal["advisor_tool_result"]`

          - `"advisor_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCodeExecutionToolResultBlockParam: …`

        - `content: BetaCodeExecutionToolResultBlockParamContent`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `class BetaCodeExecutionToolResultErrorParam: …`

            - `error_code: BetaCodeExecutionToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["code_execution_tool_result_error"]`

              - `"code_execution_tool_result_error"`

          - `class BetaCodeExecutionResultBlockParam: …`

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

                - `"code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["code_execution_result"]`

              - `"code_execution_result"`

          - `class BetaEncryptedCodeExecutionResultBlockParam: …`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

            - `encrypted_stdout: str`

            - `return_code: int`

            - `stderr: str`

            - `type: Literal["encrypted_code_execution_result"]`

              - `"encrypted_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["code_execution_tool_result"]`

          - `"code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaBashCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaBashCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"output_file_too_large"`

            - `type: Literal["bash_code_execution_tool_result_error"]`

              - `"bash_code_execution_tool_result_error"`

          - `class BetaBashCodeExecutionResultBlockParam: …`

            - `content: List[BetaBashCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["bash_code_execution_output"]`

                - `"bash_code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["bash_code_execution_result"]`

              - `"bash_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["bash_code_execution_tool_result"]`

          - `"bash_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"file_not_found"`

            - `type: Literal["text_editor_code_execution_tool_result_error"]`

              - `"text_editor_code_execution_tool_result_error"`

            - `error_message: Optional[str]`

          - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

            - `content: str`

            - `file_type: Literal["text", "image", "pdf"]`

              - `"text"`

              - `"image"`

              - `"pdf"`

            - `type: Literal["text_editor_code_execution_view_result"]`

              - `"text_editor_code_execution_view_result"`

            - `num_lines: Optional[int]`

            - `start_line: Optional[int]`

            - `total_lines: Optional[int]`

          - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

            - `is_file_update: bool`

            - `type: Literal["text_editor_code_execution_create_result"]`

              - `"text_editor_code_execution_create_result"`

          - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

            - `type: Literal["text_editor_code_execution_str_replace_result"]`

              - `"text_editor_code_execution_str_replace_result"`

            - `lines: Optional[List[str]]`

            - `new_lines: Optional[int]`

            - `new_start: Optional[int]`

            - `old_lines: Optional[int]`

            - `old_start: Optional[int]`

        - `tool_use_id: str`

        - `type: Literal["text_editor_code_execution_tool_result"]`

          - `"text_editor_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaToolSearchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaToolSearchToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["tool_search_tool_result_error"]`

              - `"tool_search_tool_result_error"`

          - `class BetaToolSearchToolSearchResultBlockParam: …`

            - `tool_references: List[BetaToolReferenceBlockParam]`

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

            - `type: Literal["tool_search_tool_search_result"]`

              - `"tool_search_tool_search_result"`

        - `tool_use_id: str`

        - `type: Literal["tool_search_tool_result"]`

          - `"tool_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaMCPToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `server_name: str`

          The name of the MCP server

        - `type: Literal["mcp_tool_use"]`

          - `"mcp_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestMCPToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["mcp_tool_result"]`

          - `"mcp_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

          - `str`

          - `List[BetaTextBlockParam]`

            - `text: str`

            - `type: Literal["text"]`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `citations: Optional[List[BetaTextCitationParam]]`

        - `is_error: Optional[bool]`

      - `class BetaContainerUploadBlockParam: …`

        A content block that represents a file to be uploaded to the container
        Files uploaded via this block will be available in the container's input directory.

        - `file_id: str`

        - `type: Literal["container_upload"]`

          - `"container_upload"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCompactionBlockParam: …`

        A compaction block containing summary of previous context.

        Users should round-trip these blocks from responses to subsequent requests
        to maintain context across compaction boundaries.

        When content is None, the block represents a failed compaction. The server
        treats these as no-ops. Empty string content is not allowed.

        - `type: Literal["compaction"]`

          - `"compaction"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[str]`

          Summary of previously compacted content, or null if compaction failed

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

      - `class BetaMidConversationSystemBlockParam: …`

        System instructions that appear mid-conversation.

        Use this block to provide or update system-level instructions at a specific
        point in the conversation, rather than only via the top-level `system` parameter.

        - `content: List[BetaTextBlockParam]`

          System instruction text blocks.

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `type: Literal["mid_conv_system"]`

          - `"mid_conv_system"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

  - `role: Literal["user", "assistant", "system"]`

    - `"user"`

    - `"assistant"`

    - `"system"`

- `model: ModelParam`

  The model that will complete your prompt.

  See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

  - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
    - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
    - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
    - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
    - `claude-sonnet-4-6` - Best combination of speed and intelligence
    - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
    - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
    - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
    - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
    - `claude-sonnet-4-5` - High-performance model for agents and coding
    - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
    - `claude-opus-4-1` - Exceptional model for specialized complex tasks
    - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
    - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

    - `"claude-opus-4-8"`

      Frontier intelligence for long-running agents and coding

    - `"claude-opus-4-7"`

      Frontier intelligence for long-running agents and coding

    - `"claude-mythos-preview"`

      New class of intelligence, strongest in coding and cybersecurity

    - `"claude-opus-4-6"`

      Frontier intelligence for long-running agents and coding

    - `"claude-sonnet-4-6"`

      Best combination of speed and intelligence

    - `"claude-haiku-4-5"`

      Fastest model with near-frontier intelligence

    - `"claude-haiku-4-5-20251001"`

      Fastest model with near-frontier intelligence

    - `"claude-opus-4-5"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-opus-4-5-20251101"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-sonnet-4-5"`

      High-performance model for agents and coding

    - `"claude-sonnet-4-5-20250929"`

      High-performance model for agents and coding

    - `"claude-opus-4-1"`

      Exceptional model for specialized complex tasks

    - `"claude-opus-4-1-20250805"`

      Exceptional model for specialized complex tasks

    - `"claude-opus-4-0"`

      Powerful model for complex tasks

    - `"claude-opus-4-20250514"`

      Powerful model for complex tasks

    - `"claude-sonnet-4-0"`

      High-performance model with extended thinking

    - `"claude-sonnet-4-20250514"`

      High-performance model with extended thinking

    - `"claude-3-haiku-20240307"`

      Fast and cost-effective model

  - `str`

- `cache_control: Optional[BetaCacheControlEphemeralParam]`

  Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

- `container: Optional[Container]`

  Container identifier for reuse across requests.

  - `class BetaContainerParams: …`

    Container parameters with skills to be loaded.

    - `id: Optional[str]`

      Container id

    - `skills: Optional[List[BetaSkillParams]]`

      List of skills to load in the container

      - `skill_id: str`

        Skill ID

      - `type: Literal["anthropic", "custom"]`

        Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

        - `"anthropic"`

        - `"custom"`

      - `version: Optional[str]`

        Skill version or 'latest' for most recent version

  - `str`

- `context_management: Optional[BetaContextManagementConfigParam]`

  Context management configuration.

  This allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.

  - `edits: Optional[List[Edit]]`

    List of context management edits to apply

    - `class BetaClearToolUses20250919Edit: …`

      - `type: Literal["clear_tool_uses_20250919"]`

        - `"clear_tool_uses_20250919"`

      - `clear_at_least: Optional[BetaInputTokensClearAtLeast]`

        Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.

        - `type: Literal["input_tokens"]`

          - `"input_tokens"`

        - `value: int`

      - `clear_tool_inputs: Optional[Union[bool, List[str], null]]`

        Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

        - `bool`

        - `List[str]`

      - `exclude_tools: Optional[List[str]]`

        Tool names whose uses are preserved from clearing

      - `keep: Optional[BetaToolUsesKeep]`

        Number of tool uses to retain in the conversation

        - `type: Literal["tool_uses"]`

          - `"tool_uses"`

        - `value: int`

      - `trigger: Optional[Trigger]`

        Condition that triggers the context management strategy

        - `class BetaInputTokensTrigger: …`

          - `type: Literal["input_tokens"]`

            - `"input_tokens"`

          - `value: int`

        - `class BetaToolUsesTrigger: …`

          - `type: Literal["tool_uses"]`

            - `"tool_uses"`

          - `value: int`

    - `class BetaClearThinking20251015Edit: …`

      - `type: Literal["clear_thinking_20251015"]`

        - `"clear_thinking_20251015"`

      - `keep: Optional[Keep]`

        Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.

        - `class BetaThinkingTurns: …`

          - `type: Literal["thinking_turns"]`

            - `"thinking_turns"`

          - `value: int`

        - `class BetaAllThinkingTurns: …`

          - `type: Literal["all"]`

            - `"all"`

        - `Literal["all"]`

          - `"all"`

    - `class BetaCompact20260112Edit: …`

      Automatically compact older context when reaching the configured trigger threshold.

      - `type: Literal["compact_20260112"]`

        - `"compact_20260112"`

      - `instructions: Optional[str]`

        Additional instructions for summarization.

      - `pause_after_compaction: Optional[bool]`

        Whether to pause after compaction and return the compaction block to the user.

      - `trigger: Optional[BetaInputTokensTrigger]`

        When to trigger compaction. Defaults to 150000 input tokens.

- `diagnostics: Optional[BetaDiagnosticsParam]`

  Request-level diagnostics. Currently carries the previous response
  id for prompt-cache divergence reporting.

  - `previous_message_id: Optional[str]`

    The `id` (`msg_...`) from this client's previous /v1/messages response. The server compares that request's prompt fingerprint against this one and returns `diagnostics.cache_miss_reason` when the prompt-cache prefix could not be reused. Pass `null` on the first turn to opt in without a prior message to compare.

- `inference_geo: Optional[str]`

  Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used.

- `mcp_servers: Optional[Iterable[BetaRequestMCPServerURLDefinitionParam]]`

  MCP servers to be utilized in this request

  - `name: str`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

  - `authorization_token: Optional[str]`

  - `tool_configuration: Optional[BetaRequestMCPServerToolConfiguration]`

    - `allowed_tools: Optional[List[str]]`

    - `enabled: Optional[bool]`

- `metadata: Optional[BetaMetadataParam]`

  An object describing metadata about the request.

  - `user_id: Optional[str]`

    An external identifier for the user who is associated with the request.

    This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

- `output_config: Optional[BetaOutputConfigParam]`

  Configuration options for the model's output, such as the output format.

  - `effort: Optional[Literal["low", "medium", "high", 2 more]]`

    All possible effort levels.

    - `"low"`

    - `"medium"`

    - `"high"`

    - `"xhigh"`

    - `"max"`

  - `format: Optional[BetaJSONOutputFormat]`

    A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

    - `schema: Dict[str, object]`

      The JSON schema of the format

    - `type: Literal["json_schema"]`

      - `"json_schema"`

  - `task_budget: Optional[BetaTokenTaskBudget]`

    User-configurable total token budget across contexts.

    - `total: int`

      Total token budget across all contexts in the session.

    - `type: Literal["tokens"]`

      The budget type. Currently only 'tokens' is supported.

      - `"tokens"`

    - `remaining: Optional[int]`

      Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.

- `output_format: Optional[BetaJSONOutputFormatParam]`

  Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

  A schema to specify Claude's output format in responses. This parameter will be removed in a future release.

- `service_tier: Optional[Literal["auto", "standard_only"]]`

  Determines whether to use priority capacity (if available) or standard capacity for this request.

  Anthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.

  - `"auto"`

  - `"standard_only"`

- `speed: Optional[Literal["standard", "fast"]]`

  The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.

  - `"standard"`

  - `"fast"`

- `stop_sequences: Optional[Sequence[str]]`

  Custom text sequences that will cause the model to stop generating.

  Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`.

  If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.

- `stream: Optional[Literal[false]]`

  Whether to incrementally stream the response using server-sent events.

  See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.

  - `false`

- `system: Optional[Union[str, Iterable[BetaTextBlockParam]]]`

  System prompt.

  A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).

  - `str`

  - `Iterable[BetaTextBlockParam]`

    - `text: str`

    - `type: Literal["text"]`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[List[BetaTextCitationParam]]`

- `temperature: Optional[float]`

  Amount of randomness injected into the response.

  Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.

  Note that even with `temperature` of `0.0`, the results will not be fully deterministic.

- `thinking: Optional[BetaThinkingConfigParam]`

  Configuration for enabling Claude's extended thinking.

  When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.

  See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

  - `class BetaThinkingConfigEnabled: …`

    - `budget_tokens: int`

      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.

      Must be ≥1024 and less than `max_tokens`.

      See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

    - `type: Literal["enabled"]`

      - `"enabled"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

  - `class BetaThinkingConfigDisabled: …`

    - `type: Literal["disabled"]`

      - `"disabled"`

  - `class BetaThinkingConfigAdaptive: …`

    - `type: Literal["adaptive"]`

      - `"adaptive"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

- `tool_choice: Optional[BetaToolChoiceParam]`

  How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

  - `class BetaToolChoiceAuto: …`

    The model will automatically decide whether to use tools.

    - `type: Literal["auto"]`

      - `"auto"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output at most one tool use.

  - `class BetaToolChoiceAny: …`

    The model will use any available tools.

    - `type: Literal["any"]`

      - `"any"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceTool: …`

    The model will use the specified tool with `tool_choice.name`.

    - `name: str`

      The name of the tool to use.

    - `type: Literal["tool"]`

      - `"tool"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceNone: …`

    The model will not be allowed to use tools.

    - `type: Literal["none"]`

      - `"none"`

- `tools: Optional[Iterable[BetaToolUnionParam]]`

  Definitions of tools that the model may use.

  If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.

  There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).

  Each tool definition includes:

  * `name`: Name of the tool.
  * `description`: Optional, but strongly-recommended description of the tool.
  * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.

  For example, if you defined `tools` as:

  ```json
  [
    {
      "name": "get_stock_price",
      "description": "Get the current stock price for a given ticker symbol.",
      "input_schema": {
        "type": "object",
        "properties": {
          "ticker": {
            "type": "string",
            "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
          }
        },
        "required": ["ticker"]
      }
    }
  ]
  ```

  And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this:

  ```json
  [
    {
      "type": "tool_use",
      "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
      "name": "get_stock_price",
      "input": { "ticker": "^GSPC" }
    }
  ]
  ```

  You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message:

  ```json
  [
    {
      "type": "tool_result",
      "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
      "content": "259.75 USD"
    }
  ]
  ```

  Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.

  See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.

  - `class BetaTool: …`

    - `input_schema: InputSchema`

      [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

      This defines the shape of the `input` that your tool accepts and that the model will produce.

      - `type: Literal["object"]`

        - `"object"`

      - `properties: Optional[Dict[str, object]]`

      - `required: Optional[List[str]]`

    - `name: str`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `description: Optional[str]`

      Description of what this tool does.

      Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.

    - `eager_input_streaming: Optional[bool]`

      Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `type: Optional[Literal["custom"]]`

      - `"custom"`

  - `class BetaToolBash20241022: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20241022"]`

      - `"bash_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolBash20250124: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20250124"]`

      - `"bash_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250522: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250522"]`

      - `"code_execution_20250522"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250825: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250825"]`

      - `"code_execution_20250825"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20260120: …`

    Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20260120"]`

      - `"code_execution_20260120"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20241022: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20241022"]`

      - `"computer_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMemoryTool20250818: …`

    - `name: Literal["memory"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"memory"`

    - `type: Literal["memory_20250818"]`

      - `"memory_20250818"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20250124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20250124"]`

      - `"computer_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20241022: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20241022"]`

      - `"text_editor_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20251124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20251124"]`

      - `"computer_20251124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `enable_zoom: Optional[bool]`

      Whether to enable an action to take a zoomed-in screenshot of the screen.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250124: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20250124"]`

      - `"text_editor_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250429: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250429"]`

      - `"text_editor_20250429"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250728: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250728"]`

      - `"text_editor_20250728"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `max_characters: Optional[int]`

      Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20250305: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20250305"]`

      - `"web_search_20250305"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

      - `type: Literal["approximate"]`

        - `"approximate"`

      - `city: Optional[str]`

        The city of the user.

      - `country: Optional[str]`

        The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

      - `region: Optional[str]`

        The region of the user.

      - `timezone: Optional[str]`

        The [IANA timezone](https://nodatime.org/TimeZones) of the user.

  - `class BetaWebFetchTool20250910: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20250910"]`

      - `"web_fetch_20250910"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20260209: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20260209"]`

      - `"web_search_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

  - `class BetaWebFetchTool20260209: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260209"]`

      - `"web_fetch_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebFetchTool20260309: …`

    Web fetch tool with use_cache parameter for bypassing cached content.

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260309"]`

      - `"web_fetch_20260309"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `use_cache: Optional[bool]`

      Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.

  - `class BetaAdvisorTool20260301: …`

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `name: Literal["advisor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"advisor"`

    - `type: Literal["advisor_20260301"]`

      - `"advisor_20260301"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caching: Optional[BetaCacheControlEphemeral]`

      Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolBm25_20251119: …`

    - `name: Literal["tool_search_tool_bm25"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_bm25"`

    - `type: Literal["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]`

      - `"tool_search_tool_bm25_20251119"`

      - `"tool_search_tool_bm25"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolRegex20251119: …`

    - `name: Literal["tool_search_tool_regex"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_regex"`

    - `type: Literal["tool_search_tool_regex_20251119", "tool_search_tool_regex"]`

      - `"tool_search_tool_regex_20251119"`

      - `"tool_search_tool_regex"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMCPToolset: …`

    Configuration for a group of tools from an MCP server.

    Allows configuring enabled status and defer_loading for all tools
    from an MCP server, with optional per-tool overrides.

    - `mcp_server_name: str`

      Name of the MCP server to configure tools for

    - `type: Literal["mcp_toolset"]`

      - `"mcp_toolset"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `configs: Optional[Dict[str, BetaMCPToolConfig]]`

      Configuration overrides for specific tools, keyed by tool name

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

    - `default_config: Optional[BetaMCPToolDefaultConfig]`

      Default configuration applied to all tools from this server

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

- `top_k: Optional[int]`

  Only sample from the top K options for each subsequent token.

  Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).

  Recommended for advanced use cases only.

- `top_p: Optional[float]`

  Use nucleus sampling.

  In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.

  Recommended for advanced use cases only.

- `user_profile_id: Optional[str]`

  The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessage: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `container: Optional[BetaContainer]`

    Information about the container used in the request (for the code execution tool)

    - `id: str`

      Identifier for the container used in this request

    - `expires_at: datetime`

      The time at which the container will expire.

    - `skills: Optional[List[BetaSkill]]`

      Skills loaded in the container

      - `skill_id: str`

        Skill ID

      - `type: Literal["anthropic", "custom"]`

        Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

        - `"anthropic"`

        - `"custom"`

      - `version: str`

        Skill version or 'latest' for most recent version

  - `content: List[BetaContentBlock]`

    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 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.

    For example, if the input `messages` were:

    ```json
    [
      {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
      {"role": "assistant", "content": "The best answer is ("}
    ]
    ```

    Then the response `content` might be:

    ```json
    [{"type": "text", "text": "B)"}]
    ```

    - `class BetaTextBlock: …`

      - `citations: Optional[List[BetaTextCitation]]`

        Citations supporting the text block.

        The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

        - `class BetaCitationCharLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `file_id: Optional[str]`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `file_id: Optional[str]`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `file_id: Optional[str]`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationsWebSearchResultLocation: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

      - `text: str`

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaThinkingBlock: …`

      - `signature: str`

      - `thinking: str`

      - `type: Literal["thinking"]`

        - `"thinking"`

    - `class BetaRedactedThinkingBlock: …`

      - `data: str`

      - `type: Literal["redacted_thinking"]`

        - `"redacted_thinking"`

    - `class BetaToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

      - `type: Literal["tool_use"]`

        - `"tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

          - `type: Literal["direct"]`

            - `"direct"`

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

          - `tool_id: str`

          - `type: Literal["code_execution_20250825"]`

            - `"code_execution_20250825"`

        - `class BetaServerToolCaller20260120: …`

          - `tool_id: str`

          - `type: Literal["code_execution_20260120"]`

            - `"code_execution_20260120"`

    - `class BetaServerToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

        - `"advisor"`

        - `"web_search"`

        - `"web_fetch"`

        - `"code_execution"`

        - `"bash_code_execution"`

        - `"text_editor_code_execution"`

        - `"tool_search_tool_regex"`

        - `"tool_search_tool_bm25"`

      - `type: Literal["server_tool_use"]`

        - `"server_tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebSearchToolResultBlock: …`

      - `content: BetaWebSearchToolResultBlockContent`

        - `class BetaWebSearchToolResultError: …`

          - `error_code: BetaWebSearchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"max_uses_exceeded"`

            - `"too_many_requests"`

            - `"query_too_long"`

            - `"request_too_large"`

          - `type: Literal["web_search_tool_result_error"]`

            - `"web_search_tool_result_error"`

        - `List[BetaWebSearchResultBlock]`

          - `encrypted_content: str`

          - `page_age: Optional[str]`

          - `title: str`

          - `type: Literal["web_search_result"]`

            - `"web_search_result"`

          - `url: str`

      - `tool_use_id: str`

      - `type: Literal["web_search_tool_result"]`

        - `"web_search_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebFetchToolResultBlock: …`

      - `content: Content`

        - `class BetaWebFetchToolResultErrorBlock: …`

          - `error_code: BetaWebFetchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"url_too_long"`

            - `"url_not_allowed"`

            - `"url_not_in_prior_context"`

            - `"url_not_accessible"`

            - `"unsupported_content_type"`

            - `"too_many_requests"`

            - `"max_uses_exceeded"`

            - `"unavailable"`

          - `type: Literal["web_fetch_tool_result_error"]`

            - `"web_fetch_tool_result_error"`

        - `class BetaWebFetchBlock: …`

          - `content: BetaDocumentBlock`

            - `citations: Optional[BetaCitationConfig]`

              Citation configuration for the document

              - `enabled: bool`

            - `source: Source`

              - `class BetaBase64PDFSource: …`

                - `data: str`

                - `media_type: Literal["application/pdf"]`

                  - `"application/pdf"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaPlainTextSource: …`

                - `data: str`

                - `media_type: Literal["text/plain"]`

                  - `"text/plain"`

                - `type: Literal["text"]`

                  - `"text"`

            - `title: Optional[str]`

              The title of the document

            - `type: Literal["document"]`

              - `"document"`

          - `retrieved_at: Optional[str]`

            ISO 8601 timestamp when the content was retrieved

          - `type: Literal["web_fetch_result"]`

            - `"web_fetch_result"`

          - `url: str`

            Fetched content URL

      - `tool_use_id: str`

      - `type: Literal["web_fetch_tool_result"]`

        - `"web_fetch_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaAdvisorToolResultBlock: …`

      - `content: Content`

        - `class BetaAdvisorToolResultError: …`

          - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

            - `"max_uses_exceeded"`

            - `"prompt_too_long"`

            - `"too_many_requests"`

            - `"overloaded"`

            - `"unavailable"`

            - `"execution_time_exceeded"`

          - `type: Literal["advisor_tool_result_error"]`

            - `"advisor_tool_result_error"`

        - `class BetaAdvisorResultBlock: …`

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

          - `text: str`

          - `type: Literal["advisor_result"]`

            - `"advisor_result"`

        - `class BetaAdvisorRedactedResultBlock: …`

          - `encrypted_content: str`

            Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

          - `type: Literal["advisor_redacted_result"]`

            - `"advisor_redacted_result"`

      - `tool_use_id: str`

      - `type: Literal["advisor_tool_result"]`

        - `"advisor_tool_result"`

    - `class BetaCodeExecutionToolResultBlock: …`

      - `content: BetaCodeExecutionToolResultBlockContent`

        Code execution result with encrypted stdout for PFC + web_search results.

        - `class BetaCodeExecutionToolResultError: …`

          - `error_code: BetaCodeExecutionToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `type: Literal["code_execution_tool_result_error"]`

            - `"code_execution_tool_result_error"`

        - `class BetaCodeExecutionResultBlock: …`

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

              - `"code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["code_execution_result"]`

            - `"code_execution_result"`

        - `class BetaEncryptedCodeExecutionResultBlock: …`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

          - `encrypted_stdout: str`

          - `return_code: int`

          - `stderr: str`

          - `type: Literal["encrypted_code_execution_result"]`

            - `"encrypted_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["code_execution_tool_result"]`

        - `"code_execution_tool_result"`

    - `class BetaBashCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaBashCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"output_file_too_large"`

          - `type: Literal["bash_code_execution_tool_result_error"]`

            - `"bash_code_execution_tool_result_error"`

        - `class BetaBashCodeExecutionResultBlock: …`

          - `content: List[BetaBashCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["bash_code_execution_output"]`

              - `"bash_code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["bash_code_execution_result"]`

            - `"bash_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["bash_code_execution_tool_result"]`

        - `"bash_code_execution_tool_result"`

    - `class BetaTextEditorCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaTextEditorCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"file_not_found"`

          - `error_message: Optional[str]`

          - `type: Literal["text_editor_code_execution_tool_result_error"]`

            - `"text_editor_code_execution_tool_result_error"`

        - `class BetaTextEditorCodeExecutionViewResultBlock: …`

          - `content: str`

          - `file_type: Literal["text", "image", "pdf"]`

            - `"text"`

            - `"image"`

            - `"pdf"`

          - `num_lines: Optional[int]`

          - `start_line: Optional[int]`

          - `total_lines: Optional[int]`

          - `type: Literal["text_editor_code_execution_view_result"]`

            - `"text_editor_code_execution_view_result"`

        - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

          - `is_file_update: bool`

          - `type: Literal["text_editor_code_execution_create_result"]`

            - `"text_editor_code_execution_create_result"`

        - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

          - `lines: Optional[List[str]]`

          - `new_lines: Optional[int]`

          - `new_start: Optional[int]`

          - `old_lines: Optional[int]`

          - `old_start: Optional[int]`

          - `type: Literal["text_editor_code_execution_str_replace_result"]`

            - `"text_editor_code_execution_str_replace_result"`

      - `tool_use_id: str`

      - `type: Literal["text_editor_code_execution_tool_result"]`

        - `"text_editor_code_execution_tool_result"`

    - `class BetaToolSearchToolResultBlock: …`

      - `content: Content`

        - `class BetaToolSearchToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `error_message: Optional[str]`

          - `type: Literal["tool_search_tool_result_error"]`

            - `"tool_search_tool_result_error"`

        - `class BetaToolSearchToolSearchResultBlock: …`

          - `tool_references: List[BetaToolReferenceBlock]`

            - `tool_name: str`

            - `type: Literal["tool_reference"]`

              - `"tool_reference"`

          - `type: Literal["tool_search_tool_search_result"]`

            - `"tool_search_tool_search_result"`

      - `tool_use_id: str`

      - `type: Literal["tool_search_tool_result"]`

        - `"tool_search_tool_result"`

    - `class BetaMCPToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

        The name of the MCP tool

      - `server_name: str`

        The name of the MCP server

      - `type: Literal["mcp_tool_use"]`

        - `"mcp_tool_use"`

    - `class BetaMCPToolResultBlock: …`

      - `content: Union[str, List[BetaTextBlock]]`

        - `str`

        - `List[BetaTextBlock]`

          - `citations: Optional[List[BetaTextCitation]]`

            Citations supporting the text block.

            The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

          - `text: str`

          - `type: Literal["text"]`

      - `is_error: bool`

      - `tool_use_id: str`

      - `type: Literal["mcp_tool_result"]`

        - `"mcp_tool_result"`

    - `class BetaContainerUploadBlock: …`

      Response model for a file uploaded to the container.

      - `file_id: str`

      - `type: Literal["container_upload"]`

        - `"container_upload"`

    - `class BetaCompactionBlock: …`

      A compaction block returned when autocompact is triggered.

      When content is None, it indicates the compaction failed to produce a valid
      summary (e.g., malformed output from the model). Clients may round-trip
      compaction blocks with null content; the server treats them as no-ops.

      - `content: Optional[str]`

        Summary of compacted content, or null if compaction failed

      - `encrypted_content: Optional[str]`

        Opaque metadata from prior compaction, to be round-tripped verbatim

      - `type: Literal["compaction"]`

        - `"compaction"`

  - `context_management: Optional[BetaContextManagementResponse]`

    Context management response.

    Information about context management strategies applied during the request.

    - `applied_edits: List[AppliedEdit]`

      List of context management edits that were applied.

      - `class BetaClearToolUses20250919EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_tool_uses: int`

          Number of tool uses that were cleared.

        - `type: Literal["clear_tool_uses_20250919"]`

          The type of context management edit applied.

          - `"clear_tool_uses_20250919"`

      - `class BetaClearThinking20251015EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_thinking_turns: int`

          Number of thinking turns that were cleared.

        - `type: Literal["clear_thinking_20251015"]`

          The type of context management edit applied.

          - `"clear_thinking_20251015"`

  - `diagnostics: Optional[BetaDiagnostics]`

    Response envelope for request-level diagnostics. Present (possibly
    null) whenever the caller supplied `diagnostics` on the request.

    - `cache_miss_reason: Optional[CacheMissReason]`

      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.

      - `class BetaCacheMissModelChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["model_changed"]`

          - `"model_changed"`

      - `class BetaCacheMissSystemChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["system_changed"]`

          - `"system_changed"`

      - `class BetaCacheMissToolsChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["tools_changed"]`

          - `"tools_changed"`

      - `class BetaCacheMissMessagesChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["messages_changed"]`

          - `"messages_changed"`

      - `class BetaCacheMissPreviousMessageNotFound: …`

        - `type: Literal["previous_message_not_found"]`

          - `"previous_message_not_found"`

      - `class BetaCacheMissUnavailable: …`

        - `type: Literal["unavailable"]`

          - `"unavailable"`

  - `model: Model`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
      - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
      - `claude-opus-4-1` - Exceptional model for specialized complex tasks
      - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
      - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-mythos-preview"`

        New class of intelligence, strongest in coding and cybersecurity

      - `"claude-opus-4-6"`

        Frontier intelligence for long-running agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

      - `"claude-opus-4-1"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-1-20250805"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-0"`

        Powerful model for complex tasks

      - `"claude-opus-4-20250514"`

        Powerful model for complex tasks

      - `"claude-sonnet-4-0"`

        High-performance model with extended thinking

      - `"claude-sonnet-4-20250514"`

        High-performance model with extended thinking

      - `"claude-3-haiku-20240307"`

        Fast and cost-effective model

    - `str`

  - `role: Literal["assistant"]`

    Conversational role of the generated message.

    This will always be `"assistant"`.

    - `"assistant"`

  - `stop_details: Optional[BetaRefusalStopDetails]`

    Structured information about a refusal.

    - `category: Optional[Literal["cyber", "bio"]]`

      The policy category that triggered the refusal.

      `null` when the refusal doesn't map to a named category.

      - `"cyber"`

      - `"bio"`

    - `explanation: Optional[str]`

      Human-readable explanation of the refusal.

      This text is not guaranteed to be stable. `null` when no explanation is available for the category.

    - `type: Literal["refusal"]`

      - `"refusal"`

  - `stop_reason: Optional[BetaStopReason]`

    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 maximum
    * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
    * `"tool_use"`: the model invoked one or more tools
    * `"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.
    * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

    In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

    - `"end_turn"`

    - `"max_tokens"`

    - `"stop_sequence"`

    - `"tool_use"`

    - `"pause_turn"`

    - `"compaction"`

    - `"refusal"`

    - `"model_context_window_exceeded"`

  - `stop_sequence: Optional[str]`

    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.

  - `type: Literal["message"]`

    Object type.

    For Messages, this is always `"message"`.

    - `"message"`

  - `usage: BetaUsage`

    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 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.

    For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

    Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

    - `cache_creation: Optional[BetaCacheCreation]`

      Breakdown of cached tokens by TTL

      - `ephemeral_1h_input_tokens: int`

        The number of input tokens used to create the 1 hour cache entry.

      - `ephemeral_5m_input_tokens: int`

        The number of input tokens used to create the 5 minute cache entry.

    - `cache_creation_input_tokens: Optional[int]`

      The number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: Optional[int]`

      The number of input tokens read from the cache.

    - `inference_geo: Optional[str]`

      The geographic region where inference was performed for this request.

    - `input_tokens: int`

      The number of input tokens which were used.

    - `iterations: Optional[BetaIterationsUsage]`

      Per-iteration token usage breakdown.

      Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

      - Determine which iterations exceeded long context thresholds (>=200k tokens)
      - Calculate the true context window size from the last iteration
      - Understand token accumulation across server-side tool use loops

      - `class BetaMessageIterationUsage: …`

        Token usage for a sampling iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["message"]`

          Usage for a sampling iteration

          - `"message"`

      - `class BetaCompactionIterationUsage: …`

        Token usage for a compaction iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["compaction"]`

          Usage for a compaction iteration

          - `"compaction"`

      - `class BetaAdvisorMessageIterationUsage: …`

        Token usage for an advisor sub-inference iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["advisor_message"]`

          Usage for an advisor sub-inference iteration

          - `"advisor_message"`

    - `output_tokens: int`

      The number of output tokens which were used.

    - `output_tokens_details: Optional[BetaOutputTokensDetails]`

      Breakdown of output tokens by category.

      `output_tokens` remains the inclusive, authoritative total used for billing.
      This object provides a read-only decomposition for observability — for example,
      how many of the billed output tokens were spent on internal reasoning that may
      have been summarized before being returned to you.

      - `thinking_tokens: int`

        Number of output tokens the model generated as internal reasoning, including
        the thinking-block delimiter tokens.

        Reflects the raw reasoning the model produced, not the (possibly shorter)
        summarized thinking text returned in the response body. Computed by
        re-tokenizing the raw reasoning text, so it may differ from the model's exact
        generation count by a small number of tokens. Always ≤ `output_tokens`;
        `output_tokens - thinking_tokens` approximates the non-reasoning output.

    - `server_tool_use: Optional[BetaServerToolUsage]`

      The number of server tool requests.

      - `web_fetch_requests: int`

        The number of web fetch tool requests.

      - `web_search_requests: int`

        The number of web search tool requests.

    - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

      If the request used the priority, standard, or batch tier.

      - `"standard"`

      - `"priority"`

      - `"batch"`

    - `speed: Optional[Literal["standard", "fast"]]`

      The inference speed mode used for this request.

      - `"standard"`

      - `"fast"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
for message in client.beta.messages.create(
    max_tokens=1024,
    messages=[{
        "content": "Hello, world",
        "role": "user",
    }],
    model="claude-opus-4-6",
):
  print(message)
```

#### Response

```json
{
  "id": "msg_013Zva2CMHLNnXjNJJKqJ2EF",
  "container": {
    "id": "id",
    "expires_at": "2019-12-27T18:11:19.117Z",
    "skills": [
      {
        "skill_id": "pdf",
        "type": "anthropic",
        "version": "latest"
      }
    ]
  },
  "content": [
    {
      "citations": [
        {
          "cited_text": "cited_text",
          "document_index": 0,
          "document_title": "document_title",
          "end_char_index": 0,
          "file_id": "file_id",
          "start_char_index": 0,
          "type": "char_location"
        }
      ],
      "text": "Hi! My name is Claude.",
      "type": "text"
    }
  ],
  "context_management": {
    "applied_edits": [
      {
        "cleared_input_tokens": 0,
        "cleared_tool_uses": 0,
        "type": "clear_tool_uses_20250919"
      }
    ]
  },
  "diagnostics": {
    "cache_miss_reason": {
      "cache_missed_input_tokens": 0,
      "type": "model_changed"
    }
  },
  "model": "claude-opus-4-6",
  "role": "assistant",
  "stop_details": {
    "category": "cyber",
    "explanation": "explanation",
    "type": "refusal"
  },
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "type": "message",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_creation_input_tokens": 2051,
    "cache_read_input_tokens": 2051,
    "inference_geo": "inference_geo",
    "input_tokens": 2095,
    "iterations": [
      {
        "cache_creation": {
          "ephemeral_1h_input_tokens": 0,
          "ephemeral_5m_input_tokens": 0
        },
        "cache_creation_input_tokens": 0,
        "cache_read_input_tokens": 0,
        "input_tokens": 0,
        "output_tokens": 0,
        "type": "message"
      }
    ],
    "output_tokens": 503,
    "output_tokens_details": {
      "thinking_tokens": 0
    },
    "server_tool_use": {
      "web_fetch_requests": 2,
      "web_search_requests": 0
    },
    "service_tier": "standard",
    "speed": "standard"
  }
}
```

## Count tokens in a Message

`beta.messages.count_tokens(MessageCountTokensParams**kwargs)  -> BetaMessageTokensCount`

**post** `/v1/messages/count_tokens`

Count the number of tokens in a Message.

The Token Count API can be used to count the number of tokens in a Message, including tools, images, and documents, without creating it.

Learn more about token counting in our [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)

### Parameters

- `messages: Iterable[BetaMessageParam]`

  Input messages.

  Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.

  Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.

  If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.

  Example with a single `user` message:

  ```json
  [{"role": "user", "content": "Hello, Claude"}]
  ```

  Example with multiple conversational turns:

  ```json
  [
    {"role": "user", "content": "Hello there."},
    {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},
    {"role": "user", "content": "Can you explain LLMs in plain English?"},
  ]
  ```

  Example with a partially-filled response from Claude:

  ```json
  [
    {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
    {"role": "assistant", "content": "The best answer is ("},
  ]
  ```

  Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent:

  ```json
  {"role": "user", "content": "Hello, Claude"}
  ```

  ```json
  {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}
  ```

  See [input examples](https://docs.claude.com/en/api/messages-examples).

  Note that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API.

  There is a limit of 100,000 messages in a single request.

  - `content: Union[str, List[BetaContentBlockParam]]`

    - `str`

    - `List[BetaContentBlockParam]`

      - `class BetaTextBlockParam: …`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

          - `type: Literal["ephemeral"]`

            - `"ephemeral"`

          - `ttl: Optional[Literal["5m", "1h"]]`

            The time-to-live for the cache control breakpoint.

            This may be one the following values:

            - `5m`: 5 minutes
            - `1h`: 1 hour

            Defaults to `5m`.

            - `"5m"`

            - `"1h"`

        - `citations: Optional[List[BetaTextCitationParam]]`

          - `class BetaCitationCharLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationWebSearchResultLocationParam: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

      - `class BetaImageBlockParam: …`

        - `source: Source`

          - `class BetaBase64ImageSource: …`

            - `data: str`

            - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

              - `"image/jpeg"`

              - `"image/png"`

              - `"image/gif"`

              - `"image/webp"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaURLImageSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileImageSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestDocumentBlock: …`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaContentBlockSource: …`

            - `content: Union[str, List[BetaContentBlockSourceContent]]`

              - `str`

              - `List[BetaContentBlockSourceContent]`

                - `class BetaTextBlockParam: …`

                - `class BetaImageBlockParam: …`

            - `type: Literal["content"]`

              - `"content"`

          - `class BetaURLPDFSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileDocumentSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          - `enabled: Optional[bool]`

        - `context: Optional[str]`

        - `title: Optional[str]`

      - `class BetaSearchResultBlockParam: …`

        - `content: List[BetaTextBlockParam]`

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `source: str`

        - `title: str`

        - `type: Literal["search_result"]`

          - `"search_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

      - `class BetaThinkingBlockParam: …`

        - `signature: str`

        - `thinking: str`

        - `type: Literal["thinking"]`

          - `"thinking"`

      - `class BetaRedactedThinkingBlockParam: …`

        - `data: str`

        - `type: Literal["redacted_thinking"]`

          - `"redacted_thinking"`

      - `class BetaToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `type: Literal["tool_use"]`

          - `"tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

            - `type: Literal["direct"]`

              - `"direct"`

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

            - `tool_id: str`

            - `type: Literal["code_execution_20250825"]`

              - `"code_execution_20250825"`

          - `class BetaServerToolCaller20260120: …`

            - `tool_id: str`

            - `type: Literal["code_execution_20260120"]`

              - `"code_execution_20260120"`

      - `class BetaToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["tool_result"]`

          - `"tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[Content], null]]`

          - `str`

          - `List[Content]`

            - `class BetaTextBlockParam: …`

            - `class BetaImageBlockParam: …`

            - `class BetaSearchResultBlockParam: …`

            - `class BetaRequestDocumentBlock: …`

            - `class BetaToolReferenceBlockParam: …`

              Tool reference block that can be included in tool_result content.

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

                - `"tool_reference"`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

        - `is_error: Optional[bool]`

      - `class BetaServerToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

          - `"advisor"`

          - `"web_search"`

          - `"web_fetch"`

          - `"code_execution"`

          - `"bash_code_execution"`

          - `"text_editor_code_execution"`

          - `"tool_search_tool_regex"`

          - `"tool_search_tool_bm25"`

        - `type: Literal["server_tool_use"]`

          - `"server_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebSearchToolResultBlockParam: …`

        - `content: BetaWebSearchToolResultBlockParamContent`

          - `List[BetaWebSearchResultBlockParam]`

            - `encrypted_content: str`

            - `title: str`

            - `type: Literal["web_search_result"]`

              - `"web_search_result"`

            - `url: str`

            - `page_age: Optional[str]`

          - `class BetaWebSearchToolRequestError: …`

            - `error_code: BetaWebSearchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"max_uses_exceeded"`

              - `"too_many_requests"`

              - `"query_too_long"`

              - `"request_too_large"`

            - `type: Literal["web_search_tool_result_error"]`

              - `"web_search_tool_result_error"`

        - `tool_use_id: str`

        - `type: Literal["web_search_tool_result"]`

          - `"web_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebFetchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaWebFetchToolResultErrorBlockParam: …`

            - `error_code: BetaWebFetchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"url_too_long"`

              - `"url_not_allowed"`

              - `"url_not_in_prior_context"`

              - `"url_not_accessible"`

              - `"unsupported_content_type"`

              - `"too_many_requests"`

              - `"max_uses_exceeded"`

              - `"unavailable"`

            - `type: Literal["web_fetch_tool_result_error"]`

              - `"web_fetch_tool_result_error"`

          - `class BetaWebFetchBlockParam: …`

            - `content: BetaRequestDocumentBlock`

            - `type: Literal["web_fetch_result"]`

              - `"web_fetch_result"`

            - `url: str`

              Fetched content URL

            - `retrieved_at: Optional[str]`

              ISO 8601 timestamp when the content was retrieved

        - `tool_use_id: str`

        - `type: Literal["web_fetch_tool_result"]`

          - `"web_fetch_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaAdvisorToolResultBlockParam: …`

        - `content: Content`

          - `class BetaAdvisorToolResultErrorParam: …`

            - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

              - `"max_uses_exceeded"`

              - `"prompt_too_long"`

              - `"too_many_requests"`

              - `"overloaded"`

              - `"unavailable"`

              - `"execution_time_exceeded"`

            - `type: Literal["advisor_tool_result_error"]`

              - `"advisor_tool_result_error"`

          - `class BetaAdvisorResultBlockParam: …`

            - `text: str`

            - `type: Literal["advisor_result"]`

              - `"advisor_result"`

            - `stop_reason: Optional[str]`

          - `class BetaAdvisorRedactedResultBlockParam: …`

            - `encrypted_content: str`

              Opaque blob produced by a prior response; must be round-tripped verbatim.

            - `type: Literal["advisor_redacted_result"]`

              - `"advisor_redacted_result"`

            - `stop_reason: Optional[str]`

        - `tool_use_id: str`

        - `type: Literal["advisor_tool_result"]`

          - `"advisor_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCodeExecutionToolResultBlockParam: …`

        - `content: BetaCodeExecutionToolResultBlockParamContent`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `class BetaCodeExecutionToolResultErrorParam: …`

            - `error_code: BetaCodeExecutionToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["code_execution_tool_result_error"]`

              - `"code_execution_tool_result_error"`

          - `class BetaCodeExecutionResultBlockParam: …`

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

                - `"code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["code_execution_result"]`

              - `"code_execution_result"`

          - `class BetaEncryptedCodeExecutionResultBlockParam: …`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

            - `encrypted_stdout: str`

            - `return_code: int`

            - `stderr: str`

            - `type: Literal["encrypted_code_execution_result"]`

              - `"encrypted_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["code_execution_tool_result"]`

          - `"code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaBashCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaBashCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"output_file_too_large"`

            - `type: Literal["bash_code_execution_tool_result_error"]`

              - `"bash_code_execution_tool_result_error"`

          - `class BetaBashCodeExecutionResultBlockParam: …`

            - `content: List[BetaBashCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["bash_code_execution_output"]`

                - `"bash_code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["bash_code_execution_result"]`

              - `"bash_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["bash_code_execution_tool_result"]`

          - `"bash_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"file_not_found"`

            - `type: Literal["text_editor_code_execution_tool_result_error"]`

              - `"text_editor_code_execution_tool_result_error"`

            - `error_message: Optional[str]`

          - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

            - `content: str`

            - `file_type: Literal["text", "image", "pdf"]`

              - `"text"`

              - `"image"`

              - `"pdf"`

            - `type: Literal["text_editor_code_execution_view_result"]`

              - `"text_editor_code_execution_view_result"`

            - `num_lines: Optional[int]`

            - `start_line: Optional[int]`

            - `total_lines: Optional[int]`

          - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

            - `is_file_update: bool`

            - `type: Literal["text_editor_code_execution_create_result"]`

              - `"text_editor_code_execution_create_result"`

          - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

            - `type: Literal["text_editor_code_execution_str_replace_result"]`

              - `"text_editor_code_execution_str_replace_result"`

            - `lines: Optional[List[str]]`

            - `new_lines: Optional[int]`

            - `new_start: Optional[int]`

            - `old_lines: Optional[int]`

            - `old_start: Optional[int]`

        - `tool_use_id: str`

        - `type: Literal["text_editor_code_execution_tool_result"]`

          - `"text_editor_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaToolSearchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaToolSearchToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["tool_search_tool_result_error"]`

              - `"tool_search_tool_result_error"`

          - `class BetaToolSearchToolSearchResultBlockParam: …`

            - `tool_references: List[BetaToolReferenceBlockParam]`

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

            - `type: Literal["tool_search_tool_search_result"]`

              - `"tool_search_tool_search_result"`

        - `tool_use_id: str`

        - `type: Literal["tool_search_tool_result"]`

          - `"tool_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaMCPToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `server_name: str`

          The name of the MCP server

        - `type: Literal["mcp_tool_use"]`

          - `"mcp_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestMCPToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["mcp_tool_result"]`

          - `"mcp_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

          - `str`

          - `List[BetaTextBlockParam]`

            - `text: str`

            - `type: Literal["text"]`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `citations: Optional[List[BetaTextCitationParam]]`

        - `is_error: Optional[bool]`

      - `class BetaContainerUploadBlockParam: …`

        A content block that represents a file to be uploaded to the container
        Files uploaded via this block will be available in the container's input directory.

        - `file_id: str`

        - `type: Literal["container_upload"]`

          - `"container_upload"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCompactionBlockParam: …`

        A compaction block containing summary of previous context.

        Users should round-trip these blocks from responses to subsequent requests
        to maintain context across compaction boundaries.

        When content is None, the block represents a failed compaction. The server
        treats these as no-ops. Empty string content is not allowed.

        - `type: Literal["compaction"]`

          - `"compaction"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[str]`

          Summary of previously compacted content, or null if compaction failed

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

      - `class BetaMidConversationSystemBlockParam: …`

        System instructions that appear mid-conversation.

        Use this block to provide or update system-level instructions at a specific
        point in the conversation, rather than only via the top-level `system` parameter.

        - `content: List[BetaTextBlockParam]`

          System instruction text blocks.

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `type: Literal["mid_conv_system"]`

          - `"mid_conv_system"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

  - `role: Literal["user", "assistant", "system"]`

    - `"user"`

    - `"assistant"`

    - `"system"`

- `model: ModelParam`

  The model that will complete your prompt.

  See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

  - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
    - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
    - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
    - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
    - `claude-sonnet-4-6` - Best combination of speed and intelligence
    - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
    - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
    - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
    - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
    - `claude-sonnet-4-5` - High-performance model for agents and coding
    - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
    - `claude-opus-4-1` - Exceptional model for specialized complex tasks
    - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
    - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
    - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

    - `"claude-opus-4-8"`

      Frontier intelligence for long-running agents and coding

    - `"claude-opus-4-7"`

      Frontier intelligence for long-running agents and coding

    - `"claude-mythos-preview"`

      New class of intelligence, strongest in coding and cybersecurity

    - `"claude-opus-4-6"`

      Frontier intelligence for long-running agents and coding

    - `"claude-sonnet-4-6"`

      Best combination of speed and intelligence

    - `"claude-haiku-4-5"`

      Fastest model with near-frontier intelligence

    - `"claude-haiku-4-5-20251001"`

      Fastest model with near-frontier intelligence

    - `"claude-opus-4-5"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-opus-4-5-20251101"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-sonnet-4-5"`

      High-performance model for agents and coding

    - `"claude-sonnet-4-5-20250929"`

      High-performance model for agents and coding

    - `"claude-opus-4-1"`

      Exceptional model for specialized complex tasks

    - `"claude-opus-4-1-20250805"`

      Exceptional model for specialized complex tasks

    - `"claude-opus-4-0"`

      Powerful model for complex tasks

    - `"claude-opus-4-20250514"`

      Powerful model for complex tasks

    - `"claude-sonnet-4-0"`

      High-performance model with extended thinking

    - `"claude-sonnet-4-20250514"`

      High-performance model with extended thinking

    - `"claude-3-haiku-20240307"`

      Fast and cost-effective model

  - `str`

- `cache_control: Optional[BetaCacheControlEphemeralParam]`

  Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

- `context_management: Optional[BetaContextManagementConfigParam]`

  Context management configuration.

  This allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.

  - `edits: Optional[List[Edit]]`

    List of context management edits to apply

    - `class BetaClearToolUses20250919Edit: …`

      - `type: Literal["clear_tool_uses_20250919"]`

        - `"clear_tool_uses_20250919"`

      - `clear_at_least: Optional[BetaInputTokensClearAtLeast]`

        Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.

        - `type: Literal["input_tokens"]`

          - `"input_tokens"`

        - `value: int`

      - `clear_tool_inputs: Optional[Union[bool, List[str], null]]`

        Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

        - `bool`

        - `List[str]`

      - `exclude_tools: Optional[List[str]]`

        Tool names whose uses are preserved from clearing

      - `keep: Optional[BetaToolUsesKeep]`

        Number of tool uses to retain in the conversation

        - `type: Literal["tool_uses"]`

          - `"tool_uses"`

        - `value: int`

      - `trigger: Optional[Trigger]`

        Condition that triggers the context management strategy

        - `class BetaInputTokensTrigger: …`

          - `type: Literal["input_tokens"]`

            - `"input_tokens"`

          - `value: int`

        - `class BetaToolUsesTrigger: …`

          - `type: Literal["tool_uses"]`

            - `"tool_uses"`

          - `value: int`

    - `class BetaClearThinking20251015Edit: …`

      - `type: Literal["clear_thinking_20251015"]`

        - `"clear_thinking_20251015"`

      - `keep: Optional[Keep]`

        Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.

        - `class BetaThinkingTurns: …`

          - `type: Literal["thinking_turns"]`

            - `"thinking_turns"`

          - `value: int`

        - `class BetaAllThinkingTurns: …`

          - `type: Literal["all"]`

            - `"all"`

        - `Literal["all"]`

          - `"all"`

    - `class BetaCompact20260112Edit: …`

      Automatically compact older context when reaching the configured trigger threshold.

      - `type: Literal["compact_20260112"]`

        - `"compact_20260112"`

      - `instructions: Optional[str]`

        Additional instructions for summarization.

      - `pause_after_compaction: Optional[bool]`

        Whether to pause after compaction and return the compaction block to the user.

      - `trigger: Optional[BetaInputTokensTrigger]`

        When to trigger compaction. Defaults to 150000 input tokens.

- `mcp_servers: Optional[Iterable[BetaRequestMCPServerURLDefinitionParam]]`

  MCP servers to be utilized in this request

  - `name: str`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

  - `authorization_token: Optional[str]`

  - `tool_configuration: Optional[BetaRequestMCPServerToolConfiguration]`

    - `allowed_tools: Optional[List[str]]`

    - `enabled: Optional[bool]`

- `output_config: Optional[BetaOutputConfigParam]`

  Configuration options for the model's output, such as the output format.

  - `effort: Optional[Literal["low", "medium", "high", 2 more]]`

    All possible effort levels.

    - `"low"`

    - `"medium"`

    - `"high"`

    - `"xhigh"`

    - `"max"`

  - `format: Optional[BetaJSONOutputFormat]`

    A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

    - `schema: Dict[str, object]`

      The JSON schema of the format

    - `type: Literal["json_schema"]`

      - `"json_schema"`

  - `task_budget: Optional[BetaTokenTaskBudget]`

    User-configurable total token budget across contexts.

    - `total: int`

      Total token budget across all contexts in the session.

    - `type: Literal["tokens"]`

      The budget type. Currently only 'tokens' is supported.

      - `"tokens"`

    - `remaining: Optional[int]`

      Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.

- `output_format: Optional[BetaJSONOutputFormatParam]`

  Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

  A schema to specify Claude's output format in responses. This parameter will be removed in a future release.

- `speed: Optional[Literal["standard", "fast"]]`

  The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.

  - `"standard"`

  - `"fast"`

- `system: Optional[Union[str, Iterable[BetaTextBlockParam]]]`

  System prompt.

  A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).

  - `str`

  - `Iterable[BetaTextBlockParam]`

    - `text: str`

    - `type: Literal["text"]`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[List[BetaTextCitationParam]]`

- `thinking: Optional[BetaThinkingConfigParam]`

  Configuration for enabling Claude's extended thinking.

  When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.

  See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

  - `class BetaThinkingConfigEnabled: …`

    - `budget_tokens: int`

      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.

      Must be ≥1024 and less than `max_tokens`.

      See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

    - `type: Literal["enabled"]`

      - `"enabled"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

  - `class BetaThinkingConfigDisabled: …`

    - `type: Literal["disabled"]`

      - `"disabled"`

  - `class BetaThinkingConfigAdaptive: …`

    - `type: Literal["adaptive"]`

      - `"adaptive"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

- `tool_choice: Optional[BetaToolChoiceParam]`

  How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

  - `class BetaToolChoiceAuto: …`

    The model will automatically decide whether to use tools.

    - `type: Literal["auto"]`

      - `"auto"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output at most one tool use.

  - `class BetaToolChoiceAny: …`

    The model will use any available tools.

    - `type: Literal["any"]`

      - `"any"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceTool: …`

    The model will use the specified tool with `tool_choice.name`.

    - `name: str`

      The name of the tool to use.

    - `type: Literal["tool"]`

      - `"tool"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceNone: …`

    The model will not be allowed to use tools.

    - `type: Literal["none"]`

      - `"none"`

- `tools: Optional[Iterable[Tool]]`

  Definitions of tools that the model may use.

  If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.

  There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).

  Each tool definition includes:

  * `name`: Name of the tool.
  * `description`: Optional, but strongly-recommended description of the tool.
  * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.

  For example, if you defined `tools` as:

  ```json
  [
    {
      "name": "get_stock_price",
      "description": "Get the current stock price for a given ticker symbol.",
      "input_schema": {
        "type": "object",
        "properties": {
          "ticker": {
            "type": "string",
            "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
          }
        },
        "required": ["ticker"]
      }
    }
  ]
  ```

  And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this:

  ```json
  [
    {
      "type": "tool_use",
      "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
      "name": "get_stock_price",
      "input": { "ticker": "^GSPC" }
    }
  ]
  ```

  You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message:

  ```json
  [
    {
      "type": "tool_result",
      "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
      "content": "259.75 USD"
    }
  ]
  ```

  Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.

  See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.

  - `class BetaTool: …`

    - `input_schema: InputSchema`

      [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

      This defines the shape of the `input` that your tool accepts and that the model will produce.

      - `type: Literal["object"]`

        - `"object"`

      - `properties: Optional[Dict[str, object]]`

      - `required: Optional[List[str]]`

    - `name: str`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `description: Optional[str]`

      Description of what this tool does.

      Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.

    - `eager_input_streaming: Optional[bool]`

      Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `type: Optional[Literal["custom"]]`

      - `"custom"`

  - `class BetaToolBash20241022: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20241022"]`

      - `"bash_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolBash20250124: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20250124"]`

      - `"bash_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250522: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250522"]`

      - `"code_execution_20250522"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250825: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250825"]`

      - `"code_execution_20250825"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20260120: …`

    Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20260120"]`

      - `"code_execution_20260120"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20241022: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20241022"]`

      - `"computer_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMemoryTool20250818: …`

    - `name: Literal["memory"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"memory"`

    - `type: Literal["memory_20250818"]`

      - `"memory_20250818"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20250124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20250124"]`

      - `"computer_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20241022: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20241022"]`

      - `"text_editor_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20251124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20251124"]`

      - `"computer_20251124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `enable_zoom: Optional[bool]`

      Whether to enable an action to take a zoomed-in screenshot of the screen.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250124: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20250124"]`

      - `"text_editor_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250429: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250429"]`

      - `"text_editor_20250429"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250728: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250728"]`

      - `"text_editor_20250728"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `max_characters: Optional[int]`

      Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20250305: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20250305"]`

      - `"web_search_20250305"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

      - `type: Literal["approximate"]`

        - `"approximate"`

      - `city: Optional[str]`

        The city of the user.

      - `country: Optional[str]`

        The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

      - `region: Optional[str]`

        The region of the user.

      - `timezone: Optional[str]`

        The [IANA timezone](https://nodatime.org/TimeZones) of the user.

  - `class BetaWebFetchTool20250910: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20250910"]`

      - `"web_fetch_20250910"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20260209: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20260209"]`

      - `"web_search_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

  - `class BetaWebFetchTool20260209: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260209"]`

      - `"web_fetch_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebFetchTool20260309: …`

    Web fetch tool with use_cache parameter for bypassing cached content.

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260309"]`

      - `"web_fetch_20260309"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `use_cache: Optional[bool]`

      Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.

  - `class BetaAdvisorTool20260301: …`

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `name: Literal["advisor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"advisor"`

    - `type: Literal["advisor_20260301"]`

      - `"advisor_20260301"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caching: Optional[BetaCacheControlEphemeral]`

      Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolBm25_20251119: …`

    - `name: Literal["tool_search_tool_bm25"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_bm25"`

    - `type: Literal["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]`

      - `"tool_search_tool_bm25_20251119"`

      - `"tool_search_tool_bm25"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolRegex20251119: …`

    - `name: Literal["tool_search_tool_regex"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_regex"`

    - `type: Literal["tool_search_tool_regex_20251119", "tool_search_tool_regex"]`

      - `"tool_search_tool_regex_20251119"`

      - `"tool_search_tool_regex"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMCPToolset: …`

    Configuration for a group of tools from an MCP server.

    Allows configuring enabled status and defer_loading for all tools
    from an MCP server, with optional per-tool overrides.

    - `mcp_server_name: str`

      Name of the MCP server to configure tools for

    - `type: Literal["mcp_toolset"]`

      - `"mcp_toolset"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `configs: Optional[Dict[str, BetaMCPToolConfig]]`

      Configuration overrides for specific tools, keyed by tool name

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

    - `default_config: Optional[BetaMCPToolDefaultConfig]`

      Default configuration applied to all tools from this server

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageTokensCount: …`

  - `context_management: Optional[BetaCountTokensContextManagementResponse]`

    Information about context management applied to the message.

    - `original_input_tokens: int`

      The original token count before context management was applied

  - `input_tokens: int`

    The total number of tokens across the provided list of messages, system prompt, and tools.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_message_tokens_count = client.beta.messages.count_tokens(
    messages=[{
        "content": "Hello, world",
        "role": "user",
    }],
    model="claude-opus-4-6",
)
print(beta_message_tokens_count.context_management)
```

#### Response

```json
{
  "context_management": {
    "original_input_tokens": 0
  },
  "input_tokens": 2095
}
```

## Domain Types

### Beta Advisor Message Iteration Usage

- `class BetaAdvisorMessageIterationUsage: …`

  Token usage for an advisor sub-inference iteration.

  - `cache_creation: Optional[BetaCacheCreation]`

    Breakdown of cached tokens by TTL

    - `ephemeral_1h_input_tokens: int`

      The number of input tokens used to create the 1 hour cache entry.

    - `ephemeral_5m_input_tokens: int`

      The number of input tokens used to create the 5 minute cache entry.

  - `cache_creation_input_tokens: int`

    The number of input tokens used to create the cache entry.

  - `cache_read_input_tokens: int`

    The number of input tokens read from the cache.

  - `input_tokens: int`

    The number of input tokens which were used.

  - `model: Model`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
      - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
      - `claude-opus-4-1` - Exceptional model for specialized complex tasks
      - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
      - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-mythos-preview"`

        New class of intelligence, strongest in coding and cybersecurity

      - `"claude-opus-4-6"`

        Frontier intelligence for long-running agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

      - `"claude-opus-4-1"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-1-20250805"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-0"`

        Powerful model for complex tasks

      - `"claude-opus-4-20250514"`

        Powerful model for complex tasks

      - `"claude-sonnet-4-0"`

        High-performance model with extended thinking

      - `"claude-sonnet-4-20250514"`

        High-performance model with extended thinking

      - `"claude-3-haiku-20240307"`

        Fast and cost-effective model

    - `str`

  - `output_tokens: int`

    The number of output tokens which were used.

  - `type: Literal["advisor_message"]`

    Usage for an advisor sub-inference iteration

    - `"advisor_message"`

### Beta Advisor Redacted Result Block

- `class BetaAdvisorRedactedResultBlock: …`

  - `encrypted_content: str`

    Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

  - `stop_reason: Optional[str]`

    The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

  - `type: Literal["advisor_redacted_result"]`

    - `"advisor_redacted_result"`

### Beta Advisor Redacted Result Block Param

- `class BetaAdvisorRedactedResultBlockParam: …`

  - `encrypted_content: str`

    Opaque blob produced by a prior response; must be round-tripped verbatim.

  - `type: Literal["advisor_redacted_result"]`

    - `"advisor_redacted_result"`

  - `stop_reason: Optional[str]`

### Beta Advisor Result Block

- `class BetaAdvisorResultBlock: …`

  - `stop_reason: Optional[str]`

    The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

  - `text: str`

  - `type: Literal["advisor_result"]`

    - `"advisor_result"`

### Beta Advisor Result Block Param

- `class BetaAdvisorResultBlockParam: …`

  - `text: str`

  - `type: Literal["advisor_result"]`

    - `"advisor_result"`

  - `stop_reason: Optional[str]`

### Beta Advisor Tool 20260301

- `class BetaAdvisorTool20260301: …`

  - `model: Model`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
      - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
      - `claude-opus-4-1` - Exceptional model for specialized complex tasks
      - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
      - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-mythos-preview"`

        New class of intelligence, strongest in coding and cybersecurity

      - `"claude-opus-4-6"`

        Frontier intelligence for long-running agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

      - `"claude-opus-4-1"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-1-20250805"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-0"`

        Powerful model for complex tasks

      - `"claude-opus-4-20250514"`

        Powerful model for complex tasks

      - `"claude-sonnet-4-0"`

        High-performance model with extended thinking

      - `"claude-sonnet-4-20250514"`

        High-performance model with extended thinking

      - `"claude-3-haiku-20240307"`

        Fast and cost-effective model

    - `str`

  - `name: Literal["advisor"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"advisor"`

  - `type: Literal["advisor_20260301"]`

    - `"advisor_20260301"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `caching: Optional[BetaCacheControlEphemeral]`

    Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Advisor Tool Result Block

- `class BetaAdvisorToolResultBlock: …`

  - `content: Content`

    - `class BetaAdvisorToolResultError: …`

      - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

        - `"max_uses_exceeded"`

        - `"prompt_too_long"`

        - `"too_many_requests"`

        - `"overloaded"`

        - `"unavailable"`

        - `"execution_time_exceeded"`

      - `type: Literal["advisor_tool_result_error"]`

        - `"advisor_tool_result_error"`

    - `class BetaAdvisorResultBlock: …`

      - `stop_reason: Optional[str]`

        The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

      - `text: str`

      - `type: Literal["advisor_result"]`

        - `"advisor_result"`

    - `class BetaAdvisorRedactedResultBlock: …`

      - `encrypted_content: str`

        Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

      - `stop_reason: Optional[str]`

        The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

      - `type: Literal["advisor_redacted_result"]`

        - `"advisor_redacted_result"`

  - `tool_use_id: str`

  - `type: Literal["advisor_tool_result"]`

    - `"advisor_tool_result"`

### Beta Advisor Tool Result Block Param

- `class BetaAdvisorToolResultBlockParam: …`

  - `content: Content`

    - `class BetaAdvisorToolResultErrorParam: …`

      - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

        - `"max_uses_exceeded"`

        - `"prompt_too_long"`

        - `"too_many_requests"`

        - `"overloaded"`

        - `"unavailable"`

        - `"execution_time_exceeded"`

      - `type: Literal["advisor_tool_result_error"]`

        - `"advisor_tool_result_error"`

    - `class BetaAdvisorResultBlockParam: …`

      - `text: str`

      - `type: Literal["advisor_result"]`

        - `"advisor_result"`

      - `stop_reason: Optional[str]`

    - `class BetaAdvisorRedactedResultBlockParam: …`

      - `encrypted_content: str`

        Opaque blob produced by a prior response; must be round-tripped verbatim.

      - `type: Literal["advisor_redacted_result"]`

        - `"advisor_redacted_result"`

      - `stop_reason: Optional[str]`

  - `tool_use_id: str`

  - `type: Literal["advisor_tool_result"]`

    - `"advisor_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Advisor Tool Result Error

- `class BetaAdvisorToolResultError: …`

  - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

    - `"max_uses_exceeded"`

    - `"prompt_too_long"`

    - `"too_many_requests"`

    - `"overloaded"`

    - `"unavailable"`

    - `"execution_time_exceeded"`

  - `type: Literal["advisor_tool_result_error"]`

    - `"advisor_tool_result_error"`

### Beta Advisor Tool Result Error Param

- `class BetaAdvisorToolResultErrorParam: …`

  - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

    - `"max_uses_exceeded"`

    - `"prompt_too_long"`

    - `"too_many_requests"`

    - `"overloaded"`

    - `"unavailable"`

    - `"execution_time_exceeded"`

  - `type: Literal["advisor_tool_result_error"]`

    - `"advisor_tool_result_error"`

### Beta All Thinking Turns

- `class BetaAllThinkingTurns: …`

  - `type: Literal["all"]`

    - `"all"`

### Beta Base64 Image Source

- `class BetaBase64ImageSource: …`

  - `data: str`

  - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

    - `"image/jpeg"`

    - `"image/png"`

    - `"image/gif"`

    - `"image/webp"`

  - `type: Literal["base64"]`

    - `"base64"`

### Beta Base64 PDF Source

- `class BetaBase64PDFSource: …`

  - `data: str`

  - `media_type: Literal["application/pdf"]`

    - `"application/pdf"`

  - `type: Literal["base64"]`

    - `"base64"`

### Beta Bash Code Execution Output Block

- `class BetaBashCodeExecutionOutputBlock: …`

  - `file_id: str`

  - `type: Literal["bash_code_execution_output"]`

    - `"bash_code_execution_output"`

### Beta Bash Code Execution Output Block Param

- `class BetaBashCodeExecutionOutputBlockParam: …`

  - `file_id: str`

  - `type: Literal["bash_code_execution_output"]`

    - `"bash_code_execution_output"`

### Beta Bash Code Execution Result Block

- `class BetaBashCodeExecutionResultBlock: …`

  - `content: List[BetaBashCodeExecutionOutputBlock]`

    - `file_id: str`

    - `type: Literal["bash_code_execution_output"]`

      - `"bash_code_execution_output"`

  - `return_code: int`

  - `stderr: str`

  - `stdout: str`

  - `type: Literal["bash_code_execution_result"]`

    - `"bash_code_execution_result"`

### Beta Bash Code Execution Result Block Param

- `class BetaBashCodeExecutionResultBlockParam: …`

  - `content: List[BetaBashCodeExecutionOutputBlockParam]`

    - `file_id: str`

    - `type: Literal["bash_code_execution_output"]`

      - `"bash_code_execution_output"`

  - `return_code: int`

  - `stderr: str`

  - `stdout: str`

  - `type: Literal["bash_code_execution_result"]`

    - `"bash_code_execution_result"`

### Beta Bash Code Execution Tool Result Block

- `class BetaBashCodeExecutionToolResultBlock: …`

  - `content: Content`

    - `class BetaBashCodeExecutionToolResultError: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

        - `"output_file_too_large"`

      - `type: Literal["bash_code_execution_tool_result_error"]`

        - `"bash_code_execution_tool_result_error"`

    - `class BetaBashCodeExecutionResultBlock: …`

      - `content: List[BetaBashCodeExecutionOutputBlock]`

        - `file_id: str`

        - `type: Literal["bash_code_execution_output"]`

          - `"bash_code_execution_output"`

      - `return_code: int`

      - `stderr: str`

      - `stdout: str`

      - `type: Literal["bash_code_execution_result"]`

        - `"bash_code_execution_result"`

  - `tool_use_id: str`

  - `type: Literal["bash_code_execution_tool_result"]`

    - `"bash_code_execution_tool_result"`

### Beta Bash Code Execution Tool Result Block Param

- `class BetaBashCodeExecutionToolResultBlockParam: …`

  - `content: Content`

    - `class BetaBashCodeExecutionToolResultErrorParam: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

        - `"output_file_too_large"`

      - `type: Literal["bash_code_execution_tool_result_error"]`

        - `"bash_code_execution_tool_result_error"`

    - `class BetaBashCodeExecutionResultBlockParam: …`

      - `content: List[BetaBashCodeExecutionOutputBlockParam]`

        - `file_id: str`

        - `type: Literal["bash_code_execution_output"]`

          - `"bash_code_execution_output"`

      - `return_code: int`

      - `stderr: str`

      - `stdout: str`

      - `type: Literal["bash_code_execution_result"]`

        - `"bash_code_execution_result"`

  - `tool_use_id: str`

  - `type: Literal["bash_code_execution_tool_result"]`

    - `"bash_code_execution_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Bash Code Execution Tool Result Error

- `class BetaBashCodeExecutionToolResultError: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

    - `"output_file_too_large"`

  - `type: Literal["bash_code_execution_tool_result_error"]`

    - `"bash_code_execution_tool_result_error"`

### Beta Bash Code Execution Tool Result Error Param

- `class BetaBashCodeExecutionToolResultErrorParam: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

    - `"output_file_too_large"`

  - `type: Literal["bash_code_execution_tool_result_error"]`

    - `"bash_code_execution_tool_result_error"`

### Beta Cache Control Ephemeral

- `class BetaCacheControlEphemeral: …`

  - `type: Literal["ephemeral"]`

    - `"ephemeral"`

  - `ttl: Optional[Literal["5m", "1h"]]`

    The time-to-live for the cache control breakpoint.

    This may be one the following values:

    - `5m`: 5 minutes
    - `1h`: 1 hour

    Defaults to `5m`.

    - `"5m"`

    - `"1h"`

### Beta Cache Creation

- `class BetaCacheCreation: …`

  - `ephemeral_1h_input_tokens: int`

    The number of input tokens used to create the 1 hour cache entry.

  - `ephemeral_5m_input_tokens: int`

    The number of input tokens used to create the 5 minute cache entry.

### Beta Cache Miss Messages Changed

- `class BetaCacheMissMessagesChanged: …`

  - `cache_missed_input_tokens: int`

    Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

  - `type: Literal["messages_changed"]`

    - `"messages_changed"`

### Beta Cache Miss Model Changed

- `class BetaCacheMissModelChanged: …`

  - `cache_missed_input_tokens: int`

    Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

  - `type: Literal["model_changed"]`

    - `"model_changed"`

### Beta Cache Miss Previous Message Not Found

- `class BetaCacheMissPreviousMessageNotFound: …`

  - `type: Literal["previous_message_not_found"]`

    - `"previous_message_not_found"`

### Beta Cache Miss System Changed

- `class BetaCacheMissSystemChanged: …`

  - `cache_missed_input_tokens: int`

    Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

  - `type: Literal["system_changed"]`

    - `"system_changed"`

### Beta Cache Miss Tools Changed

- `class BetaCacheMissToolsChanged: …`

  - `cache_missed_input_tokens: int`

    Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

  - `type: Literal["tools_changed"]`

    - `"tools_changed"`

### Beta Cache Miss Unavailable

- `class BetaCacheMissUnavailable: …`

  - `type: Literal["unavailable"]`

    - `"unavailable"`

### Beta Citation Char Location

- `class BetaCitationCharLocation: …`

  - `cited_text: str`

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_char_index: int`

  - `file_id: Optional[str]`

  - `start_char_index: int`

  - `type: Literal["char_location"]`

    - `"char_location"`

### Beta Citation Char Location Param

- `class BetaCitationCharLocationParam: …`

  - `cited_text: str`

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_char_index: int`

  - `start_char_index: int`

  - `type: Literal["char_location"]`

    - `"char_location"`

### Beta Citation Config

- `class BetaCitationConfig: …`

  - `enabled: bool`

### Beta Citation Content Block Location

- `class BetaCitationContentBlockLocation: …`

  - `cited_text: str`

    The full text of the cited block range, concatenated.

    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_block_index: int`

    Exclusive 0-based end index of the cited block range in the source's `content` array.

    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

  - `file_id: Optional[str]`

  - `start_block_index: int`

    0-based index of the first cited block in the source's `content` array.

  - `type: Literal["content_block_location"]`

    - `"content_block_location"`

### Beta Citation Content Block Location Param

- `class BetaCitationContentBlockLocationParam: …`

  - `cited_text: str`

    The full text of the cited block range, concatenated.

    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_block_index: int`

    Exclusive 0-based end index of the cited block range in the source's `content` array.

    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

  - `start_block_index: int`

    0-based index of the first cited block in the source's `content` array.

  - `type: Literal["content_block_location"]`

    - `"content_block_location"`

### Beta Citation Page Location

- `class BetaCitationPageLocation: …`

  - `cited_text: str`

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_page_number: int`

  - `file_id: Optional[str]`

  - `start_page_number: int`

  - `type: Literal["page_location"]`

    - `"page_location"`

### Beta Citation Page Location Param

- `class BetaCitationPageLocationParam: …`

  - `cited_text: str`

  - `document_index: int`

  - `document_title: Optional[str]`

  - `end_page_number: int`

  - `start_page_number: int`

  - `type: Literal["page_location"]`

    - `"page_location"`

### Beta Citation Search Result Location

- `class BetaCitationSearchResultLocation: …`

  - `cited_text: str`

    The full text of the cited block range, concatenated.

    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

  - `end_block_index: int`

    Exclusive 0-based end index of the cited block range in the source's `content` array.

    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

  - `search_result_index: int`

    0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

    Counted separately from `document_index`; server-side web search results are not included in this count.

  - `source: str`

  - `start_block_index: int`

    0-based index of the first cited block in the source's `content` array.

  - `title: Optional[str]`

  - `type: Literal["search_result_location"]`

    - `"search_result_location"`

### Beta Citation Search Result Location Param

- `class BetaCitationSearchResultLocationParam: …`

  - `cited_text: str`

    The full text of the cited block range, concatenated.

    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

  - `end_block_index: int`

    Exclusive 0-based end index of the cited block range in the source's `content` array.

    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

  - `search_result_index: int`

    0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

    Counted separately from `document_index`; server-side web search results are not included in this count.

  - `source: str`

  - `start_block_index: int`

    0-based index of the first cited block in the source's `content` array.

  - `title: Optional[str]`

  - `type: Literal["search_result_location"]`

    - `"search_result_location"`

### Beta Citation Web Search Result Location Param

- `class BetaCitationWebSearchResultLocationParam: …`

  - `cited_text: str`

  - `encrypted_index: str`

  - `title: Optional[str]`

  - `type: Literal["web_search_result_location"]`

    - `"web_search_result_location"`

  - `url: str`

### Beta Citations Config Param

- `class BetaCitationsConfigParam: …`

  - `enabled: Optional[bool]`

### Beta Citations Delta

- `class BetaCitationsDelta: …`

  - `citation: Citation`

    - `class BetaCitationCharLocation: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_char_index: int`

      - `file_id: Optional[str]`

      - `start_char_index: int`

      - `type: Literal["char_location"]`

        - `"char_location"`

    - `class BetaCitationPageLocation: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_page_number: int`

      - `file_id: Optional[str]`

      - `start_page_number: int`

      - `type: Literal["page_location"]`

        - `"page_location"`

    - `class BetaCitationContentBlockLocation: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `file_id: Optional[str]`

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `type: Literal["content_block_location"]`

        - `"content_block_location"`

    - `class BetaCitationsWebSearchResultLocation: …`

      - `cited_text: str`

      - `encrypted_index: str`

      - `title: Optional[str]`

      - `type: Literal["web_search_result_location"]`

        - `"web_search_result_location"`

      - `url: str`

    - `class BetaCitationSearchResultLocation: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `search_result_index: int`

        0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

        Counted separately from `document_index`; server-side web search results are not included in this count.

      - `source: str`

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `title: Optional[str]`

      - `type: Literal["search_result_location"]`

        - `"search_result_location"`

  - `type: Literal["citations_delta"]`

    - `"citations_delta"`

### Beta Citations Web Search Result Location

- `class BetaCitationsWebSearchResultLocation: …`

  - `cited_text: str`

  - `encrypted_index: str`

  - `title: Optional[str]`

  - `type: Literal["web_search_result_location"]`

    - `"web_search_result_location"`

  - `url: str`

### Beta Clear Thinking 20251015 Edit

- `class BetaClearThinking20251015Edit: …`

  - `type: Literal["clear_thinking_20251015"]`

    - `"clear_thinking_20251015"`

  - `keep: Optional[Keep]`

    Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.

    - `class BetaThinkingTurns: …`

      - `type: Literal["thinking_turns"]`

        - `"thinking_turns"`

      - `value: int`

    - `class BetaAllThinkingTurns: …`

      - `type: Literal["all"]`

        - `"all"`

    - `Literal["all"]`

      - `"all"`

### Beta Clear Thinking 20251015 Edit Response

- `class BetaClearThinking20251015EditResponse: …`

  - `cleared_input_tokens: int`

    Number of input tokens cleared by this edit.

  - `cleared_thinking_turns: int`

    Number of thinking turns that were cleared.

  - `type: Literal["clear_thinking_20251015"]`

    The type of context management edit applied.

    - `"clear_thinking_20251015"`

### Beta Clear Tool Uses 20250919 Edit

- `class BetaClearToolUses20250919Edit: …`

  - `type: Literal["clear_tool_uses_20250919"]`

    - `"clear_tool_uses_20250919"`

  - `clear_at_least: Optional[BetaInputTokensClearAtLeast]`

    Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.

    - `type: Literal["input_tokens"]`

      - `"input_tokens"`

    - `value: int`

  - `clear_tool_inputs: Optional[Union[bool, List[str], null]]`

    Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

    - `bool`

    - `List[str]`

  - `exclude_tools: Optional[List[str]]`

    Tool names whose uses are preserved from clearing

  - `keep: Optional[BetaToolUsesKeep]`

    Number of tool uses to retain in the conversation

    - `type: Literal["tool_uses"]`

      - `"tool_uses"`

    - `value: int`

  - `trigger: Optional[Trigger]`

    Condition that triggers the context management strategy

    - `class BetaInputTokensTrigger: …`

      - `type: Literal["input_tokens"]`

        - `"input_tokens"`

      - `value: int`

    - `class BetaToolUsesTrigger: …`

      - `type: Literal["tool_uses"]`

        - `"tool_uses"`

      - `value: int`

### Beta Clear Tool Uses 20250919 Edit Response

- `class BetaClearToolUses20250919EditResponse: …`

  - `cleared_input_tokens: int`

    Number of input tokens cleared by this edit.

  - `cleared_tool_uses: int`

    Number of tool uses that were cleared.

  - `type: Literal["clear_tool_uses_20250919"]`

    The type of context management edit applied.

    - `"clear_tool_uses_20250919"`

### Beta Code Execution Output Block

- `class BetaCodeExecutionOutputBlock: …`

  - `file_id: str`

  - `type: Literal["code_execution_output"]`

    - `"code_execution_output"`

### Beta Code Execution Output Block Param

- `class BetaCodeExecutionOutputBlockParam: …`

  - `file_id: str`

  - `type: Literal["code_execution_output"]`

    - `"code_execution_output"`

### Beta Code Execution Result Block

- `class BetaCodeExecutionResultBlock: …`

  - `content: List[BetaCodeExecutionOutputBlock]`

    - `file_id: str`

    - `type: Literal["code_execution_output"]`

      - `"code_execution_output"`

  - `return_code: int`

  - `stderr: str`

  - `stdout: str`

  - `type: Literal["code_execution_result"]`

    - `"code_execution_result"`

### Beta Code Execution Result Block Param

- `class BetaCodeExecutionResultBlockParam: …`

  - `content: List[BetaCodeExecutionOutputBlockParam]`

    - `file_id: str`

    - `type: Literal["code_execution_output"]`

      - `"code_execution_output"`

  - `return_code: int`

  - `stderr: str`

  - `stdout: str`

  - `type: Literal["code_execution_result"]`

    - `"code_execution_result"`

### Beta Code Execution Tool 20250522

- `class BetaCodeExecutionTool20250522: …`

  - `name: Literal["code_execution"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"code_execution"`

  - `type: Literal["code_execution_20250522"]`

    - `"code_execution_20250522"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Code Execution Tool 20250825

- `class BetaCodeExecutionTool20250825: …`

  - `name: Literal["code_execution"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"code_execution"`

  - `type: Literal["code_execution_20250825"]`

    - `"code_execution_20250825"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Code Execution Tool 20260120

- `class BetaCodeExecutionTool20260120: …`

  Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

  - `name: Literal["code_execution"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"code_execution"`

  - `type: Literal["code_execution_20260120"]`

    - `"code_execution_20260120"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Code Execution Tool Result Block

- `class BetaCodeExecutionToolResultBlock: …`

  - `content: BetaCodeExecutionToolResultBlockContent`

    Code execution result with encrypted stdout for PFC + web_search results.

    - `class BetaCodeExecutionToolResultError: …`

      - `error_code: BetaCodeExecutionToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

      - `type: Literal["code_execution_tool_result_error"]`

        - `"code_execution_tool_result_error"`

    - `class BetaCodeExecutionResultBlock: …`

      - `content: List[BetaCodeExecutionOutputBlock]`

        - `file_id: str`

        - `type: Literal["code_execution_output"]`

          - `"code_execution_output"`

      - `return_code: int`

      - `stderr: str`

      - `stdout: str`

      - `type: Literal["code_execution_result"]`

        - `"code_execution_result"`

    - `class BetaEncryptedCodeExecutionResultBlock: …`

      Code execution result with encrypted stdout for PFC + web_search results.

      - `content: List[BetaCodeExecutionOutputBlock]`

        - `file_id: str`

        - `type: Literal["code_execution_output"]`

      - `encrypted_stdout: str`

      - `return_code: int`

      - `stderr: str`

      - `type: Literal["encrypted_code_execution_result"]`

        - `"encrypted_code_execution_result"`

  - `tool_use_id: str`

  - `type: Literal["code_execution_tool_result"]`

    - `"code_execution_tool_result"`

### Beta Code Execution Tool Result Block Content

- `BetaCodeExecutionToolResultBlockContent`

  Code execution result with encrypted stdout for PFC + web_search results.

  - `class BetaCodeExecutionToolResultError: …`

    - `error_code: BetaCodeExecutionToolResultErrorCode`

      - `"invalid_tool_input"`

      - `"unavailable"`

      - `"too_many_requests"`

      - `"execution_time_exceeded"`

    - `type: Literal["code_execution_tool_result_error"]`

      - `"code_execution_tool_result_error"`

  - `class BetaCodeExecutionResultBlock: …`

    - `content: List[BetaCodeExecutionOutputBlock]`

      - `file_id: str`

      - `type: Literal["code_execution_output"]`

        - `"code_execution_output"`

    - `return_code: int`

    - `stderr: str`

    - `stdout: str`

    - `type: Literal["code_execution_result"]`

      - `"code_execution_result"`

  - `class BetaEncryptedCodeExecutionResultBlock: …`

    Code execution result with encrypted stdout for PFC + web_search results.

    - `content: List[BetaCodeExecutionOutputBlock]`

      - `file_id: str`

      - `type: Literal["code_execution_output"]`

    - `encrypted_stdout: str`

    - `return_code: int`

    - `stderr: str`

    - `type: Literal["encrypted_code_execution_result"]`

      - `"encrypted_code_execution_result"`

### Beta Code Execution Tool Result Block Param

- `class BetaCodeExecutionToolResultBlockParam: …`

  - `content: BetaCodeExecutionToolResultBlockParamContent`

    Code execution result with encrypted stdout for PFC + web_search results.

    - `class BetaCodeExecutionToolResultErrorParam: …`

      - `error_code: BetaCodeExecutionToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

      - `type: Literal["code_execution_tool_result_error"]`

        - `"code_execution_tool_result_error"`

    - `class BetaCodeExecutionResultBlockParam: …`

      - `content: List[BetaCodeExecutionOutputBlockParam]`

        - `file_id: str`

        - `type: Literal["code_execution_output"]`

          - `"code_execution_output"`

      - `return_code: int`

      - `stderr: str`

      - `stdout: str`

      - `type: Literal["code_execution_result"]`

        - `"code_execution_result"`

    - `class BetaEncryptedCodeExecutionResultBlockParam: …`

      Code execution result with encrypted stdout for PFC + web_search results.

      - `content: List[BetaCodeExecutionOutputBlockParam]`

        - `file_id: str`

        - `type: Literal["code_execution_output"]`

      - `encrypted_stdout: str`

      - `return_code: int`

      - `stderr: str`

      - `type: Literal["encrypted_code_execution_result"]`

        - `"encrypted_code_execution_result"`

  - `tool_use_id: str`

  - `type: Literal["code_execution_tool_result"]`

    - `"code_execution_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Code Execution Tool Result Block Param Content

- `BetaCodeExecutionToolResultBlockParamContent`

  Code execution result with encrypted stdout for PFC + web_search results.

  - `class BetaCodeExecutionToolResultErrorParam: …`

    - `error_code: BetaCodeExecutionToolResultErrorCode`

      - `"invalid_tool_input"`

      - `"unavailable"`

      - `"too_many_requests"`

      - `"execution_time_exceeded"`

    - `type: Literal["code_execution_tool_result_error"]`

      - `"code_execution_tool_result_error"`

  - `class BetaCodeExecutionResultBlockParam: …`

    - `content: List[BetaCodeExecutionOutputBlockParam]`

      - `file_id: str`

      - `type: Literal["code_execution_output"]`

        - `"code_execution_output"`

    - `return_code: int`

    - `stderr: str`

    - `stdout: str`

    - `type: Literal["code_execution_result"]`

      - `"code_execution_result"`

  - `class BetaEncryptedCodeExecutionResultBlockParam: …`

    Code execution result with encrypted stdout for PFC + web_search results.

    - `content: List[BetaCodeExecutionOutputBlockParam]`

      - `file_id: str`

      - `type: Literal["code_execution_output"]`

    - `encrypted_stdout: str`

    - `return_code: int`

    - `stderr: str`

    - `type: Literal["encrypted_code_execution_result"]`

      - `"encrypted_code_execution_result"`

### Beta Code Execution Tool Result Error

- `class BetaCodeExecutionToolResultError: …`

  - `error_code: BetaCodeExecutionToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

  - `type: Literal["code_execution_tool_result_error"]`

    - `"code_execution_tool_result_error"`

### Beta Code Execution Tool Result Error Code

- `Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

  - `"invalid_tool_input"`

  - `"unavailable"`

  - `"too_many_requests"`

  - `"execution_time_exceeded"`

### Beta Code Execution Tool Result Error Param

- `class BetaCodeExecutionToolResultErrorParam: …`

  - `error_code: BetaCodeExecutionToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

  - `type: Literal["code_execution_tool_result_error"]`

    - `"code_execution_tool_result_error"`

### Beta Compact 20260112 Edit

- `class BetaCompact20260112Edit: …`

  Automatically compact older context when reaching the configured trigger threshold.

  - `type: Literal["compact_20260112"]`

    - `"compact_20260112"`

  - `instructions: Optional[str]`

    Additional instructions for summarization.

  - `pause_after_compaction: Optional[bool]`

    Whether to pause after compaction and return the compaction block to the user.

  - `trigger: Optional[BetaInputTokensTrigger]`

    When to trigger compaction. Defaults to 150000 input tokens.

    - `type: Literal["input_tokens"]`

      - `"input_tokens"`

    - `value: int`

### Beta Compaction Block

- `class BetaCompactionBlock: …`

  A compaction block returned when autocompact is triggered.

  When content is None, it indicates the compaction failed to produce a valid
  summary (e.g., malformed output from the model). Clients may round-trip
  compaction blocks with null content; the server treats them as no-ops.

  - `content: Optional[str]`

    Summary of compacted content, or null if compaction failed

  - `encrypted_content: Optional[str]`

    Opaque metadata from prior compaction, to be round-tripped verbatim

  - `type: Literal["compaction"]`

    - `"compaction"`

### Beta Compaction Block Param

- `class BetaCompactionBlockParam: …`

  A compaction block containing summary of previous context.

  Users should round-trip these blocks from responses to subsequent requests
  to maintain context across compaction boundaries.

  When content is None, the block represents a failed compaction. The server
  treats these as no-ops. Empty string content is not allowed.

  - `type: Literal["compaction"]`

    - `"compaction"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `content: Optional[str]`

    Summary of previously compacted content, or null if compaction failed

  - `encrypted_content: Optional[str]`

    Opaque metadata from prior compaction, to be round-tripped verbatim

### Beta Compaction Content Block Delta

- `class BetaCompactionContentBlockDelta: …`

  - `content: Optional[str]`

  - `encrypted_content: Optional[str]`

    Opaque metadata from prior compaction, to be round-tripped verbatim

  - `type: Literal["compaction_delta"]`

    - `"compaction_delta"`

### Beta Compaction Iteration Usage

- `class BetaCompactionIterationUsage: …`

  Token usage for a compaction iteration.

  - `cache_creation: Optional[BetaCacheCreation]`

    Breakdown of cached tokens by TTL

    - `ephemeral_1h_input_tokens: int`

      The number of input tokens used to create the 1 hour cache entry.

    - `ephemeral_5m_input_tokens: int`

      The number of input tokens used to create the 5 minute cache entry.

  - `cache_creation_input_tokens: int`

    The number of input tokens used to create the cache entry.

  - `cache_read_input_tokens: int`

    The number of input tokens read from the cache.

  - `input_tokens: int`

    The number of input tokens which were used.

  - `output_tokens: int`

    The number of output tokens which were used.

  - `type: Literal["compaction"]`

    Usage for a compaction iteration

    - `"compaction"`

### Beta Container

- `class BetaContainer: …`

  Information about the container used in the request (for the code execution tool)

  - `id: str`

    Identifier for the container used in this request

  - `expires_at: datetime`

    The time at which the container will expire.

  - `skills: Optional[List[BetaSkill]]`

    Skills loaded in the container

    - `skill_id: str`

      Skill ID

    - `type: Literal["anthropic", "custom"]`

      Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

      - `"anthropic"`

      - `"custom"`

    - `version: str`

      Skill version or 'latest' for most recent version

### Beta Container Params

- `class BetaContainerParams: …`

  Container parameters with skills to be loaded.

  - `id: Optional[str]`

    Container id

  - `skills: Optional[List[BetaSkillParams]]`

    List of skills to load in the container

    - `skill_id: str`

      Skill ID

    - `type: Literal["anthropic", "custom"]`

      Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

      - `"anthropic"`

      - `"custom"`

    - `version: Optional[str]`

      Skill version or 'latest' for most recent version

### Beta Container Upload Block

- `class BetaContainerUploadBlock: …`

  Response model for a file uploaded to the container.

  - `file_id: str`

  - `type: Literal["container_upload"]`

    - `"container_upload"`

### Beta Container Upload Block Param

- `class BetaContainerUploadBlockParam: …`

  A content block that represents a file to be uploaded to the container
  Files uploaded via this block will be available in the container's input directory.

  - `file_id: str`

  - `type: Literal["container_upload"]`

    - `"container_upload"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Content Block

- `BetaContentBlock`

  Response model for a file uploaded to the container.

  - `class BetaTextBlock: …`

    - `citations: Optional[List[BetaTextCitation]]`

      Citations supporting the text block.

      The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

      - `class BetaCitationCharLocation: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `file_id: Optional[str]`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocation: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `file_id: Optional[str]`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocation: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `file_id: Optional[str]`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationsWebSearchResultLocation: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocation: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

    - `text: str`

    - `type: Literal["text"]`

      - `"text"`

  - `class BetaThinkingBlock: …`

    - `signature: str`

    - `thinking: str`

    - `type: Literal["thinking"]`

      - `"thinking"`

  - `class BetaRedactedThinkingBlock: …`

    - `data: str`

    - `type: Literal["redacted_thinking"]`

      - `"redacted_thinking"`

  - `class BetaToolUseBlock: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: str`

    - `type: Literal["tool_use"]`

      - `"tool_use"`

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

        - `type: Literal["direct"]`

          - `"direct"`

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

        - `tool_id: str`

        - `type: Literal["code_execution_20250825"]`

          - `"code_execution_20250825"`

      - `class BetaServerToolCaller20260120: …`

        - `tool_id: str`

        - `type: Literal["code_execution_20260120"]`

          - `"code_execution_20260120"`

  - `class BetaServerToolUseBlock: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

      - `"advisor"`

      - `"web_search"`

      - `"web_fetch"`

      - `"code_execution"`

      - `"bash_code_execution"`

      - `"text_editor_code_execution"`

      - `"tool_search_tool_regex"`

      - `"tool_search_tool_bm25"`

    - `type: Literal["server_tool_use"]`

      - `"server_tool_use"`

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaWebSearchToolResultBlock: …`

    - `content: BetaWebSearchToolResultBlockContent`

      - `class BetaWebSearchToolResultError: …`

        - `error_code: BetaWebSearchToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"max_uses_exceeded"`

          - `"too_many_requests"`

          - `"query_too_long"`

          - `"request_too_large"`

        - `type: Literal["web_search_tool_result_error"]`

          - `"web_search_tool_result_error"`

      - `List[BetaWebSearchResultBlock]`

        - `encrypted_content: str`

        - `page_age: Optional[str]`

        - `title: str`

        - `type: Literal["web_search_result"]`

          - `"web_search_result"`

        - `url: str`

    - `tool_use_id: str`

    - `type: Literal["web_search_tool_result"]`

      - `"web_search_tool_result"`

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaWebFetchToolResultBlock: …`

    - `content: Content`

      - `class BetaWebFetchToolResultErrorBlock: …`

        - `error_code: BetaWebFetchToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"url_too_long"`

          - `"url_not_allowed"`

          - `"url_not_in_prior_context"`

          - `"url_not_accessible"`

          - `"unsupported_content_type"`

          - `"too_many_requests"`

          - `"max_uses_exceeded"`

          - `"unavailable"`

        - `type: Literal["web_fetch_tool_result_error"]`

          - `"web_fetch_tool_result_error"`

      - `class BetaWebFetchBlock: …`

        - `content: BetaDocumentBlock`

          - `citations: Optional[BetaCitationConfig]`

            Citation configuration for the document

            - `enabled: bool`

          - `source: Source`

            - `class BetaBase64PDFSource: …`

              - `data: str`

              - `media_type: Literal["application/pdf"]`

                - `"application/pdf"`

              - `type: Literal["base64"]`

                - `"base64"`

            - `class BetaPlainTextSource: …`

              - `data: str`

              - `media_type: Literal["text/plain"]`

                - `"text/plain"`

              - `type: Literal["text"]`

                - `"text"`

          - `title: Optional[str]`

            The title of the document

          - `type: Literal["document"]`

            - `"document"`

        - `retrieved_at: Optional[str]`

          ISO 8601 timestamp when the content was retrieved

        - `type: Literal["web_fetch_result"]`

          - `"web_fetch_result"`

        - `url: str`

          Fetched content URL

    - `tool_use_id: str`

    - `type: Literal["web_fetch_tool_result"]`

      - `"web_fetch_tool_result"`

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaAdvisorToolResultBlock: …`

    - `content: Content`

      - `class BetaAdvisorToolResultError: …`

        - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

          - `"max_uses_exceeded"`

          - `"prompt_too_long"`

          - `"too_many_requests"`

          - `"overloaded"`

          - `"unavailable"`

          - `"execution_time_exceeded"`

        - `type: Literal["advisor_tool_result_error"]`

          - `"advisor_tool_result_error"`

      - `class BetaAdvisorResultBlock: …`

        - `stop_reason: Optional[str]`

          The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

        - `text: str`

        - `type: Literal["advisor_result"]`

          - `"advisor_result"`

      - `class BetaAdvisorRedactedResultBlock: …`

        - `encrypted_content: str`

          Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

        - `stop_reason: Optional[str]`

          The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

        - `type: Literal["advisor_redacted_result"]`

          - `"advisor_redacted_result"`

    - `tool_use_id: str`

    - `type: Literal["advisor_tool_result"]`

      - `"advisor_tool_result"`

  - `class BetaCodeExecutionToolResultBlock: …`

    - `content: BetaCodeExecutionToolResultBlockContent`

      Code execution result with encrypted stdout for PFC + web_search results.

      - `class BetaCodeExecutionToolResultError: …`

        - `error_code: BetaCodeExecutionToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

        - `type: Literal["code_execution_tool_result_error"]`

          - `"code_execution_tool_result_error"`

      - `class BetaCodeExecutionResultBlock: …`

        - `content: List[BetaCodeExecutionOutputBlock]`

          - `file_id: str`

          - `type: Literal["code_execution_output"]`

            - `"code_execution_output"`

        - `return_code: int`

        - `stderr: str`

        - `stdout: str`

        - `type: Literal["code_execution_result"]`

          - `"code_execution_result"`

      - `class BetaEncryptedCodeExecutionResultBlock: …`

        Code execution result with encrypted stdout for PFC + web_search results.

        - `content: List[BetaCodeExecutionOutputBlock]`

          - `file_id: str`

          - `type: Literal["code_execution_output"]`

        - `encrypted_stdout: str`

        - `return_code: int`

        - `stderr: str`

        - `type: Literal["encrypted_code_execution_result"]`

          - `"encrypted_code_execution_result"`

    - `tool_use_id: str`

    - `type: Literal["code_execution_tool_result"]`

      - `"code_execution_tool_result"`

  - `class BetaBashCodeExecutionToolResultBlock: …`

    - `content: Content`

      - `class BetaBashCodeExecutionToolResultError: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

          - `"output_file_too_large"`

        - `type: Literal["bash_code_execution_tool_result_error"]`

          - `"bash_code_execution_tool_result_error"`

      - `class BetaBashCodeExecutionResultBlock: …`

        - `content: List[BetaBashCodeExecutionOutputBlock]`

          - `file_id: str`

          - `type: Literal["bash_code_execution_output"]`

            - `"bash_code_execution_output"`

        - `return_code: int`

        - `stderr: str`

        - `stdout: str`

        - `type: Literal["bash_code_execution_result"]`

          - `"bash_code_execution_result"`

    - `tool_use_id: str`

    - `type: Literal["bash_code_execution_tool_result"]`

      - `"bash_code_execution_tool_result"`

  - `class BetaTextEditorCodeExecutionToolResultBlock: …`

    - `content: Content`

      - `class BetaTextEditorCodeExecutionToolResultError: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

          - `"file_not_found"`

        - `error_message: Optional[str]`

        - `type: Literal["text_editor_code_execution_tool_result_error"]`

          - `"text_editor_code_execution_tool_result_error"`

      - `class BetaTextEditorCodeExecutionViewResultBlock: …`

        - `content: str`

        - `file_type: Literal["text", "image", "pdf"]`

          - `"text"`

          - `"image"`

          - `"pdf"`

        - `num_lines: Optional[int]`

        - `start_line: Optional[int]`

        - `total_lines: Optional[int]`

        - `type: Literal["text_editor_code_execution_view_result"]`

          - `"text_editor_code_execution_view_result"`

      - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

        - `is_file_update: bool`

        - `type: Literal["text_editor_code_execution_create_result"]`

          - `"text_editor_code_execution_create_result"`

      - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

        - `lines: Optional[List[str]]`

        - `new_lines: Optional[int]`

        - `new_start: Optional[int]`

        - `old_lines: Optional[int]`

        - `old_start: Optional[int]`

        - `type: Literal["text_editor_code_execution_str_replace_result"]`

          - `"text_editor_code_execution_str_replace_result"`

    - `tool_use_id: str`

    - `type: Literal["text_editor_code_execution_tool_result"]`

      - `"text_editor_code_execution_tool_result"`

  - `class BetaToolSearchToolResultBlock: …`

    - `content: Content`

      - `class BetaToolSearchToolResultError: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

        - `error_message: Optional[str]`

        - `type: Literal["tool_search_tool_result_error"]`

          - `"tool_search_tool_result_error"`

      - `class BetaToolSearchToolSearchResultBlock: …`

        - `tool_references: List[BetaToolReferenceBlock]`

          - `tool_name: str`

          - `type: Literal["tool_reference"]`

            - `"tool_reference"`

        - `type: Literal["tool_search_tool_search_result"]`

          - `"tool_search_tool_search_result"`

    - `tool_use_id: str`

    - `type: Literal["tool_search_tool_result"]`

      - `"tool_search_tool_result"`

  - `class BetaMCPToolUseBlock: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: str`

      The name of the MCP tool

    - `server_name: str`

      The name of the MCP server

    - `type: Literal["mcp_tool_use"]`

      - `"mcp_tool_use"`

  - `class BetaMCPToolResultBlock: …`

    - `content: Union[str, List[BetaTextBlock]]`

      - `str`

      - `List[BetaTextBlock]`

        - `citations: Optional[List[BetaTextCitation]]`

          Citations supporting the text block.

          The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

        - `text: str`

        - `type: Literal["text"]`

    - `is_error: bool`

    - `tool_use_id: str`

    - `type: Literal["mcp_tool_result"]`

      - `"mcp_tool_result"`

  - `class BetaContainerUploadBlock: …`

    Response model for a file uploaded to the container.

    - `file_id: str`

    - `type: Literal["container_upload"]`

      - `"container_upload"`

  - `class BetaCompactionBlock: …`

    A compaction block returned when autocompact is triggered.

    When content is None, it indicates the compaction failed to produce a valid
    summary (e.g., malformed output from the model). Clients may round-trip
    compaction blocks with null content; the server treats them as no-ops.

    - `content: Optional[str]`

      Summary of compacted content, or null if compaction failed

    - `encrypted_content: Optional[str]`

      Opaque metadata from prior compaction, to be round-tripped verbatim

    - `type: Literal["compaction"]`

      - `"compaction"`

### Beta Content Block Param

- `BetaContentBlockParam`

  Regular text content.

  - `class BetaTextBlockParam: …`

    - `text: str`

    - `type: Literal["text"]`

      - `"text"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

    - `citations: Optional[List[BetaTextCitationParam]]`

      - `class BetaCitationCharLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationWebSearchResultLocationParam: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

  - `class BetaImageBlockParam: …`

    - `source: Source`

      - `class BetaBase64ImageSource: …`

        - `data: str`

        - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

          - `"image/jpeg"`

          - `"image/png"`

          - `"image/gif"`

          - `"image/webp"`

        - `type: Literal["base64"]`

          - `"base64"`

      - `class BetaURLImageSource: …`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `class BetaFileImageSource: …`

        - `file_id: str`

        - `type: Literal["file"]`

          - `"file"`

    - `type: Literal["image"]`

      - `"image"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaRequestDocumentBlock: …`

    - `source: Source`

      - `class BetaBase64PDFSource: …`

        - `data: str`

        - `media_type: Literal["application/pdf"]`

          - `"application/pdf"`

        - `type: Literal["base64"]`

          - `"base64"`

      - `class BetaPlainTextSource: …`

        - `data: str`

        - `media_type: Literal["text/plain"]`

          - `"text/plain"`

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaContentBlockSource: …`

        - `content: Union[str, List[BetaContentBlockSourceContent]]`

          - `str`

          - `List[BetaContentBlockSourceContent]`

            - `class BetaTextBlockParam: …`

            - `class BetaImageBlockParam: …`

        - `type: Literal["content"]`

          - `"content"`

      - `class BetaURLPDFSource: …`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `class BetaFileDocumentSource: …`

        - `file_id: str`

        - `type: Literal["file"]`

          - `"file"`

    - `type: Literal["document"]`

      - `"document"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      - `enabled: Optional[bool]`

    - `context: Optional[str]`

    - `title: Optional[str]`

  - `class BetaSearchResultBlockParam: …`

    - `content: List[BetaTextBlockParam]`

      - `text: str`

      - `type: Literal["text"]`

      - `cache_control: Optional[BetaCacheControlEphemeral]`

        Create a cache control breakpoint at this content block.

      - `citations: Optional[List[BetaTextCitationParam]]`

    - `source: str`

    - `title: str`

    - `type: Literal["search_result"]`

      - `"search_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

  - `class BetaThinkingBlockParam: …`

    - `signature: str`

    - `thinking: str`

    - `type: Literal["thinking"]`

      - `"thinking"`

  - `class BetaRedactedThinkingBlockParam: …`

    - `data: str`

    - `type: Literal["redacted_thinking"]`

      - `"redacted_thinking"`

  - `class BetaToolUseBlockParam: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: str`

    - `type: Literal["tool_use"]`

      - `"tool_use"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

        - `type: Literal["direct"]`

          - `"direct"`

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

        - `tool_id: str`

        - `type: Literal["code_execution_20250825"]`

          - `"code_execution_20250825"`

      - `class BetaServerToolCaller20260120: …`

        - `tool_id: str`

        - `type: Literal["code_execution_20260120"]`

          - `"code_execution_20260120"`

  - `class BetaToolResultBlockParam: …`

    - `tool_use_id: str`

    - `type: Literal["tool_result"]`

      - `"tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `content: Optional[Union[str, List[Content], null]]`

      - `str`

      - `List[Content]`

        - `class BetaTextBlockParam: …`

        - `class BetaImageBlockParam: …`

        - `class BetaSearchResultBlockParam: …`

        - `class BetaRequestDocumentBlock: …`

        - `class BetaToolReferenceBlockParam: …`

          Tool reference block that can be included in tool_result content.

          - `tool_name: str`

          - `type: Literal["tool_reference"]`

            - `"tool_reference"`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

    - `is_error: Optional[bool]`

  - `class BetaServerToolUseBlockParam: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

      - `"advisor"`

      - `"web_search"`

      - `"web_fetch"`

      - `"code_execution"`

      - `"bash_code_execution"`

      - `"text_editor_code_execution"`

      - `"tool_search_tool_regex"`

      - `"tool_search_tool_bm25"`

    - `type: Literal["server_tool_use"]`

      - `"server_tool_use"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaWebSearchToolResultBlockParam: …`

    - `content: BetaWebSearchToolResultBlockParamContent`

      - `List[BetaWebSearchResultBlockParam]`

        - `encrypted_content: str`

        - `title: str`

        - `type: Literal["web_search_result"]`

          - `"web_search_result"`

        - `url: str`

        - `page_age: Optional[str]`

      - `class BetaWebSearchToolRequestError: …`

        - `error_code: BetaWebSearchToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"max_uses_exceeded"`

          - `"too_many_requests"`

          - `"query_too_long"`

          - `"request_too_large"`

        - `type: Literal["web_search_tool_result_error"]`

          - `"web_search_tool_result_error"`

    - `tool_use_id: str`

    - `type: Literal["web_search_tool_result"]`

      - `"web_search_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaWebFetchToolResultBlockParam: …`

    - `content: Content`

      - `class BetaWebFetchToolResultErrorBlockParam: …`

        - `error_code: BetaWebFetchToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"url_too_long"`

          - `"url_not_allowed"`

          - `"url_not_in_prior_context"`

          - `"url_not_accessible"`

          - `"unsupported_content_type"`

          - `"too_many_requests"`

          - `"max_uses_exceeded"`

          - `"unavailable"`

        - `type: Literal["web_fetch_tool_result_error"]`

          - `"web_fetch_tool_result_error"`

      - `class BetaWebFetchBlockParam: …`

        - `content: BetaRequestDocumentBlock`

        - `type: Literal["web_fetch_result"]`

          - `"web_fetch_result"`

        - `url: str`

          Fetched content URL

        - `retrieved_at: Optional[str]`

          ISO 8601 timestamp when the content was retrieved

    - `tool_use_id: str`

    - `type: Literal["web_fetch_tool_result"]`

      - `"web_fetch_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caller: Optional[Caller]`

      Tool invocation directly from the model.

      - `class BetaDirectCaller: …`

        Tool invocation directly from the model.

      - `class BetaServerToolCaller: …`

        Tool invocation generated by a server-side tool.

      - `class BetaServerToolCaller20260120: …`

  - `class BetaAdvisorToolResultBlockParam: …`

    - `content: Content`

      - `class BetaAdvisorToolResultErrorParam: …`

        - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

          - `"max_uses_exceeded"`

          - `"prompt_too_long"`

          - `"too_many_requests"`

          - `"overloaded"`

          - `"unavailable"`

          - `"execution_time_exceeded"`

        - `type: Literal["advisor_tool_result_error"]`

          - `"advisor_tool_result_error"`

      - `class BetaAdvisorResultBlockParam: …`

        - `text: str`

        - `type: Literal["advisor_result"]`

          - `"advisor_result"`

        - `stop_reason: Optional[str]`

      - `class BetaAdvisorRedactedResultBlockParam: …`

        - `encrypted_content: str`

          Opaque blob produced by a prior response; must be round-tripped verbatim.

        - `type: Literal["advisor_redacted_result"]`

          - `"advisor_redacted_result"`

        - `stop_reason: Optional[str]`

    - `tool_use_id: str`

    - `type: Literal["advisor_tool_result"]`

      - `"advisor_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaCodeExecutionToolResultBlockParam: …`

    - `content: BetaCodeExecutionToolResultBlockParamContent`

      Code execution result with encrypted stdout for PFC + web_search results.

      - `class BetaCodeExecutionToolResultErrorParam: …`

        - `error_code: BetaCodeExecutionToolResultErrorCode`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

        - `type: Literal["code_execution_tool_result_error"]`

          - `"code_execution_tool_result_error"`

      - `class BetaCodeExecutionResultBlockParam: …`

        - `content: List[BetaCodeExecutionOutputBlockParam]`

          - `file_id: str`

          - `type: Literal["code_execution_output"]`

            - `"code_execution_output"`

        - `return_code: int`

        - `stderr: str`

        - `stdout: str`

        - `type: Literal["code_execution_result"]`

          - `"code_execution_result"`

      - `class BetaEncryptedCodeExecutionResultBlockParam: …`

        Code execution result with encrypted stdout for PFC + web_search results.

        - `content: List[BetaCodeExecutionOutputBlockParam]`

          - `file_id: str`

          - `type: Literal["code_execution_output"]`

        - `encrypted_stdout: str`

        - `return_code: int`

        - `stderr: str`

        - `type: Literal["encrypted_code_execution_result"]`

          - `"encrypted_code_execution_result"`

    - `tool_use_id: str`

    - `type: Literal["code_execution_tool_result"]`

      - `"code_execution_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaBashCodeExecutionToolResultBlockParam: …`

    - `content: Content`

      - `class BetaBashCodeExecutionToolResultErrorParam: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

          - `"output_file_too_large"`

        - `type: Literal["bash_code_execution_tool_result_error"]`

          - `"bash_code_execution_tool_result_error"`

      - `class BetaBashCodeExecutionResultBlockParam: …`

        - `content: List[BetaBashCodeExecutionOutputBlockParam]`

          - `file_id: str`

          - `type: Literal["bash_code_execution_output"]`

            - `"bash_code_execution_output"`

        - `return_code: int`

        - `stderr: str`

        - `stdout: str`

        - `type: Literal["bash_code_execution_result"]`

          - `"bash_code_execution_result"`

    - `tool_use_id: str`

    - `type: Literal["bash_code_execution_tool_result"]`

      - `"bash_code_execution_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

    - `content: Content`

      - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

          - `"file_not_found"`

        - `type: Literal["text_editor_code_execution_tool_result_error"]`

          - `"text_editor_code_execution_tool_result_error"`

        - `error_message: Optional[str]`

      - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

        - `content: str`

        - `file_type: Literal["text", "image", "pdf"]`

          - `"text"`

          - `"image"`

          - `"pdf"`

        - `type: Literal["text_editor_code_execution_view_result"]`

          - `"text_editor_code_execution_view_result"`

        - `num_lines: Optional[int]`

        - `start_line: Optional[int]`

        - `total_lines: Optional[int]`

      - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

        - `is_file_update: bool`

        - `type: Literal["text_editor_code_execution_create_result"]`

          - `"text_editor_code_execution_create_result"`

      - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

        - `type: Literal["text_editor_code_execution_str_replace_result"]`

          - `"text_editor_code_execution_str_replace_result"`

        - `lines: Optional[List[str]]`

        - `new_lines: Optional[int]`

        - `new_start: Optional[int]`

        - `old_lines: Optional[int]`

        - `old_start: Optional[int]`

    - `tool_use_id: str`

    - `type: Literal["text_editor_code_execution_tool_result"]`

      - `"text_editor_code_execution_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaToolSearchToolResultBlockParam: …`

    - `content: Content`

      - `class BetaToolSearchToolResultErrorParam: …`

        - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

          - `"invalid_tool_input"`

          - `"unavailable"`

          - `"too_many_requests"`

          - `"execution_time_exceeded"`

        - `type: Literal["tool_search_tool_result_error"]`

          - `"tool_search_tool_result_error"`

      - `class BetaToolSearchToolSearchResultBlockParam: …`

        - `tool_references: List[BetaToolReferenceBlockParam]`

          - `tool_name: str`

          - `type: Literal["tool_reference"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

        - `type: Literal["tool_search_tool_search_result"]`

          - `"tool_search_tool_search_result"`

    - `tool_use_id: str`

    - `type: Literal["tool_search_tool_result"]`

      - `"tool_search_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaMCPToolUseBlockParam: …`

    - `id: str`

    - `input: Dict[str, object]`

    - `name: str`

    - `server_name: str`

      The name of the MCP server

    - `type: Literal["mcp_tool_use"]`

      - `"mcp_tool_use"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaRequestMCPToolResultBlockParam: …`

    - `tool_use_id: str`

    - `type: Literal["mcp_tool_result"]`

      - `"mcp_tool_result"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

      - `str`

      - `List[BetaTextBlockParam]`

        - `text: str`

        - `type: Literal["text"]`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[List[BetaTextCitationParam]]`

    - `is_error: Optional[bool]`

  - `class BetaContainerUploadBlockParam: …`

    A content block that represents a file to be uploaded to the container
    Files uploaded via this block will be available in the container's input directory.

    - `file_id: str`

    - `type: Literal["container_upload"]`

      - `"container_upload"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

  - `class BetaCompactionBlockParam: …`

    A compaction block containing summary of previous context.

    Users should round-trip these blocks from responses to subsequent requests
    to maintain context across compaction boundaries.

    When content is None, the block represents a failed compaction. The server
    treats these as no-ops. Empty string content is not allowed.

    - `type: Literal["compaction"]`

      - `"compaction"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `content: Optional[str]`

      Summary of previously compacted content, or null if compaction failed

    - `encrypted_content: Optional[str]`

      Opaque metadata from prior compaction, to be round-tripped verbatim

  - `class BetaMidConversationSystemBlockParam: …`

    System instructions that appear mid-conversation.

    Use this block to provide or update system-level instructions at a specific
    point in the conversation, rather than only via the top-level `system` parameter.

    - `content: List[BetaTextBlockParam]`

      System instruction text blocks.

      - `text: str`

      - `type: Literal["text"]`

      - `cache_control: Optional[BetaCacheControlEphemeral]`

        Create a cache control breakpoint at this content block.

      - `citations: Optional[List[BetaTextCitationParam]]`

    - `type: Literal["mid_conv_system"]`

      - `"mid_conv_system"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

### Beta Content Block Source

- `class BetaContentBlockSource: …`

  - `content: Union[str, List[BetaContentBlockSourceContent]]`

    - `str`

    - `List[BetaContentBlockSourceContent]`

      - `class BetaTextBlockParam: …`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

          - `type: Literal["ephemeral"]`

            - `"ephemeral"`

          - `ttl: Optional[Literal["5m", "1h"]]`

            The time-to-live for the cache control breakpoint.

            This may be one the following values:

            - `5m`: 5 minutes
            - `1h`: 1 hour

            Defaults to `5m`.

            - `"5m"`

            - `"1h"`

        - `citations: Optional[List[BetaTextCitationParam]]`

          - `class BetaCitationCharLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationWebSearchResultLocationParam: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

      - `class BetaImageBlockParam: …`

        - `source: Source`

          - `class BetaBase64ImageSource: …`

            - `data: str`

            - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

              - `"image/jpeg"`

              - `"image/png"`

              - `"image/gif"`

              - `"image/webp"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaURLImageSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileImageSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

  - `type: Literal["content"]`

    - `"content"`

### Beta Content Block Source Content

- `BetaContentBlockSourceContent`

  - `class BetaTextBlockParam: …`

    - `text: str`

    - `type: Literal["text"]`

      - `"text"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

    - `citations: Optional[List[BetaTextCitationParam]]`

      - `class BetaCitationCharLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationWebSearchResultLocationParam: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

  - `class BetaImageBlockParam: …`

    - `source: Source`

      - `class BetaBase64ImageSource: …`

        - `data: str`

        - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

          - `"image/jpeg"`

          - `"image/png"`

          - `"image/gif"`

          - `"image/webp"`

        - `type: Literal["base64"]`

          - `"base64"`

      - `class BetaURLImageSource: …`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `class BetaFileImageSource: …`

        - `file_id: str`

        - `type: Literal["file"]`

          - `"file"`

    - `type: Literal["image"]`

      - `"image"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

### Beta Context Management Config

- `class BetaContextManagementConfig: …`

  - `edits: Optional[List[Edit]]`

    List of context management edits to apply

    - `class BetaClearToolUses20250919Edit: …`

      - `type: Literal["clear_tool_uses_20250919"]`

        - `"clear_tool_uses_20250919"`

      - `clear_at_least: Optional[BetaInputTokensClearAtLeast]`

        Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.

        - `type: Literal["input_tokens"]`

          - `"input_tokens"`

        - `value: int`

      - `clear_tool_inputs: Optional[Union[bool, List[str], null]]`

        Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

        - `bool`

        - `List[str]`

      - `exclude_tools: Optional[List[str]]`

        Tool names whose uses are preserved from clearing

      - `keep: Optional[BetaToolUsesKeep]`

        Number of tool uses to retain in the conversation

        - `type: Literal["tool_uses"]`

          - `"tool_uses"`

        - `value: int`

      - `trigger: Optional[Trigger]`

        Condition that triggers the context management strategy

        - `class BetaInputTokensTrigger: …`

          - `type: Literal["input_tokens"]`

            - `"input_tokens"`

          - `value: int`

        - `class BetaToolUsesTrigger: …`

          - `type: Literal["tool_uses"]`

            - `"tool_uses"`

          - `value: int`

    - `class BetaClearThinking20251015Edit: …`

      - `type: Literal["clear_thinking_20251015"]`

        - `"clear_thinking_20251015"`

      - `keep: Optional[Keep]`

        Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.

        - `class BetaThinkingTurns: …`

          - `type: Literal["thinking_turns"]`

            - `"thinking_turns"`

          - `value: int`

        - `class BetaAllThinkingTurns: …`

          - `type: Literal["all"]`

            - `"all"`

        - `Literal["all"]`

          - `"all"`

    - `class BetaCompact20260112Edit: …`

      Automatically compact older context when reaching the configured trigger threshold.

      - `type: Literal["compact_20260112"]`

        - `"compact_20260112"`

      - `instructions: Optional[str]`

        Additional instructions for summarization.

      - `pause_after_compaction: Optional[bool]`

        Whether to pause after compaction and return the compaction block to the user.

      - `trigger: Optional[BetaInputTokensTrigger]`

        When to trigger compaction. Defaults to 150000 input tokens.

### Beta Context Management Response

- `class BetaContextManagementResponse: …`

  - `applied_edits: List[AppliedEdit]`

    List of context management edits that were applied.

    - `class BetaClearToolUses20250919EditResponse: …`

      - `cleared_input_tokens: int`

        Number of input tokens cleared by this edit.

      - `cleared_tool_uses: int`

        Number of tool uses that were cleared.

      - `type: Literal["clear_tool_uses_20250919"]`

        The type of context management edit applied.

        - `"clear_tool_uses_20250919"`

    - `class BetaClearThinking20251015EditResponse: …`

      - `cleared_input_tokens: int`

        Number of input tokens cleared by this edit.

      - `cleared_thinking_turns: int`

        Number of thinking turns that were cleared.

      - `type: Literal["clear_thinking_20251015"]`

        The type of context management edit applied.

        - `"clear_thinking_20251015"`

### Beta Count Tokens Context Management Response

- `class BetaCountTokensContextManagementResponse: …`

  - `original_input_tokens: int`

    The original token count before context management was applied

### Beta Diagnostics

- `class BetaDiagnostics: …`

  Response envelope for request-level diagnostics. Present (possibly
  null) whenever the caller supplied `diagnostics` on the request.

  - `cache_miss_reason: Optional[CacheMissReason]`

    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.

    - `class BetaCacheMissModelChanged: …`

      - `cache_missed_input_tokens: int`

        Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

      - `type: Literal["model_changed"]`

        - `"model_changed"`

    - `class BetaCacheMissSystemChanged: …`

      - `cache_missed_input_tokens: int`

        Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

      - `type: Literal["system_changed"]`

        - `"system_changed"`

    - `class BetaCacheMissToolsChanged: …`

      - `cache_missed_input_tokens: int`

        Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

      - `type: Literal["tools_changed"]`

        - `"tools_changed"`

    - `class BetaCacheMissMessagesChanged: …`

      - `cache_missed_input_tokens: int`

        Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

      - `type: Literal["messages_changed"]`

        - `"messages_changed"`

    - `class BetaCacheMissPreviousMessageNotFound: …`

      - `type: Literal["previous_message_not_found"]`

        - `"previous_message_not_found"`

    - `class BetaCacheMissUnavailable: …`

      - `type: Literal["unavailable"]`

        - `"unavailable"`

### Beta Diagnostics Param

- `class BetaDiagnosticsParam: …`

  Request-level diagnostics. Currently carries the previous response
  id for prompt-cache divergence reporting.

  - `previous_message_id: Optional[str]`

    The `id` (`msg_...`) from this client's previous /v1/messages response. The server compares that request's prompt fingerprint against this one and returns `diagnostics.cache_miss_reason` when the prompt-cache prefix could not be reused. Pass `null` on the first turn to opt in without a prior message to compare.

### Beta Direct Caller

- `class BetaDirectCaller: …`

  Tool invocation directly from the model.

  - `type: Literal["direct"]`

    - `"direct"`

### Beta Document Block

- `class BetaDocumentBlock: …`

  - `citations: Optional[BetaCitationConfig]`

    Citation configuration for the document

    - `enabled: bool`

  - `source: Source`

    - `class BetaBase64PDFSource: …`

      - `data: str`

      - `media_type: Literal["application/pdf"]`

        - `"application/pdf"`

      - `type: Literal["base64"]`

        - `"base64"`

    - `class BetaPlainTextSource: …`

      - `data: str`

      - `media_type: Literal["text/plain"]`

        - `"text/plain"`

      - `type: Literal["text"]`

        - `"text"`

  - `title: Optional[str]`

    The title of the document

  - `type: Literal["document"]`

    - `"document"`

### Beta Encrypted Code Execution Result Block

- `class BetaEncryptedCodeExecutionResultBlock: …`

  Code execution result with encrypted stdout for PFC + web_search results.

  - `content: List[BetaCodeExecutionOutputBlock]`

    - `file_id: str`

    - `type: Literal["code_execution_output"]`

      - `"code_execution_output"`

  - `encrypted_stdout: str`

  - `return_code: int`

  - `stderr: str`

  - `type: Literal["encrypted_code_execution_result"]`

    - `"encrypted_code_execution_result"`

### Beta Encrypted Code Execution Result Block Param

- `class BetaEncryptedCodeExecutionResultBlockParam: …`

  Code execution result with encrypted stdout for PFC + web_search results.

  - `content: List[BetaCodeExecutionOutputBlockParam]`

    - `file_id: str`

    - `type: Literal["code_execution_output"]`

      - `"code_execution_output"`

  - `encrypted_stdout: str`

  - `return_code: int`

  - `stderr: str`

  - `type: Literal["encrypted_code_execution_result"]`

    - `"encrypted_code_execution_result"`

### Beta File Document Source

- `class BetaFileDocumentSource: …`

  - `file_id: str`

  - `type: Literal["file"]`

    - `"file"`

### Beta File Image Source

- `class BetaFileImageSource: …`

  - `file_id: str`

  - `type: Literal["file"]`

    - `"file"`

### Beta Image Block Param

- `class BetaImageBlockParam: …`

  - `source: Source`

    - `class BetaBase64ImageSource: …`

      - `data: str`

      - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

        - `"image/jpeg"`

        - `"image/png"`

        - `"image/gif"`

        - `"image/webp"`

      - `type: Literal["base64"]`

        - `"base64"`

    - `class BetaURLImageSource: …`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `class BetaFileImageSource: …`

      - `file_id: str`

      - `type: Literal["file"]`

        - `"file"`

  - `type: Literal["image"]`

    - `"image"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Input JSON Delta

- `class BetaInputJSONDelta: …`

  - `partial_json: str`

  - `type: Literal["input_json_delta"]`

    - `"input_json_delta"`

### Beta Input Tokens Clear At Least

- `class BetaInputTokensClearAtLeast: …`

  - `type: Literal["input_tokens"]`

    - `"input_tokens"`

  - `value: int`

### Beta Input Tokens Trigger

- `class BetaInputTokensTrigger: …`

  - `type: Literal["input_tokens"]`

    - `"input_tokens"`

  - `value: int`

### Beta Iterations Usage

- `Optional[List[BetaIterationsUsageItem]]`

  Per-iteration token usage breakdown.

  Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

  - Determine which iterations exceeded long context thresholds (>=200k tokens)
  - Calculate the true context window size from the last iteration
  - Understand token accumulation across server-side tool use loops

  - `class BetaMessageIterationUsage: …`

    Token usage for a sampling iteration.

    - `cache_creation: Optional[BetaCacheCreation]`

      Breakdown of cached tokens by TTL

      - `ephemeral_1h_input_tokens: int`

        The number of input tokens used to create the 1 hour cache entry.

      - `ephemeral_5m_input_tokens: int`

        The number of input tokens used to create the 5 minute cache entry.

    - `cache_creation_input_tokens: int`

      The number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: int`

      The number of input tokens read from the cache.

    - `input_tokens: int`

      The number of input tokens which were used.

    - `output_tokens: int`

      The number of output tokens which were used.

    - `type: Literal["message"]`

      Usage for a sampling iteration

      - `"message"`

  - `class BetaCompactionIterationUsage: …`

    Token usage for a compaction iteration.

    - `cache_creation: Optional[BetaCacheCreation]`

      Breakdown of cached tokens by TTL

    - `cache_creation_input_tokens: int`

      The number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: int`

      The number of input tokens read from the cache.

    - `input_tokens: int`

      The number of input tokens which were used.

    - `output_tokens: int`

      The number of output tokens which were used.

    - `type: Literal["compaction"]`

      Usage for a compaction iteration

      - `"compaction"`

  - `class BetaAdvisorMessageIterationUsage: …`

    Token usage for an advisor sub-inference iteration.

    - `cache_creation: Optional[BetaCacheCreation]`

      Breakdown of cached tokens by TTL

    - `cache_creation_input_tokens: int`

      The number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: int`

      The number of input tokens read from the cache.

    - `input_tokens: int`

      The number of input tokens which were used.

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
        - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
        - `claude-opus-4-1` - Exceptional model for specialized complex tasks
        - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
        - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-mythos-preview"`

          New class of intelligence, strongest in coding and cybersecurity

        - `"claude-opus-4-6"`

          Frontier intelligence for long-running agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

        - `"claude-opus-4-1"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-1-20250805"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-0"`

          Powerful model for complex tasks

        - `"claude-opus-4-20250514"`

          Powerful model for complex tasks

        - `"claude-sonnet-4-0"`

          High-performance model with extended thinking

        - `"claude-sonnet-4-20250514"`

          High-performance model with extended thinking

        - `"claude-3-haiku-20240307"`

          Fast and cost-effective model

      - `str`

    - `output_tokens: int`

      The number of output tokens which were used.

    - `type: Literal["advisor_message"]`

      Usage for an advisor sub-inference iteration

      - `"advisor_message"`

### Beta JSON Output Format

- `class BetaJSONOutputFormat: …`

  - `schema: Dict[str, object]`

    The JSON schema of the format

  - `type: Literal["json_schema"]`

    - `"json_schema"`

### Beta MCP Tool Config

- `class BetaMCPToolConfig: …`

  Configuration for a specific tool in an MCP toolset.

  - `defer_loading: Optional[bool]`

  - `enabled: Optional[bool]`

### Beta MCP Tool Default Config

- `class BetaMCPToolDefaultConfig: …`

  Default configuration for tools in an MCP toolset.

  - `defer_loading: Optional[bool]`

  - `enabled: Optional[bool]`

### Beta MCP Tool Result Block

- `class BetaMCPToolResultBlock: …`

  - `content: Union[str, List[BetaTextBlock]]`

    - `str`

    - `List[BetaTextBlock]`

      - `citations: Optional[List[BetaTextCitation]]`

        Citations supporting the text block.

        The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

        - `class BetaCitationCharLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `file_id: Optional[str]`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `file_id: Optional[str]`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `file_id: Optional[str]`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationsWebSearchResultLocation: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

      - `text: str`

      - `type: Literal["text"]`

        - `"text"`

  - `is_error: bool`

  - `tool_use_id: str`

  - `type: Literal["mcp_tool_result"]`

    - `"mcp_tool_result"`

### Beta MCP Tool Use Block

- `class BetaMCPToolUseBlock: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: str`

    The name of the MCP tool

  - `server_name: str`

    The name of the MCP server

  - `type: Literal["mcp_tool_use"]`

    - `"mcp_tool_use"`

### Beta MCP Tool Use Block Param

- `class BetaMCPToolUseBlockParam: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: str`

  - `server_name: str`

    The name of the MCP server

  - `type: Literal["mcp_tool_use"]`

    - `"mcp_tool_use"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta MCP Toolset

- `class BetaMCPToolset: …`

  Configuration for a group of tools from an MCP server.

  Allows configuring enabled status and defer_loading for all tools
  from an MCP server, with optional per-tool overrides.

  - `mcp_server_name: str`

    Name of the MCP server to configure tools for

  - `type: Literal["mcp_toolset"]`

    - `"mcp_toolset"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `configs: Optional[Dict[str, BetaMCPToolConfig]]`

    Configuration overrides for specific tools, keyed by tool name

    - `defer_loading: Optional[bool]`

    - `enabled: Optional[bool]`

  - `default_config: Optional[BetaMCPToolDefaultConfig]`

    Default configuration applied to all tools from this server

    - `defer_loading: Optional[bool]`

    - `enabled: Optional[bool]`

### Beta Memory Tool 20250818

- `class BetaMemoryTool20250818: …`

  - `name: Literal["memory"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"memory"`

  - `type: Literal["memory_20250818"]`

    - `"memory_20250818"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Memory Tool 20250818 Command

- `BetaMemoryTool20250818Command`

  - `class BetaMemoryTool20250818ViewCommand: …`

    - `command: Literal["view"]`

      Command type identifier

      - `"view"`

    - `path: str`

      Path to directory or file to view

    - `view_range: Optional[List[int]]`

      Optional line range for viewing specific lines

  - `class BetaMemoryTool20250818CreateCommand: …`

    - `command: Literal["create"]`

      Command type identifier

      - `"create"`

    - `file_text: str`

      Content to write to the file

    - `path: str`

      Path where the file should be created

  - `class BetaMemoryTool20250818StrReplaceCommand: …`

    - `command: Literal["str_replace"]`

      Command type identifier

      - `"str_replace"`

    - `new_str: str`

      Text to replace with

    - `old_str: str`

      Text to search for and replace

    - `path: str`

      Path to the file where text should be replaced

  - `class BetaMemoryTool20250818InsertCommand: …`

    - `command: Literal["insert"]`

      Command type identifier

      - `"insert"`

    - `insert_line: int`

      Line number where text should be inserted

    - `insert_text: str`

      Text to insert at the specified line

    - `path: str`

      Path to the file where text should be inserted

  - `class BetaMemoryTool20250818DeleteCommand: …`

    - `command: Literal["delete"]`

      Command type identifier

      - `"delete"`

    - `path: str`

      Path to the file or directory to delete

  - `class BetaMemoryTool20250818RenameCommand: …`

    - `command: Literal["rename"]`

      Command type identifier

      - `"rename"`

    - `new_path: str`

      New path for the file or directory

    - `old_path: str`

      Current path of the file or directory

### Beta Memory Tool 20250818 Create Command

- `class BetaMemoryTool20250818CreateCommand: …`

  - `command: Literal["create"]`

    Command type identifier

    - `"create"`

  - `file_text: str`

    Content to write to the file

  - `path: str`

    Path where the file should be created

### Beta Memory Tool 20250818 Delete Command

- `class BetaMemoryTool20250818DeleteCommand: …`

  - `command: Literal["delete"]`

    Command type identifier

    - `"delete"`

  - `path: str`

    Path to the file or directory to delete

### Beta Memory Tool 20250818 Insert Command

- `class BetaMemoryTool20250818InsertCommand: …`

  - `command: Literal["insert"]`

    Command type identifier

    - `"insert"`

  - `insert_line: int`

    Line number where text should be inserted

  - `insert_text: str`

    Text to insert at the specified line

  - `path: str`

    Path to the file where text should be inserted

### Beta Memory Tool 20250818 Rename Command

- `class BetaMemoryTool20250818RenameCommand: …`

  - `command: Literal["rename"]`

    Command type identifier

    - `"rename"`

  - `new_path: str`

    New path for the file or directory

  - `old_path: str`

    Current path of the file or directory

### Beta Memory Tool 20250818 Str Replace Command

- `class BetaMemoryTool20250818StrReplaceCommand: …`

  - `command: Literal["str_replace"]`

    Command type identifier

    - `"str_replace"`

  - `new_str: str`

    Text to replace with

  - `old_str: str`

    Text to search for and replace

  - `path: str`

    Path to the file where text should be replaced

### Beta Memory Tool 20250818 View Command

- `class BetaMemoryTool20250818ViewCommand: …`

  - `command: Literal["view"]`

    Command type identifier

    - `"view"`

  - `path: str`

    Path to directory or file to view

  - `view_range: Optional[List[int]]`

    Optional line range for viewing specific lines

### Beta Message

- `class BetaMessage: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `container: Optional[BetaContainer]`

    Information about the container used in the request (for the code execution tool)

    - `id: str`

      Identifier for the container used in this request

    - `expires_at: datetime`

      The time at which the container will expire.

    - `skills: Optional[List[BetaSkill]]`

      Skills loaded in the container

      - `skill_id: str`

        Skill ID

      - `type: Literal["anthropic", "custom"]`

        Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

        - `"anthropic"`

        - `"custom"`

      - `version: str`

        Skill version or 'latest' for most recent version

  - `content: List[BetaContentBlock]`

    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 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.

    For example, if the input `messages` were:

    ```json
    [
      {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
      {"role": "assistant", "content": "The best answer is ("}
    ]
    ```

    Then the response `content` might be:

    ```json
    [{"type": "text", "text": "B)"}]
    ```

    - `class BetaTextBlock: …`

      - `citations: Optional[List[BetaTextCitation]]`

        Citations supporting the text block.

        The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

        - `class BetaCitationCharLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `file_id: Optional[str]`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `file_id: Optional[str]`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `file_id: Optional[str]`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationsWebSearchResultLocation: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

      - `text: str`

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaThinkingBlock: …`

      - `signature: str`

      - `thinking: str`

      - `type: Literal["thinking"]`

        - `"thinking"`

    - `class BetaRedactedThinkingBlock: …`

      - `data: str`

      - `type: Literal["redacted_thinking"]`

        - `"redacted_thinking"`

    - `class BetaToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

      - `type: Literal["tool_use"]`

        - `"tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

          - `type: Literal["direct"]`

            - `"direct"`

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

          - `tool_id: str`

          - `type: Literal["code_execution_20250825"]`

            - `"code_execution_20250825"`

        - `class BetaServerToolCaller20260120: …`

          - `tool_id: str`

          - `type: Literal["code_execution_20260120"]`

            - `"code_execution_20260120"`

    - `class BetaServerToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

        - `"advisor"`

        - `"web_search"`

        - `"web_fetch"`

        - `"code_execution"`

        - `"bash_code_execution"`

        - `"text_editor_code_execution"`

        - `"tool_search_tool_regex"`

        - `"tool_search_tool_bm25"`

      - `type: Literal["server_tool_use"]`

        - `"server_tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebSearchToolResultBlock: …`

      - `content: BetaWebSearchToolResultBlockContent`

        - `class BetaWebSearchToolResultError: …`

          - `error_code: BetaWebSearchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"max_uses_exceeded"`

            - `"too_many_requests"`

            - `"query_too_long"`

            - `"request_too_large"`

          - `type: Literal["web_search_tool_result_error"]`

            - `"web_search_tool_result_error"`

        - `List[BetaWebSearchResultBlock]`

          - `encrypted_content: str`

          - `page_age: Optional[str]`

          - `title: str`

          - `type: Literal["web_search_result"]`

            - `"web_search_result"`

          - `url: str`

      - `tool_use_id: str`

      - `type: Literal["web_search_tool_result"]`

        - `"web_search_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebFetchToolResultBlock: …`

      - `content: Content`

        - `class BetaWebFetchToolResultErrorBlock: …`

          - `error_code: BetaWebFetchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"url_too_long"`

            - `"url_not_allowed"`

            - `"url_not_in_prior_context"`

            - `"url_not_accessible"`

            - `"unsupported_content_type"`

            - `"too_many_requests"`

            - `"max_uses_exceeded"`

            - `"unavailable"`

          - `type: Literal["web_fetch_tool_result_error"]`

            - `"web_fetch_tool_result_error"`

        - `class BetaWebFetchBlock: …`

          - `content: BetaDocumentBlock`

            - `citations: Optional[BetaCitationConfig]`

              Citation configuration for the document

              - `enabled: bool`

            - `source: Source`

              - `class BetaBase64PDFSource: …`

                - `data: str`

                - `media_type: Literal["application/pdf"]`

                  - `"application/pdf"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaPlainTextSource: …`

                - `data: str`

                - `media_type: Literal["text/plain"]`

                  - `"text/plain"`

                - `type: Literal["text"]`

                  - `"text"`

            - `title: Optional[str]`

              The title of the document

            - `type: Literal["document"]`

              - `"document"`

          - `retrieved_at: Optional[str]`

            ISO 8601 timestamp when the content was retrieved

          - `type: Literal["web_fetch_result"]`

            - `"web_fetch_result"`

          - `url: str`

            Fetched content URL

      - `tool_use_id: str`

      - `type: Literal["web_fetch_tool_result"]`

        - `"web_fetch_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaAdvisorToolResultBlock: …`

      - `content: Content`

        - `class BetaAdvisorToolResultError: …`

          - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

            - `"max_uses_exceeded"`

            - `"prompt_too_long"`

            - `"too_many_requests"`

            - `"overloaded"`

            - `"unavailable"`

            - `"execution_time_exceeded"`

          - `type: Literal["advisor_tool_result_error"]`

            - `"advisor_tool_result_error"`

        - `class BetaAdvisorResultBlock: …`

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

          - `text: str`

          - `type: Literal["advisor_result"]`

            - `"advisor_result"`

        - `class BetaAdvisorRedactedResultBlock: …`

          - `encrypted_content: str`

            Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

          - `type: Literal["advisor_redacted_result"]`

            - `"advisor_redacted_result"`

      - `tool_use_id: str`

      - `type: Literal["advisor_tool_result"]`

        - `"advisor_tool_result"`

    - `class BetaCodeExecutionToolResultBlock: …`

      - `content: BetaCodeExecutionToolResultBlockContent`

        Code execution result with encrypted stdout for PFC + web_search results.

        - `class BetaCodeExecutionToolResultError: …`

          - `error_code: BetaCodeExecutionToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `type: Literal["code_execution_tool_result_error"]`

            - `"code_execution_tool_result_error"`

        - `class BetaCodeExecutionResultBlock: …`

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

              - `"code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["code_execution_result"]`

            - `"code_execution_result"`

        - `class BetaEncryptedCodeExecutionResultBlock: …`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

          - `encrypted_stdout: str`

          - `return_code: int`

          - `stderr: str`

          - `type: Literal["encrypted_code_execution_result"]`

            - `"encrypted_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["code_execution_tool_result"]`

        - `"code_execution_tool_result"`

    - `class BetaBashCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaBashCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"output_file_too_large"`

          - `type: Literal["bash_code_execution_tool_result_error"]`

            - `"bash_code_execution_tool_result_error"`

        - `class BetaBashCodeExecutionResultBlock: …`

          - `content: List[BetaBashCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["bash_code_execution_output"]`

              - `"bash_code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["bash_code_execution_result"]`

            - `"bash_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["bash_code_execution_tool_result"]`

        - `"bash_code_execution_tool_result"`

    - `class BetaTextEditorCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaTextEditorCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"file_not_found"`

          - `error_message: Optional[str]`

          - `type: Literal["text_editor_code_execution_tool_result_error"]`

            - `"text_editor_code_execution_tool_result_error"`

        - `class BetaTextEditorCodeExecutionViewResultBlock: …`

          - `content: str`

          - `file_type: Literal["text", "image", "pdf"]`

            - `"text"`

            - `"image"`

            - `"pdf"`

          - `num_lines: Optional[int]`

          - `start_line: Optional[int]`

          - `total_lines: Optional[int]`

          - `type: Literal["text_editor_code_execution_view_result"]`

            - `"text_editor_code_execution_view_result"`

        - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

          - `is_file_update: bool`

          - `type: Literal["text_editor_code_execution_create_result"]`

            - `"text_editor_code_execution_create_result"`

        - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

          - `lines: Optional[List[str]]`

          - `new_lines: Optional[int]`

          - `new_start: Optional[int]`

          - `old_lines: Optional[int]`

          - `old_start: Optional[int]`

          - `type: Literal["text_editor_code_execution_str_replace_result"]`

            - `"text_editor_code_execution_str_replace_result"`

      - `tool_use_id: str`

      - `type: Literal["text_editor_code_execution_tool_result"]`

        - `"text_editor_code_execution_tool_result"`

    - `class BetaToolSearchToolResultBlock: …`

      - `content: Content`

        - `class BetaToolSearchToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `error_message: Optional[str]`

          - `type: Literal["tool_search_tool_result_error"]`

            - `"tool_search_tool_result_error"`

        - `class BetaToolSearchToolSearchResultBlock: …`

          - `tool_references: List[BetaToolReferenceBlock]`

            - `tool_name: str`

            - `type: Literal["tool_reference"]`

              - `"tool_reference"`

          - `type: Literal["tool_search_tool_search_result"]`

            - `"tool_search_tool_search_result"`

      - `tool_use_id: str`

      - `type: Literal["tool_search_tool_result"]`

        - `"tool_search_tool_result"`

    - `class BetaMCPToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

        The name of the MCP tool

      - `server_name: str`

        The name of the MCP server

      - `type: Literal["mcp_tool_use"]`

        - `"mcp_tool_use"`

    - `class BetaMCPToolResultBlock: …`

      - `content: Union[str, List[BetaTextBlock]]`

        - `str`

        - `List[BetaTextBlock]`

          - `citations: Optional[List[BetaTextCitation]]`

            Citations supporting the text block.

            The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

          - `text: str`

          - `type: Literal["text"]`

      - `is_error: bool`

      - `tool_use_id: str`

      - `type: Literal["mcp_tool_result"]`

        - `"mcp_tool_result"`

    - `class BetaContainerUploadBlock: …`

      Response model for a file uploaded to the container.

      - `file_id: str`

      - `type: Literal["container_upload"]`

        - `"container_upload"`

    - `class BetaCompactionBlock: …`

      A compaction block returned when autocompact is triggered.

      When content is None, it indicates the compaction failed to produce a valid
      summary (e.g., malformed output from the model). Clients may round-trip
      compaction blocks with null content; the server treats them as no-ops.

      - `content: Optional[str]`

        Summary of compacted content, or null if compaction failed

      - `encrypted_content: Optional[str]`

        Opaque metadata from prior compaction, to be round-tripped verbatim

      - `type: Literal["compaction"]`

        - `"compaction"`

  - `context_management: Optional[BetaContextManagementResponse]`

    Context management response.

    Information about context management strategies applied during the request.

    - `applied_edits: List[AppliedEdit]`

      List of context management edits that were applied.

      - `class BetaClearToolUses20250919EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_tool_uses: int`

          Number of tool uses that were cleared.

        - `type: Literal["clear_tool_uses_20250919"]`

          The type of context management edit applied.

          - `"clear_tool_uses_20250919"`

      - `class BetaClearThinking20251015EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_thinking_turns: int`

          Number of thinking turns that were cleared.

        - `type: Literal["clear_thinking_20251015"]`

          The type of context management edit applied.

          - `"clear_thinking_20251015"`

  - `diagnostics: Optional[BetaDiagnostics]`

    Response envelope for request-level diagnostics. Present (possibly
    null) whenever the caller supplied `diagnostics` on the request.

    - `cache_miss_reason: Optional[CacheMissReason]`

      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.

      - `class BetaCacheMissModelChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["model_changed"]`

          - `"model_changed"`

      - `class BetaCacheMissSystemChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["system_changed"]`

          - `"system_changed"`

      - `class BetaCacheMissToolsChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["tools_changed"]`

          - `"tools_changed"`

      - `class BetaCacheMissMessagesChanged: …`

        - `cache_missed_input_tokens: int`

          Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

        - `type: Literal["messages_changed"]`

          - `"messages_changed"`

      - `class BetaCacheMissPreviousMessageNotFound: …`

        - `type: Literal["previous_message_not_found"]`

          - `"previous_message_not_found"`

      - `class BetaCacheMissUnavailable: …`

        - `type: Literal["unavailable"]`

          - `"unavailable"`

  - `model: Model`

    The model that will complete your prompt.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
      - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
      - `claude-opus-4-1` - Exceptional model for specialized complex tasks
      - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
      - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
      - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-mythos-preview"`

        New class of intelligence, strongest in coding and cybersecurity

      - `"claude-opus-4-6"`

        Frontier intelligence for long-running agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

      - `"claude-opus-4-1"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-1-20250805"`

        Exceptional model for specialized complex tasks

      - `"claude-opus-4-0"`

        Powerful model for complex tasks

      - `"claude-opus-4-20250514"`

        Powerful model for complex tasks

      - `"claude-sonnet-4-0"`

        High-performance model with extended thinking

      - `"claude-sonnet-4-20250514"`

        High-performance model with extended thinking

      - `"claude-3-haiku-20240307"`

        Fast and cost-effective model

    - `str`

  - `role: Literal["assistant"]`

    Conversational role of the generated message.

    This will always be `"assistant"`.

    - `"assistant"`

  - `stop_details: Optional[BetaRefusalStopDetails]`

    Structured information about a refusal.

    - `category: Optional[Literal["cyber", "bio"]]`

      The policy category that triggered the refusal.

      `null` when the refusal doesn't map to a named category.

      - `"cyber"`

      - `"bio"`

    - `explanation: Optional[str]`

      Human-readable explanation of the refusal.

      This text is not guaranteed to be stable. `null` when no explanation is available for the category.

    - `type: Literal["refusal"]`

      - `"refusal"`

  - `stop_reason: Optional[BetaStopReason]`

    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 maximum
    * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
    * `"tool_use"`: the model invoked one or more tools
    * `"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.
    * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

    In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

    - `"end_turn"`

    - `"max_tokens"`

    - `"stop_sequence"`

    - `"tool_use"`

    - `"pause_turn"`

    - `"compaction"`

    - `"refusal"`

    - `"model_context_window_exceeded"`

  - `stop_sequence: Optional[str]`

    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.

  - `type: Literal["message"]`

    Object type.

    For Messages, this is always `"message"`.

    - `"message"`

  - `usage: BetaUsage`

    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 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.

    For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

    Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

    - `cache_creation: Optional[BetaCacheCreation]`

      Breakdown of cached tokens by TTL

      - `ephemeral_1h_input_tokens: int`

        The number of input tokens used to create the 1 hour cache entry.

      - `ephemeral_5m_input_tokens: int`

        The number of input tokens used to create the 5 minute cache entry.

    - `cache_creation_input_tokens: Optional[int]`

      The number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: Optional[int]`

      The number of input tokens read from the cache.

    - `inference_geo: Optional[str]`

      The geographic region where inference was performed for this request.

    - `input_tokens: int`

      The number of input tokens which were used.

    - `iterations: Optional[BetaIterationsUsage]`

      Per-iteration token usage breakdown.

      Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

      - Determine which iterations exceeded long context thresholds (>=200k tokens)
      - Calculate the true context window size from the last iteration
      - Understand token accumulation across server-side tool use loops

      - `class BetaMessageIterationUsage: …`

        Token usage for a sampling iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["message"]`

          Usage for a sampling iteration

          - `"message"`

      - `class BetaCompactionIterationUsage: …`

        Token usage for a compaction iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["compaction"]`

          Usage for a compaction iteration

          - `"compaction"`

      - `class BetaAdvisorMessageIterationUsage: …`

        Token usage for an advisor sub-inference iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["advisor_message"]`

          Usage for an advisor sub-inference iteration

          - `"advisor_message"`

    - `output_tokens: int`

      The number of output tokens which were used.

    - `output_tokens_details: Optional[BetaOutputTokensDetails]`

      Breakdown of output tokens by category.

      `output_tokens` remains the inclusive, authoritative total used for billing.
      This object provides a read-only decomposition for observability — for example,
      how many of the billed output tokens were spent on internal reasoning that may
      have been summarized before being returned to you.

      - `thinking_tokens: int`

        Number of output tokens the model generated as internal reasoning, including
        the thinking-block delimiter tokens.

        Reflects the raw reasoning the model produced, not the (possibly shorter)
        summarized thinking text returned in the response body. Computed by
        re-tokenizing the raw reasoning text, so it may differ from the model's exact
        generation count by a small number of tokens. Always ≤ `output_tokens`;
        `output_tokens - thinking_tokens` approximates the non-reasoning output.

    - `server_tool_use: Optional[BetaServerToolUsage]`

      The number of server tool requests.

      - `web_fetch_requests: int`

        The number of web fetch tool requests.

      - `web_search_requests: int`

        The number of web search tool requests.

    - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

      If the request used the priority, standard, or batch tier.

      - `"standard"`

      - `"priority"`

      - `"batch"`

    - `speed: Optional[Literal["standard", "fast"]]`

      The inference speed mode used for this request.

      - `"standard"`

      - `"fast"`

### Beta Message Delta Usage

- `class BetaMessageDeltaUsage: …`

  - `cache_creation_input_tokens: Optional[int]`

    The cumulative number of input tokens used to create the cache entry.

  - `cache_read_input_tokens: Optional[int]`

    The cumulative number of input tokens read from the cache.

  - `input_tokens: Optional[int]`

    The cumulative number of input tokens which were used.

  - `iterations: Optional[BetaIterationsUsage]`

    Per-iteration token usage breakdown.

    Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

    - Determine which iterations exceeded long context thresholds (>=200k tokens)
    - Calculate the true context window size from the last iteration
    - Understand token accumulation across server-side tool use loops

    - `class BetaMessageIterationUsage: …`

      Token usage for a sampling iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

        - `ephemeral_1h_input_tokens: int`

          The number of input tokens used to create the 1 hour cache entry.

        - `ephemeral_5m_input_tokens: int`

          The number of input tokens used to create the 5 minute cache entry.

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["message"]`

        Usage for a sampling iteration

        - `"message"`

    - `class BetaCompactionIterationUsage: …`

      Token usage for a compaction iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["compaction"]`

        Usage for a compaction iteration

        - `"compaction"`

    - `class BetaAdvisorMessageIterationUsage: …`

      Token usage for an advisor sub-inference iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `model: Model`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
          - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
          - `claude-opus-4-1` - Exceptional model for specialized complex tasks
          - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
          - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-mythos-preview"`

            New class of intelligence, strongest in coding and cybersecurity

          - `"claude-opus-4-6"`

            Frontier intelligence for long-running agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

          - `"claude-opus-4-1"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-1-20250805"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-0"`

            Powerful model for complex tasks

          - `"claude-opus-4-20250514"`

            Powerful model for complex tasks

          - `"claude-sonnet-4-0"`

            High-performance model with extended thinking

          - `"claude-sonnet-4-20250514"`

            High-performance model with extended thinking

          - `"claude-3-haiku-20240307"`

            Fast and cost-effective model

        - `str`

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["advisor_message"]`

        Usage for an advisor sub-inference iteration

        - `"advisor_message"`

  - `output_tokens: int`

    The cumulative number of output tokens which were used.

  - `output_tokens_details: Optional[BetaOutputTokensDetails]`

    Breakdown of output tokens by category.

    `output_tokens` remains the inclusive, authoritative total used for billing.
    This object provides a read-only decomposition for observability — for example,
    how many of the billed output tokens were spent on internal reasoning that may
    have been summarized before being returned to you.

    - `thinking_tokens: int`

      Number of output tokens the model generated as internal reasoning, including
      the thinking-block delimiter tokens.

      Reflects the raw reasoning the model produced, not the (possibly shorter)
      summarized thinking text returned in the response body. Computed by
      re-tokenizing the raw reasoning text, so it may differ from the model's exact
      generation count by a small number of tokens. Always ≤ `output_tokens`;
      `output_tokens - thinking_tokens` approximates the non-reasoning output.

  - `server_tool_use: Optional[BetaServerToolUsage]`

    The number of server tool requests.

    - `web_fetch_requests: int`

      The number of web fetch tool requests.

    - `web_search_requests: int`

      The number of web search tool requests.

### Beta Message Iteration Usage

- `class BetaMessageIterationUsage: …`

  Token usage for a sampling iteration.

  - `cache_creation: Optional[BetaCacheCreation]`

    Breakdown of cached tokens by TTL

    - `ephemeral_1h_input_tokens: int`

      The number of input tokens used to create the 1 hour cache entry.

    - `ephemeral_5m_input_tokens: int`

      The number of input tokens used to create the 5 minute cache entry.

  - `cache_creation_input_tokens: int`

    The number of input tokens used to create the cache entry.

  - `cache_read_input_tokens: int`

    The number of input tokens read from the cache.

  - `input_tokens: int`

    The number of input tokens which were used.

  - `output_tokens: int`

    The number of output tokens which were used.

  - `type: Literal["message"]`

    Usage for a sampling iteration

    - `"message"`

### Beta Message Param

- `class BetaMessageParam: …`

  - `content: Union[str, List[BetaContentBlockParam]]`

    - `str`

    - `List[BetaContentBlockParam]`

      - `class BetaTextBlockParam: …`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

          - `type: Literal["ephemeral"]`

            - `"ephemeral"`

          - `ttl: Optional[Literal["5m", "1h"]]`

            The time-to-live for the cache control breakpoint.

            This may be one the following values:

            - `5m`: 5 minutes
            - `1h`: 1 hour

            Defaults to `5m`.

            - `"5m"`

            - `"1h"`

        - `citations: Optional[List[BetaTextCitationParam]]`

          - `class BetaCitationCharLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationWebSearchResultLocationParam: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

      - `class BetaImageBlockParam: …`

        - `source: Source`

          - `class BetaBase64ImageSource: …`

            - `data: str`

            - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

              - `"image/jpeg"`

              - `"image/png"`

              - `"image/gif"`

              - `"image/webp"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaURLImageSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileImageSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestDocumentBlock: …`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaContentBlockSource: …`

            - `content: Union[str, List[BetaContentBlockSourceContent]]`

              - `str`

              - `List[BetaContentBlockSourceContent]`

                - `class BetaTextBlockParam: …`

                - `class BetaImageBlockParam: …`

            - `type: Literal["content"]`

              - `"content"`

          - `class BetaURLPDFSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileDocumentSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          - `enabled: Optional[bool]`

        - `context: Optional[str]`

        - `title: Optional[str]`

      - `class BetaSearchResultBlockParam: …`

        - `content: List[BetaTextBlockParam]`

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `source: str`

        - `title: str`

        - `type: Literal["search_result"]`

          - `"search_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

      - `class BetaThinkingBlockParam: …`

        - `signature: str`

        - `thinking: str`

        - `type: Literal["thinking"]`

          - `"thinking"`

      - `class BetaRedactedThinkingBlockParam: …`

        - `data: str`

        - `type: Literal["redacted_thinking"]`

          - `"redacted_thinking"`

      - `class BetaToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `type: Literal["tool_use"]`

          - `"tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

            - `type: Literal["direct"]`

              - `"direct"`

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

            - `tool_id: str`

            - `type: Literal["code_execution_20250825"]`

              - `"code_execution_20250825"`

          - `class BetaServerToolCaller20260120: …`

            - `tool_id: str`

            - `type: Literal["code_execution_20260120"]`

              - `"code_execution_20260120"`

      - `class BetaToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["tool_result"]`

          - `"tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[Content], null]]`

          - `str`

          - `List[Content]`

            - `class BetaTextBlockParam: …`

            - `class BetaImageBlockParam: …`

            - `class BetaSearchResultBlockParam: …`

            - `class BetaRequestDocumentBlock: …`

            - `class BetaToolReferenceBlockParam: …`

              Tool reference block that can be included in tool_result content.

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

                - `"tool_reference"`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

        - `is_error: Optional[bool]`

      - `class BetaServerToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

          - `"advisor"`

          - `"web_search"`

          - `"web_fetch"`

          - `"code_execution"`

          - `"bash_code_execution"`

          - `"text_editor_code_execution"`

          - `"tool_search_tool_regex"`

          - `"tool_search_tool_bm25"`

        - `type: Literal["server_tool_use"]`

          - `"server_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebSearchToolResultBlockParam: …`

        - `content: BetaWebSearchToolResultBlockParamContent`

          - `List[BetaWebSearchResultBlockParam]`

            - `encrypted_content: str`

            - `title: str`

            - `type: Literal["web_search_result"]`

              - `"web_search_result"`

            - `url: str`

            - `page_age: Optional[str]`

          - `class BetaWebSearchToolRequestError: …`

            - `error_code: BetaWebSearchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"max_uses_exceeded"`

              - `"too_many_requests"`

              - `"query_too_long"`

              - `"request_too_large"`

            - `type: Literal["web_search_tool_result_error"]`

              - `"web_search_tool_result_error"`

        - `tool_use_id: str`

        - `type: Literal["web_search_tool_result"]`

          - `"web_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebFetchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaWebFetchToolResultErrorBlockParam: …`

            - `error_code: BetaWebFetchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"url_too_long"`

              - `"url_not_allowed"`

              - `"url_not_in_prior_context"`

              - `"url_not_accessible"`

              - `"unsupported_content_type"`

              - `"too_many_requests"`

              - `"max_uses_exceeded"`

              - `"unavailable"`

            - `type: Literal["web_fetch_tool_result_error"]`

              - `"web_fetch_tool_result_error"`

          - `class BetaWebFetchBlockParam: …`

            - `content: BetaRequestDocumentBlock`

            - `type: Literal["web_fetch_result"]`

              - `"web_fetch_result"`

            - `url: str`

              Fetched content URL

            - `retrieved_at: Optional[str]`

              ISO 8601 timestamp when the content was retrieved

        - `tool_use_id: str`

        - `type: Literal["web_fetch_tool_result"]`

          - `"web_fetch_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaAdvisorToolResultBlockParam: …`

        - `content: Content`

          - `class BetaAdvisorToolResultErrorParam: …`

            - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

              - `"max_uses_exceeded"`

              - `"prompt_too_long"`

              - `"too_many_requests"`

              - `"overloaded"`

              - `"unavailable"`

              - `"execution_time_exceeded"`

            - `type: Literal["advisor_tool_result_error"]`

              - `"advisor_tool_result_error"`

          - `class BetaAdvisorResultBlockParam: …`

            - `text: str`

            - `type: Literal["advisor_result"]`

              - `"advisor_result"`

            - `stop_reason: Optional[str]`

          - `class BetaAdvisorRedactedResultBlockParam: …`

            - `encrypted_content: str`

              Opaque blob produced by a prior response; must be round-tripped verbatim.

            - `type: Literal["advisor_redacted_result"]`

              - `"advisor_redacted_result"`

            - `stop_reason: Optional[str]`

        - `tool_use_id: str`

        - `type: Literal["advisor_tool_result"]`

          - `"advisor_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCodeExecutionToolResultBlockParam: …`

        - `content: BetaCodeExecutionToolResultBlockParamContent`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `class BetaCodeExecutionToolResultErrorParam: …`

            - `error_code: BetaCodeExecutionToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["code_execution_tool_result_error"]`

              - `"code_execution_tool_result_error"`

          - `class BetaCodeExecutionResultBlockParam: …`

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

                - `"code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["code_execution_result"]`

              - `"code_execution_result"`

          - `class BetaEncryptedCodeExecutionResultBlockParam: …`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `content: List[BetaCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

            - `encrypted_stdout: str`

            - `return_code: int`

            - `stderr: str`

            - `type: Literal["encrypted_code_execution_result"]`

              - `"encrypted_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["code_execution_tool_result"]`

          - `"code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaBashCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaBashCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"output_file_too_large"`

            - `type: Literal["bash_code_execution_tool_result_error"]`

              - `"bash_code_execution_tool_result_error"`

          - `class BetaBashCodeExecutionResultBlockParam: …`

            - `content: List[BetaBashCodeExecutionOutputBlockParam]`

              - `file_id: str`

              - `type: Literal["bash_code_execution_output"]`

                - `"bash_code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["bash_code_execution_result"]`

              - `"bash_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["bash_code_execution_tool_result"]`

          - `"bash_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

        - `content: Content`

          - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"file_not_found"`

            - `type: Literal["text_editor_code_execution_tool_result_error"]`

              - `"text_editor_code_execution_tool_result_error"`

            - `error_message: Optional[str]`

          - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

            - `content: str`

            - `file_type: Literal["text", "image", "pdf"]`

              - `"text"`

              - `"image"`

              - `"pdf"`

            - `type: Literal["text_editor_code_execution_view_result"]`

              - `"text_editor_code_execution_view_result"`

            - `num_lines: Optional[int]`

            - `start_line: Optional[int]`

            - `total_lines: Optional[int]`

          - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

            - `is_file_update: bool`

            - `type: Literal["text_editor_code_execution_create_result"]`

              - `"text_editor_code_execution_create_result"`

          - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

            - `type: Literal["text_editor_code_execution_str_replace_result"]`

              - `"text_editor_code_execution_str_replace_result"`

            - `lines: Optional[List[str]]`

            - `new_lines: Optional[int]`

            - `new_start: Optional[int]`

            - `old_lines: Optional[int]`

            - `old_start: Optional[int]`

        - `tool_use_id: str`

        - `type: Literal["text_editor_code_execution_tool_result"]`

          - `"text_editor_code_execution_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaToolSearchToolResultBlockParam: …`

        - `content: Content`

          - `class BetaToolSearchToolResultErrorParam: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["tool_search_tool_result_error"]`

              - `"tool_search_tool_result_error"`

          - `class BetaToolSearchToolSearchResultBlockParam: …`

            - `tool_references: List[BetaToolReferenceBlockParam]`

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

            - `type: Literal["tool_search_tool_search_result"]`

              - `"tool_search_tool_search_result"`

        - `tool_use_id: str`

        - `type: Literal["tool_search_tool_result"]`

          - `"tool_search_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaMCPToolUseBlockParam: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `server_name: str`

          The name of the MCP server

        - `type: Literal["mcp_tool_use"]`

          - `"mcp_tool_use"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaRequestMCPToolResultBlockParam: …`

        - `tool_use_id: str`

        - `type: Literal["mcp_tool_result"]`

          - `"mcp_tool_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

          - `str`

          - `List[BetaTextBlockParam]`

            - `text: str`

            - `type: Literal["text"]`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `citations: Optional[List[BetaTextCitationParam]]`

        - `is_error: Optional[bool]`

      - `class BetaContainerUploadBlockParam: …`

        A content block that represents a file to be uploaded to the container
        Files uploaded via this block will be available in the container's input directory.

        - `file_id: str`

        - `type: Literal["container_upload"]`

          - `"container_upload"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaCompactionBlockParam: …`

        A compaction block containing summary of previous context.

        Users should round-trip these blocks from responses to subsequent requests
        to maintain context across compaction boundaries.

        When content is None, the block represents a failed compaction. The server
        treats these as no-ops. Empty string content is not allowed.

        - `type: Literal["compaction"]`

          - `"compaction"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `content: Optional[str]`

          Summary of previously compacted content, or null if compaction failed

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

      - `class BetaMidConversationSystemBlockParam: …`

        System instructions that appear mid-conversation.

        Use this block to provide or update system-level instructions at a specific
        point in the conversation, rather than only via the top-level `system` parameter.

        - `content: List[BetaTextBlockParam]`

          System instruction text blocks.

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `type: Literal["mid_conv_system"]`

          - `"mid_conv_system"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

  - `role: Literal["user", "assistant", "system"]`

    - `"user"`

    - `"assistant"`

    - `"system"`

### Beta Message Tokens Count

- `class BetaMessageTokensCount: …`

  - `context_management: Optional[BetaCountTokensContextManagementResponse]`

    Information about context management applied to the message.

    - `original_input_tokens: int`

      The original token count before context management was applied

  - `input_tokens: int`

    The total number of tokens across the provided list of messages, system prompt, and tools.

### Beta Metadata

- `class BetaMetadata: …`

  - `user_id: Optional[str]`

    An external identifier for the user who is associated with the request.

    This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

### Beta Mid Conversation System Block Param

- `class BetaMidConversationSystemBlockParam: …`

  System instructions that appear mid-conversation.

  Use this block to provide or update system-level instructions at a specific
  point in the conversation, rather than only via the top-level `system` parameter.

  - `content: List[BetaTextBlockParam]`

    System instruction text blocks.

    - `text: str`

    - `type: Literal["text"]`

      - `"text"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

    - `citations: Optional[List[BetaTextCitationParam]]`

      - `class BetaCitationCharLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationWebSearchResultLocationParam: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

  - `type: Literal["mid_conv_system"]`

    - `"mid_conv_system"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

### Beta Output Config

- `class BetaOutputConfig: …`

  - `effort: Optional[Literal["low", "medium", "high", 2 more]]`

    All possible effort levels.

    - `"low"`

    - `"medium"`

    - `"high"`

    - `"xhigh"`

    - `"max"`

  - `format: Optional[BetaJSONOutputFormat]`

    A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

    - `schema: Dict[str, object]`

      The JSON schema of the format

    - `type: Literal["json_schema"]`

      - `"json_schema"`

  - `task_budget: Optional[BetaTokenTaskBudget]`

    User-configurable total token budget across contexts.

    - `total: int`

      Total token budget across all contexts in the session.

    - `type: Literal["tokens"]`

      The budget type. Currently only 'tokens' is supported.

      - `"tokens"`

    - `remaining: Optional[int]`

      Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.

### Beta Output Tokens Details

- `class BetaOutputTokensDetails: …`

  - `thinking_tokens: int`

    Number of output tokens the model generated as internal reasoning, including
    the thinking-block delimiter tokens.

    Reflects the raw reasoning the model produced, not the (possibly shorter)
    summarized thinking text returned in the response body. Computed by
    re-tokenizing the raw reasoning text, so it may differ from the model's exact
    generation count by a small number of tokens. Always ≤ `output_tokens`;
    `output_tokens - thinking_tokens` approximates the non-reasoning output.

### Beta Plain Text Source

- `class BetaPlainTextSource: …`

  - `data: str`

  - `media_type: Literal["text/plain"]`

    - `"text/plain"`

  - `type: Literal["text"]`

    - `"text"`

### Beta Raw Content Block Delta

- `BetaRawContentBlockDelta`

  - `class BetaTextDelta: …`

    - `text: str`

    - `type: Literal["text_delta"]`

      - `"text_delta"`

  - `class BetaInputJSONDelta: …`

    - `partial_json: str`

    - `type: Literal["input_json_delta"]`

      - `"input_json_delta"`

  - `class BetaCitationsDelta: …`

    - `citation: Citation`

      - `class BetaCitationCharLocation: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `file_id: Optional[str]`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocation: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `file_id: Optional[str]`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocation: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `file_id: Optional[str]`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationsWebSearchResultLocation: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocation: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

    - `type: Literal["citations_delta"]`

      - `"citations_delta"`

  - `class BetaThinkingDelta: …`

    - `estimated_tokens: Optional[int]`

      Per-frame increment of a coarse, running estimate of the tokens this thinking block has produced so far. Present whenever the `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display` resolves to `"omitted"` and a count is due this frame. Sum the increments across `thinking_delta` frames on this block for a progress indicator. Each increment is a non-negative multiple of a fixed quantum and the cadence is rate-limited, so this is a deliberately lossy display hint, not a billable count; `usage.output_tokens` remains authoritative.

    - `thinking: str`

    - `type: Literal["thinking_delta"]`

      - `"thinking_delta"`

  - `class BetaSignatureDelta: …`

    - `signature: str`

    - `type: Literal["signature_delta"]`

      - `"signature_delta"`

  - `class BetaCompactionContentBlockDelta: …`

    - `content: Optional[str]`

    - `encrypted_content: Optional[str]`

      Opaque metadata from prior compaction, to be round-tripped verbatim

    - `type: Literal["compaction_delta"]`

      - `"compaction_delta"`

### Beta Raw Content Block Delta Event

- `class BetaRawContentBlockDeltaEvent: …`

  - `delta: BetaRawContentBlockDelta`

    - `class BetaTextDelta: …`

      - `text: str`

      - `type: Literal["text_delta"]`

        - `"text_delta"`

    - `class BetaInputJSONDelta: …`

      - `partial_json: str`

      - `type: Literal["input_json_delta"]`

        - `"input_json_delta"`

    - `class BetaCitationsDelta: …`

      - `citation: Citation`

        - `class BetaCitationCharLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `file_id: Optional[str]`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `file_id: Optional[str]`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `file_id: Optional[str]`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationsWebSearchResultLocation: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

      - `type: Literal["citations_delta"]`

        - `"citations_delta"`

    - `class BetaThinkingDelta: …`

      - `estimated_tokens: Optional[int]`

        Per-frame increment of a coarse, running estimate of the tokens this thinking block has produced so far. Present whenever the `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display` resolves to `"omitted"` and a count is due this frame. Sum the increments across `thinking_delta` frames on this block for a progress indicator. Each increment is a non-negative multiple of a fixed quantum and the cadence is rate-limited, so this is a deliberately lossy display hint, not a billable count; `usage.output_tokens` remains authoritative.

      - `thinking: str`

      - `type: Literal["thinking_delta"]`

        - `"thinking_delta"`

    - `class BetaSignatureDelta: …`

      - `signature: str`

      - `type: Literal["signature_delta"]`

        - `"signature_delta"`

    - `class BetaCompactionContentBlockDelta: …`

      - `content: Optional[str]`

      - `encrypted_content: Optional[str]`

        Opaque metadata from prior compaction, to be round-tripped verbatim

      - `type: Literal["compaction_delta"]`

        - `"compaction_delta"`

  - `index: int`

  - `type: Literal["content_block_delta"]`

    - `"content_block_delta"`

### Beta Raw Content Block Start Event

- `class BetaRawContentBlockStartEvent: …`

  - `content_block: ContentBlock`

    Response model for a file uploaded to the container.

    - `class BetaTextBlock: …`

      - `citations: Optional[List[BetaTextCitation]]`

        Citations supporting the text block.

        The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

        - `class BetaCitationCharLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `file_id: Optional[str]`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocation: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `file_id: Optional[str]`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `file_id: Optional[str]`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationsWebSearchResultLocation: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocation: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

      - `text: str`

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaThinkingBlock: …`

      - `signature: str`

      - `thinking: str`

      - `type: Literal["thinking"]`

        - `"thinking"`

    - `class BetaRedactedThinkingBlock: …`

      - `data: str`

      - `type: Literal["redacted_thinking"]`

        - `"redacted_thinking"`

    - `class BetaToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

      - `type: Literal["tool_use"]`

        - `"tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

          - `type: Literal["direct"]`

            - `"direct"`

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

          - `tool_id: str`

          - `type: Literal["code_execution_20250825"]`

            - `"code_execution_20250825"`

        - `class BetaServerToolCaller20260120: …`

          - `tool_id: str`

          - `type: Literal["code_execution_20260120"]`

            - `"code_execution_20260120"`

    - `class BetaServerToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

        - `"advisor"`

        - `"web_search"`

        - `"web_fetch"`

        - `"code_execution"`

        - `"bash_code_execution"`

        - `"text_editor_code_execution"`

        - `"tool_search_tool_regex"`

        - `"tool_search_tool_bm25"`

      - `type: Literal["server_tool_use"]`

        - `"server_tool_use"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebSearchToolResultBlock: …`

      - `content: BetaWebSearchToolResultBlockContent`

        - `class BetaWebSearchToolResultError: …`

          - `error_code: BetaWebSearchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"max_uses_exceeded"`

            - `"too_many_requests"`

            - `"query_too_long"`

            - `"request_too_large"`

          - `type: Literal["web_search_tool_result_error"]`

            - `"web_search_tool_result_error"`

        - `List[BetaWebSearchResultBlock]`

          - `encrypted_content: str`

          - `page_age: Optional[str]`

          - `title: str`

          - `type: Literal["web_search_result"]`

            - `"web_search_result"`

          - `url: str`

      - `tool_use_id: str`

      - `type: Literal["web_search_tool_result"]`

        - `"web_search_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaWebFetchToolResultBlock: …`

      - `content: Content`

        - `class BetaWebFetchToolResultErrorBlock: …`

          - `error_code: BetaWebFetchToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"url_too_long"`

            - `"url_not_allowed"`

            - `"url_not_in_prior_context"`

            - `"url_not_accessible"`

            - `"unsupported_content_type"`

            - `"too_many_requests"`

            - `"max_uses_exceeded"`

            - `"unavailable"`

          - `type: Literal["web_fetch_tool_result_error"]`

            - `"web_fetch_tool_result_error"`

        - `class BetaWebFetchBlock: …`

          - `content: BetaDocumentBlock`

            - `citations: Optional[BetaCitationConfig]`

              Citation configuration for the document

              - `enabled: bool`

            - `source: Source`

              - `class BetaBase64PDFSource: …`

                - `data: str`

                - `media_type: Literal["application/pdf"]`

                  - `"application/pdf"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaPlainTextSource: …`

                - `data: str`

                - `media_type: Literal["text/plain"]`

                  - `"text/plain"`

                - `type: Literal["text"]`

                  - `"text"`

            - `title: Optional[str]`

              The title of the document

            - `type: Literal["document"]`

              - `"document"`

          - `retrieved_at: Optional[str]`

            ISO 8601 timestamp when the content was retrieved

          - `type: Literal["web_fetch_result"]`

            - `"web_fetch_result"`

          - `url: str`

            Fetched content URL

      - `tool_use_id: str`

      - `type: Literal["web_fetch_tool_result"]`

        - `"web_fetch_tool_result"`

      - `caller: Optional[Caller]`

        Tool invocation directly from the model.

        - `class BetaDirectCaller: …`

          Tool invocation directly from the model.

        - `class BetaServerToolCaller: …`

          Tool invocation generated by a server-side tool.

        - `class BetaServerToolCaller20260120: …`

    - `class BetaAdvisorToolResultBlock: …`

      - `content: Content`

        - `class BetaAdvisorToolResultError: …`

          - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

            - `"max_uses_exceeded"`

            - `"prompt_too_long"`

            - `"too_many_requests"`

            - `"overloaded"`

            - `"unavailable"`

            - `"execution_time_exceeded"`

          - `type: Literal["advisor_tool_result_error"]`

            - `"advisor_tool_result_error"`

        - `class BetaAdvisorResultBlock: …`

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

          - `text: str`

          - `type: Literal["advisor_result"]`

            - `"advisor_result"`

        - `class BetaAdvisorRedactedResultBlock: …`

          - `encrypted_content: str`

            Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

          - `stop_reason: Optional[str]`

            The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

          - `type: Literal["advisor_redacted_result"]`

            - `"advisor_redacted_result"`

      - `tool_use_id: str`

      - `type: Literal["advisor_tool_result"]`

        - `"advisor_tool_result"`

    - `class BetaCodeExecutionToolResultBlock: …`

      - `content: BetaCodeExecutionToolResultBlockContent`

        Code execution result with encrypted stdout for PFC + web_search results.

        - `class BetaCodeExecutionToolResultError: …`

          - `error_code: BetaCodeExecutionToolResultErrorCode`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `type: Literal["code_execution_tool_result_error"]`

            - `"code_execution_tool_result_error"`

        - `class BetaCodeExecutionResultBlock: …`

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

              - `"code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["code_execution_result"]`

            - `"code_execution_result"`

        - `class BetaEncryptedCodeExecutionResultBlock: …`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `content: List[BetaCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["code_execution_output"]`

          - `encrypted_stdout: str`

          - `return_code: int`

          - `stderr: str`

          - `type: Literal["encrypted_code_execution_result"]`

            - `"encrypted_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["code_execution_tool_result"]`

        - `"code_execution_tool_result"`

    - `class BetaBashCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaBashCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"output_file_too_large"`

          - `type: Literal["bash_code_execution_tool_result_error"]`

            - `"bash_code_execution_tool_result_error"`

        - `class BetaBashCodeExecutionResultBlock: …`

          - `content: List[BetaBashCodeExecutionOutputBlock]`

            - `file_id: str`

            - `type: Literal["bash_code_execution_output"]`

              - `"bash_code_execution_output"`

          - `return_code: int`

          - `stderr: str`

          - `stdout: str`

          - `type: Literal["bash_code_execution_result"]`

            - `"bash_code_execution_result"`

      - `tool_use_id: str`

      - `type: Literal["bash_code_execution_tool_result"]`

        - `"bash_code_execution_tool_result"`

    - `class BetaTextEditorCodeExecutionToolResultBlock: …`

      - `content: Content`

        - `class BetaTextEditorCodeExecutionToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

            - `"file_not_found"`

          - `error_message: Optional[str]`

          - `type: Literal["text_editor_code_execution_tool_result_error"]`

            - `"text_editor_code_execution_tool_result_error"`

        - `class BetaTextEditorCodeExecutionViewResultBlock: …`

          - `content: str`

          - `file_type: Literal["text", "image", "pdf"]`

            - `"text"`

            - `"image"`

            - `"pdf"`

          - `num_lines: Optional[int]`

          - `start_line: Optional[int]`

          - `total_lines: Optional[int]`

          - `type: Literal["text_editor_code_execution_view_result"]`

            - `"text_editor_code_execution_view_result"`

        - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

          - `is_file_update: bool`

          - `type: Literal["text_editor_code_execution_create_result"]`

            - `"text_editor_code_execution_create_result"`

        - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

          - `lines: Optional[List[str]]`

          - `new_lines: Optional[int]`

          - `new_start: Optional[int]`

          - `old_lines: Optional[int]`

          - `old_start: Optional[int]`

          - `type: Literal["text_editor_code_execution_str_replace_result"]`

            - `"text_editor_code_execution_str_replace_result"`

      - `tool_use_id: str`

      - `type: Literal["text_editor_code_execution_tool_result"]`

        - `"text_editor_code_execution_tool_result"`

    - `class BetaToolSearchToolResultBlock: …`

      - `content: Content`

        - `class BetaToolSearchToolResultError: …`

          - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

            - `"invalid_tool_input"`

            - `"unavailable"`

            - `"too_many_requests"`

            - `"execution_time_exceeded"`

          - `error_message: Optional[str]`

          - `type: Literal["tool_search_tool_result_error"]`

            - `"tool_search_tool_result_error"`

        - `class BetaToolSearchToolSearchResultBlock: …`

          - `tool_references: List[BetaToolReferenceBlock]`

            - `tool_name: str`

            - `type: Literal["tool_reference"]`

              - `"tool_reference"`

          - `type: Literal["tool_search_tool_search_result"]`

            - `"tool_search_tool_search_result"`

      - `tool_use_id: str`

      - `type: Literal["tool_search_tool_result"]`

        - `"tool_search_tool_result"`

    - `class BetaMCPToolUseBlock: …`

      - `id: str`

      - `input: Dict[str, object]`

      - `name: str`

        The name of the MCP tool

      - `server_name: str`

        The name of the MCP server

      - `type: Literal["mcp_tool_use"]`

        - `"mcp_tool_use"`

    - `class BetaMCPToolResultBlock: …`

      - `content: Union[str, List[BetaTextBlock]]`

        - `str`

        - `List[BetaTextBlock]`

          - `citations: Optional[List[BetaTextCitation]]`

            Citations supporting the text block.

            The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

          - `text: str`

          - `type: Literal["text"]`

      - `is_error: bool`

      - `tool_use_id: str`

      - `type: Literal["mcp_tool_result"]`

        - `"mcp_tool_result"`

    - `class BetaContainerUploadBlock: …`

      Response model for a file uploaded to the container.

      - `file_id: str`

      - `type: Literal["container_upload"]`

        - `"container_upload"`

    - `class BetaCompactionBlock: …`

      A compaction block returned when autocompact is triggered.

      When content is None, it indicates the compaction failed to produce a valid
      summary (e.g., malformed output from the model). Clients may round-trip
      compaction blocks with null content; the server treats them as no-ops.

      - `content: Optional[str]`

        Summary of compacted content, or null if compaction failed

      - `encrypted_content: Optional[str]`

        Opaque metadata from prior compaction, to be round-tripped verbatim

      - `type: Literal["compaction"]`

        - `"compaction"`

  - `index: int`

  - `type: Literal["content_block_start"]`

    - `"content_block_start"`

### Beta Raw Content Block Stop Event

- `class BetaRawContentBlockStopEvent: …`

  - `index: int`

  - `type: Literal["content_block_stop"]`

    - `"content_block_stop"`

### Beta Raw Message Delta Event

- `class BetaRawMessageDeltaEvent: …`

  - `context_management: Optional[BetaContextManagementResponse]`

    Information about context management strategies applied during the request

    - `applied_edits: List[AppliedEdit]`

      List of context management edits that were applied.

      - `class BetaClearToolUses20250919EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_tool_uses: int`

          Number of tool uses that were cleared.

        - `type: Literal["clear_tool_uses_20250919"]`

          The type of context management edit applied.

          - `"clear_tool_uses_20250919"`

      - `class BetaClearThinking20251015EditResponse: …`

        - `cleared_input_tokens: int`

          Number of input tokens cleared by this edit.

        - `cleared_thinking_turns: int`

          Number of thinking turns that were cleared.

        - `type: Literal["clear_thinking_20251015"]`

          The type of context management edit applied.

          - `"clear_thinking_20251015"`

  - `delta: Delta`

    - `container: Optional[BetaContainer]`

      Information about the container used in the request (for the code execution tool)

      - `id: str`

        Identifier for the container used in this request

      - `expires_at: datetime`

        The time at which the container will expire.

      - `skills: Optional[List[BetaSkill]]`

        Skills loaded in the container

        - `skill_id: str`

          Skill ID

        - `type: Literal["anthropic", "custom"]`

          Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

          - `"anthropic"`

          - `"custom"`

        - `version: str`

          Skill version or 'latest' for most recent version

    - `stop_details: Optional[BetaRefusalStopDetails]`

      Structured information about a refusal.

      - `category: Optional[Literal["cyber", "bio"]]`

        The policy category that triggered the refusal.

        `null` when the refusal doesn't map to a named category.

        - `"cyber"`

        - `"bio"`

      - `explanation: Optional[str]`

        Human-readable explanation of the refusal.

        This text is not guaranteed to be stable. `null` when no explanation is available for the category.

      - `type: Literal["refusal"]`

        - `"refusal"`

    - `stop_reason: Optional[BetaStopReason]`

      - `"end_turn"`

      - `"max_tokens"`

      - `"stop_sequence"`

      - `"tool_use"`

      - `"pause_turn"`

      - `"compaction"`

      - `"refusal"`

      - `"model_context_window_exceeded"`

    - `stop_sequence: Optional[str]`

  - `type: Literal["message_delta"]`

    - `"message_delta"`

  - `usage: BetaMessageDeltaUsage`

    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 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.

    For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

    Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

    - `cache_creation_input_tokens: Optional[int]`

      The cumulative number of input tokens used to create the cache entry.

    - `cache_read_input_tokens: Optional[int]`

      The cumulative number of input tokens read from the cache.

    - `input_tokens: Optional[int]`

      The cumulative number of input tokens which were used.

    - `iterations: Optional[BetaIterationsUsage]`

      Per-iteration token usage breakdown.

      Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

      - Determine which iterations exceeded long context thresholds (>=200k tokens)
      - Calculate the true context window size from the last iteration
      - Understand token accumulation across server-side tool use loops

      - `class BetaMessageIterationUsage: …`

        Token usage for a sampling iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

          - `ephemeral_1h_input_tokens: int`

            The number of input tokens used to create the 1 hour cache entry.

          - `ephemeral_5m_input_tokens: int`

            The number of input tokens used to create the 5 minute cache entry.

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["message"]`

          Usage for a sampling iteration

          - `"message"`

      - `class BetaCompactionIterationUsage: …`

        Token usage for a compaction iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["compaction"]`

          Usage for a compaction iteration

          - `"compaction"`

      - `class BetaAdvisorMessageIterationUsage: …`

        Token usage for an advisor sub-inference iteration.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

        - `cache_creation_input_tokens: int`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: int`

          The number of input tokens read from the cache.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

            The model that will complete your prompt.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
            - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
            - `claude-opus-4-1` - Exceptional model for specialized complex tasks
            - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
            - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-mythos-preview"`

              New class of intelligence, strongest in coding and cybersecurity

            - `"claude-opus-4-6"`

              Frontier intelligence for long-running agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

            - `"claude-opus-4-1"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-1-20250805"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-0"`

              Powerful model for complex tasks

            - `"claude-opus-4-20250514"`

              Powerful model for complex tasks

            - `"claude-sonnet-4-0"`

              High-performance model with extended thinking

            - `"claude-sonnet-4-20250514"`

              High-performance model with extended thinking

            - `"claude-3-haiku-20240307"`

              Fast and cost-effective model

          - `str`

        - `output_tokens: int`

          The number of output tokens which were used.

        - `type: Literal["advisor_message"]`

          Usage for an advisor sub-inference iteration

          - `"advisor_message"`

    - `output_tokens: int`

      The cumulative number of output tokens which were used.

    - `output_tokens_details: Optional[BetaOutputTokensDetails]`

      Breakdown of output tokens by category.

      `output_tokens` remains the inclusive, authoritative total used for billing.
      This object provides a read-only decomposition for observability — for example,
      how many of the billed output tokens were spent on internal reasoning that may
      have been summarized before being returned to you.

      - `thinking_tokens: int`

        Number of output tokens the model generated as internal reasoning, including
        the thinking-block delimiter tokens.

        Reflects the raw reasoning the model produced, not the (possibly shorter)
        summarized thinking text returned in the response body. Computed by
        re-tokenizing the raw reasoning text, so it may differ from the model's exact
        generation count by a small number of tokens. Always ≤ `output_tokens`;
        `output_tokens - thinking_tokens` approximates the non-reasoning output.

    - `server_tool_use: Optional[BetaServerToolUsage]`

      The number of server tool requests.

      - `web_fetch_requests: int`

        The number of web fetch tool requests.

      - `web_search_requests: int`

        The number of web search tool requests.

### Beta Raw Message Start Event

- `class BetaRawMessageStartEvent: …`

  - `message: BetaMessage`

    - `id: str`

      Unique object identifier.

      The format and length of IDs may change over time.

    - `container: Optional[BetaContainer]`

      Information about the container used in the request (for the code execution tool)

      - `id: str`

        Identifier for the container used in this request

      - `expires_at: datetime`

        The time at which the container will expire.

      - `skills: Optional[List[BetaSkill]]`

        Skills loaded in the container

        - `skill_id: str`

          Skill ID

        - `type: Literal["anthropic", "custom"]`

          Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

          - `"anthropic"`

          - `"custom"`

        - `version: str`

          Skill version or 'latest' for most recent version

    - `content: List[BetaContentBlock]`

      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 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.

      For example, if the input `messages` were:

      ```json
      [
        {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
        {"role": "assistant", "content": "The best answer is ("}
      ]
      ```

      Then the response `content` might be:

      ```json
      [{"type": "text", "text": "B)"}]
      ```

      - `class BetaTextBlock: …`

        - `citations: Optional[List[BetaTextCitation]]`

          Citations supporting the text block.

          The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

          - `class BetaCitationCharLocation: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `file_id: Optional[str]`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocation: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `file_id: Optional[str]`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocation: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `file_id: Optional[str]`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationsWebSearchResultLocation: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocation: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaThinkingBlock: …`

        - `signature: str`

        - `thinking: str`

        - `type: Literal["thinking"]`

          - `"thinking"`

      - `class BetaRedactedThinkingBlock: …`

        - `data: str`

        - `type: Literal["redacted_thinking"]`

          - `"redacted_thinking"`

      - `class BetaToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `type: Literal["tool_use"]`

          - `"tool_use"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

            - `type: Literal["direct"]`

              - `"direct"`

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

            - `tool_id: str`

            - `type: Literal["code_execution_20250825"]`

              - `"code_execution_20250825"`

          - `class BetaServerToolCaller20260120: …`

            - `tool_id: str`

            - `type: Literal["code_execution_20260120"]`

              - `"code_execution_20260120"`

      - `class BetaServerToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

          - `"advisor"`

          - `"web_search"`

          - `"web_fetch"`

          - `"code_execution"`

          - `"bash_code_execution"`

          - `"text_editor_code_execution"`

          - `"tool_search_tool_regex"`

          - `"tool_search_tool_bm25"`

        - `type: Literal["server_tool_use"]`

          - `"server_tool_use"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebSearchToolResultBlock: …`

        - `content: BetaWebSearchToolResultBlockContent`

          - `class BetaWebSearchToolResultError: …`

            - `error_code: BetaWebSearchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"max_uses_exceeded"`

              - `"too_many_requests"`

              - `"query_too_long"`

              - `"request_too_large"`

            - `type: Literal["web_search_tool_result_error"]`

              - `"web_search_tool_result_error"`

          - `List[BetaWebSearchResultBlock]`

            - `encrypted_content: str`

            - `page_age: Optional[str]`

            - `title: str`

            - `type: Literal["web_search_result"]`

              - `"web_search_result"`

            - `url: str`

        - `tool_use_id: str`

        - `type: Literal["web_search_tool_result"]`

          - `"web_search_tool_result"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebFetchToolResultBlock: …`

        - `content: Content`

          - `class BetaWebFetchToolResultErrorBlock: …`

            - `error_code: BetaWebFetchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"url_too_long"`

              - `"url_not_allowed"`

              - `"url_not_in_prior_context"`

              - `"url_not_accessible"`

              - `"unsupported_content_type"`

              - `"too_many_requests"`

              - `"max_uses_exceeded"`

              - `"unavailable"`

            - `type: Literal["web_fetch_tool_result_error"]`

              - `"web_fetch_tool_result_error"`

          - `class BetaWebFetchBlock: …`

            - `content: BetaDocumentBlock`

              - `citations: Optional[BetaCitationConfig]`

                Citation configuration for the document

                - `enabled: bool`

              - `source: Source`

                - `class BetaBase64PDFSource: …`

                  - `data: str`

                  - `media_type: Literal["application/pdf"]`

                    - `"application/pdf"`

                  - `type: Literal["base64"]`

                    - `"base64"`

                - `class BetaPlainTextSource: …`

                  - `data: str`

                  - `media_type: Literal["text/plain"]`

                    - `"text/plain"`

                  - `type: Literal["text"]`

                    - `"text"`

              - `title: Optional[str]`

                The title of the document

              - `type: Literal["document"]`

                - `"document"`

            - `retrieved_at: Optional[str]`

              ISO 8601 timestamp when the content was retrieved

            - `type: Literal["web_fetch_result"]`

              - `"web_fetch_result"`

            - `url: str`

              Fetched content URL

        - `tool_use_id: str`

        - `type: Literal["web_fetch_tool_result"]`

          - `"web_fetch_tool_result"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaAdvisorToolResultBlock: …`

        - `content: Content`

          - `class BetaAdvisorToolResultError: …`

            - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

              - `"max_uses_exceeded"`

              - `"prompt_too_long"`

              - `"too_many_requests"`

              - `"overloaded"`

              - `"unavailable"`

              - `"execution_time_exceeded"`

            - `type: Literal["advisor_tool_result_error"]`

              - `"advisor_tool_result_error"`

          - `class BetaAdvisorResultBlock: …`

            - `stop_reason: Optional[str]`

              The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

            - `text: str`

            - `type: Literal["advisor_result"]`

              - `"advisor_result"`

          - `class BetaAdvisorRedactedResultBlock: …`

            - `encrypted_content: str`

              Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

            - `stop_reason: Optional[str]`

              The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

            - `type: Literal["advisor_redacted_result"]`

              - `"advisor_redacted_result"`

        - `tool_use_id: str`

        - `type: Literal["advisor_tool_result"]`

          - `"advisor_tool_result"`

      - `class BetaCodeExecutionToolResultBlock: …`

        - `content: BetaCodeExecutionToolResultBlockContent`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `class BetaCodeExecutionToolResultError: …`

            - `error_code: BetaCodeExecutionToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["code_execution_tool_result_error"]`

              - `"code_execution_tool_result_error"`

          - `class BetaCodeExecutionResultBlock: …`

            - `content: List[BetaCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

                - `"code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["code_execution_result"]`

              - `"code_execution_result"`

          - `class BetaEncryptedCodeExecutionResultBlock: …`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `content: List[BetaCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

            - `encrypted_stdout: str`

            - `return_code: int`

            - `stderr: str`

            - `type: Literal["encrypted_code_execution_result"]`

              - `"encrypted_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["code_execution_tool_result"]`

          - `"code_execution_tool_result"`

      - `class BetaBashCodeExecutionToolResultBlock: …`

        - `content: Content`

          - `class BetaBashCodeExecutionToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"output_file_too_large"`

            - `type: Literal["bash_code_execution_tool_result_error"]`

              - `"bash_code_execution_tool_result_error"`

          - `class BetaBashCodeExecutionResultBlock: …`

            - `content: List[BetaBashCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["bash_code_execution_output"]`

                - `"bash_code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["bash_code_execution_result"]`

              - `"bash_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["bash_code_execution_tool_result"]`

          - `"bash_code_execution_tool_result"`

      - `class BetaTextEditorCodeExecutionToolResultBlock: …`

        - `content: Content`

          - `class BetaTextEditorCodeExecutionToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"file_not_found"`

            - `error_message: Optional[str]`

            - `type: Literal["text_editor_code_execution_tool_result_error"]`

              - `"text_editor_code_execution_tool_result_error"`

          - `class BetaTextEditorCodeExecutionViewResultBlock: …`

            - `content: str`

            - `file_type: Literal["text", "image", "pdf"]`

              - `"text"`

              - `"image"`

              - `"pdf"`

            - `num_lines: Optional[int]`

            - `start_line: Optional[int]`

            - `total_lines: Optional[int]`

            - `type: Literal["text_editor_code_execution_view_result"]`

              - `"text_editor_code_execution_view_result"`

          - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

            - `is_file_update: bool`

            - `type: Literal["text_editor_code_execution_create_result"]`

              - `"text_editor_code_execution_create_result"`

          - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

            - `lines: Optional[List[str]]`

            - `new_lines: Optional[int]`

            - `new_start: Optional[int]`

            - `old_lines: Optional[int]`

            - `old_start: Optional[int]`

            - `type: Literal["text_editor_code_execution_str_replace_result"]`

              - `"text_editor_code_execution_str_replace_result"`

        - `tool_use_id: str`

        - `type: Literal["text_editor_code_execution_tool_result"]`

          - `"text_editor_code_execution_tool_result"`

      - `class BetaToolSearchToolResultBlock: …`

        - `content: Content`

          - `class BetaToolSearchToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `error_message: Optional[str]`

            - `type: Literal["tool_search_tool_result_error"]`

              - `"tool_search_tool_result_error"`

          - `class BetaToolSearchToolSearchResultBlock: …`

            - `tool_references: List[BetaToolReferenceBlock]`

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

                - `"tool_reference"`

            - `type: Literal["tool_search_tool_search_result"]`

              - `"tool_search_tool_search_result"`

        - `tool_use_id: str`

        - `type: Literal["tool_search_tool_result"]`

          - `"tool_search_tool_result"`

      - `class BetaMCPToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

          The name of the MCP tool

        - `server_name: str`

          The name of the MCP server

        - `type: Literal["mcp_tool_use"]`

          - `"mcp_tool_use"`

      - `class BetaMCPToolResultBlock: …`

        - `content: Union[str, List[BetaTextBlock]]`

          - `str`

          - `List[BetaTextBlock]`

            - `citations: Optional[List[BetaTextCitation]]`

              Citations supporting the text block.

              The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

            - `text: str`

            - `type: Literal["text"]`

        - `is_error: bool`

        - `tool_use_id: str`

        - `type: Literal["mcp_tool_result"]`

          - `"mcp_tool_result"`

      - `class BetaContainerUploadBlock: …`

        Response model for a file uploaded to the container.

        - `file_id: str`

        - `type: Literal["container_upload"]`

          - `"container_upload"`

      - `class BetaCompactionBlock: …`

        A compaction block returned when autocompact is triggered.

        When content is None, it indicates the compaction failed to produce a valid
        summary (e.g., malformed output from the model). Clients may round-trip
        compaction blocks with null content; the server treats them as no-ops.

        - `content: Optional[str]`

          Summary of compacted content, or null if compaction failed

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

        - `type: Literal["compaction"]`

          - `"compaction"`

    - `context_management: Optional[BetaContextManagementResponse]`

      Context management response.

      Information about context management strategies applied during the request.

      - `applied_edits: List[AppliedEdit]`

        List of context management edits that were applied.

        - `class BetaClearToolUses20250919EditResponse: …`

          - `cleared_input_tokens: int`

            Number of input tokens cleared by this edit.

          - `cleared_tool_uses: int`

            Number of tool uses that were cleared.

          - `type: Literal["clear_tool_uses_20250919"]`

            The type of context management edit applied.

            - `"clear_tool_uses_20250919"`

        - `class BetaClearThinking20251015EditResponse: …`

          - `cleared_input_tokens: int`

            Number of input tokens cleared by this edit.

          - `cleared_thinking_turns: int`

            Number of thinking turns that were cleared.

          - `type: Literal["clear_thinking_20251015"]`

            The type of context management edit applied.

            - `"clear_thinking_20251015"`

    - `diagnostics: Optional[BetaDiagnostics]`

      Response envelope for request-level diagnostics. Present (possibly
      null) whenever the caller supplied `diagnostics` on the request.

      - `cache_miss_reason: Optional[CacheMissReason]`

        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.

        - `class BetaCacheMissModelChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["model_changed"]`

            - `"model_changed"`

        - `class BetaCacheMissSystemChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["system_changed"]`

            - `"system_changed"`

        - `class BetaCacheMissToolsChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["tools_changed"]`

            - `"tools_changed"`

        - `class BetaCacheMissMessagesChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["messages_changed"]`

            - `"messages_changed"`

        - `class BetaCacheMissPreviousMessageNotFound: …`

          - `type: Literal["previous_message_not_found"]`

            - `"previous_message_not_found"`

        - `class BetaCacheMissUnavailable: …`

          - `type: Literal["unavailable"]`

            - `"unavailable"`

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
        - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
        - `claude-opus-4-1` - Exceptional model for specialized complex tasks
        - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
        - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-mythos-preview"`

          New class of intelligence, strongest in coding and cybersecurity

        - `"claude-opus-4-6"`

          Frontier intelligence for long-running agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

        - `"claude-opus-4-1"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-1-20250805"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-0"`

          Powerful model for complex tasks

        - `"claude-opus-4-20250514"`

          Powerful model for complex tasks

        - `"claude-sonnet-4-0"`

          High-performance model with extended thinking

        - `"claude-sonnet-4-20250514"`

          High-performance model with extended thinking

        - `"claude-3-haiku-20240307"`

          Fast and cost-effective model

      - `str`

    - `role: Literal["assistant"]`

      Conversational role of the generated message.

      This will always be `"assistant"`.

      - `"assistant"`

    - `stop_details: Optional[BetaRefusalStopDetails]`

      Structured information about a refusal.

      - `category: Optional[Literal["cyber", "bio"]]`

        The policy category that triggered the refusal.

        `null` when the refusal doesn't map to a named category.

        - `"cyber"`

        - `"bio"`

      - `explanation: Optional[str]`

        Human-readable explanation of the refusal.

        This text is not guaranteed to be stable. `null` when no explanation is available for the category.

      - `type: Literal["refusal"]`

        - `"refusal"`

    - `stop_reason: Optional[BetaStopReason]`

      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 maximum
      * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
      * `"tool_use"`: the model invoked one or more tools
      * `"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.
      * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

      In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

      - `"end_turn"`

      - `"max_tokens"`

      - `"stop_sequence"`

      - `"tool_use"`

      - `"pause_turn"`

      - `"compaction"`

      - `"refusal"`

      - `"model_context_window_exceeded"`

    - `stop_sequence: Optional[str]`

      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.

    - `type: Literal["message"]`

      Object type.

      For Messages, this is always `"message"`.

      - `"message"`

    - `usage: BetaUsage`

      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 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.

      For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

      Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

        - `ephemeral_1h_input_tokens: int`

          The number of input tokens used to create the 1 hour cache entry.

        - `ephemeral_5m_input_tokens: int`

          The number of input tokens used to create the 5 minute cache entry.

      - `cache_creation_input_tokens: Optional[int]`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: Optional[int]`

        The number of input tokens read from the cache.

      - `inference_geo: Optional[str]`

        The geographic region where inference was performed for this request.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `iterations: Optional[BetaIterationsUsage]`

        Per-iteration token usage breakdown.

        Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

        - Determine which iterations exceeded long context thresholds (>=200k tokens)
        - Calculate the true context window size from the last iteration
        - Understand token accumulation across server-side tool use loops

        - `class BetaMessageIterationUsage: …`

          Token usage for a sampling iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["message"]`

            Usage for a sampling iteration

            - `"message"`

        - `class BetaCompactionIterationUsage: …`

          Token usage for a compaction iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["compaction"]`

            Usage for a compaction iteration

            - `"compaction"`

        - `class BetaAdvisorMessageIterationUsage: …`

          Token usage for an advisor sub-inference iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `model: Model`

            The model that will complete your prompt.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["advisor_message"]`

            Usage for an advisor sub-inference iteration

            - `"advisor_message"`

      - `output_tokens: int`

        The number of output tokens which were used.

      - `output_tokens_details: Optional[BetaOutputTokensDetails]`

        Breakdown of output tokens by category.

        `output_tokens` remains the inclusive, authoritative total used for billing.
        This object provides a read-only decomposition for observability — for example,
        how many of the billed output tokens were spent on internal reasoning that may
        have been summarized before being returned to you.

        - `thinking_tokens: int`

          Number of output tokens the model generated as internal reasoning, including
          the thinking-block delimiter tokens.

          Reflects the raw reasoning the model produced, not the (possibly shorter)
          summarized thinking text returned in the response body. Computed by
          re-tokenizing the raw reasoning text, so it may differ from the model's exact
          generation count by a small number of tokens. Always ≤ `output_tokens`;
          `output_tokens - thinking_tokens` approximates the non-reasoning output.

      - `server_tool_use: Optional[BetaServerToolUsage]`

        The number of server tool requests.

        - `web_fetch_requests: int`

          The number of web fetch tool requests.

        - `web_search_requests: int`

          The number of web search tool requests.

      - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

        If the request used the priority, standard, or batch tier.

        - `"standard"`

        - `"priority"`

        - `"batch"`

      - `speed: Optional[Literal["standard", "fast"]]`

        The inference speed mode used for this request.

        - `"standard"`

        - `"fast"`

  - `type: Literal["message_start"]`

    - `"message_start"`

### Beta Raw Message Stop Event

- `class BetaRawMessageStopEvent: …`

  - `type: Literal["message_stop"]`

    - `"message_stop"`

### Beta Raw Message Stream Event

- `BetaRawMessageStreamEvent`

  - `class BetaRawMessageStartEvent: …`

    - `message: BetaMessage`

      - `id: str`

        Unique object identifier.

        The format and length of IDs may change over time.

      - `container: Optional[BetaContainer]`

        Information about the container used in the request (for the code execution tool)

        - `id: str`

          Identifier for the container used in this request

        - `expires_at: datetime`

          The time at which the container will expire.

        - `skills: Optional[List[BetaSkill]]`

          Skills loaded in the container

          - `skill_id: str`

            Skill ID

          - `type: Literal["anthropic", "custom"]`

            Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

            - `"anthropic"`

            - `"custom"`

          - `version: str`

            Skill version or 'latest' for most recent version

      - `content: List[BetaContentBlock]`

        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 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.

        For example, if the input `messages` were:

        ```json
        [
          {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
          {"role": "assistant", "content": "The best answer is ("}
        ]
        ```

        Then the response `content` might be:

        ```json
        [{"type": "text", "text": "B)"}]
        ```

        - `class BetaTextBlock: …`

          - `citations: Optional[List[BetaTextCitation]]`

            Citations supporting the text block.

            The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

            - `class BetaCitationCharLocation: …`

              - `cited_text: str`

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_char_index: int`

              - `file_id: Optional[str]`

              - `start_char_index: int`

              - `type: Literal["char_location"]`

                - `"char_location"`

            - `class BetaCitationPageLocation: …`

              - `cited_text: str`

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_page_number: int`

              - `file_id: Optional[str]`

              - `start_page_number: int`

              - `type: Literal["page_location"]`

                - `"page_location"`

            - `class BetaCitationContentBlockLocation: …`

              - `cited_text: str`

                The full text of the cited block range, concatenated.

                Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_block_index: int`

                Exclusive 0-based end index of the cited block range in the source's `content` array.

                Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

              - `file_id: Optional[str]`

              - `start_block_index: int`

                0-based index of the first cited block in the source's `content` array.

              - `type: Literal["content_block_location"]`

                - `"content_block_location"`

            - `class BetaCitationsWebSearchResultLocation: …`

              - `cited_text: str`

              - `encrypted_index: str`

              - `title: Optional[str]`

              - `type: Literal["web_search_result_location"]`

                - `"web_search_result_location"`

              - `url: str`

            - `class BetaCitationSearchResultLocation: …`

              - `cited_text: str`

                The full text of the cited block range, concatenated.

                Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

              - `end_block_index: int`

                Exclusive 0-based end index of the cited block range in the source's `content` array.

                Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

              - `search_result_index: int`

                0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                Counted separately from `document_index`; server-side web search results are not included in this count.

              - `source: str`

              - `start_block_index: int`

                0-based index of the first cited block in the source's `content` array.

              - `title: Optional[str]`

              - `type: Literal["search_result_location"]`

                - `"search_result_location"`

          - `text: str`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaThinkingBlock: …`

          - `signature: str`

          - `thinking: str`

          - `type: Literal["thinking"]`

            - `"thinking"`

        - `class BetaRedactedThinkingBlock: …`

          - `data: str`

          - `type: Literal["redacted_thinking"]`

            - `"redacted_thinking"`

        - `class BetaToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: str`

          - `type: Literal["tool_use"]`

            - `"tool_use"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

              - `type: Literal["direct"]`

                - `"direct"`

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

              - `tool_id: str`

              - `type: Literal["code_execution_20250825"]`

                - `"code_execution_20250825"`

            - `class BetaServerToolCaller20260120: …`

              - `tool_id: str`

              - `type: Literal["code_execution_20260120"]`

                - `"code_execution_20260120"`

        - `class BetaServerToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

            - `"advisor"`

            - `"web_search"`

            - `"web_fetch"`

            - `"code_execution"`

            - `"bash_code_execution"`

            - `"text_editor_code_execution"`

            - `"tool_search_tool_regex"`

            - `"tool_search_tool_bm25"`

          - `type: Literal["server_tool_use"]`

            - `"server_tool_use"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaWebSearchToolResultBlock: …`

          - `content: BetaWebSearchToolResultBlockContent`

            - `class BetaWebSearchToolResultError: …`

              - `error_code: BetaWebSearchToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"max_uses_exceeded"`

                - `"too_many_requests"`

                - `"query_too_long"`

                - `"request_too_large"`

              - `type: Literal["web_search_tool_result_error"]`

                - `"web_search_tool_result_error"`

            - `List[BetaWebSearchResultBlock]`

              - `encrypted_content: str`

              - `page_age: Optional[str]`

              - `title: str`

              - `type: Literal["web_search_result"]`

                - `"web_search_result"`

              - `url: str`

          - `tool_use_id: str`

          - `type: Literal["web_search_tool_result"]`

            - `"web_search_tool_result"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaWebFetchToolResultBlock: …`

          - `content: Content`

            - `class BetaWebFetchToolResultErrorBlock: …`

              - `error_code: BetaWebFetchToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"url_too_long"`

                - `"url_not_allowed"`

                - `"url_not_in_prior_context"`

                - `"url_not_accessible"`

                - `"unsupported_content_type"`

                - `"too_many_requests"`

                - `"max_uses_exceeded"`

                - `"unavailable"`

              - `type: Literal["web_fetch_tool_result_error"]`

                - `"web_fetch_tool_result_error"`

            - `class BetaWebFetchBlock: …`

              - `content: BetaDocumentBlock`

                - `citations: Optional[BetaCitationConfig]`

                  Citation configuration for the document

                  - `enabled: bool`

                - `source: Source`

                  - `class BetaBase64PDFSource: …`

                    - `data: str`

                    - `media_type: Literal["application/pdf"]`

                      - `"application/pdf"`

                    - `type: Literal["base64"]`

                      - `"base64"`

                  - `class BetaPlainTextSource: …`

                    - `data: str`

                    - `media_type: Literal["text/plain"]`

                      - `"text/plain"`

                    - `type: Literal["text"]`

                      - `"text"`

                - `title: Optional[str]`

                  The title of the document

                - `type: Literal["document"]`

                  - `"document"`

              - `retrieved_at: Optional[str]`

                ISO 8601 timestamp when the content was retrieved

              - `type: Literal["web_fetch_result"]`

                - `"web_fetch_result"`

              - `url: str`

                Fetched content URL

          - `tool_use_id: str`

          - `type: Literal["web_fetch_tool_result"]`

            - `"web_fetch_tool_result"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaAdvisorToolResultBlock: …`

          - `content: Content`

            - `class BetaAdvisorToolResultError: …`

              - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

                - `"max_uses_exceeded"`

                - `"prompt_too_long"`

                - `"too_many_requests"`

                - `"overloaded"`

                - `"unavailable"`

                - `"execution_time_exceeded"`

              - `type: Literal["advisor_tool_result_error"]`

                - `"advisor_tool_result_error"`

            - `class BetaAdvisorResultBlock: …`

              - `stop_reason: Optional[str]`

                The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

              - `text: str`

              - `type: Literal["advisor_result"]`

                - `"advisor_result"`

            - `class BetaAdvisorRedactedResultBlock: …`

              - `encrypted_content: str`

                Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

              - `stop_reason: Optional[str]`

                The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

              - `type: Literal["advisor_redacted_result"]`

                - `"advisor_redacted_result"`

          - `tool_use_id: str`

          - `type: Literal["advisor_tool_result"]`

            - `"advisor_tool_result"`

        - `class BetaCodeExecutionToolResultBlock: …`

          - `content: BetaCodeExecutionToolResultBlockContent`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `class BetaCodeExecutionToolResultError: …`

              - `error_code: BetaCodeExecutionToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

              - `type: Literal["code_execution_tool_result_error"]`

                - `"code_execution_tool_result_error"`

            - `class BetaCodeExecutionResultBlock: …`

              - `content: List[BetaCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["code_execution_output"]`

                  - `"code_execution_output"`

              - `return_code: int`

              - `stderr: str`

              - `stdout: str`

              - `type: Literal["code_execution_result"]`

                - `"code_execution_result"`

            - `class BetaEncryptedCodeExecutionResultBlock: …`

              Code execution result with encrypted stdout for PFC + web_search results.

              - `content: List[BetaCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["code_execution_output"]`

              - `encrypted_stdout: str`

              - `return_code: int`

              - `stderr: str`

              - `type: Literal["encrypted_code_execution_result"]`

                - `"encrypted_code_execution_result"`

          - `tool_use_id: str`

          - `type: Literal["code_execution_tool_result"]`

            - `"code_execution_tool_result"`

        - `class BetaBashCodeExecutionToolResultBlock: …`

          - `content: Content`

            - `class BetaBashCodeExecutionToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

                - `"output_file_too_large"`

              - `type: Literal["bash_code_execution_tool_result_error"]`

                - `"bash_code_execution_tool_result_error"`

            - `class BetaBashCodeExecutionResultBlock: …`

              - `content: List[BetaBashCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["bash_code_execution_output"]`

                  - `"bash_code_execution_output"`

              - `return_code: int`

              - `stderr: str`

              - `stdout: str`

              - `type: Literal["bash_code_execution_result"]`

                - `"bash_code_execution_result"`

          - `tool_use_id: str`

          - `type: Literal["bash_code_execution_tool_result"]`

            - `"bash_code_execution_tool_result"`

        - `class BetaTextEditorCodeExecutionToolResultBlock: …`

          - `content: Content`

            - `class BetaTextEditorCodeExecutionToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

                - `"file_not_found"`

              - `error_message: Optional[str]`

              - `type: Literal["text_editor_code_execution_tool_result_error"]`

                - `"text_editor_code_execution_tool_result_error"`

            - `class BetaTextEditorCodeExecutionViewResultBlock: …`

              - `content: str`

              - `file_type: Literal["text", "image", "pdf"]`

                - `"text"`

                - `"image"`

                - `"pdf"`

              - `num_lines: Optional[int]`

              - `start_line: Optional[int]`

              - `total_lines: Optional[int]`

              - `type: Literal["text_editor_code_execution_view_result"]`

                - `"text_editor_code_execution_view_result"`

            - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

              - `is_file_update: bool`

              - `type: Literal["text_editor_code_execution_create_result"]`

                - `"text_editor_code_execution_create_result"`

            - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

              - `lines: Optional[List[str]]`

              - `new_lines: Optional[int]`

              - `new_start: Optional[int]`

              - `old_lines: Optional[int]`

              - `old_start: Optional[int]`

              - `type: Literal["text_editor_code_execution_str_replace_result"]`

                - `"text_editor_code_execution_str_replace_result"`

          - `tool_use_id: str`

          - `type: Literal["text_editor_code_execution_tool_result"]`

            - `"text_editor_code_execution_tool_result"`

        - `class BetaToolSearchToolResultBlock: …`

          - `content: Content`

            - `class BetaToolSearchToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

              - `error_message: Optional[str]`

              - `type: Literal["tool_search_tool_result_error"]`

                - `"tool_search_tool_result_error"`

            - `class BetaToolSearchToolSearchResultBlock: …`

              - `tool_references: List[BetaToolReferenceBlock]`

                - `tool_name: str`

                - `type: Literal["tool_reference"]`

                  - `"tool_reference"`

              - `type: Literal["tool_search_tool_search_result"]`

                - `"tool_search_tool_search_result"`

          - `tool_use_id: str`

          - `type: Literal["tool_search_tool_result"]`

            - `"tool_search_tool_result"`

        - `class BetaMCPToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: str`

            The name of the MCP tool

          - `server_name: str`

            The name of the MCP server

          - `type: Literal["mcp_tool_use"]`

            - `"mcp_tool_use"`

        - `class BetaMCPToolResultBlock: …`

          - `content: Union[str, List[BetaTextBlock]]`

            - `str`

            - `List[BetaTextBlock]`

              - `citations: Optional[List[BetaTextCitation]]`

                Citations supporting the text block.

                The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

              - `text: str`

              - `type: Literal["text"]`

          - `is_error: bool`

          - `tool_use_id: str`

          - `type: Literal["mcp_tool_result"]`

            - `"mcp_tool_result"`

        - `class BetaContainerUploadBlock: …`

          Response model for a file uploaded to the container.

          - `file_id: str`

          - `type: Literal["container_upload"]`

            - `"container_upload"`

        - `class BetaCompactionBlock: …`

          A compaction block returned when autocompact is triggered.

          When content is None, it indicates the compaction failed to produce a valid
          summary (e.g., malformed output from the model). Clients may round-trip
          compaction blocks with null content; the server treats them as no-ops.

          - `content: Optional[str]`

            Summary of compacted content, or null if compaction failed

          - `encrypted_content: Optional[str]`

            Opaque metadata from prior compaction, to be round-tripped verbatim

          - `type: Literal["compaction"]`

            - `"compaction"`

      - `context_management: Optional[BetaContextManagementResponse]`

        Context management response.

        Information about context management strategies applied during the request.

        - `applied_edits: List[AppliedEdit]`

          List of context management edits that were applied.

          - `class BetaClearToolUses20250919EditResponse: …`

            - `cleared_input_tokens: int`

              Number of input tokens cleared by this edit.

            - `cleared_tool_uses: int`

              Number of tool uses that were cleared.

            - `type: Literal["clear_tool_uses_20250919"]`

              The type of context management edit applied.

              - `"clear_tool_uses_20250919"`

          - `class BetaClearThinking20251015EditResponse: …`

            - `cleared_input_tokens: int`

              Number of input tokens cleared by this edit.

            - `cleared_thinking_turns: int`

              Number of thinking turns that were cleared.

            - `type: Literal["clear_thinking_20251015"]`

              The type of context management edit applied.

              - `"clear_thinking_20251015"`

      - `diagnostics: Optional[BetaDiagnostics]`

        Response envelope for request-level diagnostics. Present (possibly
        null) whenever the caller supplied `diagnostics` on the request.

        - `cache_miss_reason: Optional[CacheMissReason]`

          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.

          - `class BetaCacheMissModelChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["model_changed"]`

              - `"model_changed"`

          - `class BetaCacheMissSystemChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["system_changed"]`

              - `"system_changed"`

          - `class BetaCacheMissToolsChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["tools_changed"]`

              - `"tools_changed"`

          - `class BetaCacheMissMessagesChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["messages_changed"]`

              - `"messages_changed"`

          - `class BetaCacheMissPreviousMessageNotFound: …`

            - `type: Literal["previous_message_not_found"]`

              - `"previous_message_not_found"`

          - `class BetaCacheMissUnavailable: …`

            - `type: Literal["unavailable"]`

              - `"unavailable"`

      - `model: Model`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
          - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
          - `claude-opus-4-1` - Exceptional model for specialized complex tasks
          - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
          - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-mythos-preview"`

            New class of intelligence, strongest in coding and cybersecurity

          - `"claude-opus-4-6"`

            Frontier intelligence for long-running agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

          - `"claude-opus-4-1"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-1-20250805"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-0"`

            Powerful model for complex tasks

          - `"claude-opus-4-20250514"`

            Powerful model for complex tasks

          - `"claude-sonnet-4-0"`

            High-performance model with extended thinking

          - `"claude-sonnet-4-20250514"`

            High-performance model with extended thinking

          - `"claude-3-haiku-20240307"`

            Fast and cost-effective model

        - `str`

      - `role: Literal["assistant"]`

        Conversational role of the generated message.

        This will always be `"assistant"`.

        - `"assistant"`

      - `stop_details: Optional[BetaRefusalStopDetails]`

        Structured information about a refusal.

        - `category: Optional[Literal["cyber", "bio"]]`

          The policy category that triggered the refusal.

          `null` when the refusal doesn't map to a named category.

          - `"cyber"`

          - `"bio"`

        - `explanation: Optional[str]`

          Human-readable explanation of the refusal.

          This text is not guaranteed to be stable. `null` when no explanation is available for the category.

        - `type: Literal["refusal"]`

          - `"refusal"`

      - `stop_reason: Optional[BetaStopReason]`

        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 maximum
        * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
        * `"tool_use"`: the model invoked one or more tools
        * `"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.
        * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

        In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

        - `"end_turn"`

        - `"max_tokens"`

        - `"stop_sequence"`

        - `"tool_use"`

        - `"pause_turn"`

        - `"compaction"`

        - `"refusal"`

        - `"model_context_window_exceeded"`

      - `stop_sequence: Optional[str]`

        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.

      - `type: Literal["message"]`

        Object type.

        For Messages, this is always `"message"`.

        - `"message"`

      - `usage: BetaUsage`

        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 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.

        For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

        Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

          - `ephemeral_1h_input_tokens: int`

            The number of input tokens used to create the 1 hour cache entry.

          - `ephemeral_5m_input_tokens: int`

            The number of input tokens used to create the 5 minute cache entry.

        - `cache_creation_input_tokens: Optional[int]`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: Optional[int]`

          The number of input tokens read from the cache.

        - `inference_geo: Optional[str]`

          The geographic region where inference was performed for this request.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `iterations: Optional[BetaIterationsUsage]`

          Per-iteration token usage breakdown.

          Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

          - Determine which iterations exceeded long context thresholds (>=200k tokens)
          - Calculate the true context window size from the last iteration
          - Understand token accumulation across server-side tool use loops

          - `class BetaMessageIterationUsage: …`

            Token usage for a sampling iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["message"]`

              Usage for a sampling iteration

              - `"message"`

          - `class BetaCompactionIterationUsage: …`

            Token usage for a compaction iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["compaction"]`

              Usage for a compaction iteration

              - `"compaction"`

          - `class BetaAdvisorMessageIterationUsage: …`

            Token usage for an advisor sub-inference iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `model: Model`

              The model that will complete your prompt.

              See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["advisor_message"]`

              Usage for an advisor sub-inference iteration

              - `"advisor_message"`

        - `output_tokens: int`

          The number of output tokens which were used.

        - `output_tokens_details: Optional[BetaOutputTokensDetails]`

          Breakdown of output tokens by category.

          `output_tokens` remains the inclusive, authoritative total used for billing.
          This object provides a read-only decomposition for observability — for example,
          how many of the billed output tokens were spent on internal reasoning that may
          have been summarized before being returned to you.

          - `thinking_tokens: int`

            Number of output tokens the model generated as internal reasoning, including
            the thinking-block delimiter tokens.

            Reflects the raw reasoning the model produced, not the (possibly shorter)
            summarized thinking text returned in the response body. Computed by
            re-tokenizing the raw reasoning text, so it may differ from the model's exact
            generation count by a small number of tokens. Always ≤ `output_tokens`;
            `output_tokens - thinking_tokens` approximates the non-reasoning output.

        - `server_tool_use: Optional[BetaServerToolUsage]`

          The number of server tool requests.

          - `web_fetch_requests: int`

            The number of web fetch tool requests.

          - `web_search_requests: int`

            The number of web search tool requests.

        - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

          If the request used the priority, standard, or batch tier.

          - `"standard"`

          - `"priority"`

          - `"batch"`

        - `speed: Optional[Literal["standard", "fast"]]`

          The inference speed mode used for this request.

          - `"standard"`

          - `"fast"`

    - `type: Literal["message_start"]`

      - `"message_start"`

  - `class BetaRawMessageDeltaEvent: …`

    - `context_management: Optional[BetaContextManagementResponse]`

      Information about context management strategies applied during the request

    - `delta: Delta`

      - `container: Optional[BetaContainer]`

        Information about the container used in the request (for the code execution tool)

      - `stop_details: Optional[BetaRefusalStopDetails]`

        Structured information about a refusal.

      - `stop_reason: Optional[BetaStopReason]`

      - `stop_sequence: Optional[str]`

    - `type: Literal["message_delta"]`

      - `"message_delta"`

    - `usage: BetaMessageDeltaUsage`

      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 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.

      For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

      Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

      - `cache_creation_input_tokens: Optional[int]`

        The cumulative number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: Optional[int]`

        The cumulative number of input tokens read from the cache.

      - `input_tokens: Optional[int]`

        The cumulative number of input tokens which were used.

      - `iterations: Optional[BetaIterationsUsage]`

        Per-iteration token usage breakdown.

        Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

        - Determine which iterations exceeded long context thresholds (>=200k tokens)
        - Calculate the true context window size from the last iteration
        - Understand token accumulation across server-side tool use loops

      - `output_tokens: int`

        The cumulative number of output tokens which were used.

      - `output_tokens_details: Optional[BetaOutputTokensDetails]`

        Breakdown of output tokens by category.

        `output_tokens` remains the inclusive, authoritative total used for billing.
        This object provides a read-only decomposition for observability — for example,
        how many of the billed output tokens were spent on internal reasoning that may
        have been summarized before being returned to you.

      - `server_tool_use: Optional[BetaServerToolUsage]`

        The number of server tool requests.

  - `class BetaRawMessageStopEvent: …`

    - `type: Literal["message_stop"]`

      - `"message_stop"`

  - `class BetaRawContentBlockStartEvent: …`

    - `content_block: ContentBlock`

      Response model for a file uploaded to the container.

      - `class BetaTextBlock: …`

      - `class BetaThinkingBlock: …`

      - `class BetaRedactedThinkingBlock: …`

      - `class BetaToolUseBlock: …`

      - `class BetaServerToolUseBlock: …`

      - `class BetaWebSearchToolResultBlock: …`

      - `class BetaWebFetchToolResultBlock: …`

      - `class BetaAdvisorToolResultBlock: …`

      - `class BetaCodeExecutionToolResultBlock: …`

      - `class BetaBashCodeExecutionToolResultBlock: …`

      - `class BetaTextEditorCodeExecutionToolResultBlock: …`

      - `class BetaToolSearchToolResultBlock: …`

      - `class BetaMCPToolUseBlock: …`

      - `class BetaMCPToolResultBlock: …`

      - `class BetaContainerUploadBlock: …`

        Response model for a file uploaded to the container.

      - `class BetaCompactionBlock: …`

        A compaction block returned when autocompact is triggered.

        When content is None, it indicates the compaction failed to produce a valid
        summary (e.g., malformed output from the model). Clients may round-trip
        compaction blocks with null content; the server treats them as no-ops.

    - `index: int`

    - `type: Literal["content_block_start"]`

      - `"content_block_start"`

  - `class BetaRawContentBlockDeltaEvent: …`

    - `delta: BetaRawContentBlockDelta`

      - `class BetaTextDelta: …`

        - `text: str`

        - `type: Literal["text_delta"]`

          - `"text_delta"`

      - `class BetaInputJSONDelta: …`

        - `partial_json: str`

        - `type: Literal["input_json_delta"]`

          - `"input_json_delta"`

      - `class BetaCitationsDelta: …`

        - `citation: Citation`

          - `class BetaCitationCharLocation: …`

          - `class BetaCitationPageLocation: …`

          - `class BetaCitationContentBlockLocation: …`

          - `class BetaCitationsWebSearchResultLocation: …`

          - `class BetaCitationSearchResultLocation: …`

        - `type: Literal["citations_delta"]`

          - `"citations_delta"`

      - `class BetaThinkingDelta: …`

        - `estimated_tokens: Optional[int]`

          Per-frame increment of a coarse, running estimate of the tokens this thinking block has produced so far. Present whenever the `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display` resolves to `"omitted"` and a count is due this frame. Sum the increments across `thinking_delta` frames on this block for a progress indicator. Each increment is a non-negative multiple of a fixed quantum and the cadence is rate-limited, so this is a deliberately lossy display hint, not a billable count; `usage.output_tokens` remains authoritative.

        - `thinking: str`

        - `type: Literal["thinking_delta"]`

          - `"thinking_delta"`

      - `class BetaSignatureDelta: …`

        - `signature: str`

        - `type: Literal["signature_delta"]`

          - `"signature_delta"`

      - `class BetaCompactionContentBlockDelta: …`

        - `content: Optional[str]`

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

        - `type: Literal["compaction_delta"]`

          - `"compaction_delta"`

    - `index: int`

    - `type: Literal["content_block_delta"]`

      - `"content_block_delta"`

  - `class BetaRawContentBlockStopEvent: …`

    - `index: int`

    - `type: Literal["content_block_stop"]`

      - `"content_block_stop"`

### Beta Redacted Thinking Block

- `class BetaRedactedThinkingBlock: …`

  - `data: str`

  - `type: Literal["redacted_thinking"]`

    - `"redacted_thinking"`

### Beta Redacted Thinking Block Param

- `class BetaRedactedThinkingBlockParam: …`

  - `data: str`

  - `type: Literal["redacted_thinking"]`

    - `"redacted_thinking"`

### Beta Refusal Stop Details

- `class BetaRefusalStopDetails: …`

  Structured information about a refusal.

  - `category: Optional[Literal["cyber", "bio"]]`

    The policy category that triggered the refusal.

    `null` when the refusal doesn't map to a named category.

    - `"cyber"`

    - `"bio"`

  - `explanation: Optional[str]`

    Human-readable explanation of the refusal.

    This text is not guaranteed to be stable. `null` when no explanation is available for the category.

  - `type: Literal["refusal"]`

    - `"refusal"`

### Beta Request Document Block

- `class BetaRequestDocumentBlock: …`

  - `source: Source`

    - `class BetaBase64PDFSource: …`

      - `data: str`

      - `media_type: Literal["application/pdf"]`

        - `"application/pdf"`

      - `type: Literal["base64"]`

        - `"base64"`

    - `class BetaPlainTextSource: …`

      - `data: str`

      - `media_type: Literal["text/plain"]`

        - `"text/plain"`

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaContentBlockSource: …`

      - `content: Union[str, List[BetaContentBlockSourceContent]]`

        - `str`

        - `List[BetaContentBlockSourceContent]`

          - `class BetaTextBlockParam: …`

            - `text: str`

            - `type: Literal["text"]`

              - `"text"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

              - `type: Literal["ephemeral"]`

                - `"ephemeral"`

              - `ttl: Optional[Literal["5m", "1h"]]`

                The time-to-live for the cache control breakpoint.

                This may be one the following values:

                - `5m`: 5 minutes
                - `1h`: 1 hour

                Defaults to `5m`.

                - `"5m"`

                - `"1h"`

            - `citations: Optional[List[BetaTextCitationParam]]`

              - `class BetaCitationCharLocationParam: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_char_index: int`

                - `start_char_index: int`

                - `type: Literal["char_location"]`

                  - `"char_location"`

              - `class BetaCitationPageLocationParam: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_page_number: int`

                - `start_page_number: int`

                - `type: Literal["page_location"]`

                  - `"page_location"`

              - `class BetaCitationContentBlockLocationParam: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `type: Literal["content_block_location"]`

                  - `"content_block_location"`

              - `class BetaCitationWebSearchResultLocationParam: …`

                - `cited_text: str`

                - `encrypted_index: str`

                - `title: Optional[str]`

                - `type: Literal["web_search_result_location"]`

                  - `"web_search_result_location"`

                - `url: str`

              - `class BetaCitationSearchResultLocationParam: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `search_result_index: int`

                  0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                  Counted separately from `document_index`; server-side web search results are not included in this count.

                - `source: str`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `title: Optional[str]`

                - `type: Literal["search_result_location"]`

                  - `"search_result_location"`

          - `class BetaImageBlockParam: …`

            - `source: Source`

              - `class BetaBase64ImageSource: …`

                - `data: str`

                - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

                  - `"image/jpeg"`

                  - `"image/png"`

                  - `"image/gif"`

                  - `"image/webp"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaURLImageSource: …`

                - `type: Literal["url"]`

                  - `"url"`

                - `url: str`

              - `class BetaFileImageSource: …`

                - `file_id: str`

                - `type: Literal["file"]`

                  - `"file"`

            - `type: Literal["image"]`

              - `"image"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

      - `type: Literal["content"]`

        - `"content"`

    - `class BetaURLPDFSource: …`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `class BetaFileDocumentSource: …`

      - `file_id: str`

      - `type: Literal["file"]`

        - `"file"`

  - `type: Literal["document"]`

    - `"document"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

  - `citations: Optional[BetaCitationsConfigParam]`

    - `enabled: Optional[bool]`

  - `context: Optional[str]`

  - `title: Optional[str]`

### Beta Request MCP Server Tool Configuration

- `class BetaRequestMCPServerToolConfiguration: …`

  - `allowed_tools: Optional[List[str]]`

  - `enabled: Optional[bool]`

### Beta Request MCP Server URL Definition

- `class BetaRequestMCPServerURLDefinition: …`

  - `name: str`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

  - `authorization_token: Optional[str]`

  - `tool_configuration: Optional[BetaRequestMCPServerToolConfiguration]`

    - `allowed_tools: Optional[List[str]]`

    - `enabled: Optional[bool]`

### Beta Request MCP Tool Result Block Param

- `class BetaRequestMCPToolResultBlockParam: …`

  - `tool_use_id: str`

  - `type: Literal["mcp_tool_result"]`

    - `"mcp_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

    - `str`

    - `List[BetaTextBlockParam]`

      - `text: str`

      - `type: Literal["text"]`

        - `"text"`

      - `cache_control: Optional[BetaCacheControlEphemeral]`

        Create a cache control breakpoint at this content block.

      - `citations: Optional[List[BetaTextCitationParam]]`

        - `class BetaCitationCharLocationParam: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_char_index: int`

          - `start_char_index: int`

          - `type: Literal["char_location"]`

            - `"char_location"`

        - `class BetaCitationPageLocationParam: …`

          - `cited_text: str`

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_page_number: int`

          - `start_page_number: int`

          - `type: Literal["page_location"]`

            - `"page_location"`

        - `class BetaCitationContentBlockLocationParam: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `document_index: int`

          - `document_title: Optional[str]`

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `type: Literal["content_block_location"]`

            - `"content_block_location"`

        - `class BetaCitationWebSearchResultLocationParam: …`

          - `cited_text: str`

          - `encrypted_index: str`

          - `title: Optional[str]`

          - `type: Literal["web_search_result_location"]`

            - `"web_search_result_location"`

          - `url: str`

        - `class BetaCitationSearchResultLocationParam: …`

          - `cited_text: str`

            The full text of the cited block range, concatenated.

            Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

          - `end_block_index: int`

            Exclusive 0-based end index of the cited block range in the source's `content` array.

            Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

          - `search_result_index: int`

            0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

            Counted separately from `document_index`; server-side web search results are not included in this count.

          - `source: str`

          - `start_block_index: int`

            0-based index of the first cited block in the source's `content` array.

          - `title: Optional[str]`

          - `type: Literal["search_result_location"]`

            - `"search_result_location"`

  - `is_error: Optional[bool]`

### Beta Search Result Block Param

- `class BetaSearchResultBlockParam: …`

  - `content: List[BetaTextBlockParam]`

    - `text: str`

    - `type: Literal["text"]`

      - `"text"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

    - `citations: Optional[List[BetaTextCitationParam]]`

      - `class BetaCitationCharLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_char_index: int`

        - `start_char_index: int`

        - `type: Literal["char_location"]`

          - `"char_location"`

      - `class BetaCitationPageLocationParam: …`

        - `cited_text: str`

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_page_number: int`

        - `start_page_number: int`

        - `type: Literal["page_location"]`

          - `"page_location"`

      - `class BetaCitationContentBlockLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `document_index: int`

        - `document_title: Optional[str]`

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `type: Literal["content_block_location"]`

          - `"content_block_location"`

      - `class BetaCitationWebSearchResultLocationParam: …`

        - `cited_text: str`

        - `encrypted_index: str`

        - `title: Optional[str]`

        - `type: Literal["web_search_result_location"]`

          - `"web_search_result_location"`

        - `url: str`

      - `class BetaCitationSearchResultLocationParam: …`

        - `cited_text: str`

          The full text of the cited block range, concatenated.

          Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

        - `end_block_index: int`

          Exclusive 0-based end index of the cited block range in the source's `content` array.

          Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

        - `search_result_index: int`

          0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

          Counted separately from `document_index`; server-side web search results are not included in this count.

        - `source: str`

        - `start_block_index: int`

          0-based index of the first cited block in the source's `content` array.

        - `title: Optional[str]`

        - `type: Literal["search_result_location"]`

          - `"search_result_location"`

  - `source: str`

  - `title: str`

  - `type: Literal["search_result"]`

    - `"search_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

  - `citations: Optional[BetaCitationsConfigParam]`

    - `enabled: Optional[bool]`

### Beta Server Tool Caller

- `class BetaServerToolCaller: …`

  Tool invocation generated by a server-side tool.

  - `tool_id: str`

  - `type: Literal["code_execution_20250825"]`

    - `"code_execution_20250825"`

### Beta Server Tool Caller 20260120

- `class BetaServerToolCaller20260120: …`

  - `tool_id: str`

  - `type: Literal["code_execution_20260120"]`

    - `"code_execution_20260120"`

### Beta Server Tool Usage

- `class BetaServerToolUsage: …`

  - `web_fetch_requests: int`

    The number of web fetch tool requests.

  - `web_search_requests: int`

    The number of web search tool requests.

### Beta Server Tool Use Block

- `class BetaServerToolUseBlock: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

    - `"advisor"`

    - `"web_search"`

    - `"web_fetch"`

    - `"code_execution"`

    - `"bash_code_execution"`

    - `"text_editor_code_execution"`

    - `"tool_search_tool_regex"`

    - `"tool_search_tool_bm25"`

  - `type: Literal["server_tool_use"]`

    - `"server_tool_use"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Server Tool Use Block Param

- `class BetaServerToolUseBlockParam: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

    - `"advisor"`

    - `"web_search"`

    - `"web_fetch"`

    - `"code_execution"`

    - `"bash_code_execution"`

    - `"text_editor_code_execution"`

    - `"tool_search_tool_regex"`

    - `"tool_search_tool_bm25"`

  - `type: Literal["server_tool_use"]`

    - `"server_tool_use"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Signature Delta

- `class BetaSignatureDelta: …`

  - `signature: str`

  - `type: Literal["signature_delta"]`

    - `"signature_delta"`

### Beta Skill

- `class BetaSkill: …`

  A skill that was loaded in a container (response model).

  - `skill_id: str`

    Skill ID

  - `type: Literal["anthropic", "custom"]`

    Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

    - `"anthropic"`

    - `"custom"`

  - `version: str`

    Skill version or 'latest' for most recent version

### Beta Skill Params

- `class BetaSkillParams: …`

  Specification for a skill to be loaded in a container (request model).

  - `skill_id: str`

    Skill ID

  - `type: Literal["anthropic", "custom"]`

    Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

    - `"anthropic"`

    - `"custom"`

  - `version: Optional[str]`

    Skill version or 'latest' for most recent version

### Beta Stop Reason

- `Literal["end_turn", "max_tokens", "stop_sequence", 5 more]`

  - `"end_turn"`

  - `"max_tokens"`

  - `"stop_sequence"`

  - `"tool_use"`

  - `"pause_turn"`

  - `"compaction"`

  - `"refusal"`

  - `"model_context_window_exceeded"`

### Beta Text Block

- `class BetaTextBlock: …`

  - `citations: Optional[List[BetaTextCitation]]`

    Citations supporting the text block.

    The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

    - `class BetaCitationCharLocation: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_char_index: int`

      - `file_id: Optional[str]`

      - `start_char_index: int`

      - `type: Literal["char_location"]`

        - `"char_location"`

    - `class BetaCitationPageLocation: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_page_number: int`

      - `file_id: Optional[str]`

      - `start_page_number: int`

      - `type: Literal["page_location"]`

        - `"page_location"`

    - `class BetaCitationContentBlockLocation: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `file_id: Optional[str]`

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `type: Literal["content_block_location"]`

        - `"content_block_location"`

    - `class BetaCitationsWebSearchResultLocation: …`

      - `cited_text: str`

      - `encrypted_index: str`

      - `title: Optional[str]`

      - `type: Literal["web_search_result_location"]`

        - `"web_search_result_location"`

      - `url: str`

    - `class BetaCitationSearchResultLocation: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `search_result_index: int`

        0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

        Counted separately from `document_index`; server-side web search results are not included in this count.

      - `source: str`

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `title: Optional[str]`

      - `type: Literal["search_result_location"]`

        - `"search_result_location"`

  - `text: str`

  - `type: Literal["text"]`

    - `"text"`

### Beta Text Block Param

- `class BetaTextBlockParam: …`

  - `text: str`

  - `type: Literal["text"]`

    - `"text"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `citations: Optional[List[BetaTextCitationParam]]`

    - `class BetaCitationCharLocationParam: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_char_index: int`

      - `start_char_index: int`

      - `type: Literal["char_location"]`

        - `"char_location"`

    - `class BetaCitationPageLocationParam: …`

      - `cited_text: str`

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_page_number: int`

      - `start_page_number: int`

      - `type: Literal["page_location"]`

        - `"page_location"`

    - `class BetaCitationContentBlockLocationParam: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `document_index: int`

      - `document_title: Optional[str]`

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `type: Literal["content_block_location"]`

        - `"content_block_location"`

    - `class BetaCitationWebSearchResultLocationParam: …`

      - `cited_text: str`

      - `encrypted_index: str`

      - `title: Optional[str]`

      - `type: Literal["web_search_result_location"]`

        - `"web_search_result_location"`

      - `url: str`

    - `class BetaCitationSearchResultLocationParam: …`

      - `cited_text: str`

        The full text of the cited block range, concatenated.

        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

      - `end_block_index: int`

        Exclusive 0-based end index of the cited block range in the source's `content` array.

        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

      - `search_result_index: int`

        0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

        Counted separately from `document_index`; server-side web search results are not included in this count.

      - `source: str`

      - `start_block_index: int`

        0-based index of the first cited block in the source's `content` array.

      - `title: Optional[str]`

      - `type: Literal["search_result_location"]`

        - `"search_result_location"`

### Beta Text Citation

- `BetaTextCitation`

  - `class BetaCitationCharLocation: …`

    - `cited_text: str`

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_char_index: int`

    - `file_id: Optional[str]`

    - `start_char_index: int`

    - `type: Literal["char_location"]`

      - `"char_location"`

  - `class BetaCitationPageLocation: …`

    - `cited_text: str`

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_page_number: int`

    - `file_id: Optional[str]`

    - `start_page_number: int`

    - `type: Literal["page_location"]`

      - `"page_location"`

  - `class BetaCitationContentBlockLocation: …`

    - `cited_text: str`

      The full text of the cited block range, concatenated.

      Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_block_index: int`

      Exclusive 0-based end index of the cited block range in the source's `content` array.

      Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

    - `file_id: Optional[str]`

    - `start_block_index: int`

      0-based index of the first cited block in the source's `content` array.

    - `type: Literal["content_block_location"]`

      - `"content_block_location"`

  - `class BetaCitationsWebSearchResultLocation: …`

    - `cited_text: str`

    - `encrypted_index: str`

    - `title: Optional[str]`

    - `type: Literal["web_search_result_location"]`

      - `"web_search_result_location"`

    - `url: str`

  - `class BetaCitationSearchResultLocation: …`

    - `cited_text: str`

      The full text of the cited block range, concatenated.

      Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

    - `end_block_index: int`

      Exclusive 0-based end index of the cited block range in the source's `content` array.

      Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

    - `search_result_index: int`

      0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

      Counted separately from `document_index`; server-side web search results are not included in this count.

    - `source: str`

    - `start_block_index: int`

      0-based index of the first cited block in the source's `content` array.

    - `title: Optional[str]`

    - `type: Literal["search_result_location"]`

      - `"search_result_location"`

### Beta Text Citation Param

- `BetaTextCitationParam`

  - `class BetaCitationCharLocationParam: …`

    - `cited_text: str`

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_char_index: int`

    - `start_char_index: int`

    - `type: Literal["char_location"]`

      - `"char_location"`

  - `class BetaCitationPageLocationParam: …`

    - `cited_text: str`

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_page_number: int`

    - `start_page_number: int`

    - `type: Literal["page_location"]`

      - `"page_location"`

  - `class BetaCitationContentBlockLocationParam: …`

    - `cited_text: str`

      The full text of the cited block range, concatenated.

      Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

    - `document_index: int`

    - `document_title: Optional[str]`

    - `end_block_index: int`

      Exclusive 0-based end index of the cited block range in the source's `content` array.

      Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

    - `start_block_index: int`

      0-based index of the first cited block in the source's `content` array.

    - `type: Literal["content_block_location"]`

      - `"content_block_location"`

  - `class BetaCitationWebSearchResultLocationParam: …`

    - `cited_text: str`

    - `encrypted_index: str`

    - `title: Optional[str]`

    - `type: Literal["web_search_result_location"]`

      - `"web_search_result_location"`

    - `url: str`

  - `class BetaCitationSearchResultLocationParam: …`

    - `cited_text: str`

      The full text of the cited block range, concatenated.

      Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

    - `end_block_index: int`

      Exclusive 0-based end index of the cited block range in the source's `content` array.

      Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

    - `search_result_index: int`

      0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

      Counted separately from `document_index`; server-side web search results are not included in this count.

    - `source: str`

    - `start_block_index: int`

      0-based index of the first cited block in the source's `content` array.

    - `title: Optional[str]`

    - `type: Literal["search_result_location"]`

      - `"search_result_location"`

### Beta Text Delta

- `class BetaTextDelta: …`

  - `text: str`

  - `type: Literal["text_delta"]`

    - `"text_delta"`

### Beta Text Editor Code Execution Create Result Block

- `class BetaTextEditorCodeExecutionCreateResultBlock: …`

  - `is_file_update: bool`

  - `type: Literal["text_editor_code_execution_create_result"]`

    - `"text_editor_code_execution_create_result"`

### Beta Text Editor Code Execution Create Result Block Param

- `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

  - `is_file_update: bool`

  - `type: Literal["text_editor_code_execution_create_result"]`

    - `"text_editor_code_execution_create_result"`

### Beta Text Editor Code Execution Str Replace Result Block

- `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

  - `lines: Optional[List[str]]`

  - `new_lines: Optional[int]`

  - `new_start: Optional[int]`

  - `old_lines: Optional[int]`

  - `old_start: Optional[int]`

  - `type: Literal["text_editor_code_execution_str_replace_result"]`

    - `"text_editor_code_execution_str_replace_result"`

### Beta Text Editor Code Execution Str Replace Result Block Param

- `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

  - `type: Literal["text_editor_code_execution_str_replace_result"]`

    - `"text_editor_code_execution_str_replace_result"`

  - `lines: Optional[List[str]]`

  - `new_lines: Optional[int]`

  - `new_start: Optional[int]`

  - `old_lines: Optional[int]`

  - `old_start: Optional[int]`

### Beta Text Editor Code Execution Tool Result Block

- `class BetaTextEditorCodeExecutionToolResultBlock: …`

  - `content: Content`

    - `class BetaTextEditorCodeExecutionToolResultError: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

        - `"file_not_found"`

      - `error_message: Optional[str]`

      - `type: Literal["text_editor_code_execution_tool_result_error"]`

        - `"text_editor_code_execution_tool_result_error"`

    - `class BetaTextEditorCodeExecutionViewResultBlock: …`

      - `content: str`

      - `file_type: Literal["text", "image", "pdf"]`

        - `"text"`

        - `"image"`

        - `"pdf"`

      - `num_lines: Optional[int]`

      - `start_line: Optional[int]`

      - `total_lines: Optional[int]`

      - `type: Literal["text_editor_code_execution_view_result"]`

        - `"text_editor_code_execution_view_result"`

    - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

      - `is_file_update: bool`

      - `type: Literal["text_editor_code_execution_create_result"]`

        - `"text_editor_code_execution_create_result"`

    - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

      - `lines: Optional[List[str]]`

      - `new_lines: Optional[int]`

      - `new_start: Optional[int]`

      - `old_lines: Optional[int]`

      - `old_start: Optional[int]`

      - `type: Literal["text_editor_code_execution_str_replace_result"]`

        - `"text_editor_code_execution_str_replace_result"`

  - `tool_use_id: str`

  - `type: Literal["text_editor_code_execution_tool_result"]`

    - `"text_editor_code_execution_tool_result"`

### Beta Text Editor Code Execution Tool Result Block Param

- `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

  - `content: Content`

    - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

        - `"file_not_found"`

      - `type: Literal["text_editor_code_execution_tool_result_error"]`

        - `"text_editor_code_execution_tool_result_error"`

      - `error_message: Optional[str]`

    - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

      - `content: str`

      - `file_type: Literal["text", "image", "pdf"]`

        - `"text"`

        - `"image"`

        - `"pdf"`

      - `type: Literal["text_editor_code_execution_view_result"]`

        - `"text_editor_code_execution_view_result"`

      - `num_lines: Optional[int]`

      - `start_line: Optional[int]`

      - `total_lines: Optional[int]`

    - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

      - `is_file_update: bool`

      - `type: Literal["text_editor_code_execution_create_result"]`

        - `"text_editor_code_execution_create_result"`

    - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

      - `type: Literal["text_editor_code_execution_str_replace_result"]`

        - `"text_editor_code_execution_str_replace_result"`

      - `lines: Optional[List[str]]`

      - `new_lines: Optional[int]`

      - `new_start: Optional[int]`

      - `old_lines: Optional[int]`

      - `old_start: Optional[int]`

  - `tool_use_id: str`

  - `type: Literal["text_editor_code_execution_tool_result"]`

    - `"text_editor_code_execution_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Text Editor Code Execution Tool Result Error

- `class BetaTextEditorCodeExecutionToolResultError: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

    - `"file_not_found"`

  - `error_message: Optional[str]`

  - `type: Literal["text_editor_code_execution_tool_result_error"]`

    - `"text_editor_code_execution_tool_result_error"`

### Beta Text Editor Code Execution Tool Result Error Param

- `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

    - `"file_not_found"`

  - `type: Literal["text_editor_code_execution_tool_result_error"]`

    - `"text_editor_code_execution_tool_result_error"`

  - `error_message: Optional[str]`

### Beta Text Editor Code Execution View Result Block

- `class BetaTextEditorCodeExecutionViewResultBlock: …`

  - `content: str`

  - `file_type: Literal["text", "image", "pdf"]`

    - `"text"`

    - `"image"`

    - `"pdf"`

  - `num_lines: Optional[int]`

  - `start_line: Optional[int]`

  - `total_lines: Optional[int]`

  - `type: Literal["text_editor_code_execution_view_result"]`

    - `"text_editor_code_execution_view_result"`

### Beta Text Editor Code Execution View Result Block Param

- `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

  - `content: str`

  - `file_type: Literal["text", "image", "pdf"]`

    - `"text"`

    - `"image"`

    - `"pdf"`

  - `type: Literal["text_editor_code_execution_view_result"]`

    - `"text_editor_code_execution_view_result"`

  - `num_lines: Optional[int]`

  - `start_line: Optional[int]`

  - `total_lines: Optional[int]`

### Beta Thinking Block

- `class BetaThinkingBlock: …`

  - `signature: str`

  - `thinking: str`

  - `type: Literal["thinking"]`

    - `"thinking"`

### Beta Thinking Block Param

- `class BetaThinkingBlockParam: …`

  - `signature: str`

  - `thinking: str`

  - `type: Literal["thinking"]`

    - `"thinking"`

### Beta Thinking Config Adaptive

- `class BetaThinkingConfigAdaptive: …`

  - `type: Literal["adaptive"]`

    - `"adaptive"`

  - `display: Optional[Literal["summarized", "omitted"]]`

    Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

    - `"summarized"`

    - `"omitted"`

### Beta Thinking Config Disabled

- `class BetaThinkingConfigDisabled: …`

  - `type: Literal["disabled"]`

    - `"disabled"`

### Beta Thinking Config Enabled

- `class BetaThinkingConfigEnabled: …`

  - `budget_tokens: int`

    Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.

    Must be ≥1024 and less than `max_tokens`.

    See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

  - `type: Literal["enabled"]`

    - `"enabled"`

  - `display: Optional[Literal["summarized", "omitted"]]`

    Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

    - `"summarized"`

    - `"omitted"`

### Beta Thinking Config Param

- `BetaThinkingConfigParam`

  Configuration for enabling Claude's extended thinking.

  When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.

  See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

  - `class BetaThinkingConfigEnabled: …`

    - `budget_tokens: int`

      Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.

      Must be ≥1024 and less than `max_tokens`.

      See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

    - `type: Literal["enabled"]`

      - `"enabled"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

  - `class BetaThinkingConfigDisabled: …`

    - `type: Literal["disabled"]`

      - `"disabled"`

  - `class BetaThinkingConfigAdaptive: …`

    - `type: Literal["adaptive"]`

      - `"adaptive"`

    - `display: Optional[Literal["summarized", "omitted"]]`

      Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

      - `"summarized"`

      - `"omitted"`

### Beta Thinking Delta

- `class BetaThinkingDelta: …`

  - `estimated_tokens: Optional[int]`

    Per-frame increment of a coarse, running estimate of the tokens this thinking block has produced so far. Present whenever the `thinking-token-count-2026-05-13` beta is set; `null` unless `thinking.display` resolves to `"omitted"` and a count is due this frame. Sum the increments across `thinking_delta` frames on this block for a progress indicator. Each increment is a non-negative multiple of a fixed quantum and the cadence is rate-limited, so this is a deliberately lossy display hint, not a billable count; `usage.output_tokens` remains authoritative.

  - `thinking: str`

  - `type: Literal["thinking_delta"]`

    - `"thinking_delta"`

### Beta Thinking Turns

- `class BetaThinkingTurns: …`

  - `type: Literal["thinking_turns"]`

    - `"thinking_turns"`

  - `value: int`

### Beta Token Task Budget

- `class BetaTokenTaskBudget: …`

  User-configurable total token budget across contexts.

  - `total: int`

    Total token budget across all contexts in the session.

  - `type: Literal["tokens"]`

    The budget type. Currently only 'tokens' is supported.

    - `"tokens"`

  - `remaining: Optional[int]`

    Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.

### Beta Tool

- `class BetaTool: …`

  - `input_schema: InputSchema`

    [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

    This defines the shape of the `input` that your tool accepts and that the model will produce.

    - `type: Literal["object"]`

      - `"object"`

    - `properties: Optional[Dict[str, object]]`

    - `required: Optional[List[str]]`

  - `name: str`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `description: Optional[str]`

    Description of what this tool does.

    Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.

  - `eager_input_streaming: Optional[bool]`

    Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

  - `type: Optional[Literal["custom"]]`

    - `"custom"`

### Beta Tool Bash 20241022

- `class BetaToolBash20241022: …`

  - `name: Literal["bash"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"bash"`

  - `type: Literal["bash_20241022"]`

    - `"bash_20241022"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Bash 20250124

- `class BetaToolBash20250124: …`

  - `name: Literal["bash"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"bash"`

  - `type: Literal["bash_20250124"]`

    - `"bash_20250124"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Choice

- `BetaToolChoice`

  How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

  - `class BetaToolChoiceAuto: …`

    The model will automatically decide whether to use tools.

    - `type: Literal["auto"]`

      - `"auto"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output at most one tool use.

  - `class BetaToolChoiceAny: …`

    The model will use any available tools.

    - `type: Literal["any"]`

      - `"any"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceTool: …`

    The model will use the specified tool with `tool_choice.name`.

    - `name: str`

      The name of the tool to use.

    - `type: Literal["tool"]`

      - `"tool"`

    - `disable_parallel_tool_use: Optional[bool]`

      Whether to disable parallel tool use.

      Defaults to `false`. If set to `true`, the model will output exactly one tool use.

  - `class BetaToolChoiceNone: …`

    The model will not be allowed to use tools.

    - `type: Literal["none"]`

      - `"none"`

### Beta Tool Choice Any

- `class BetaToolChoiceAny: …`

  The model will use any available tools.

  - `type: Literal["any"]`

    - `"any"`

  - `disable_parallel_tool_use: Optional[bool]`

    Whether to disable parallel tool use.

    Defaults to `false`. If set to `true`, the model will output exactly one tool use.

### Beta Tool Choice Auto

- `class BetaToolChoiceAuto: …`

  The model will automatically decide whether to use tools.

  - `type: Literal["auto"]`

    - `"auto"`

  - `disable_parallel_tool_use: Optional[bool]`

    Whether to disable parallel tool use.

    Defaults to `false`. If set to `true`, the model will output at most one tool use.

### Beta Tool Choice None

- `class BetaToolChoiceNone: …`

  The model will not be allowed to use tools.

  - `type: Literal["none"]`

    - `"none"`

### Beta Tool Choice Tool

- `class BetaToolChoiceTool: …`

  The model will use the specified tool with `tool_choice.name`.

  - `name: str`

    The name of the tool to use.

  - `type: Literal["tool"]`

    - `"tool"`

  - `disable_parallel_tool_use: Optional[bool]`

    Whether to disable parallel tool use.

    Defaults to `false`. If set to `true`, the model will output exactly one tool use.

### Beta Tool Computer Use 20241022

- `class BetaToolComputerUse20241022: …`

  - `display_height_px: int`

    The height of the display in pixels.

  - `display_width_px: int`

    The width of the display in pixels.

  - `name: Literal["computer"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"computer"`

  - `type: Literal["computer_20241022"]`

    - `"computer_20241022"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `display_number: Optional[int]`

    The X11 display number (e.g. 0, 1) for the display.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Computer Use 20250124

- `class BetaToolComputerUse20250124: …`

  - `display_height_px: int`

    The height of the display in pixels.

  - `display_width_px: int`

    The width of the display in pixels.

  - `name: Literal["computer"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"computer"`

  - `type: Literal["computer_20250124"]`

    - `"computer_20250124"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `display_number: Optional[int]`

    The X11 display number (e.g. 0, 1) for the display.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Computer Use 20251124

- `class BetaToolComputerUse20251124: …`

  - `display_height_px: int`

    The height of the display in pixels.

  - `display_width_px: int`

    The width of the display in pixels.

  - `name: Literal["computer"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"computer"`

  - `type: Literal["computer_20251124"]`

    - `"computer_20251124"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `display_number: Optional[int]`

    The X11 display number (e.g. 0, 1) for the display.

  - `enable_zoom: Optional[bool]`

    Whether to enable an action to take a zoomed-in screenshot of the screen.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Reference Block

- `class BetaToolReferenceBlock: …`

  - `tool_name: str`

  - `type: Literal["tool_reference"]`

    - `"tool_reference"`

### Beta Tool Reference Block Param

- `class BetaToolReferenceBlockParam: …`

  Tool reference block that can be included in tool_result content.

  - `tool_name: str`

  - `type: Literal["tool_reference"]`

    - `"tool_reference"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

### Beta Tool Result Block Param

- `class BetaToolResultBlockParam: …`

  - `tool_use_id: str`

  - `type: Literal["tool_result"]`

    - `"tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `content: Optional[Union[str, List[Content], null]]`

    - `str`

    - `List[Content]`

      - `class BetaTextBlockParam: …`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[List[BetaTextCitationParam]]`

          - `class BetaCitationCharLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocationParam: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationWebSearchResultLocationParam: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocationParam: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

      - `class BetaImageBlockParam: …`

        - `source: Source`

          - `class BetaBase64ImageSource: …`

            - `data: str`

            - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

              - `"image/jpeg"`

              - `"image/png"`

              - `"image/gif"`

              - `"image/webp"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaURLImageSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileImageSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

      - `class BetaSearchResultBlockParam: …`

        - `content: List[BetaTextBlockParam]`

          - `text: str`

          - `type: Literal["text"]`

          - `cache_control: Optional[BetaCacheControlEphemeral]`

            Create a cache control breakpoint at this content block.

          - `citations: Optional[List[BetaTextCitationParam]]`

        - `source: str`

        - `title: str`

        - `type: Literal["search_result"]`

          - `"search_result"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          - `enabled: Optional[bool]`

      - `class BetaRequestDocumentBlock: …`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaContentBlockSource: …`

            - `content: Union[str, List[BetaContentBlockSourceContent]]`

              - `str`

              - `List[BetaContentBlockSourceContent]`

                - `class BetaTextBlockParam: …`

                - `class BetaImageBlockParam: …`

            - `type: Literal["content"]`

              - `"content"`

          - `class BetaURLPDFSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileDocumentSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

        - `context: Optional[str]`

        - `title: Optional[str]`

      - `class BetaToolReferenceBlockParam: …`

        Tool reference block that can be included in tool_result content.

        - `tool_name: str`

        - `type: Literal["tool_reference"]`

          - `"tool_reference"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

  - `is_error: Optional[bool]`

### Beta Tool Search Tool Bm25 20251119

- `class BetaToolSearchToolBm25_20251119: …`

  - `name: Literal["tool_search_tool_bm25"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"tool_search_tool_bm25"`

  - `type: Literal["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]`

    - `"tool_search_tool_bm25_20251119"`

    - `"tool_search_tool_bm25"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Search Tool Regex 20251119

- `class BetaToolSearchToolRegex20251119: …`

  - `name: Literal["tool_search_tool_regex"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"tool_search_tool_regex"`

  - `type: Literal["tool_search_tool_regex_20251119", "tool_search_tool_regex"]`

    - `"tool_search_tool_regex_20251119"`

    - `"tool_search_tool_regex"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Search Tool Result Block

- `class BetaToolSearchToolResultBlock: …`

  - `content: Content`

    - `class BetaToolSearchToolResultError: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

      - `error_message: Optional[str]`

      - `type: Literal["tool_search_tool_result_error"]`

        - `"tool_search_tool_result_error"`

    - `class BetaToolSearchToolSearchResultBlock: …`

      - `tool_references: List[BetaToolReferenceBlock]`

        - `tool_name: str`

        - `type: Literal["tool_reference"]`

          - `"tool_reference"`

      - `type: Literal["tool_search_tool_search_result"]`

        - `"tool_search_tool_search_result"`

  - `tool_use_id: str`

  - `type: Literal["tool_search_tool_result"]`

    - `"tool_search_tool_result"`

### Beta Tool Search Tool Result Block Param

- `class BetaToolSearchToolResultBlockParam: …`

  - `content: Content`

    - `class BetaToolSearchToolResultErrorParam: …`

      - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"too_many_requests"`

        - `"execution_time_exceeded"`

      - `type: Literal["tool_search_tool_result_error"]`

        - `"tool_search_tool_result_error"`

    - `class BetaToolSearchToolSearchResultBlockParam: …`

      - `tool_references: List[BetaToolReferenceBlockParam]`

        - `tool_name: str`

        - `type: Literal["tool_reference"]`

          - `"tool_reference"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

          - `type: Literal["ephemeral"]`

            - `"ephemeral"`

          - `ttl: Optional[Literal["5m", "1h"]]`

            The time-to-live for the cache control breakpoint.

            This may be one the following values:

            - `5m`: 5 minutes
            - `1h`: 1 hour

            Defaults to `5m`.

            - `"5m"`

            - `"1h"`

      - `type: Literal["tool_search_tool_search_result"]`

        - `"tool_search_tool_search_result"`

  - `tool_use_id: str`

  - `type: Literal["tool_search_tool_result"]`

    - `"tool_search_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

### Beta Tool Search Tool Result Error

- `class BetaToolSearchToolResultError: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

  - `error_message: Optional[str]`

  - `type: Literal["tool_search_tool_result_error"]`

    - `"tool_search_tool_result_error"`

### Beta Tool Search Tool Result Error Param

- `class BetaToolSearchToolResultErrorParam: …`

  - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"too_many_requests"`

    - `"execution_time_exceeded"`

  - `type: Literal["tool_search_tool_result_error"]`

    - `"tool_search_tool_result_error"`

### Beta Tool Search Tool Search Result Block

- `class BetaToolSearchToolSearchResultBlock: …`

  - `tool_references: List[BetaToolReferenceBlock]`

    - `tool_name: str`

    - `type: Literal["tool_reference"]`

      - `"tool_reference"`

  - `type: Literal["tool_search_tool_search_result"]`

    - `"tool_search_tool_search_result"`

### Beta Tool Search Tool Search Result Block Param

- `class BetaToolSearchToolSearchResultBlockParam: …`

  - `tool_references: List[BetaToolReferenceBlockParam]`

    - `tool_name: str`

    - `type: Literal["tool_reference"]`

      - `"tool_reference"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

  - `type: Literal["tool_search_tool_search_result"]`

    - `"tool_search_tool_search_result"`

### Beta Tool Text Editor 20241022

- `class BetaToolTextEditor20241022: …`

  - `name: Literal["str_replace_editor"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"str_replace_editor"`

  - `type: Literal["text_editor_20241022"]`

    - `"text_editor_20241022"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Text Editor 20250124

- `class BetaToolTextEditor20250124: …`

  - `name: Literal["str_replace_editor"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"str_replace_editor"`

  - `type: Literal["text_editor_20250124"]`

    - `"text_editor_20250124"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Text Editor 20250429

- `class BetaToolTextEditor20250429: …`

  - `name: Literal["str_replace_based_edit_tool"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"str_replace_based_edit_tool"`

  - `type: Literal["text_editor_20250429"]`

    - `"text_editor_20250429"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Text Editor 20250728

- `class BetaToolTextEditor20250728: …`

  - `name: Literal["str_replace_based_edit_tool"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"str_replace_based_edit_tool"`

  - `type: Literal["text_editor_20250728"]`

    - `"text_editor_20250728"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `input_examples: Optional[List[Dict[str, object]]]`

  - `max_characters: Optional[int]`

    Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Tool Union

- `BetaToolUnion`

  Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

  - `class BetaTool: …`

    - `input_schema: InputSchema`

      [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

      This defines the shape of the `input` that your tool accepts and that the model will produce.

      - `type: Literal["object"]`

        - `"object"`

      - `properties: Optional[Dict[str, object]]`

      - `required: Optional[List[str]]`

    - `name: str`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

      - `type: Literal["ephemeral"]`

        - `"ephemeral"`

      - `ttl: Optional[Literal["5m", "1h"]]`

        The time-to-live for the cache control breakpoint.

        This may be one the following values:

        - `5m`: 5 minutes
        - `1h`: 1 hour

        Defaults to `5m`.

        - `"5m"`

        - `"1h"`

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `description: Optional[str]`

      Description of what this tool does.

      Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.

    - `eager_input_streaming: Optional[bool]`

      Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `type: Optional[Literal["custom"]]`

      - `"custom"`

  - `class BetaToolBash20241022: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20241022"]`

      - `"bash_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolBash20250124: …`

    - `name: Literal["bash"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"bash"`

    - `type: Literal["bash_20250124"]`

      - `"bash_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250522: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250522"]`

      - `"code_execution_20250522"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20250825: …`

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20250825"]`

      - `"code_execution_20250825"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaCodeExecutionTool20260120: …`

    Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

    - `name: Literal["code_execution"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"code_execution"`

    - `type: Literal["code_execution_20260120"]`

      - `"code_execution_20260120"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20241022: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20241022"]`

      - `"computer_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMemoryTool20250818: …`

    - `name: Literal["memory"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"memory"`

    - `type: Literal["memory_20250818"]`

      - `"memory_20250818"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20250124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20250124"]`

      - `"computer_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20241022: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20241022"]`

      - `"text_editor_20241022"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolComputerUse20251124: …`

    - `display_height_px: int`

      The height of the display in pixels.

    - `display_width_px: int`

      The width of the display in pixels.

    - `name: Literal["computer"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"computer"`

    - `type: Literal["computer_20251124"]`

      - `"computer_20251124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `display_number: Optional[int]`

      The X11 display number (e.g. 0, 1) for the display.

    - `enable_zoom: Optional[bool]`

      Whether to enable an action to take a zoomed-in screenshot of the screen.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250124: …`

    - `name: Literal["str_replace_editor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_editor"`

    - `type: Literal["text_editor_20250124"]`

      - `"text_editor_20250124"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250429: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250429"]`

      - `"text_editor_20250429"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolTextEditor20250728: …`

    - `name: Literal["str_replace_based_edit_tool"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"str_replace_based_edit_tool"`

    - `type: Literal["text_editor_20250728"]`

      - `"text_editor_20250728"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `input_examples: Optional[List[Dict[str, object]]]`

    - `max_characters: Optional[int]`

      Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20250305: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20250305"]`

      - `"web_search_20250305"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

      - `type: Literal["approximate"]`

        - `"approximate"`

      - `city: Optional[str]`

        The city of the user.

      - `country: Optional[str]`

        The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

      - `region: Optional[str]`

        The region of the user.

      - `timezone: Optional[str]`

        The [IANA timezone](https://nodatime.org/TimeZones) of the user.

  - `class BetaWebFetchTool20250910: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20250910"]`

      - `"web_fetch_20250910"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

      - `enabled: Optional[bool]`

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebSearchTool20260209: …`

    - `name: Literal["web_search"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_search"`

    - `type: Literal["web_search_20260209"]`

      - `"web_search_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

    - `blocked_domains: Optional[List[str]]`

      If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `user_location: Optional[BetaUserLocation]`

      Parameters for the user's location. Used to provide more relevant search results.

  - `class BetaWebFetchTool20260209: …`

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260209"]`

      - `"web_fetch_20260209"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaWebFetchTool20260309: …`

    Web fetch tool with use_cache parameter for bypassing cached content.

    - `name: Literal["web_fetch"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"web_fetch"`

    - `type: Literal["web_fetch_20260309"]`

      - `"web_fetch_20260309"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `allowed_domains: Optional[List[str]]`

      List of domains to allow fetching from

    - `blocked_domains: Optional[List[str]]`

      List of domains to block fetching from

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      Citations configuration for fetched documents. Citations are disabled by default.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_content_tokens: Optional[int]`

      Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

    - `use_cache: Optional[bool]`

      Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.

  - `class BetaAdvisorTool20260301: …`

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
        - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
        - `claude-opus-4-1` - Exceptional model for specialized complex tasks
        - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
        - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-mythos-preview"`

          New class of intelligence, strongest in coding and cybersecurity

        - `"claude-opus-4-6"`

          Frontier intelligence for long-running agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

        - `"claude-opus-4-1"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-1-20250805"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-0"`

          Powerful model for complex tasks

        - `"claude-opus-4-20250514"`

          Powerful model for complex tasks

        - `"claude-sonnet-4-0"`

          High-performance model with extended thinking

        - `"claude-sonnet-4-20250514"`

          High-performance model with extended thinking

        - `"claude-3-haiku-20240307"`

          Fast and cost-effective model

      - `str`

    - `name: Literal["advisor"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"advisor"`

    - `type: Literal["advisor_20260301"]`

      - `"advisor_20260301"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `caching: Optional[BetaCacheControlEphemeral]`

      Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `max_uses: Optional[int]`

      Maximum number of times the tool can be used in the API request.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolBm25_20251119: …`

    - `name: Literal["tool_search_tool_bm25"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_bm25"`

    - `type: Literal["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]`

      - `"tool_search_tool_bm25_20251119"`

      - `"tool_search_tool_bm25"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaToolSearchToolRegex20251119: …`

    - `name: Literal["tool_search_tool_regex"]`

      Name of the tool.

      This is how the tool will be called by the model and in `tool_use` blocks.

      - `"tool_search_tool_regex"`

    - `type: Literal["tool_search_tool_regex_20251119", "tool_search_tool_regex"]`

      - `"tool_search_tool_regex_20251119"`

      - `"tool_search_tool_regex"`

    - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

      - `"direct"`

      - `"code_execution_20250825"`

      - `"code_execution_20260120"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `defer_loading: Optional[bool]`

      If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

    - `strict: Optional[bool]`

      When true, guarantees schema validation on tool names and inputs

  - `class BetaMCPToolset: …`

    Configuration for a group of tools from an MCP server.

    Allows configuring enabled status and defer_loading for all tools
    from an MCP server, with optional per-tool overrides.

    - `mcp_server_name: str`

      Name of the MCP server to configure tools for

    - `type: Literal["mcp_toolset"]`

      - `"mcp_toolset"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `configs: Optional[Dict[str, BetaMCPToolConfig]]`

      Configuration overrides for specific tools, keyed by tool name

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

    - `default_config: Optional[BetaMCPToolDefaultConfig]`

      Default configuration applied to all tools from this server

      - `defer_loading: Optional[bool]`

      - `enabled: Optional[bool]`

### Beta Tool Use Block

- `class BetaToolUseBlock: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: str`

  - `type: Literal["tool_use"]`

    - `"tool_use"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Tool Use Block Param

- `class BetaToolUseBlockParam: …`

  - `id: str`

  - `input: Dict[str, object]`

  - `name: str`

  - `type: Literal["tool_use"]`

    - `"tool_use"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Tool Uses Keep

- `class BetaToolUsesKeep: …`

  - `type: Literal["tool_uses"]`

    - `"tool_uses"`

  - `value: int`

### Beta Tool Uses Trigger

- `class BetaToolUsesTrigger: …`

  - `type: Literal["tool_uses"]`

    - `"tool_uses"`

  - `value: int`

### Beta URL Image Source

- `class BetaURLImageSource: …`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

### Beta URL PDF Source

- `class BetaURLPDFSource: …`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

### Beta Usage

- `class BetaUsage: …`

  - `cache_creation: Optional[BetaCacheCreation]`

    Breakdown of cached tokens by TTL

    - `ephemeral_1h_input_tokens: int`

      The number of input tokens used to create the 1 hour cache entry.

    - `ephemeral_5m_input_tokens: int`

      The number of input tokens used to create the 5 minute cache entry.

  - `cache_creation_input_tokens: Optional[int]`

    The number of input tokens used to create the cache entry.

  - `cache_read_input_tokens: Optional[int]`

    The number of input tokens read from the cache.

  - `inference_geo: Optional[str]`

    The geographic region where inference was performed for this request.

  - `input_tokens: int`

    The number of input tokens which were used.

  - `iterations: Optional[BetaIterationsUsage]`

    Per-iteration token usage breakdown.

    Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

    - Determine which iterations exceeded long context thresholds (>=200k tokens)
    - Calculate the true context window size from the last iteration
    - Understand token accumulation across server-side tool use loops

    - `class BetaMessageIterationUsage: …`

      Token usage for a sampling iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["message"]`

        Usage for a sampling iteration

        - `"message"`

    - `class BetaCompactionIterationUsage: …`

      Token usage for a compaction iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["compaction"]`

        Usage for a compaction iteration

        - `"compaction"`

    - `class BetaAdvisorMessageIterationUsage: …`

      Token usage for an advisor sub-inference iteration.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

      - `cache_creation_input_tokens: int`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: int`

        The number of input tokens read from the cache.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `model: Model`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
          - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
          - `claude-opus-4-1` - Exceptional model for specialized complex tasks
          - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
          - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-mythos-preview"`

            New class of intelligence, strongest in coding and cybersecurity

          - `"claude-opus-4-6"`

            Frontier intelligence for long-running agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

          - `"claude-opus-4-1"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-1-20250805"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-0"`

            Powerful model for complex tasks

          - `"claude-opus-4-20250514"`

            Powerful model for complex tasks

          - `"claude-sonnet-4-0"`

            High-performance model with extended thinking

          - `"claude-sonnet-4-20250514"`

            High-performance model with extended thinking

          - `"claude-3-haiku-20240307"`

            Fast and cost-effective model

        - `str`

      - `output_tokens: int`

        The number of output tokens which were used.

      - `type: Literal["advisor_message"]`

        Usage for an advisor sub-inference iteration

        - `"advisor_message"`

  - `output_tokens: int`

    The number of output tokens which were used.

  - `output_tokens_details: Optional[BetaOutputTokensDetails]`

    Breakdown of output tokens by category.

    `output_tokens` remains the inclusive, authoritative total used for billing.
    This object provides a read-only decomposition for observability — for example,
    how many of the billed output tokens were spent on internal reasoning that may
    have been summarized before being returned to you.

    - `thinking_tokens: int`

      Number of output tokens the model generated as internal reasoning, including
      the thinking-block delimiter tokens.

      Reflects the raw reasoning the model produced, not the (possibly shorter)
      summarized thinking text returned in the response body. Computed by
      re-tokenizing the raw reasoning text, so it may differ from the model's exact
      generation count by a small number of tokens. Always ≤ `output_tokens`;
      `output_tokens - thinking_tokens` approximates the non-reasoning output.

  - `server_tool_use: Optional[BetaServerToolUsage]`

    The number of server tool requests.

    - `web_fetch_requests: int`

      The number of web fetch tool requests.

    - `web_search_requests: int`

      The number of web search tool requests.

  - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

    If the request used the priority, standard, or batch tier.

    - `"standard"`

    - `"priority"`

    - `"batch"`

  - `speed: Optional[Literal["standard", "fast"]]`

    The inference speed mode used for this request.

    - `"standard"`

    - `"fast"`

### Beta User Location

- `class BetaUserLocation: …`

  - `type: Literal["approximate"]`

    - `"approximate"`

  - `city: Optional[str]`

    The city of the user.

  - `country: Optional[str]`

    The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

  - `region: Optional[str]`

    The region of the user.

  - `timezone: Optional[str]`

    The [IANA timezone](https://nodatime.org/TimeZones) of the user.

### Beta Web Fetch Block

- `class BetaWebFetchBlock: …`

  - `content: BetaDocumentBlock`

    - `citations: Optional[BetaCitationConfig]`

      Citation configuration for the document

      - `enabled: bool`

    - `source: Source`

      - `class BetaBase64PDFSource: …`

        - `data: str`

        - `media_type: Literal["application/pdf"]`

          - `"application/pdf"`

        - `type: Literal["base64"]`

          - `"base64"`

      - `class BetaPlainTextSource: …`

        - `data: str`

        - `media_type: Literal["text/plain"]`

          - `"text/plain"`

        - `type: Literal["text"]`

          - `"text"`

    - `title: Optional[str]`

      The title of the document

    - `type: Literal["document"]`

      - `"document"`

  - `retrieved_at: Optional[str]`

    ISO 8601 timestamp when the content was retrieved

  - `type: Literal["web_fetch_result"]`

    - `"web_fetch_result"`

  - `url: str`

    Fetched content URL

### Beta Web Fetch Block Param

- `class BetaWebFetchBlockParam: …`

  - `content: BetaRequestDocumentBlock`

    - `source: Source`

      - `class BetaBase64PDFSource: …`

        - `data: str`

        - `media_type: Literal["application/pdf"]`

          - `"application/pdf"`

        - `type: Literal["base64"]`

          - `"base64"`

      - `class BetaPlainTextSource: …`

        - `data: str`

        - `media_type: Literal["text/plain"]`

          - `"text/plain"`

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaContentBlockSource: …`

        - `content: Union[str, List[BetaContentBlockSourceContent]]`

          - `str`

          - `List[BetaContentBlockSourceContent]`

            - `class BetaTextBlockParam: …`

              - `text: str`

              - `type: Literal["text"]`

                - `"text"`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

                - `type: Literal["ephemeral"]`

                  - `"ephemeral"`

                - `ttl: Optional[Literal["5m", "1h"]]`

                  The time-to-live for the cache control breakpoint.

                  This may be one the following values:

                  - `5m`: 5 minutes
                  - `1h`: 1 hour

                  Defaults to `5m`.

                  - `"5m"`

                  - `"1h"`

              - `citations: Optional[List[BetaTextCitationParam]]`

                - `class BetaCitationCharLocationParam: …`

                  - `cited_text: str`

                  - `document_index: int`

                  - `document_title: Optional[str]`

                  - `end_char_index: int`

                  - `start_char_index: int`

                  - `type: Literal["char_location"]`

                    - `"char_location"`

                - `class BetaCitationPageLocationParam: …`

                  - `cited_text: str`

                  - `document_index: int`

                  - `document_title: Optional[str]`

                  - `end_page_number: int`

                  - `start_page_number: int`

                  - `type: Literal["page_location"]`

                    - `"page_location"`

                - `class BetaCitationContentBlockLocationParam: …`

                  - `cited_text: str`

                    The full text of the cited block range, concatenated.

                    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                  - `document_index: int`

                  - `document_title: Optional[str]`

                  - `end_block_index: int`

                    Exclusive 0-based end index of the cited block range in the source's `content` array.

                    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                  - `start_block_index: int`

                    0-based index of the first cited block in the source's `content` array.

                  - `type: Literal["content_block_location"]`

                    - `"content_block_location"`

                - `class BetaCitationWebSearchResultLocationParam: …`

                  - `cited_text: str`

                  - `encrypted_index: str`

                  - `title: Optional[str]`

                  - `type: Literal["web_search_result_location"]`

                    - `"web_search_result_location"`

                  - `url: str`

                - `class BetaCitationSearchResultLocationParam: …`

                  - `cited_text: str`

                    The full text of the cited block range, concatenated.

                    Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                  - `end_block_index: int`

                    Exclusive 0-based end index of the cited block range in the source's `content` array.

                    Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                  - `search_result_index: int`

                    0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                    Counted separately from `document_index`; server-side web search results are not included in this count.

                  - `source: str`

                  - `start_block_index: int`

                    0-based index of the first cited block in the source's `content` array.

                  - `title: Optional[str]`

                  - `type: Literal["search_result_location"]`

                    - `"search_result_location"`

            - `class BetaImageBlockParam: …`

              - `source: Source`

                - `class BetaBase64ImageSource: …`

                  - `data: str`

                  - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

                    - `"image/jpeg"`

                    - `"image/png"`

                    - `"image/gif"`

                    - `"image/webp"`

                  - `type: Literal["base64"]`

                    - `"base64"`

                - `class BetaURLImageSource: …`

                  - `type: Literal["url"]`

                    - `"url"`

                  - `url: str`

                - `class BetaFileImageSource: …`

                  - `file_id: str`

                  - `type: Literal["file"]`

                    - `"file"`

              - `type: Literal["image"]`

                - `"image"`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

        - `type: Literal["content"]`

          - `"content"`

      - `class BetaURLPDFSource: …`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `class BetaFileDocumentSource: …`

        - `file_id: str`

        - `type: Literal["file"]`

          - `"file"`

    - `type: Literal["document"]`

      - `"document"`

    - `cache_control: Optional[BetaCacheControlEphemeral]`

      Create a cache control breakpoint at this content block.

    - `citations: Optional[BetaCitationsConfigParam]`

      - `enabled: Optional[bool]`

    - `context: Optional[str]`

    - `title: Optional[str]`

  - `type: Literal["web_fetch_result"]`

    - `"web_fetch_result"`

  - `url: str`

    Fetched content URL

  - `retrieved_at: Optional[str]`

    ISO 8601 timestamp when the content was retrieved

### Beta Web Fetch Tool 20250910

- `class BetaWebFetchTool20250910: …`

  - `name: Literal["web_fetch"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"web_fetch"`

  - `type: Literal["web_fetch_20250910"]`

    - `"web_fetch_20250910"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `allowed_domains: Optional[List[str]]`

    List of domains to allow fetching from

  - `blocked_domains: Optional[List[str]]`

    List of domains to block fetching from

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `citations: Optional[BetaCitationsConfigParam]`

    Citations configuration for fetched documents. Citations are disabled by default.

    - `enabled: Optional[bool]`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_content_tokens: Optional[int]`

    Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Web Fetch Tool 20260209

- `class BetaWebFetchTool20260209: …`

  - `name: Literal["web_fetch"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"web_fetch"`

  - `type: Literal["web_fetch_20260209"]`

    - `"web_fetch_20260209"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `allowed_domains: Optional[List[str]]`

    List of domains to allow fetching from

  - `blocked_domains: Optional[List[str]]`

    List of domains to block fetching from

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `citations: Optional[BetaCitationsConfigParam]`

    Citations configuration for fetched documents. Citations are disabled by default.

    - `enabled: Optional[bool]`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_content_tokens: Optional[int]`

    Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

### Beta Web Fetch Tool 20260309

- `class BetaWebFetchTool20260309: …`

  Web fetch tool with use_cache parameter for bypassing cached content.

  - `name: Literal["web_fetch"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"web_fetch"`

  - `type: Literal["web_fetch_20260309"]`

    - `"web_fetch_20260309"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `allowed_domains: Optional[List[str]]`

    List of domains to allow fetching from

  - `blocked_domains: Optional[List[str]]`

    List of domains to block fetching from

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `citations: Optional[BetaCitationsConfigParam]`

    Citations configuration for fetched documents. Citations are disabled by default.

    - `enabled: Optional[bool]`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_content_tokens: Optional[int]`

    Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

  - `use_cache: Optional[bool]`

    Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.

### Beta Web Fetch Tool Result Block

- `class BetaWebFetchToolResultBlock: …`

  - `content: Content`

    - `class BetaWebFetchToolResultErrorBlock: …`

      - `error_code: BetaWebFetchToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"url_too_long"`

        - `"url_not_allowed"`

        - `"url_not_in_prior_context"`

        - `"url_not_accessible"`

        - `"unsupported_content_type"`

        - `"too_many_requests"`

        - `"max_uses_exceeded"`

        - `"unavailable"`

      - `type: Literal["web_fetch_tool_result_error"]`

        - `"web_fetch_tool_result_error"`

    - `class BetaWebFetchBlock: …`

      - `content: BetaDocumentBlock`

        - `citations: Optional[BetaCitationConfig]`

          Citation configuration for the document

          - `enabled: bool`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

        - `title: Optional[str]`

          The title of the document

        - `type: Literal["document"]`

          - `"document"`

      - `retrieved_at: Optional[str]`

        ISO 8601 timestamp when the content was retrieved

      - `type: Literal["web_fetch_result"]`

        - `"web_fetch_result"`

      - `url: str`

        Fetched content URL

  - `tool_use_id: str`

  - `type: Literal["web_fetch_tool_result"]`

    - `"web_fetch_tool_result"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Web Fetch Tool Result Block Param

- `class BetaWebFetchToolResultBlockParam: …`

  - `content: Content`

    - `class BetaWebFetchToolResultErrorBlockParam: …`

      - `error_code: BetaWebFetchToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"url_too_long"`

        - `"url_not_allowed"`

        - `"url_not_in_prior_context"`

        - `"url_not_accessible"`

        - `"unsupported_content_type"`

        - `"too_many_requests"`

        - `"max_uses_exceeded"`

        - `"unavailable"`

      - `type: Literal["web_fetch_tool_result_error"]`

        - `"web_fetch_tool_result_error"`

    - `class BetaWebFetchBlockParam: …`

      - `content: BetaRequestDocumentBlock`

        - `source: Source`

          - `class BetaBase64PDFSource: …`

            - `data: str`

            - `media_type: Literal["application/pdf"]`

              - `"application/pdf"`

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaPlainTextSource: …`

            - `data: str`

            - `media_type: Literal["text/plain"]`

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaContentBlockSource: …`

            - `content: Union[str, List[BetaContentBlockSourceContent]]`

              - `str`

              - `List[BetaContentBlockSourceContent]`

                - `class BetaTextBlockParam: …`

                  - `text: str`

                  - `type: Literal["text"]`

                    - `"text"`

                  - `cache_control: Optional[BetaCacheControlEphemeral]`

                    Create a cache control breakpoint at this content block.

                    - `type: Literal["ephemeral"]`

                      - `"ephemeral"`

                    - `ttl: Optional[Literal["5m", "1h"]]`

                      The time-to-live for the cache control breakpoint.

                      This may be one the following values:

                      - `5m`: 5 minutes
                      - `1h`: 1 hour

                      Defaults to `5m`.

                      - `"5m"`

                      - `"1h"`

                  - `citations: Optional[List[BetaTextCitationParam]]`

                    - `class BetaCitationCharLocationParam: …`

                      - `cited_text: str`

                      - `document_index: int`

                      - `document_title: Optional[str]`

                      - `end_char_index: int`

                      - `start_char_index: int`

                      - `type: Literal["char_location"]`

                        - `"char_location"`

                    - `class BetaCitationPageLocationParam: …`

                      - `cited_text: str`

                      - `document_index: int`

                      - `document_title: Optional[str]`

                      - `end_page_number: int`

                      - `start_page_number: int`

                      - `type: Literal["page_location"]`

                        - `"page_location"`

                    - `class BetaCitationContentBlockLocationParam: …`

                      - `cited_text: str`

                        The full text of the cited block range, concatenated.

                        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                      - `document_index: int`

                      - `document_title: Optional[str]`

                      - `end_block_index: int`

                        Exclusive 0-based end index of the cited block range in the source's `content` array.

                        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                      - `start_block_index: int`

                        0-based index of the first cited block in the source's `content` array.

                      - `type: Literal["content_block_location"]`

                        - `"content_block_location"`

                    - `class BetaCitationWebSearchResultLocationParam: …`

                      - `cited_text: str`

                      - `encrypted_index: str`

                      - `title: Optional[str]`

                      - `type: Literal["web_search_result_location"]`

                        - `"web_search_result_location"`

                      - `url: str`

                    - `class BetaCitationSearchResultLocationParam: …`

                      - `cited_text: str`

                        The full text of the cited block range, concatenated.

                        Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                      - `end_block_index: int`

                        Exclusive 0-based end index of the cited block range in the source's `content` array.

                        Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                      - `search_result_index: int`

                        0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                        Counted separately from `document_index`; server-side web search results are not included in this count.

                      - `source: str`

                      - `start_block_index: int`

                        0-based index of the first cited block in the source's `content` array.

                      - `title: Optional[str]`

                      - `type: Literal["search_result_location"]`

                        - `"search_result_location"`

                - `class BetaImageBlockParam: …`

                  - `source: Source`

                    - `class BetaBase64ImageSource: …`

                      - `data: str`

                      - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

                        - `"image/jpeg"`

                        - `"image/png"`

                        - `"image/gif"`

                        - `"image/webp"`

                      - `type: Literal["base64"]`

                        - `"base64"`

                    - `class BetaURLImageSource: …`

                      - `type: Literal["url"]`

                        - `"url"`

                      - `url: str`

                    - `class BetaFileImageSource: …`

                      - `file_id: str`

                      - `type: Literal["file"]`

                        - `"file"`

                  - `type: Literal["image"]`

                    - `"image"`

                  - `cache_control: Optional[BetaCacheControlEphemeral]`

                    Create a cache control breakpoint at this content block.

            - `type: Literal["content"]`

              - `"content"`

          - `class BetaURLPDFSource: …`

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

          - `class BetaFileDocumentSource: …`

            - `file_id: str`

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          - `enabled: Optional[bool]`

        - `context: Optional[str]`

        - `title: Optional[str]`

      - `type: Literal["web_fetch_result"]`

        - `"web_fetch_result"`

      - `url: str`

        Fetched content URL

      - `retrieved_at: Optional[str]`

        ISO 8601 timestamp when the content was retrieved

  - `tool_use_id: str`

  - `type: Literal["web_fetch_tool_result"]`

    - `"web_fetch_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Web Fetch Tool Result Error Block

- `class BetaWebFetchToolResultErrorBlock: …`

  - `error_code: BetaWebFetchToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"url_too_long"`

    - `"url_not_allowed"`

    - `"url_not_in_prior_context"`

    - `"url_not_accessible"`

    - `"unsupported_content_type"`

    - `"too_many_requests"`

    - `"max_uses_exceeded"`

    - `"unavailable"`

  - `type: Literal["web_fetch_tool_result_error"]`

    - `"web_fetch_tool_result_error"`

### Beta Web Fetch Tool Result Error Block Param

- `class BetaWebFetchToolResultErrorBlockParam: …`

  - `error_code: BetaWebFetchToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"url_too_long"`

    - `"url_not_allowed"`

    - `"url_not_in_prior_context"`

    - `"url_not_accessible"`

    - `"unsupported_content_type"`

    - `"too_many_requests"`

    - `"max_uses_exceeded"`

    - `"unavailable"`

  - `type: Literal["web_fetch_tool_result_error"]`

    - `"web_fetch_tool_result_error"`

### Beta Web Fetch Tool Result Error Code

- `Literal["invalid_tool_input", "url_too_long", "url_not_allowed", 6 more]`

  - `"invalid_tool_input"`

  - `"url_too_long"`

  - `"url_not_allowed"`

  - `"url_not_in_prior_context"`

  - `"url_not_accessible"`

  - `"unsupported_content_type"`

  - `"too_many_requests"`

  - `"max_uses_exceeded"`

  - `"unavailable"`

### Beta Web Search Result Block

- `class BetaWebSearchResultBlock: …`

  - `encrypted_content: str`

  - `page_age: Optional[str]`

  - `title: str`

  - `type: Literal["web_search_result"]`

    - `"web_search_result"`

  - `url: str`

### Beta Web Search Result Block Param

- `class BetaWebSearchResultBlockParam: …`

  - `encrypted_content: str`

  - `title: str`

  - `type: Literal["web_search_result"]`

    - `"web_search_result"`

  - `url: str`

  - `page_age: Optional[str]`

### Beta Web Search Tool 20250305

- `class BetaWebSearchTool20250305: …`

  - `name: Literal["web_search"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"web_search"`

  - `type: Literal["web_search_20250305"]`

    - `"web_search_20250305"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `allowed_domains: Optional[List[str]]`

    If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

  - `blocked_domains: Optional[List[str]]`

    If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

  - `user_location: Optional[BetaUserLocation]`

    Parameters for the user's location. Used to provide more relevant search results.

    - `type: Literal["approximate"]`

      - `"approximate"`

    - `city: Optional[str]`

      The city of the user.

    - `country: Optional[str]`

      The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

    - `region: Optional[str]`

      The region of the user.

    - `timezone: Optional[str]`

      The [IANA timezone](https://nodatime.org/TimeZones) of the user.

### Beta Web Search Tool 20260209

- `class BetaWebSearchTool20260209: …`

  - `name: Literal["web_search"]`

    Name of the tool.

    This is how the tool will be called by the model and in `tool_use` blocks.

    - `"web_search"`

  - `type: Literal["web_search_20260209"]`

    - `"web_search_20260209"`

  - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

    - `"direct"`

    - `"code_execution_20250825"`

    - `"code_execution_20260120"`

  - `allowed_domains: Optional[List[str]]`

    If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

  - `blocked_domains: Optional[List[str]]`

    If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `defer_loading: Optional[bool]`

    If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

  - `max_uses: Optional[int]`

    Maximum number of times the tool can be used in the API request.

  - `strict: Optional[bool]`

    When true, guarantees schema validation on tool names and inputs

  - `user_location: Optional[BetaUserLocation]`

    Parameters for the user's location. Used to provide more relevant search results.

    - `type: Literal["approximate"]`

      - `"approximate"`

    - `city: Optional[str]`

      The city of the user.

    - `country: Optional[str]`

      The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

    - `region: Optional[str]`

      The region of the user.

    - `timezone: Optional[str]`

      The [IANA timezone](https://nodatime.org/TimeZones) of the user.

### Beta Web Search Tool Request Error

- `class BetaWebSearchToolRequestError: …`

  - `error_code: BetaWebSearchToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"max_uses_exceeded"`

    - `"too_many_requests"`

    - `"query_too_long"`

    - `"request_too_large"`

  - `type: Literal["web_search_tool_result_error"]`

    - `"web_search_tool_result_error"`

### Beta Web Search Tool Result Block

- `class BetaWebSearchToolResultBlock: …`

  - `content: BetaWebSearchToolResultBlockContent`

    - `class BetaWebSearchToolResultError: …`

      - `error_code: BetaWebSearchToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"max_uses_exceeded"`

        - `"too_many_requests"`

        - `"query_too_long"`

        - `"request_too_large"`

      - `type: Literal["web_search_tool_result_error"]`

        - `"web_search_tool_result_error"`

    - `List[BetaWebSearchResultBlock]`

      - `encrypted_content: str`

      - `page_age: Optional[str]`

      - `title: str`

      - `type: Literal["web_search_result"]`

        - `"web_search_result"`

      - `url: str`

  - `tool_use_id: str`

  - `type: Literal["web_search_tool_result"]`

    - `"web_search_tool_result"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Web Search Tool Result Block Content

- `BetaWebSearchToolResultBlockContent`

  - `class BetaWebSearchToolResultError: …`

    - `error_code: BetaWebSearchToolResultErrorCode`

      - `"invalid_tool_input"`

      - `"unavailable"`

      - `"max_uses_exceeded"`

      - `"too_many_requests"`

      - `"query_too_long"`

      - `"request_too_large"`

    - `type: Literal["web_search_tool_result_error"]`

      - `"web_search_tool_result_error"`

  - `List[BetaWebSearchResultBlock]`

    - `encrypted_content: str`

    - `page_age: Optional[str]`

    - `title: str`

    - `type: Literal["web_search_result"]`

      - `"web_search_result"`

    - `url: str`

### Beta Web Search Tool Result Block Param

- `class BetaWebSearchToolResultBlockParam: …`

  - `content: BetaWebSearchToolResultBlockParamContent`

    - `List[BetaWebSearchResultBlockParam]`

      - `encrypted_content: str`

      - `title: str`

      - `type: Literal["web_search_result"]`

        - `"web_search_result"`

      - `url: str`

      - `page_age: Optional[str]`

    - `class BetaWebSearchToolRequestError: …`

      - `error_code: BetaWebSearchToolResultErrorCode`

        - `"invalid_tool_input"`

        - `"unavailable"`

        - `"max_uses_exceeded"`

        - `"too_many_requests"`

        - `"query_too_long"`

        - `"request_too_large"`

      - `type: Literal["web_search_tool_result_error"]`

        - `"web_search_tool_result_error"`

  - `tool_use_id: str`

  - `type: Literal["web_search_tool_result"]`

    - `"web_search_tool_result"`

  - `cache_control: Optional[BetaCacheControlEphemeral]`

    Create a cache control breakpoint at this content block.

    - `type: Literal["ephemeral"]`

      - `"ephemeral"`

    - `ttl: Optional[Literal["5m", "1h"]]`

      The time-to-live for the cache control breakpoint.

      This may be one the following values:

      - `5m`: 5 minutes
      - `1h`: 1 hour

      Defaults to `5m`.

      - `"5m"`

      - `"1h"`

  - `caller: Optional[Caller]`

    Tool invocation directly from the model.

    - `class BetaDirectCaller: …`

      Tool invocation directly from the model.

      - `type: Literal["direct"]`

        - `"direct"`

    - `class BetaServerToolCaller: …`

      Tool invocation generated by a server-side tool.

      - `tool_id: str`

      - `type: Literal["code_execution_20250825"]`

        - `"code_execution_20250825"`

    - `class BetaServerToolCaller20260120: …`

      - `tool_id: str`

      - `type: Literal["code_execution_20260120"]`

        - `"code_execution_20260120"`

### Beta Web Search Tool Result Block Param Content

- `BetaWebSearchToolResultBlockParamContent`

  - `List[BetaWebSearchResultBlockParam]`

    - `encrypted_content: str`

    - `title: str`

    - `type: Literal["web_search_result"]`

      - `"web_search_result"`

    - `url: str`

    - `page_age: Optional[str]`

  - `class BetaWebSearchToolRequestError: …`

    - `error_code: BetaWebSearchToolResultErrorCode`

      - `"invalid_tool_input"`

      - `"unavailable"`

      - `"max_uses_exceeded"`

      - `"too_many_requests"`

      - `"query_too_long"`

      - `"request_too_large"`

    - `type: Literal["web_search_tool_result_error"]`

      - `"web_search_tool_result_error"`

### Beta Web Search Tool Result Error

- `class BetaWebSearchToolResultError: …`

  - `error_code: BetaWebSearchToolResultErrorCode`

    - `"invalid_tool_input"`

    - `"unavailable"`

    - `"max_uses_exceeded"`

    - `"too_many_requests"`

    - `"query_too_long"`

    - `"request_too_large"`

  - `type: Literal["web_search_tool_result_error"]`

    - `"web_search_tool_result_error"`

### Beta Web Search Tool Result Error Code

- `Literal["invalid_tool_input", "unavailable", "max_uses_exceeded", 3 more]`

  - `"invalid_tool_input"`

  - `"unavailable"`

  - `"max_uses_exceeded"`

  - `"too_many_requests"`

  - `"query_too_long"`

  - `"request_too_large"`

# Batches

## Create a Message Batch

`beta.messages.batches.create(BatchCreateParams**kwargs)  -> BetaMessageBatch`

**post** `/v1/messages/batches`

Send a batch of Message creation requests.

The Message Batches API can be used to process multiple Messages API requests at once. Once a Message Batch is created, it begins processing immediately. Batches can take up to 24 hours to complete.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `requests: Iterable[Request]`

  List of requests for prompt completion. Each is an individual request to create a Message.

  - `custom_id: str`

    Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.

    Must be unique for each request within the Message Batch.

  - `params: RequestParams`

    Messages API creation parameters for the individual request.

    See the [Messages API reference](https://docs.claude.com/en/api/messages) for full documentation on available parameters.

    - `max_tokens: int`

      The maximum number of tokens to generate before stopping.

      Note that our models may stop _before_ reaching this maximum. This parameter only specifies the absolute maximum number of tokens to generate.

      Set to `0` to populate the [prompt cache](https://docs.claude.com/en/docs/build-with-claude/prompt-caching#pre-warming-the-cache) without generating a response.

      Different models have different maximum values for this parameter.  See [models](https://docs.claude.com/en/docs/models-overview) for details.

    - `messages: Iterable[BetaMessageParam]`

      Input messages.

      Our models are trained to operate on alternating `user` and `assistant` conversational turns. When creating a new `Message`, you specify the prior conversational turns with the `messages` parameter, and the model then generates the next `Message` in the conversation. Consecutive `user` or `assistant` turns in your request will be combined into a single turn.

      Each input message must be an object with a `role` and `content`. You can specify a single `user`-role message, or you can include multiple `user` and `assistant` messages.

      If the final message uses the `assistant` role, the response content will continue immediately from the content in that message. This can be used to constrain part of the model's response.

      Example with a single `user` message:

      ```json
      [{"role": "user", "content": "Hello, Claude"}]
      ```

      Example with multiple conversational turns:

      ```json
      [
        {"role": "user", "content": "Hello there."},
        {"role": "assistant", "content": "Hi, I'm Claude. How can I help you?"},
        {"role": "user", "content": "Can you explain LLMs in plain English?"},
      ]
      ```

      Example with a partially-filled response from Claude:

      ```json
      [
        {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
        {"role": "assistant", "content": "The best answer is ("},
      ]
      ```

      Each input message `content` may be either a single `string` or an array of content blocks, where each block has a specific `type`. Using a `string` for `content` is shorthand for an array of one content block of type `"text"`. The following input messages are equivalent:

      ```json
      {"role": "user", "content": "Hello, Claude"}
      ```

      ```json
      {"role": "user", "content": [{"type": "text", "text": "Hello, Claude"}]}
      ```

      See [input examples](https://docs.claude.com/en/api/messages-examples).

      Note that if you want to include a [system prompt](https://docs.claude.com/en/docs/system-prompts), you can use the top-level `system` parameter — there is no `"system"` role for input messages in the Messages API.

      There is a limit of 100,000 messages in a single request.

      - `content: Union[str, List[BetaContentBlockParam]]`

        - `str`

        - `List[BetaContentBlockParam]`

          - `class BetaTextBlockParam: …`

            - `text: str`

            - `type: Literal["text"]`

              - `"text"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

              - `type: Literal["ephemeral"]`

                - `"ephemeral"`

              - `ttl: Optional[Literal["5m", "1h"]]`

                The time-to-live for the cache control breakpoint.

                This may be one the following values:

                - `5m`: 5 minutes
                - `1h`: 1 hour

                Defaults to `5m`.

                - `"5m"`

                - `"1h"`

            - `citations: Optional[List[BetaTextCitationParam]]`

              - `class BetaCitationCharLocationParam: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_char_index: int`

                - `start_char_index: int`

                - `type: Literal["char_location"]`

                  - `"char_location"`

              - `class BetaCitationPageLocationParam: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_page_number: int`

                - `start_page_number: int`

                - `type: Literal["page_location"]`

                  - `"page_location"`

              - `class BetaCitationContentBlockLocationParam: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `type: Literal["content_block_location"]`

                  - `"content_block_location"`

              - `class BetaCitationWebSearchResultLocationParam: …`

                - `cited_text: str`

                - `encrypted_index: str`

                - `title: Optional[str]`

                - `type: Literal["web_search_result_location"]`

                  - `"web_search_result_location"`

                - `url: str`

              - `class BetaCitationSearchResultLocationParam: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `search_result_index: int`

                  0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                  Counted separately from `document_index`; server-side web search results are not included in this count.

                - `source: str`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `title: Optional[str]`

                - `type: Literal["search_result_location"]`

                  - `"search_result_location"`

          - `class BetaImageBlockParam: …`

            - `source: Source`

              - `class BetaBase64ImageSource: …`

                - `data: str`

                - `media_type: Literal["image/jpeg", "image/png", "image/gif", "image/webp"]`

                  - `"image/jpeg"`

                  - `"image/png"`

                  - `"image/gif"`

                  - `"image/webp"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaURLImageSource: …`

                - `type: Literal["url"]`

                  - `"url"`

                - `url: str`

              - `class BetaFileImageSource: …`

                - `file_id: str`

                - `type: Literal["file"]`

                  - `"file"`

            - `type: Literal["image"]`

              - `"image"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaRequestDocumentBlock: …`

            - `source: Source`

              - `class BetaBase64PDFSource: …`

                - `data: str`

                - `media_type: Literal["application/pdf"]`

                  - `"application/pdf"`

                - `type: Literal["base64"]`

                  - `"base64"`

              - `class BetaPlainTextSource: …`

                - `data: str`

                - `media_type: Literal["text/plain"]`

                  - `"text/plain"`

                - `type: Literal["text"]`

                  - `"text"`

              - `class BetaContentBlockSource: …`

                - `content: Union[str, List[BetaContentBlockSourceContent]]`

                  - `str`

                  - `List[BetaContentBlockSourceContent]`

                    - `class BetaTextBlockParam: …`

                    - `class BetaImageBlockParam: …`

                - `type: Literal["content"]`

                  - `"content"`

              - `class BetaURLPDFSource: …`

                - `type: Literal["url"]`

                  - `"url"`

                - `url: str`

              - `class BetaFileDocumentSource: …`

                - `file_id: str`

                - `type: Literal["file"]`

                  - `"file"`

            - `type: Literal["document"]`

              - `"document"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `citations: Optional[BetaCitationsConfigParam]`

              - `enabled: Optional[bool]`

            - `context: Optional[str]`

            - `title: Optional[str]`

          - `class BetaSearchResultBlockParam: …`

            - `content: List[BetaTextBlockParam]`

              - `text: str`

              - `type: Literal["text"]`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

              - `citations: Optional[List[BetaTextCitationParam]]`

            - `source: str`

            - `title: str`

            - `type: Literal["search_result"]`

              - `"search_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `citations: Optional[BetaCitationsConfigParam]`

          - `class BetaThinkingBlockParam: …`

            - `signature: str`

            - `thinking: str`

            - `type: Literal["thinking"]`

              - `"thinking"`

          - `class BetaRedactedThinkingBlockParam: …`

            - `data: str`

            - `type: Literal["redacted_thinking"]`

              - `"redacted_thinking"`

          - `class BetaToolUseBlockParam: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

            - `type: Literal["tool_use"]`

              - `"tool_use"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

                - `type: Literal["direct"]`

                  - `"direct"`

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

                - `tool_id: str`

                - `type: Literal["code_execution_20250825"]`

                  - `"code_execution_20250825"`

              - `class BetaServerToolCaller20260120: …`

                - `tool_id: str`

                - `type: Literal["code_execution_20260120"]`

                  - `"code_execution_20260120"`

          - `class BetaToolResultBlockParam: …`

            - `tool_use_id: str`

            - `type: Literal["tool_result"]`

              - `"tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `content: Optional[Union[str, List[Content], null]]`

              - `str`

              - `List[Content]`

                - `class BetaTextBlockParam: …`

                - `class BetaImageBlockParam: …`

                - `class BetaSearchResultBlockParam: …`

                - `class BetaRequestDocumentBlock: …`

                - `class BetaToolReferenceBlockParam: …`

                  Tool reference block that can be included in tool_result content.

                  - `tool_name: str`

                  - `type: Literal["tool_reference"]`

                    - `"tool_reference"`

                  - `cache_control: Optional[BetaCacheControlEphemeral]`

                    Create a cache control breakpoint at this content block.

            - `is_error: Optional[bool]`

          - `class BetaServerToolUseBlockParam: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

              - `"advisor"`

              - `"web_search"`

              - `"web_fetch"`

              - `"code_execution"`

              - `"bash_code_execution"`

              - `"text_editor_code_execution"`

              - `"tool_search_tool_regex"`

              - `"tool_search_tool_bm25"`

            - `type: Literal["server_tool_use"]`

              - `"server_tool_use"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebSearchToolResultBlockParam: …`

            - `content: BetaWebSearchToolResultBlockParamContent`

              - `List[BetaWebSearchResultBlockParam]`

                - `encrypted_content: str`

                - `title: str`

                - `type: Literal["web_search_result"]`

                  - `"web_search_result"`

                - `url: str`

                - `page_age: Optional[str]`

              - `class BetaWebSearchToolRequestError: …`

                - `error_code: BetaWebSearchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"max_uses_exceeded"`

                  - `"too_many_requests"`

                  - `"query_too_long"`

                  - `"request_too_large"`

                - `type: Literal["web_search_tool_result_error"]`

                  - `"web_search_tool_result_error"`

            - `tool_use_id: str`

            - `type: Literal["web_search_tool_result"]`

              - `"web_search_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebFetchToolResultBlockParam: …`

            - `content: Content`

              - `class BetaWebFetchToolResultErrorBlockParam: …`

                - `error_code: BetaWebFetchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"url_too_long"`

                  - `"url_not_allowed"`

                  - `"url_not_in_prior_context"`

                  - `"url_not_accessible"`

                  - `"unsupported_content_type"`

                  - `"too_many_requests"`

                  - `"max_uses_exceeded"`

                  - `"unavailable"`

                - `type: Literal["web_fetch_tool_result_error"]`

                  - `"web_fetch_tool_result_error"`

              - `class BetaWebFetchBlockParam: …`

                - `content: BetaRequestDocumentBlock`

                - `type: Literal["web_fetch_result"]`

                  - `"web_fetch_result"`

                - `url: str`

                  Fetched content URL

                - `retrieved_at: Optional[str]`

                  ISO 8601 timestamp when the content was retrieved

            - `tool_use_id: str`

            - `type: Literal["web_fetch_tool_result"]`

              - `"web_fetch_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaAdvisorToolResultBlockParam: …`

            - `content: Content`

              - `class BetaAdvisorToolResultErrorParam: …`

                - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

                  - `"max_uses_exceeded"`

                  - `"prompt_too_long"`

                  - `"too_many_requests"`

                  - `"overloaded"`

                  - `"unavailable"`

                  - `"execution_time_exceeded"`

                - `type: Literal["advisor_tool_result_error"]`

                  - `"advisor_tool_result_error"`

              - `class BetaAdvisorResultBlockParam: …`

                - `text: str`

                - `type: Literal["advisor_result"]`

                  - `"advisor_result"`

                - `stop_reason: Optional[str]`

              - `class BetaAdvisorRedactedResultBlockParam: …`

                - `encrypted_content: str`

                  Opaque blob produced by a prior response; must be round-tripped verbatim.

                - `type: Literal["advisor_redacted_result"]`

                  - `"advisor_redacted_result"`

                - `stop_reason: Optional[str]`

            - `tool_use_id: str`

            - `type: Literal["advisor_tool_result"]`

              - `"advisor_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaCodeExecutionToolResultBlockParam: …`

            - `content: BetaCodeExecutionToolResultBlockParamContent`

              Code execution result with encrypted stdout for PFC + web_search results.

              - `class BetaCodeExecutionToolResultErrorParam: …`

                - `error_code: BetaCodeExecutionToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `type: Literal["code_execution_tool_result_error"]`

                  - `"code_execution_tool_result_error"`

              - `class BetaCodeExecutionResultBlockParam: …`

                - `content: List[BetaCodeExecutionOutputBlockParam]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                    - `"code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["code_execution_result"]`

                  - `"code_execution_result"`

              - `class BetaEncryptedCodeExecutionResultBlockParam: …`

                Code execution result with encrypted stdout for PFC + web_search results.

                - `content: List[BetaCodeExecutionOutputBlockParam]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                - `encrypted_stdout: str`

                - `return_code: int`

                - `stderr: str`

                - `type: Literal["encrypted_code_execution_result"]`

                  - `"encrypted_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["code_execution_tool_result"]`

              - `"code_execution_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaBashCodeExecutionToolResultBlockParam: …`

            - `content: Content`

              - `class BetaBashCodeExecutionToolResultErrorParam: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"output_file_too_large"`

                - `type: Literal["bash_code_execution_tool_result_error"]`

                  - `"bash_code_execution_tool_result_error"`

              - `class BetaBashCodeExecutionResultBlockParam: …`

                - `content: List[BetaBashCodeExecutionOutputBlockParam]`

                  - `file_id: str`

                  - `type: Literal["bash_code_execution_output"]`

                    - `"bash_code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["bash_code_execution_result"]`

                  - `"bash_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["bash_code_execution_tool_result"]`

              - `"bash_code_execution_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaTextEditorCodeExecutionToolResultBlockParam: …`

            - `content: Content`

              - `class BetaTextEditorCodeExecutionToolResultErrorParam: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"file_not_found"`

                - `type: Literal["text_editor_code_execution_tool_result_error"]`

                  - `"text_editor_code_execution_tool_result_error"`

                - `error_message: Optional[str]`

              - `class BetaTextEditorCodeExecutionViewResultBlockParam: …`

                - `content: str`

                - `file_type: Literal["text", "image", "pdf"]`

                  - `"text"`

                  - `"image"`

                  - `"pdf"`

                - `type: Literal["text_editor_code_execution_view_result"]`

                  - `"text_editor_code_execution_view_result"`

                - `num_lines: Optional[int]`

                - `start_line: Optional[int]`

                - `total_lines: Optional[int]`

              - `class BetaTextEditorCodeExecutionCreateResultBlockParam: …`

                - `is_file_update: bool`

                - `type: Literal["text_editor_code_execution_create_result"]`

                  - `"text_editor_code_execution_create_result"`

              - `class BetaTextEditorCodeExecutionStrReplaceResultBlockParam: …`

                - `type: Literal["text_editor_code_execution_str_replace_result"]`

                  - `"text_editor_code_execution_str_replace_result"`

                - `lines: Optional[List[str]]`

                - `new_lines: Optional[int]`

                - `new_start: Optional[int]`

                - `old_lines: Optional[int]`

                - `old_start: Optional[int]`

            - `tool_use_id: str`

            - `type: Literal["text_editor_code_execution_tool_result"]`

              - `"text_editor_code_execution_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaToolSearchToolResultBlockParam: …`

            - `content: Content`

              - `class BetaToolSearchToolResultErrorParam: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `type: Literal["tool_search_tool_result_error"]`

                  - `"tool_search_tool_result_error"`

              - `class BetaToolSearchToolSearchResultBlockParam: …`

                - `tool_references: List[BetaToolReferenceBlockParam]`

                  - `tool_name: str`

                  - `type: Literal["tool_reference"]`

                  - `cache_control: Optional[BetaCacheControlEphemeral]`

                    Create a cache control breakpoint at this content block.

                - `type: Literal["tool_search_tool_search_result"]`

                  - `"tool_search_tool_search_result"`

            - `tool_use_id: str`

            - `type: Literal["tool_search_tool_result"]`

              - `"tool_search_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaMCPToolUseBlockParam: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

            - `server_name: str`

              The name of the MCP server

            - `type: Literal["mcp_tool_use"]`

              - `"mcp_tool_use"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaRequestMCPToolResultBlockParam: …`

            - `tool_use_id: str`

            - `type: Literal["mcp_tool_result"]`

              - `"mcp_tool_result"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `content: Optional[Union[str, List[BetaTextBlockParam], null]]`

              - `str`

              - `List[BetaTextBlockParam]`

                - `text: str`

                - `type: Literal["text"]`

                - `cache_control: Optional[BetaCacheControlEphemeral]`

                  Create a cache control breakpoint at this content block.

                - `citations: Optional[List[BetaTextCitationParam]]`

            - `is_error: Optional[bool]`

          - `class BetaContainerUploadBlockParam: …`

            A content block that represents a file to be uploaded to the container
            Files uploaded via this block will be available in the container's input directory.

            - `file_id: str`

            - `type: Literal["container_upload"]`

              - `"container_upload"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

          - `class BetaCompactionBlockParam: …`

            A compaction block containing summary of previous context.

            Users should round-trip these blocks from responses to subsequent requests
            to maintain context across compaction boundaries.

            When content is None, the block represents a failed compaction. The server
            treats these as no-ops. Empty string content is not allowed.

            - `type: Literal["compaction"]`

              - `"compaction"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

            - `content: Optional[str]`

              Summary of previously compacted content, or null if compaction failed

            - `encrypted_content: Optional[str]`

              Opaque metadata from prior compaction, to be round-tripped verbatim

          - `class BetaMidConversationSystemBlockParam: …`

            System instructions that appear mid-conversation.

            Use this block to provide or update system-level instructions at a specific
            point in the conversation, rather than only via the top-level `system` parameter.

            - `content: List[BetaTextBlockParam]`

              System instruction text blocks.

              - `text: str`

              - `type: Literal["text"]`

              - `cache_control: Optional[BetaCacheControlEphemeral]`

                Create a cache control breakpoint at this content block.

              - `citations: Optional[List[BetaTextCitationParam]]`

            - `type: Literal["mid_conv_system"]`

              - `"mid_conv_system"`

            - `cache_control: Optional[BetaCacheControlEphemeral]`

              Create a cache control breakpoint at this content block.

      - `role: Literal["user", "assistant", "system"]`

        - `"user"`

        - `"assistant"`

        - `"system"`

    - `model: ModelParam`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
        - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
        - `claude-opus-4-1` - Exceptional model for specialized complex tasks
        - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
        - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-mythos-preview"`

          New class of intelligence, strongest in coding and cybersecurity

        - `"claude-opus-4-6"`

          Frontier intelligence for long-running agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

        - `"claude-opus-4-1"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-1-20250805"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-0"`

          Powerful model for complex tasks

        - `"claude-opus-4-20250514"`

          Powerful model for complex tasks

        - `"claude-sonnet-4-0"`

          High-performance model with extended thinking

        - `"claude-sonnet-4-20250514"`

          High-performance model with extended thinking

        - `"claude-3-haiku-20240307"`

          Fast and cost-effective model

      - `str`

    - `cache_control: Optional[BetaCacheControlEphemeralParam]`

      Top-level cache control automatically applies a cache_control marker to the last cacheable block in the request.

    - `container: Optional[RequestParamsContainer]`

      Container identifier for reuse across requests.

      - `class BetaContainerParams: …`

        Container parameters with skills to be loaded.

        - `id: Optional[str]`

          Container id

        - `skills: Optional[List[BetaSkillParams]]`

          List of skills to load in the container

          - `skill_id: str`

            Skill ID

          - `type: Literal["anthropic", "custom"]`

            Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

            - `"anthropic"`

            - `"custom"`

          - `version: Optional[str]`

            Skill version or 'latest' for most recent version

      - `str`

    - `context_management: Optional[BetaContextManagementConfigParam]`

      Context management configuration.

      This allows you to control how Claude manages context across multiple requests, such as whether to clear function results or not.

      - `edits: Optional[List[Edit]]`

        List of context management edits to apply

        - `class BetaClearToolUses20250919Edit: …`

          - `type: Literal["clear_tool_uses_20250919"]`

            - `"clear_tool_uses_20250919"`

          - `clear_at_least: Optional[BetaInputTokensClearAtLeast]`

            Minimum number of tokens that must be cleared when triggered. Context will only be modified if at least this many tokens can be removed.

            - `type: Literal["input_tokens"]`

              - `"input_tokens"`

            - `value: int`

          - `clear_tool_inputs: Optional[Union[bool, List[str], null]]`

            Whether to clear all tool inputs (bool) or specific tool inputs to clear (list)

            - `bool`

            - `List[str]`

          - `exclude_tools: Optional[List[str]]`

            Tool names whose uses are preserved from clearing

          - `keep: Optional[BetaToolUsesKeep]`

            Number of tool uses to retain in the conversation

            - `type: Literal["tool_uses"]`

              - `"tool_uses"`

            - `value: int`

          - `trigger: Optional[Trigger]`

            Condition that triggers the context management strategy

            - `class BetaInputTokensTrigger: …`

              - `type: Literal["input_tokens"]`

                - `"input_tokens"`

              - `value: int`

            - `class BetaToolUsesTrigger: …`

              - `type: Literal["tool_uses"]`

                - `"tool_uses"`

              - `value: int`

        - `class BetaClearThinking20251015Edit: …`

          - `type: Literal["clear_thinking_20251015"]`

            - `"clear_thinking_20251015"`

          - `keep: Optional[Keep]`

            Number of most recent assistant turns to keep thinking blocks for. Older turns will have their thinking blocks removed.

            - `class BetaThinkingTurns: …`

              - `type: Literal["thinking_turns"]`

                - `"thinking_turns"`

              - `value: int`

            - `class BetaAllThinkingTurns: …`

              - `type: Literal["all"]`

                - `"all"`

            - `Literal["all"]`

              - `"all"`

        - `class BetaCompact20260112Edit: …`

          Automatically compact older context when reaching the configured trigger threshold.

          - `type: Literal["compact_20260112"]`

            - `"compact_20260112"`

          - `instructions: Optional[str]`

            Additional instructions for summarization.

          - `pause_after_compaction: Optional[bool]`

            Whether to pause after compaction and return the compaction block to the user.

          - `trigger: Optional[BetaInputTokensTrigger]`

            When to trigger compaction. Defaults to 150000 input tokens.

    - `diagnostics: Optional[BetaDiagnosticsParam]`

      Request-level diagnostics. Currently carries the previous response
      id for prompt-cache divergence reporting.

      - `previous_message_id: Optional[str]`

        The `id` (`msg_...`) from this client's previous /v1/messages response. The server compares that request's prompt fingerprint against this one and returns `diagnostics.cache_miss_reason` when the prompt-cache prefix could not be reused. Pass `null` on the first turn to opt in without a prior message to compare.

    - `inference_geo: Optional[str]`

      Specifies the geographic region for inference processing. If not specified, the workspace's `default_inference_geo` is used.

    - `mcp_servers: Optional[Iterable[BetaRequestMCPServerURLDefinitionParam]]`

      MCP servers to be utilized in this request

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

      - `authorization_token: Optional[str]`

      - `tool_configuration: Optional[BetaRequestMCPServerToolConfiguration]`

        - `allowed_tools: Optional[List[str]]`

        - `enabled: Optional[bool]`

    - `metadata: Optional[BetaMetadataParam]`

      An object describing metadata about the request.

      - `user_id: Optional[str]`

        An external identifier for the user who is associated with the request.

        This should be a uuid, hash value, or other opaque identifier. Anthropic may use this id to help detect abuse. Do not include any identifying information such as name, email address, or phone number.

    - `output_config: Optional[BetaOutputConfigParam]`

      Configuration options for the model's output, such as the output format.

      - `effort: Optional[Literal["low", "medium", "high", 2 more]]`

        All possible effort levels.

        - `"low"`

        - `"medium"`

        - `"high"`

        - `"xhigh"`

        - `"max"`

      - `format: Optional[BetaJSONOutputFormat]`

        A schema to specify Claude's output format in responses. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

        - `schema: Dict[str, object]`

          The JSON schema of the format

        - `type: Literal["json_schema"]`

          - `"json_schema"`

      - `task_budget: Optional[BetaTokenTaskBudget]`

        User-configurable total token budget across contexts.

        - `total: int`

          Total token budget across all contexts in the session.

        - `type: Literal["tokens"]`

          The budget type. Currently only 'tokens' is supported.

          - `"tokens"`

        - `remaining: Optional[int]`

          Remaining tokens in the budget. Use this to track usage across contexts when implementing compaction client-side. Defaults to total if not provided.

    - `output_format: Optional[BetaJSONOutputFormatParam]`

      Deprecated: Use `output_config.format` instead. See [structured outputs](https://platform.claude.com/docs/en/build-with-claude/structured-outputs)

      A schema to specify Claude's output format in responses. This parameter will be removed in a future release.

    - `service_tier: Optional[Literal["auto", "standard_only"]]`

      Determines whether to use priority capacity (if available) or standard capacity for this request.

      Anthropic offers different levels of service for your API requests. See [service-tiers](https://docs.claude.com/en/api/service-tiers) for details.

      - `"auto"`

      - `"standard_only"`

    - `speed: Optional[Literal["standard", "fast"]]`

      The inference speed mode for this request. `"fast"` enables high output-tokens-per-second inference.

      - `"standard"`

      - `"fast"`

    - `stop_sequences: Optional[Sequence[str]]`

      Custom text sequences that will cause the model to stop generating.

      Our models will normally stop when they have naturally completed their turn, which will result in a response `stop_reason` of `"end_turn"`.

      If you want the model to stop generating when it encounters custom strings of text, you can use the `stop_sequences` parameter. If the model encounters one of the custom sequences, the response `stop_reason` value will be `"stop_sequence"` and the response `stop_sequence` value will contain the matched stop sequence.

    - `stream: Optional[bool]`

      Whether to incrementally stream the response using server-sent events.

      See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.

    - `system: Optional[Union[str, Iterable[BetaTextBlockParam]]]`

      System prompt.

      A system prompt is a way of providing context and instructions to Claude, such as specifying a particular goal or role. See our [guide to system prompts](https://docs.claude.com/en/docs/system-prompts).

      - `str`

      - `Iterable[BetaTextBlockParam]`

        - `text: str`

        - `type: Literal["text"]`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[List[BetaTextCitationParam]]`

    - `temperature: Optional[float]`

      Amount of randomness injected into the response.

      Defaults to `1.0`. Ranges from `0.0` to `1.0`. Use `temperature` closer to `0.0` for analytical / multiple choice, and closer to `1.0` for creative and generative tasks.

      Note that even with `temperature` of `0.0`, the results will not be fully deterministic.

    - `thinking: Optional[BetaThinkingConfigParam]`

      Configuration for enabling Claude's extended thinking.

      When enabled, responses include `thinking` content blocks showing Claude's thinking process before the final answer. Requires a minimum budget of 1,024 tokens and counts towards your `max_tokens` limit.

      See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

      - `class BetaThinkingConfigEnabled: …`

        - `budget_tokens: int`

          Determines how many tokens Claude can use for its internal reasoning process. Larger budgets can enable more thorough analysis for complex problems, improving response quality.

          Must be ≥1024 and less than `max_tokens`.

          See [extended thinking](https://docs.claude.com/en/docs/build-with-claude/extended-thinking) for details.

        - `type: Literal["enabled"]`

          - `"enabled"`

        - `display: Optional[Literal["summarized", "omitted"]]`

          Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

          - `"summarized"`

          - `"omitted"`

      - `class BetaThinkingConfigDisabled: …`

        - `type: Literal["disabled"]`

          - `"disabled"`

      - `class BetaThinkingConfigAdaptive: …`

        - `type: Literal["adaptive"]`

          - `"adaptive"`

        - `display: Optional[Literal["summarized", "omitted"]]`

          Controls how thinking content appears in the response. When set to `summarized`, thinking is returned normally. When set to `omitted`, thinking content is redacted but a signature is returned for multi-turn continuity. Defaults to `summarized`.

          - `"summarized"`

          - `"omitted"`

    - `tool_choice: Optional[BetaToolChoiceParam]`

      How the model should use the provided tools. The model can use a specific tool, any available tool, decide by itself, or not use tools at all.

      - `class BetaToolChoiceAuto: …`

        The model will automatically decide whether to use tools.

        - `type: Literal["auto"]`

          - `"auto"`

        - `disable_parallel_tool_use: Optional[bool]`

          Whether to disable parallel tool use.

          Defaults to `false`. If set to `true`, the model will output at most one tool use.

      - `class BetaToolChoiceAny: …`

        The model will use any available tools.

        - `type: Literal["any"]`

          - `"any"`

        - `disable_parallel_tool_use: Optional[bool]`

          Whether to disable parallel tool use.

          Defaults to `false`. If set to `true`, the model will output exactly one tool use.

      - `class BetaToolChoiceTool: …`

        The model will use the specified tool with `tool_choice.name`.

        - `name: str`

          The name of the tool to use.

        - `type: Literal["tool"]`

          - `"tool"`

        - `disable_parallel_tool_use: Optional[bool]`

          Whether to disable parallel tool use.

          Defaults to `false`. If set to `true`, the model will output exactly one tool use.

      - `class BetaToolChoiceNone: …`

        The model will not be allowed to use tools.

        - `type: Literal["none"]`

          - `"none"`

    - `tools: Optional[Iterable[BetaToolUnionParam]]`

      Definitions of tools that the model may use.

      If you include `tools` in your API request, the model may return `tool_use` content blocks that represent the model's use of those tools. You can then run those tools using the tool input generated by the model and then optionally return results back to the model using `tool_result` content blocks.

      There are two types of tools: **client tools** and **server tools**. The behavior described below applies to client tools. For [server tools](https://docs.claude.com/en/docs/agents-and-tools/tool-use/overview#server-tools), see their individual documentation as each has its own behavior (e.g., the [web search tool](https://docs.claude.com/en/docs/agents-and-tools/tool-use/web-search-tool)).

      Each tool definition includes:

      * `name`: Name of the tool.
      * `description`: Optional, but strongly-recommended description of the tool.
      * `input_schema`: [JSON schema](https://json-schema.org/draft/2020-12) for the tool `input` shape that the model will produce in `tool_use` output content blocks.

      For example, if you defined `tools` as:

      ```json
      [
        {
          "name": "get_stock_price",
          "description": "Get the current stock price for a given ticker symbol.",
          "input_schema": {
            "type": "object",
            "properties": {
              "ticker": {
                "type": "string",
                "description": "The stock ticker symbol, e.g. AAPL for Apple Inc."
              }
            },
            "required": ["ticker"]
          }
        }
      ]
      ```

      And then asked the model "What's the S&P 500 at today?", the model might produce `tool_use` content blocks in the response like this:

      ```json
      [
        {
          "type": "tool_use",
          "id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
          "name": "get_stock_price",
          "input": { "ticker": "^GSPC" }
        }
      ]
      ```

      You might then run your `get_stock_price` tool with `{"ticker": "^GSPC"}` as an input, and return the following back to the model in a subsequent `user` message:

      ```json
      [
        {
          "type": "tool_result",
          "tool_use_id": "toolu_01D7FLrfh4GYq7yT1ULFeyMV",
          "content": "259.75 USD"
        }
      ]
      ```

      Tools can be used for workflows that include running client-side tools and functions, or more generally whenever you want the model to produce a particular JSON structure of output.

      See our [guide](https://docs.claude.com/en/docs/tool-use) for more details.

      - `class BetaTool: …`

        - `input_schema: InputSchema`

          [JSON schema](https://json-schema.org/draft/2020-12) for this tool's input.

          This defines the shape of the `input` that your tool accepts and that the model will produce.

          - `type: Literal["object"]`

            - `"object"`

          - `properties: Optional[Dict[str, object]]`

          - `required: Optional[List[str]]`

        - `name: str`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `description: Optional[str]`

          Description of what this tool does.

          Tool descriptions should be as detailed as possible. The more information that the model has about what the tool is and how to use it, the better it will perform. You can use natural language descriptions to reinforce important aspects of the tool input JSON schema.

        - `eager_input_streaming: Optional[bool]`

          Enable eager input streaming for this tool. When true, tool input parameters will be streamed incrementally as they are generated, and types will be inferred on-the-fly rather than buffering the full JSON output. When false, streaming is disabled for this tool even if the fine-grained-tool-streaming beta is active. When null (default), uses the default behavior based on beta headers.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

        - `type: Optional[Literal["custom"]]`

          - `"custom"`

      - `class BetaToolBash20241022: …`

        - `name: Literal["bash"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"bash"`

        - `type: Literal["bash_20241022"]`

          - `"bash_20241022"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolBash20250124: …`

        - `name: Literal["bash"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"bash"`

        - `type: Literal["bash_20250124"]`

          - `"bash_20250124"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaCodeExecutionTool20250522: …`

        - `name: Literal["code_execution"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"code_execution"`

        - `type: Literal["code_execution_20250522"]`

          - `"code_execution_20250522"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaCodeExecutionTool20250825: …`

        - `name: Literal["code_execution"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"code_execution"`

        - `type: Literal["code_execution_20250825"]`

          - `"code_execution_20250825"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaCodeExecutionTool20260120: …`

        Code execution tool with REPL state persistence (daemon mode + gVisor checkpoint).

        - `name: Literal["code_execution"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"code_execution"`

        - `type: Literal["code_execution_20260120"]`

          - `"code_execution_20260120"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolComputerUse20241022: …`

        - `display_height_px: int`

          The height of the display in pixels.

        - `display_width_px: int`

          The width of the display in pixels.

        - `name: Literal["computer"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"computer"`

        - `type: Literal["computer_20241022"]`

          - `"computer_20241022"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `display_number: Optional[int]`

          The X11 display number (e.g. 0, 1) for the display.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaMemoryTool20250818: …`

        - `name: Literal["memory"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"memory"`

        - `type: Literal["memory_20250818"]`

          - `"memory_20250818"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolComputerUse20250124: …`

        - `display_height_px: int`

          The height of the display in pixels.

        - `display_width_px: int`

          The width of the display in pixels.

        - `name: Literal["computer"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"computer"`

        - `type: Literal["computer_20250124"]`

          - `"computer_20250124"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `display_number: Optional[int]`

          The X11 display number (e.g. 0, 1) for the display.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolTextEditor20241022: …`

        - `name: Literal["str_replace_editor"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"str_replace_editor"`

        - `type: Literal["text_editor_20241022"]`

          - `"text_editor_20241022"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolComputerUse20251124: …`

        - `display_height_px: int`

          The height of the display in pixels.

        - `display_width_px: int`

          The width of the display in pixels.

        - `name: Literal["computer"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"computer"`

        - `type: Literal["computer_20251124"]`

          - `"computer_20251124"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `display_number: Optional[int]`

          The X11 display number (e.g. 0, 1) for the display.

        - `enable_zoom: Optional[bool]`

          Whether to enable an action to take a zoomed-in screenshot of the screen.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolTextEditor20250124: …`

        - `name: Literal["str_replace_editor"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"str_replace_editor"`

        - `type: Literal["text_editor_20250124"]`

          - `"text_editor_20250124"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolTextEditor20250429: …`

        - `name: Literal["str_replace_based_edit_tool"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"str_replace_based_edit_tool"`

        - `type: Literal["text_editor_20250429"]`

          - `"text_editor_20250429"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolTextEditor20250728: …`

        - `name: Literal["str_replace_based_edit_tool"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"str_replace_based_edit_tool"`

        - `type: Literal["text_editor_20250728"]`

          - `"text_editor_20250728"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `input_examples: Optional[List[Dict[str, object]]]`

        - `max_characters: Optional[int]`

          Maximum number of characters to display when viewing a file. If not specified, defaults to displaying the full file.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaWebSearchTool20250305: …`

        - `name: Literal["web_search"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"web_search"`

        - `type: Literal["web_search_20250305"]`

          - `"web_search_20250305"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `allowed_domains: Optional[List[str]]`

          If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

        - `blocked_domains: Optional[List[str]]`

          If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

        - `user_location: Optional[BetaUserLocation]`

          Parameters for the user's location. Used to provide more relevant search results.

          - `type: Literal["approximate"]`

            - `"approximate"`

          - `city: Optional[str]`

            The city of the user.

          - `country: Optional[str]`

            The two letter [ISO country code](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2) of the user.

          - `region: Optional[str]`

            The region of the user.

          - `timezone: Optional[str]`

            The [IANA timezone](https://nodatime.org/TimeZones) of the user.

      - `class BetaWebFetchTool20250910: …`

        - `name: Literal["web_fetch"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"web_fetch"`

        - `type: Literal["web_fetch_20250910"]`

          - `"web_fetch_20250910"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `allowed_domains: Optional[List[str]]`

          List of domains to allow fetching from

        - `blocked_domains: Optional[List[str]]`

          List of domains to block fetching from

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          Citations configuration for fetched documents. Citations are disabled by default.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_content_tokens: Optional[int]`

          Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaWebSearchTool20260209: …`

        - `name: Literal["web_search"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"web_search"`

        - `type: Literal["web_search_20260209"]`

          - `"web_search_20260209"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `allowed_domains: Optional[List[str]]`

          If provided, only these domains will be included in results. Cannot be used alongside `blocked_domains`.

        - `blocked_domains: Optional[List[str]]`

          If provided, these domains will never appear in results. Cannot be used alongside `allowed_domains`.

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

        - `user_location: Optional[BetaUserLocation]`

          Parameters for the user's location. Used to provide more relevant search results.

      - `class BetaWebFetchTool20260209: …`

        - `name: Literal["web_fetch"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"web_fetch"`

        - `type: Literal["web_fetch_20260209"]`

          - `"web_fetch_20260209"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `allowed_domains: Optional[List[str]]`

          List of domains to allow fetching from

        - `blocked_domains: Optional[List[str]]`

          List of domains to block fetching from

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          Citations configuration for fetched documents. Citations are disabled by default.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_content_tokens: Optional[int]`

          Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaWebFetchTool20260309: …`

        Web fetch tool with use_cache parameter for bypassing cached content.

        - `name: Literal["web_fetch"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"web_fetch"`

        - `type: Literal["web_fetch_20260309"]`

          - `"web_fetch_20260309"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `allowed_domains: Optional[List[str]]`

          List of domains to allow fetching from

        - `blocked_domains: Optional[List[str]]`

          List of domains to block fetching from

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `citations: Optional[BetaCitationsConfigParam]`

          Citations configuration for fetched documents. Citations are disabled by default.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_content_tokens: Optional[int]`

          Maximum number of tokens used by including web page text content in the context. The limit is approximate and does not apply to binary content such as PDFs.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

        - `use_cache: Optional[bool]`

          Whether to use cached content. Set to false to bypass the cache and fetch fresh content. Only set to false when the user explicitly requests fresh content or when fetching rapidly-changing sources.

      - `class BetaAdvisorTool20260301: …`

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `name: Literal["advisor"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"advisor"`

        - `type: Literal["advisor_20260301"]`

          - `"advisor_20260301"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `caching: Optional[BetaCacheControlEphemeral]`

          Caching for the advisor's own prompt. When set, each advisor call writes a cache entry at the given TTL so subsequent calls in the same conversation read the stable prefix. When omitted, the advisor prompt is not cached.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `max_uses: Optional[int]`

          Maximum number of times the tool can be used in the API request.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolSearchToolBm25_20251119: …`

        - `name: Literal["tool_search_tool_bm25"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"tool_search_tool_bm25"`

        - `type: Literal["tool_search_tool_bm25_20251119", "tool_search_tool_bm25"]`

          - `"tool_search_tool_bm25_20251119"`

          - `"tool_search_tool_bm25"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaToolSearchToolRegex20251119: …`

        - `name: Literal["tool_search_tool_regex"]`

          Name of the tool.

          This is how the tool will be called by the model and in `tool_use` blocks.

          - `"tool_search_tool_regex"`

        - `type: Literal["tool_search_tool_regex_20251119", "tool_search_tool_regex"]`

          - `"tool_search_tool_regex_20251119"`

          - `"tool_search_tool_regex"`

        - `allowed_callers: Optional[List[Literal["direct", "code_execution_20250825", "code_execution_20260120"]]]`

          - `"direct"`

          - `"code_execution_20250825"`

          - `"code_execution_20260120"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `defer_loading: Optional[bool]`

          If true, tool will not be included in initial system prompt. Only loaded when returned via tool_reference from tool search.

        - `strict: Optional[bool]`

          When true, guarantees schema validation on tool names and inputs

      - `class BetaMCPToolset: …`

        Configuration for a group of tools from an MCP server.

        Allows configuring enabled status and defer_loading for all tools
        from an MCP server, with optional per-tool overrides.

        - `mcp_server_name: str`

          Name of the MCP server to configure tools for

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

        - `cache_control: Optional[BetaCacheControlEphemeral]`

          Create a cache control breakpoint at this content block.

        - `configs: Optional[Dict[str, BetaMCPToolConfig]]`

          Configuration overrides for specific tools, keyed by tool name

          - `defer_loading: Optional[bool]`

          - `enabled: Optional[bool]`

        - `default_config: Optional[BetaMCPToolDefaultConfig]`

          Default configuration applied to all tools from this server

          - `defer_loading: Optional[bool]`

          - `enabled: Optional[bool]`

    - `top_k: Optional[int]`

      Only sample from the top K options for each subsequent token.

      Used to remove "long tail" low probability responses. [Learn more technical details here](https://towardsdatascience.com/how-to-sample-from-language-models-682bceb97277).

      Recommended for advanced use cases only.

    - `top_p: Optional[float]`

      Use nucleus sampling.

      In nucleus sampling, we compute the cumulative distribution over all the options for each subsequent token in decreasing probability order and cut it off once it reaches a particular probability specified by `top_p`.

      Recommended for advanced use cases only.

    - `user_profile_id: Optional[str]`

      The user profile ID to attribute this request to. Use when acting on behalf of a party other than your organization.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageBatch: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `archived_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.

  - `cancel_initiated_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch was created.

  - `ended_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.

    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.

  - `expires_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.

  - `processing_status: Literal["in_progress", "canceling", "ended"]`

    Processing status of the Message Batch.

    - `"in_progress"`

    - `"canceling"`

    - `"ended"`

  - `request_counts: BetaMessageBatchRequestCounts`

    Tallies requests within the Message Batch, categorized by their status.

    Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.

    - `canceled: int`

      Number of requests in the Message Batch that have been canceled.

      This is zero until processing of the entire Message Batch has ended.

    - `errored: int`

      Number of requests in the Message Batch that encountered an error.

      This is zero until processing of the entire Message Batch has ended.

    - `expired: int`

      Number of requests in the Message Batch that have expired.

      This is zero until processing of the entire Message Batch has ended.

    - `processing: int`

      Number of requests in the Message Batch that are processing.

    - `succeeded: int`

      Number of requests in the Message Batch that have completed successfully.

      This is zero until processing of the entire Message Batch has ended.

  - `results_url: Optional[str]`

    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.

    Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

  - `type: Literal["message_batch"]`

    Object type.

    For Message Batches, this is always `"message_batch"`.

    - `"message_batch"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_message_batch = client.beta.messages.batches.create(
    requests=[{
        "custom_id": "my-custom-id-1",
        "params": {
            "max_tokens": 1024,
            "messages": [{
                "content": "Hello, world",
                "role": "user",
            }],
            "model": "claude-opus-4-6",
        },
    }],
)
print(beta_message_batch.id)
```

#### Response

```json
{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "archived_at": "2024-08-20T18:37:24.100435Z",
  "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
  "created_at": "2024-08-20T18:37:24.100435Z",
  "ended_at": "2024-08-20T18:37:24.100435Z",
  "expires_at": "2024-08-20T18:37:24.100435Z",
  "processing_status": "in_progress",
  "request_counts": {
    "canceled": 10,
    "errored": 30,
    "expired": 10,
    "processing": 100,
    "succeeded": 50
  },
  "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
  "type": "message_batch"
}
```

## Retrieve a Message Batch

`beta.messages.batches.retrieve(strmessage_batch_id, BatchRetrieveParams**kwargs)  -> BetaMessageBatch`

**get** `/v1/messages/batches/{message_batch_id}`

This endpoint is idempotent and can be used to poll for Message Batch completion. To access the results of a Message Batch, make a request to the `results_url` field in the response.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `message_batch_id: str`

  ID of the Message Batch.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageBatch: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `archived_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.

  - `cancel_initiated_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch was created.

  - `ended_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.

    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.

  - `expires_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.

  - `processing_status: Literal["in_progress", "canceling", "ended"]`

    Processing status of the Message Batch.

    - `"in_progress"`

    - `"canceling"`

    - `"ended"`

  - `request_counts: BetaMessageBatchRequestCounts`

    Tallies requests within the Message Batch, categorized by their status.

    Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.

    - `canceled: int`

      Number of requests in the Message Batch that have been canceled.

      This is zero until processing of the entire Message Batch has ended.

    - `errored: int`

      Number of requests in the Message Batch that encountered an error.

      This is zero until processing of the entire Message Batch has ended.

    - `expired: int`

      Number of requests in the Message Batch that have expired.

      This is zero until processing of the entire Message Batch has ended.

    - `processing: int`

      Number of requests in the Message Batch that are processing.

    - `succeeded: int`

      Number of requests in the Message Batch that have completed successfully.

      This is zero until processing of the entire Message Batch has ended.

  - `results_url: Optional[str]`

    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.

    Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

  - `type: Literal["message_batch"]`

    Object type.

    For Message Batches, this is always `"message_batch"`.

    - `"message_batch"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_message_batch = client.beta.messages.batches.retrieve(
    message_batch_id="message_batch_id",
)
print(beta_message_batch.id)
```

#### Response

```json
{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "archived_at": "2024-08-20T18:37:24.100435Z",
  "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
  "created_at": "2024-08-20T18:37:24.100435Z",
  "ended_at": "2024-08-20T18:37:24.100435Z",
  "expires_at": "2024-08-20T18:37:24.100435Z",
  "processing_status": "in_progress",
  "request_counts": {
    "canceled": 10,
    "errored": 30,
    "expired": 10,
    "processing": 100,
    "succeeded": 50
  },
  "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
  "type": "message_batch"
}
```

## List Message Batches

`beta.messages.batches.list(BatchListParams**kwargs)  -> SyncPage[BetaMessageBatch]`

**get** `/v1/messages/batches`

List all Message Batches within a Workspace. Most recently created batches are returned first.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `after_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object.

- `before_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object.

- `limit: Optional[int]`

  Number of items to return per page.

  Defaults to `20`. Ranges from `1` to `1000`.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageBatch: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `archived_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.

  - `cancel_initiated_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch was created.

  - `ended_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.

    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.

  - `expires_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.

  - `processing_status: Literal["in_progress", "canceling", "ended"]`

    Processing status of the Message Batch.

    - `"in_progress"`

    - `"canceling"`

    - `"ended"`

  - `request_counts: BetaMessageBatchRequestCounts`

    Tallies requests within the Message Batch, categorized by their status.

    Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.

    - `canceled: int`

      Number of requests in the Message Batch that have been canceled.

      This is zero until processing of the entire Message Batch has ended.

    - `errored: int`

      Number of requests in the Message Batch that encountered an error.

      This is zero until processing of the entire Message Batch has ended.

    - `expired: int`

      Number of requests in the Message Batch that have expired.

      This is zero until processing of the entire Message Batch has ended.

    - `processing: int`

      Number of requests in the Message Batch that are processing.

    - `succeeded: int`

      Number of requests in the Message Batch that have completed successfully.

      This is zero until processing of the entire Message Batch has ended.

  - `results_url: Optional[str]`

    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.

    Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

  - `type: Literal["message_batch"]`

    Object type.

    For Message Batches, this is always `"message_batch"`.

    - `"message_batch"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.messages.batches.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
      "archived_at": "2024-08-20T18:37:24.100435Z",
      "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
      "created_at": "2024-08-20T18:37:24.100435Z",
      "ended_at": "2024-08-20T18:37:24.100435Z",
      "expires_at": "2024-08-20T18:37:24.100435Z",
      "processing_status": "in_progress",
      "request_counts": {
        "canceled": 10,
        "errored": 30,
        "expired": 10,
        "processing": 100,
        "succeeded": 50
      },
      "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
      "type": "message_batch"
    }
  ],
  "first_id": "first_id",
  "has_more": true,
  "last_id": "last_id"
}
```

## Cancel a Message Batch

`beta.messages.batches.cancel(strmessage_batch_id, BatchCancelParams**kwargs)  -> BetaMessageBatch`

**post** `/v1/messages/batches/{message_batch_id}/cancel`

Batches may be canceled any time before processing ends. Once cancellation is initiated, the batch enters a `canceling` state, at which time the system may complete any in-progress, non-interruptible requests before finalizing cancellation.

The number of canceled requests is specified in `request_counts`. To determine which requests were canceled, check the individual results within the batch. Note that cancellation may not result in any canceled requests if they were non-interruptible.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `message_batch_id: str`

  ID of the Message Batch.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageBatch: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `archived_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.

  - `cancel_initiated_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch was created.

  - `ended_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.

    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.

  - `expires_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.

  - `processing_status: Literal["in_progress", "canceling", "ended"]`

    Processing status of the Message Batch.

    - `"in_progress"`

    - `"canceling"`

    - `"ended"`

  - `request_counts: BetaMessageBatchRequestCounts`

    Tallies requests within the Message Batch, categorized by their status.

    Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.

    - `canceled: int`

      Number of requests in the Message Batch that have been canceled.

      This is zero until processing of the entire Message Batch has ended.

    - `errored: int`

      Number of requests in the Message Batch that encountered an error.

      This is zero until processing of the entire Message Batch has ended.

    - `expired: int`

      Number of requests in the Message Batch that have expired.

      This is zero until processing of the entire Message Batch has ended.

    - `processing: int`

      Number of requests in the Message Batch that are processing.

    - `succeeded: int`

      Number of requests in the Message Batch that have completed successfully.

      This is zero until processing of the entire Message Batch has ended.

  - `results_url: Optional[str]`

    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.

    Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

  - `type: Literal["message_batch"]`

    Object type.

    For Message Batches, this is always `"message_batch"`.

    - `"message_batch"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_message_batch = client.beta.messages.batches.cancel(
    message_batch_id="message_batch_id",
)
print(beta_message_batch.id)
```

#### Response

```json
{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "archived_at": "2024-08-20T18:37:24.100435Z",
  "cancel_initiated_at": "2024-08-20T18:37:24.100435Z",
  "created_at": "2024-08-20T18:37:24.100435Z",
  "ended_at": "2024-08-20T18:37:24.100435Z",
  "expires_at": "2024-08-20T18:37:24.100435Z",
  "processing_status": "in_progress",
  "request_counts": {
    "canceled": 10,
    "errored": 30,
    "expired": 10,
    "processing": 100,
    "succeeded": 50
  },
  "results_url": "https://api.anthropic.com/v1/messages/batches/msgbatch_013Zva2CMHLNnXjNJJKqJ2EF/results",
  "type": "message_batch"
}
```

## Delete a Message Batch

`beta.messages.batches.delete(strmessage_batch_id, BatchDeleteParams**kwargs)  -> BetaDeletedMessageBatch`

**delete** `/v1/messages/batches/{message_batch_id}`

Delete a Message Batch.

Message Batches can only be deleted once they've finished processing. If you'd like to delete an in-progress batch, you must first cancel it.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `message_batch_id: str`

  ID of the Message Batch.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaDeletedMessageBatch: …`

  - `id: str`

    ID of the Message Batch.

  - `type: Literal["message_batch_deleted"]`

    Deleted object type.

    For Message Batches, this is always `"message_batch_deleted"`.

    - `"message_batch_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_deleted_message_batch = client.beta.messages.batches.delete(
    message_batch_id="message_batch_id",
)
print(beta_deleted_message_batch.id)
```

#### Response

```json
{
  "id": "msgbatch_013Zva2CMHLNnXjNJJKqJ2EF",
  "type": "message_batch_deleted"
}
```

## Retrieve Message Batch results

`beta.messages.batches.results(strmessage_batch_id, BatchResultsParams**kwargs)  -> BetaMessageBatchIndividualResponse`

**get** `/v1/messages/batches/{message_batch_id}/results`

Streams the results of a Message Batch as a `.jsonl` file.

Each line in the file is a JSON object containing the result of a single request in the Message Batch. Results are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

Learn more about the Message Batches API in our [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)

### Parameters

- `message_batch_id: str`

  ID of the Message Batch.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaMessageBatchIndividualResponse: …`

  This is a single line in the response `.jsonl` file and does not represent the response as a whole.

  - `custom_id: str`

    Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.

    Must be unique for each request within the Message Batch.

  - `result: BetaMessageBatchResult`

    Processing result for this request.

    Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

    - `class BetaMessageBatchSucceededResult: …`

      - `message: BetaMessage`

        - `id: str`

          Unique object identifier.

          The format and length of IDs may change over time.

        - `container: Optional[BetaContainer]`

          Information about the container used in the request (for the code execution tool)

          - `id: str`

            Identifier for the container used in this request

          - `expires_at: datetime`

            The time at which the container will expire.

          - `skills: Optional[List[BetaSkill]]`

            Skills loaded in the container

            - `skill_id: str`

              Skill ID

            - `type: Literal["anthropic", "custom"]`

              Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

              - `"anthropic"`

              - `"custom"`

            - `version: str`

              Skill version or 'latest' for most recent version

        - `content: List[BetaContentBlock]`

          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 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.

          For example, if the input `messages` were:

          ```json
          [
            {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
            {"role": "assistant", "content": "The best answer is ("}
          ]
          ```

          Then the response `content` might be:

          ```json
          [{"type": "text", "text": "B)"}]
          ```

          - `class BetaTextBlock: …`

            - `citations: Optional[List[BetaTextCitation]]`

              Citations supporting the text block.

              The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

              - `class BetaCitationCharLocation: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_char_index: int`

                - `file_id: Optional[str]`

                - `start_char_index: int`

                - `type: Literal["char_location"]`

                  - `"char_location"`

              - `class BetaCitationPageLocation: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_page_number: int`

                - `file_id: Optional[str]`

                - `start_page_number: int`

                - `type: Literal["page_location"]`

                  - `"page_location"`

              - `class BetaCitationContentBlockLocation: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `file_id: Optional[str]`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `type: Literal["content_block_location"]`

                  - `"content_block_location"`

              - `class BetaCitationsWebSearchResultLocation: …`

                - `cited_text: str`

                - `encrypted_index: str`

                - `title: Optional[str]`

                - `type: Literal["web_search_result_location"]`

                  - `"web_search_result_location"`

                - `url: str`

              - `class BetaCitationSearchResultLocation: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `search_result_index: int`

                  0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                  Counted separately from `document_index`; server-side web search results are not included in this count.

                - `source: str`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `title: Optional[str]`

                - `type: Literal["search_result_location"]`

                  - `"search_result_location"`

            - `text: str`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaThinkingBlock: …`

            - `signature: str`

            - `thinking: str`

            - `type: Literal["thinking"]`

              - `"thinking"`

          - `class BetaRedactedThinkingBlock: …`

            - `data: str`

            - `type: Literal["redacted_thinking"]`

              - `"redacted_thinking"`

          - `class BetaToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

            - `type: Literal["tool_use"]`

              - `"tool_use"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

                - `type: Literal["direct"]`

                  - `"direct"`

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

                - `tool_id: str`

                - `type: Literal["code_execution_20250825"]`

                  - `"code_execution_20250825"`

              - `class BetaServerToolCaller20260120: …`

                - `tool_id: str`

                - `type: Literal["code_execution_20260120"]`

                  - `"code_execution_20260120"`

          - `class BetaServerToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

              - `"advisor"`

              - `"web_search"`

              - `"web_fetch"`

              - `"code_execution"`

              - `"bash_code_execution"`

              - `"text_editor_code_execution"`

              - `"tool_search_tool_regex"`

              - `"tool_search_tool_bm25"`

            - `type: Literal["server_tool_use"]`

              - `"server_tool_use"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebSearchToolResultBlock: …`

            - `content: BetaWebSearchToolResultBlockContent`

              - `class BetaWebSearchToolResultError: …`

                - `error_code: BetaWebSearchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"max_uses_exceeded"`

                  - `"too_many_requests"`

                  - `"query_too_long"`

                  - `"request_too_large"`

                - `type: Literal["web_search_tool_result_error"]`

                  - `"web_search_tool_result_error"`

              - `List[BetaWebSearchResultBlock]`

                - `encrypted_content: str`

                - `page_age: Optional[str]`

                - `title: str`

                - `type: Literal["web_search_result"]`

                  - `"web_search_result"`

                - `url: str`

            - `tool_use_id: str`

            - `type: Literal["web_search_tool_result"]`

              - `"web_search_tool_result"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebFetchToolResultBlock: …`

            - `content: Content`

              - `class BetaWebFetchToolResultErrorBlock: …`

                - `error_code: BetaWebFetchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"url_too_long"`

                  - `"url_not_allowed"`

                  - `"url_not_in_prior_context"`

                  - `"url_not_accessible"`

                  - `"unsupported_content_type"`

                  - `"too_many_requests"`

                  - `"max_uses_exceeded"`

                  - `"unavailable"`

                - `type: Literal["web_fetch_tool_result_error"]`

                  - `"web_fetch_tool_result_error"`

              - `class BetaWebFetchBlock: …`

                - `content: BetaDocumentBlock`

                  - `citations: Optional[BetaCitationConfig]`

                    Citation configuration for the document

                    - `enabled: bool`

                  - `source: Source`

                    - `class BetaBase64PDFSource: …`

                      - `data: str`

                      - `media_type: Literal["application/pdf"]`

                        - `"application/pdf"`

                      - `type: Literal["base64"]`

                        - `"base64"`

                    - `class BetaPlainTextSource: …`

                      - `data: str`

                      - `media_type: Literal["text/plain"]`

                        - `"text/plain"`

                      - `type: Literal["text"]`

                        - `"text"`

                  - `title: Optional[str]`

                    The title of the document

                  - `type: Literal["document"]`

                    - `"document"`

                - `retrieved_at: Optional[str]`

                  ISO 8601 timestamp when the content was retrieved

                - `type: Literal["web_fetch_result"]`

                  - `"web_fetch_result"`

                - `url: str`

                  Fetched content URL

            - `tool_use_id: str`

            - `type: Literal["web_fetch_tool_result"]`

              - `"web_fetch_tool_result"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaAdvisorToolResultBlock: …`

            - `content: Content`

              - `class BetaAdvisorToolResultError: …`

                - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

                  - `"max_uses_exceeded"`

                  - `"prompt_too_long"`

                  - `"too_many_requests"`

                  - `"overloaded"`

                  - `"unavailable"`

                  - `"execution_time_exceeded"`

                - `type: Literal["advisor_tool_result_error"]`

                  - `"advisor_tool_result_error"`

              - `class BetaAdvisorResultBlock: …`

                - `stop_reason: Optional[str]`

                  The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

                - `text: str`

                - `type: Literal["advisor_result"]`

                  - `"advisor_result"`

              - `class BetaAdvisorRedactedResultBlock: …`

                - `encrypted_content: str`

                  Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

                - `stop_reason: Optional[str]`

                  The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

                - `type: Literal["advisor_redacted_result"]`

                  - `"advisor_redacted_result"`

            - `tool_use_id: str`

            - `type: Literal["advisor_tool_result"]`

              - `"advisor_tool_result"`

          - `class BetaCodeExecutionToolResultBlock: …`

            - `content: BetaCodeExecutionToolResultBlockContent`

              Code execution result with encrypted stdout for PFC + web_search results.

              - `class BetaCodeExecutionToolResultError: …`

                - `error_code: BetaCodeExecutionToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `type: Literal["code_execution_tool_result_error"]`

                  - `"code_execution_tool_result_error"`

              - `class BetaCodeExecutionResultBlock: …`

                - `content: List[BetaCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                    - `"code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["code_execution_result"]`

                  - `"code_execution_result"`

              - `class BetaEncryptedCodeExecutionResultBlock: …`

                Code execution result with encrypted stdout for PFC + web_search results.

                - `content: List[BetaCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                - `encrypted_stdout: str`

                - `return_code: int`

                - `stderr: str`

                - `type: Literal["encrypted_code_execution_result"]`

                  - `"encrypted_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["code_execution_tool_result"]`

              - `"code_execution_tool_result"`

          - `class BetaBashCodeExecutionToolResultBlock: …`

            - `content: Content`

              - `class BetaBashCodeExecutionToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"output_file_too_large"`

                - `type: Literal["bash_code_execution_tool_result_error"]`

                  - `"bash_code_execution_tool_result_error"`

              - `class BetaBashCodeExecutionResultBlock: …`

                - `content: List[BetaBashCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["bash_code_execution_output"]`

                    - `"bash_code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["bash_code_execution_result"]`

                  - `"bash_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["bash_code_execution_tool_result"]`

              - `"bash_code_execution_tool_result"`

          - `class BetaTextEditorCodeExecutionToolResultBlock: …`

            - `content: Content`

              - `class BetaTextEditorCodeExecutionToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"file_not_found"`

                - `error_message: Optional[str]`

                - `type: Literal["text_editor_code_execution_tool_result_error"]`

                  - `"text_editor_code_execution_tool_result_error"`

              - `class BetaTextEditorCodeExecutionViewResultBlock: …`

                - `content: str`

                - `file_type: Literal["text", "image", "pdf"]`

                  - `"text"`

                  - `"image"`

                  - `"pdf"`

                - `num_lines: Optional[int]`

                - `start_line: Optional[int]`

                - `total_lines: Optional[int]`

                - `type: Literal["text_editor_code_execution_view_result"]`

                  - `"text_editor_code_execution_view_result"`

              - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

                - `is_file_update: bool`

                - `type: Literal["text_editor_code_execution_create_result"]`

                  - `"text_editor_code_execution_create_result"`

              - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

                - `lines: Optional[List[str]]`

                - `new_lines: Optional[int]`

                - `new_start: Optional[int]`

                - `old_lines: Optional[int]`

                - `old_start: Optional[int]`

                - `type: Literal["text_editor_code_execution_str_replace_result"]`

                  - `"text_editor_code_execution_str_replace_result"`

            - `tool_use_id: str`

            - `type: Literal["text_editor_code_execution_tool_result"]`

              - `"text_editor_code_execution_tool_result"`

          - `class BetaToolSearchToolResultBlock: …`

            - `content: Content`

              - `class BetaToolSearchToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `error_message: Optional[str]`

                - `type: Literal["tool_search_tool_result_error"]`

                  - `"tool_search_tool_result_error"`

              - `class BetaToolSearchToolSearchResultBlock: …`

                - `tool_references: List[BetaToolReferenceBlock]`

                  - `tool_name: str`

                  - `type: Literal["tool_reference"]`

                    - `"tool_reference"`

                - `type: Literal["tool_search_tool_search_result"]`

                  - `"tool_search_tool_search_result"`

            - `tool_use_id: str`

            - `type: Literal["tool_search_tool_result"]`

              - `"tool_search_tool_result"`

          - `class BetaMCPToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

              The name of the MCP tool

            - `server_name: str`

              The name of the MCP server

            - `type: Literal["mcp_tool_use"]`

              - `"mcp_tool_use"`

          - `class BetaMCPToolResultBlock: …`

            - `content: Union[str, List[BetaTextBlock]]`

              - `str`

              - `List[BetaTextBlock]`

                - `citations: Optional[List[BetaTextCitation]]`

                  Citations supporting the text block.

                  The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

                - `text: str`

                - `type: Literal["text"]`

            - `is_error: bool`

            - `tool_use_id: str`

            - `type: Literal["mcp_tool_result"]`

              - `"mcp_tool_result"`

          - `class BetaContainerUploadBlock: …`

            Response model for a file uploaded to the container.

            - `file_id: str`

            - `type: Literal["container_upload"]`

              - `"container_upload"`

          - `class BetaCompactionBlock: …`

            A compaction block returned when autocompact is triggered.

            When content is None, it indicates the compaction failed to produce a valid
            summary (e.g., malformed output from the model). Clients may round-trip
            compaction blocks with null content; the server treats them as no-ops.

            - `content: Optional[str]`

              Summary of compacted content, or null if compaction failed

            - `encrypted_content: Optional[str]`

              Opaque metadata from prior compaction, to be round-tripped verbatim

            - `type: Literal["compaction"]`

              - `"compaction"`

        - `context_management: Optional[BetaContextManagementResponse]`

          Context management response.

          Information about context management strategies applied during the request.

          - `applied_edits: List[AppliedEdit]`

            List of context management edits that were applied.

            - `class BetaClearToolUses20250919EditResponse: …`

              - `cleared_input_tokens: int`

                Number of input tokens cleared by this edit.

              - `cleared_tool_uses: int`

                Number of tool uses that were cleared.

              - `type: Literal["clear_tool_uses_20250919"]`

                The type of context management edit applied.

                - `"clear_tool_uses_20250919"`

            - `class BetaClearThinking20251015EditResponse: …`

              - `cleared_input_tokens: int`

                Number of input tokens cleared by this edit.

              - `cleared_thinking_turns: int`

                Number of thinking turns that were cleared.

              - `type: Literal["clear_thinking_20251015"]`

                The type of context management edit applied.

                - `"clear_thinking_20251015"`

        - `diagnostics: Optional[BetaDiagnostics]`

          Response envelope for request-level diagnostics. Present (possibly
          null) whenever the caller supplied `diagnostics` on the request.

          - `cache_miss_reason: Optional[CacheMissReason]`

            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.

            - `class BetaCacheMissModelChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["model_changed"]`

                - `"model_changed"`

            - `class BetaCacheMissSystemChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["system_changed"]`

                - `"system_changed"`

            - `class BetaCacheMissToolsChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["tools_changed"]`

                - `"tools_changed"`

            - `class BetaCacheMissMessagesChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["messages_changed"]`

                - `"messages_changed"`

            - `class BetaCacheMissPreviousMessageNotFound: …`

              - `type: Literal["previous_message_not_found"]`

                - `"previous_message_not_found"`

            - `class BetaCacheMissUnavailable: …`

              - `type: Literal["unavailable"]`

                - `"unavailable"`

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

            The model that will complete your prompt.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
            - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
            - `claude-opus-4-1` - Exceptional model for specialized complex tasks
            - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
            - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-mythos-preview"`

              New class of intelligence, strongest in coding and cybersecurity

            - `"claude-opus-4-6"`

              Frontier intelligence for long-running agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

            - `"claude-opus-4-1"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-1-20250805"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-0"`

              Powerful model for complex tasks

            - `"claude-opus-4-20250514"`

              Powerful model for complex tasks

            - `"claude-sonnet-4-0"`

              High-performance model with extended thinking

            - `"claude-sonnet-4-20250514"`

              High-performance model with extended thinking

            - `"claude-3-haiku-20240307"`

              Fast and cost-effective model

          - `str`

        - `role: Literal["assistant"]`

          Conversational role of the generated message.

          This will always be `"assistant"`.

          - `"assistant"`

        - `stop_details: Optional[BetaRefusalStopDetails]`

          Structured information about a refusal.

          - `category: Optional[Literal["cyber", "bio"]]`

            The policy category that triggered the refusal.

            `null` when the refusal doesn't map to a named category.

            - `"cyber"`

            - `"bio"`

          - `explanation: Optional[str]`

            Human-readable explanation of the refusal.

            This text is not guaranteed to be stable. `null` when no explanation is available for the category.

          - `type: Literal["refusal"]`

            - `"refusal"`

        - `stop_reason: Optional[BetaStopReason]`

          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 maximum
          * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
          * `"tool_use"`: the model invoked one or more tools
          * `"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.
          * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

          In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

          - `"end_turn"`

          - `"max_tokens"`

          - `"stop_sequence"`

          - `"tool_use"`

          - `"pause_turn"`

          - `"compaction"`

          - `"refusal"`

          - `"model_context_window_exceeded"`

        - `stop_sequence: Optional[str]`

          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.

        - `type: Literal["message"]`

          Object type.

          For Messages, this is always `"message"`.

          - `"message"`

        - `usage: BetaUsage`

          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 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.

          For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

          Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

            - `ephemeral_1h_input_tokens: int`

              The number of input tokens used to create the 1 hour cache entry.

            - `ephemeral_5m_input_tokens: int`

              The number of input tokens used to create the 5 minute cache entry.

          - `cache_creation_input_tokens: Optional[int]`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: Optional[int]`

            The number of input tokens read from the cache.

          - `inference_geo: Optional[str]`

            The geographic region where inference was performed for this request.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `iterations: Optional[BetaIterationsUsage]`

            Per-iteration token usage breakdown.

            Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

            - Determine which iterations exceeded long context thresholds (>=200k tokens)
            - Calculate the true context window size from the last iteration
            - Understand token accumulation across server-side tool use loops

            - `class BetaMessageIterationUsage: …`

              Token usage for a sampling iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["message"]`

                Usage for a sampling iteration

                - `"message"`

            - `class BetaCompactionIterationUsage: …`

              Token usage for a compaction iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["compaction"]`

                Usage for a compaction iteration

                - `"compaction"`

            - `class BetaAdvisorMessageIterationUsage: …`

              Token usage for an advisor sub-inference iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `model: Model`

                The model that will complete your prompt.

                See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["advisor_message"]`

                Usage for an advisor sub-inference iteration

                - `"advisor_message"`

          - `output_tokens: int`

            The number of output tokens which were used.

          - `output_tokens_details: Optional[BetaOutputTokensDetails]`

            Breakdown of output tokens by category.

            `output_tokens` remains the inclusive, authoritative total used for billing.
            This object provides a read-only decomposition for observability — for example,
            how many of the billed output tokens were spent on internal reasoning that may
            have been summarized before being returned to you.

            - `thinking_tokens: int`

              Number of output tokens the model generated as internal reasoning, including
              the thinking-block delimiter tokens.

              Reflects the raw reasoning the model produced, not the (possibly shorter)
              summarized thinking text returned in the response body. Computed by
              re-tokenizing the raw reasoning text, so it may differ from the model's exact
              generation count by a small number of tokens. Always ≤ `output_tokens`;
              `output_tokens - thinking_tokens` approximates the non-reasoning output.

          - `server_tool_use: Optional[BetaServerToolUsage]`

            The number of server tool requests.

            - `web_fetch_requests: int`

              The number of web fetch tool requests.

            - `web_search_requests: int`

              The number of web search tool requests.

          - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

            If the request used the priority, standard, or batch tier.

            - `"standard"`

            - `"priority"`

            - `"batch"`

          - `speed: Optional[Literal["standard", "fast"]]`

            The inference speed mode used for this request.

            - `"standard"`

            - `"fast"`

      - `type: Literal["succeeded"]`

        - `"succeeded"`

    - `class BetaMessageBatchErroredResult: …`

      - `error: BetaErrorResponse`

        - `error: BetaError`

          - `class BetaInvalidRequestError: …`

            - `message: str`

            - `type: Literal["invalid_request_error"]`

              - `"invalid_request_error"`

          - `class BetaAuthenticationError: …`

            - `message: str`

            - `type: Literal["authentication_error"]`

              - `"authentication_error"`

          - `class BetaBillingError: …`

            - `message: str`

            - `type: Literal["billing_error"]`

              - `"billing_error"`

          - `class BetaPermissionError: …`

            - `message: str`

            - `type: Literal["permission_error"]`

              - `"permission_error"`

          - `class BetaNotFoundError: …`

            - `message: str`

            - `type: Literal["not_found_error"]`

              - `"not_found_error"`

          - `class BetaRateLimitError: …`

            - `message: str`

            - `type: Literal["rate_limit_error"]`

              - `"rate_limit_error"`

          - `class BetaGatewayTimeoutError: …`

            - `message: str`

            - `type: Literal["timeout_error"]`

              - `"timeout_error"`

          - `class BetaAPIError: …`

            - `message: str`

            - `type: Literal["api_error"]`

              - `"api_error"`

          - `class BetaOverloadedError: …`

            - `message: str`

            - `type: Literal["overloaded_error"]`

              - `"overloaded_error"`

        - `request_id: Optional[str]`

        - `type: Literal["error"]`

          - `"error"`

      - `type: Literal["errored"]`

        - `"errored"`

    - `class BetaMessageBatchCanceledResult: …`

      - `type: Literal["canceled"]`

        - `"canceled"`

    - `class BetaMessageBatchExpiredResult: …`

      - `type: Literal["expired"]`

        - `"expired"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
for batch in client.beta.messages.batches.results(
    message_batch_id="message_batch_id",
):
  print(batch)
```

## Domain Types

### Beta Deleted Message Batch

- `class BetaDeletedMessageBatch: …`

  - `id: str`

    ID of the Message Batch.

  - `type: Literal["message_batch_deleted"]`

    Deleted object type.

    For Message Batches, this is always `"message_batch_deleted"`.

    - `"message_batch_deleted"`

### Beta Message Batch

- `class BetaMessageBatch: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `archived_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which the Message Batch was archived and its results became unavailable.

  - `cancel_initiated_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which cancellation was initiated for the Message Batch. Specified only if cancellation was initiated.

  - `created_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch was created.

  - `ended_at: Optional[datetime]`

    RFC 3339 datetime string representing the time at which processing for the Message Batch ended. Specified only once processing ends.

    Processing ends when every request in a Message Batch has either succeeded, errored, canceled, or expired.

  - `expires_at: datetime`

    RFC 3339 datetime string representing the time at which the Message Batch will expire and end processing, which is 24 hours after creation.

  - `processing_status: Literal["in_progress", "canceling", "ended"]`

    Processing status of the Message Batch.

    - `"in_progress"`

    - `"canceling"`

    - `"ended"`

  - `request_counts: BetaMessageBatchRequestCounts`

    Tallies requests within the Message Batch, categorized by their status.

    Requests start as `processing` and move to one of the other statuses only once processing of the entire batch ends. The sum of all values always matches the total number of requests in the batch.

    - `canceled: int`

      Number of requests in the Message Batch that have been canceled.

      This is zero until processing of the entire Message Batch has ended.

    - `errored: int`

      Number of requests in the Message Batch that encountered an error.

      This is zero until processing of the entire Message Batch has ended.

    - `expired: int`

      Number of requests in the Message Batch that have expired.

      This is zero until processing of the entire Message Batch has ended.

    - `processing: int`

      Number of requests in the Message Batch that are processing.

    - `succeeded: int`

      Number of requests in the Message Batch that have completed successfully.

      This is zero until processing of the entire Message Batch has ended.

  - `results_url: Optional[str]`

    URL to a `.jsonl` file containing the results of the Message Batch requests. Specified only once processing ends.

    Results in the file are not guaranteed to be in the same order as requests. Use the `custom_id` field to match results to requests.

  - `type: Literal["message_batch"]`

    Object type.

    For Message Batches, this is always `"message_batch"`.

    - `"message_batch"`

### Beta Message Batch Canceled Result

- `class BetaMessageBatchCanceledResult: …`

  - `type: Literal["canceled"]`

    - `"canceled"`

### Beta Message Batch Errored Result

- `class BetaMessageBatchErroredResult: …`

  - `error: BetaErrorResponse`

    - `error: BetaError`

      - `class BetaInvalidRequestError: …`

        - `message: str`

        - `type: Literal["invalid_request_error"]`

          - `"invalid_request_error"`

      - `class BetaAuthenticationError: …`

        - `message: str`

        - `type: Literal["authentication_error"]`

          - `"authentication_error"`

      - `class BetaBillingError: …`

        - `message: str`

        - `type: Literal["billing_error"]`

          - `"billing_error"`

      - `class BetaPermissionError: …`

        - `message: str`

        - `type: Literal["permission_error"]`

          - `"permission_error"`

      - `class BetaNotFoundError: …`

        - `message: str`

        - `type: Literal["not_found_error"]`

          - `"not_found_error"`

      - `class BetaRateLimitError: …`

        - `message: str`

        - `type: Literal["rate_limit_error"]`

          - `"rate_limit_error"`

      - `class BetaGatewayTimeoutError: …`

        - `message: str`

        - `type: Literal["timeout_error"]`

          - `"timeout_error"`

      - `class BetaAPIError: …`

        - `message: str`

        - `type: Literal["api_error"]`

          - `"api_error"`

      - `class BetaOverloadedError: …`

        - `message: str`

        - `type: Literal["overloaded_error"]`

          - `"overloaded_error"`

    - `request_id: Optional[str]`

    - `type: Literal["error"]`

      - `"error"`

  - `type: Literal["errored"]`

    - `"errored"`

### Beta Message Batch Expired Result

- `class BetaMessageBatchExpiredResult: …`

  - `type: Literal["expired"]`

    - `"expired"`

### Beta Message Batch Individual Response

- `class BetaMessageBatchIndividualResponse: …`

  This is a single line in the response `.jsonl` file and does not represent the response as a whole.

  - `custom_id: str`

    Developer-provided ID created for each request in a Message Batch. Useful for matching results to requests, as results may be given out of request order.

    Must be unique for each request within the Message Batch.

  - `result: BetaMessageBatchResult`

    Processing result for this request.

    Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

    - `class BetaMessageBatchSucceededResult: …`

      - `message: BetaMessage`

        - `id: str`

          Unique object identifier.

          The format and length of IDs may change over time.

        - `container: Optional[BetaContainer]`

          Information about the container used in the request (for the code execution tool)

          - `id: str`

            Identifier for the container used in this request

          - `expires_at: datetime`

            The time at which the container will expire.

          - `skills: Optional[List[BetaSkill]]`

            Skills loaded in the container

            - `skill_id: str`

              Skill ID

            - `type: Literal["anthropic", "custom"]`

              Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

              - `"anthropic"`

              - `"custom"`

            - `version: str`

              Skill version or 'latest' for most recent version

        - `content: List[BetaContentBlock]`

          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 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.

          For example, if the input `messages` were:

          ```json
          [
            {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
            {"role": "assistant", "content": "The best answer is ("}
          ]
          ```

          Then the response `content` might be:

          ```json
          [{"type": "text", "text": "B)"}]
          ```

          - `class BetaTextBlock: …`

            - `citations: Optional[List[BetaTextCitation]]`

              Citations supporting the text block.

              The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

              - `class BetaCitationCharLocation: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_char_index: int`

                - `file_id: Optional[str]`

                - `start_char_index: int`

                - `type: Literal["char_location"]`

                  - `"char_location"`

              - `class BetaCitationPageLocation: …`

                - `cited_text: str`

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_page_number: int`

                - `file_id: Optional[str]`

                - `start_page_number: int`

                - `type: Literal["page_location"]`

                  - `"page_location"`

              - `class BetaCitationContentBlockLocation: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `document_index: int`

                - `document_title: Optional[str]`

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `file_id: Optional[str]`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `type: Literal["content_block_location"]`

                  - `"content_block_location"`

              - `class BetaCitationsWebSearchResultLocation: …`

                - `cited_text: str`

                - `encrypted_index: str`

                - `title: Optional[str]`

                - `type: Literal["web_search_result_location"]`

                  - `"web_search_result_location"`

                - `url: str`

              - `class BetaCitationSearchResultLocation: …`

                - `cited_text: str`

                  The full text of the cited block range, concatenated.

                  Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

                - `end_block_index: int`

                  Exclusive 0-based end index of the cited block range in the source's `content` array.

                  Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

                - `search_result_index: int`

                  0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                  Counted separately from `document_index`; server-side web search results are not included in this count.

                - `source: str`

                - `start_block_index: int`

                  0-based index of the first cited block in the source's `content` array.

                - `title: Optional[str]`

                - `type: Literal["search_result_location"]`

                  - `"search_result_location"`

            - `text: str`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaThinkingBlock: …`

            - `signature: str`

            - `thinking: str`

            - `type: Literal["thinking"]`

              - `"thinking"`

          - `class BetaRedactedThinkingBlock: …`

            - `data: str`

            - `type: Literal["redacted_thinking"]`

              - `"redacted_thinking"`

          - `class BetaToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

            - `type: Literal["tool_use"]`

              - `"tool_use"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

                - `type: Literal["direct"]`

                  - `"direct"`

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

                - `tool_id: str`

                - `type: Literal["code_execution_20250825"]`

                  - `"code_execution_20250825"`

              - `class BetaServerToolCaller20260120: …`

                - `tool_id: str`

                - `type: Literal["code_execution_20260120"]`

                  - `"code_execution_20260120"`

          - `class BetaServerToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

              - `"advisor"`

              - `"web_search"`

              - `"web_fetch"`

              - `"code_execution"`

              - `"bash_code_execution"`

              - `"text_editor_code_execution"`

              - `"tool_search_tool_regex"`

              - `"tool_search_tool_bm25"`

            - `type: Literal["server_tool_use"]`

              - `"server_tool_use"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebSearchToolResultBlock: …`

            - `content: BetaWebSearchToolResultBlockContent`

              - `class BetaWebSearchToolResultError: …`

                - `error_code: BetaWebSearchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"max_uses_exceeded"`

                  - `"too_many_requests"`

                  - `"query_too_long"`

                  - `"request_too_large"`

                - `type: Literal["web_search_tool_result_error"]`

                  - `"web_search_tool_result_error"`

              - `List[BetaWebSearchResultBlock]`

                - `encrypted_content: str`

                - `page_age: Optional[str]`

                - `title: str`

                - `type: Literal["web_search_result"]`

                  - `"web_search_result"`

                - `url: str`

            - `tool_use_id: str`

            - `type: Literal["web_search_tool_result"]`

              - `"web_search_tool_result"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaWebFetchToolResultBlock: …`

            - `content: Content`

              - `class BetaWebFetchToolResultErrorBlock: …`

                - `error_code: BetaWebFetchToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"url_too_long"`

                  - `"url_not_allowed"`

                  - `"url_not_in_prior_context"`

                  - `"url_not_accessible"`

                  - `"unsupported_content_type"`

                  - `"too_many_requests"`

                  - `"max_uses_exceeded"`

                  - `"unavailable"`

                - `type: Literal["web_fetch_tool_result_error"]`

                  - `"web_fetch_tool_result_error"`

              - `class BetaWebFetchBlock: …`

                - `content: BetaDocumentBlock`

                  - `citations: Optional[BetaCitationConfig]`

                    Citation configuration for the document

                    - `enabled: bool`

                  - `source: Source`

                    - `class BetaBase64PDFSource: …`

                      - `data: str`

                      - `media_type: Literal["application/pdf"]`

                        - `"application/pdf"`

                      - `type: Literal["base64"]`

                        - `"base64"`

                    - `class BetaPlainTextSource: …`

                      - `data: str`

                      - `media_type: Literal["text/plain"]`

                        - `"text/plain"`

                      - `type: Literal["text"]`

                        - `"text"`

                  - `title: Optional[str]`

                    The title of the document

                  - `type: Literal["document"]`

                    - `"document"`

                - `retrieved_at: Optional[str]`

                  ISO 8601 timestamp when the content was retrieved

                - `type: Literal["web_fetch_result"]`

                  - `"web_fetch_result"`

                - `url: str`

                  Fetched content URL

            - `tool_use_id: str`

            - `type: Literal["web_fetch_tool_result"]`

              - `"web_fetch_tool_result"`

            - `caller: Optional[Caller]`

              Tool invocation directly from the model.

              - `class BetaDirectCaller: …`

                Tool invocation directly from the model.

              - `class BetaServerToolCaller: …`

                Tool invocation generated by a server-side tool.

              - `class BetaServerToolCaller20260120: …`

          - `class BetaAdvisorToolResultBlock: …`

            - `content: Content`

              - `class BetaAdvisorToolResultError: …`

                - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

                  - `"max_uses_exceeded"`

                  - `"prompt_too_long"`

                  - `"too_many_requests"`

                  - `"overloaded"`

                  - `"unavailable"`

                  - `"execution_time_exceeded"`

                - `type: Literal["advisor_tool_result_error"]`

                  - `"advisor_tool_result_error"`

              - `class BetaAdvisorResultBlock: …`

                - `stop_reason: Optional[str]`

                  The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

                - `text: str`

                - `type: Literal["advisor_result"]`

                  - `"advisor_result"`

              - `class BetaAdvisorRedactedResultBlock: …`

                - `encrypted_content: str`

                  Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

                - `stop_reason: Optional[str]`

                  The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

                - `type: Literal["advisor_redacted_result"]`

                  - `"advisor_redacted_result"`

            - `tool_use_id: str`

            - `type: Literal["advisor_tool_result"]`

              - `"advisor_tool_result"`

          - `class BetaCodeExecutionToolResultBlock: …`

            - `content: BetaCodeExecutionToolResultBlockContent`

              Code execution result with encrypted stdout for PFC + web_search results.

              - `class BetaCodeExecutionToolResultError: …`

                - `error_code: BetaCodeExecutionToolResultErrorCode`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `type: Literal["code_execution_tool_result_error"]`

                  - `"code_execution_tool_result_error"`

              - `class BetaCodeExecutionResultBlock: …`

                - `content: List[BetaCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                    - `"code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["code_execution_result"]`

                  - `"code_execution_result"`

              - `class BetaEncryptedCodeExecutionResultBlock: …`

                Code execution result with encrypted stdout for PFC + web_search results.

                - `content: List[BetaCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["code_execution_output"]`

                - `encrypted_stdout: str`

                - `return_code: int`

                - `stderr: str`

                - `type: Literal["encrypted_code_execution_result"]`

                  - `"encrypted_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["code_execution_tool_result"]`

              - `"code_execution_tool_result"`

          - `class BetaBashCodeExecutionToolResultBlock: …`

            - `content: Content`

              - `class BetaBashCodeExecutionToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"output_file_too_large"`

                - `type: Literal["bash_code_execution_tool_result_error"]`

                  - `"bash_code_execution_tool_result_error"`

              - `class BetaBashCodeExecutionResultBlock: …`

                - `content: List[BetaBashCodeExecutionOutputBlock]`

                  - `file_id: str`

                  - `type: Literal["bash_code_execution_output"]`

                    - `"bash_code_execution_output"`

                - `return_code: int`

                - `stderr: str`

                - `stdout: str`

                - `type: Literal["bash_code_execution_result"]`

                  - `"bash_code_execution_result"`

            - `tool_use_id: str`

            - `type: Literal["bash_code_execution_tool_result"]`

              - `"bash_code_execution_tool_result"`

          - `class BetaTextEditorCodeExecutionToolResultBlock: …`

            - `content: Content`

              - `class BetaTextEditorCodeExecutionToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                  - `"file_not_found"`

                - `error_message: Optional[str]`

                - `type: Literal["text_editor_code_execution_tool_result_error"]`

                  - `"text_editor_code_execution_tool_result_error"`

              - `class BetaTextEditorCodeExecutionViewResultBlock: …`

                - `content: str`

                - `file_type: Literal["text", "image", "pdf"]`

                  - `"text"`

                  - `"image"`

                  - `"pdf"`

                - `num_lines: Optional[int]`

                - `start_line: Optional[int]`

                - `total_lines: Optional[int]`

                - `type: Literal["text_editor_code_execution_view_result"]`

                  - `"text_editor_code_execution_view_result"`

              - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

                - `is_file_update: bool`

                - `type: Literal["text_editor_code_execution_create_result"]`

                  - `"text_editor_code_execution_create_result"`

              - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

                - `lines: Optional[List[str]]`

                - `new_lines: Optional[int]`

                - `new_start: Optional[int]`

                - `old_lines: Optional[int]`

                - `old_start: Optional[int]`

                - `type: Literal["text_editor_code_execution_str_replace_result"]`

                  - `"text_editor_code_execution_str_replace_result"`

            - `tool_use_id: str`

            - `type: Literal["text_editor_code_execution_tool_result"]`

              - `"text_editor_code_execution_tool_result"`

          - `class BetaToolSearchToolResultBlock: …`

            - `content: Content`

              - `class BetaToolSearchToolResultError: …`

                - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

                  - `"invalid_tool_input"`

                  - `"unavailable"`

                  - `"too_many_requests"`

                  - `"execution_time_exceeded"`

                - `error_message: Optional[str]`

                - `type: Literal["tool_search_tool_result_error"]`

                  - `"tool_search_tool_result_error"`

              - `class BetaToolSearchToolSearchResultBlock: …`

                - `tool_references: List[BetaToolReferenceBlock]`

                  - `tool_name: str`

                  - `type: Literal["tool_reference"]`

                    - `"tool_reference"`

                - `type: Literal["tool_search_tool_search_result"]`

                  - `"tool_search_tool_search_result"`

            - `tool_use_id: str`

            - `type: Literal["tool_search_tool_result"]`

              - `"tool_search_tool_result"`

          - `class BetaMCPToolUseBlock: …`

            - `id: str`

            - `input: Dict[str, object]`

            - `name: str`

              The name of the MCP tool

            - `server_name: str`

              The name of the MCP server

            - `type: Literal["mcp_tool_use"]`

              - `"mcp_tool_use"`

          - `class BetaMCPToolResultBlock: …`

            - `content: Union[str, List[BetaTextBlock]]`

              - `str`

              - `List[BetaTextBlock]`

                - `citations: Optional[List[BetaTextCitation]]`

                  Citations supporting the text block.

                  The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

                - `text: str`

                - `type: Literal["text"]`

            - `is_error: bool`

            - `tool_use_id: str`

            - `type: Literal["mcp_tool_result"]`

              - `"mcp_tool_result"`

          - `class BetaContainerUploadBlock: …`

            Response model for a file uploaded to the container.

            - `file_id: str`

            - `type: Literal["container_upload"]`

              - `"container_upload"`

          - `class BetaCompactionBlock: …`

            A compaction block returned when autocompact is triggered.

            When content is None, it indicates the compaction failed to produce a valid
            summary (e.g., malformed output from the model). Clients may round-trip
            compaction blocks with null content; the server treats them as no-ops.

            - `content: Optional[str]`

              Summary of compacted content, or null if compaction failed

            - `encrypted_content: Optional[str]`

              Opaque metadata from prior compaction, to be round-tripped verbatim

            - `type: Literal["compaction"]`

              - `"compaction"`

        - `context_management: Optional[BetaContextManagementResponse]`

          Context management response.

          Information about context management strategies applied during the request.

          - `applied_edits: List[AppliedEdit]`

            List of context management edits that were applied.

            - `class BetaClearToolUses20250919EditResponse: …`

              - `cleared_input_tokens: int`

                Number of input tokens cleared by this edit.

              - `cleared_tool_uses: int`

                Number of tool uses that were cleared.

              - `type: Literal["clear_tool_uses_20250919"]`

                The type of context management edit applied.

                - `"clear_tool_uses_20250919"`

            - `class BetaClearThinking20251015EditResponse: …`

              - `cleared_input_tokens: int`

                Number of input tokens cleared by this edit.

              - `cleared_thinking_turns: int`

                Number of thinking turns that were cleared.

              - `type: Literal["clear_thinking_20251015"]`

                The type of context management edit applied.

                - `"clear_thinking_20251015"`

        - `diagnostics: Optional[BetaDiagnostics]`

          Response envelope for request-level diagnostics. Present (possibly
          null) whenever the caller supplied `diagnostics` on the request.

          - `cache_miss_reason: Optional[CacheMissReason]`

            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.

            - `class BetaCacheMissModelChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["model_changed"]`

                - `"model_changed"`

            - `class BetaCacheMissSystemChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["system_changed"]`

                - `"system_changed"`

            - `class BetaCacheMissToolsChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["tools_changed"]`

                - `"tools_changed"`

            - `class BetaCacheMissMessagesChanged: …`

              - `cache_missed_input_tokens: int`

                Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

              - `type: Literal["messages_changed"]`

                - `"messages_changed"`

            - `class BetaCacheMissPreviousMessageNotFound: …`

              - `type: Literal["previous_message_not_found"]`

                - `"previous_message_not_found"`

            - `class BetaCacheMissUnavailable: …`

              - `type: Literal["unavailable"]`

                - `"unavailable"`

        - `model: Model`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

            The model that will complete your prompt.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
            - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
            - `claude-opus-4-1` - Exceptional model for specialized complex tasks
            - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
            - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
            - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-mythos-preview"`

              New class of intelligence, strongest in coding and cybersecurity

            - `"claude-opus-4-6"`

              Frontier intelligence for long-running agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

            - `"claude-opus-4-1"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-1-20250805"`

              Exceptional model for specialized complex tasks

            - `"claude-opus-4-0"`

              Powerful model for complex tasks

            - `"claude-opus-4-20250514"`

              Powerful model for complex tasks

            - `"claude-sonnet-4-0"`

              High-performance model with extended thinking

            - `"claude-sonnet-4-20250514"`

              High-performance model with extended thinking

            - `"claude-3-haiku-20240307"`

              Fast and cost-effective model

          - `str`

        - `role: Literal["assistant"]`

          Conversational role of the generated message.

          This will always be `"assistant"`.

          - `"assistant"`

        - `stop_details: Optional[BetaRefusalStopDetails]`

          Structured information about a refusal.

          - `category: Optional[Literal["cyber", "bio"]]`

            The policy category that triggered the refusal.

            `null` when the refusal doesn't map to a named category.

            - `"cyber"`

            - `"bio"`

          - `explanation: Optional[str]`

            Human-readable explanation of the refusal.

            This text is not guaranteed to be stable. `null` when no explanation is available for the category.

          - `type: Literal["refusal"]`

            - `"refusal"`

        - `stop_reason: Optional[BetaStopReason]`

          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 maximum
          * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
          * `"tool_use"`: the model invoked one or more tools
          * `"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.
          * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

          In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

          - `"end_turn"`

          - `"max_tokens"`

          - `"stop_sequence"`

          - `"tool_use"`

          - `"pause_turn"`

          - `"compaction"`

          - `"refusal"`

          - `"model_context_window_exceeded"`

        - `stop_sequence: Optional[str]`

          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.

        - `type: Literal["message"]`

          Object type.

          For Messages, this is always `"message"`.

          - `"message"`

        - `usage: BetaUsage`

          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 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.

          For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

          Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

            - `ephemeral_1h_input_tokens: int`

              The number of input tokens used to create the 1 hour cache entry.

            - `ephemeral_5m_input_tokens: int`

              The number of input tokens used to create the 5 minute cache entry.

          - `cache_creation_input_tokens: Optional[int]`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: Optional[int]`

            The number of input tokens read from the cache.

          - `inference_geo: Optional[str]`

            The geographic region where inference was performed for this request.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `iterations: Optional[BetaIterationsUsage]`

            Per-iteration token usage breakdown.

            Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

            - Determine which iterations exceeded long context thresholds (>=200k tokens)
            - Calculate the true context window size from the last iteration
            - Understand token accumulation across server-side tool use loops

            - `class BetaMessageIterationUsage: …`

              Token usage for a sampling iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["message"]`

                Usage for a sampling iteration

                - `"message"`

            - `class BetaCompactionIterationUsage: …`

              Token usage for a compaction iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["compaction"]`

                Usage for a compaction iteration

                - `"compaction"`

            - `class BetaAdvisorMessageIterationUsage: …`

              Token usage for an advisor sub-inference iteration.

              - `cache_creation: Optional[BetaCacheCreation]`

                Breakdown of cached tokens by TTL

              - `cache_creation_input_tokens: int`

                The number of input tokens used to create the cache entry.

              - `cache_read_input_tokens: int`

                The number of input tokens read from the cache.

              - `input_tokens: int`

                The number of input tokens which were used.

              - `model: Model`

                The model that will complete your prompt.

                See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

              - `output_tokens: int`

                The number of output tokens which were used.

              - `type: Literal["advisor_message"]`

                Usage for an advisor sub-inference iteration

                - `"advisor_message"`

          - `output_tokens: int`

            The number of output tokens which were used.

          - `output_tokens_details: Optional[BetaOutputTokensDetails]`

            Breakdown of output tokens by category.

            `output_tokens` remains the inclusive, authoritative total used for billing.
            This object provides a read-only decomposition for observability — for example,
            how many of the billed output tokens were spent on internal reasoning that may
            have been summarized before being returned to you.

            - `thinking_tokens: int`

              Number of output tokens the model generated as internal reasoning, including
              the thinking-block delimiter tokens.

              Reflects the raw reasoning the model produced, not the (possibly shorter)
              summarized thinking text returned in the response body. Computed by
              re-tokenizing the raw reasoning text, so it may differ from the model's exact
              generation count by a small number of tokens. Always ≤ `output_tokens`;
              `output_tokens - thinking_tokens` approximates the non-reasoning output.

          - `server_tool_use: Optional[BetaServerToolUsage]`

            The number of server tool requests.

            - `web_fetch_requests: int`

              The number of web fetch tool requests.

            - `web_search_requests: int`

              The number of web search tool requests.

          - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

            If the request used the priority, standard, or batch tier.

            - `"standard"`

            - `"priority"`

            - `"batch"`

          - `speed: Optional[Literal["standard", "fast"]]`

            The inference speed mode used for this request.

            - `"standard"`

            - `"fast"`

      - `type: Literal["succeeded"]`

        - `"succeeded"`

    - `class BetaMessageBatchErroredResult: …`

      - `error: BetaErrorResponse`

        - `error: BetaError`

          - `class BetaInvalidRequestError: …`

            - `message: str`

            - `type: Literal["invalid_request_error"]`

              - `"invalid_request_error"`

          - `class BetaAuthenticationError: …`

            - `message: str`

            - `type: Literal["authentication_error"]`

              - `"authentication_error"`

          - `class BetaBillingError: …`

            - `message: str`

            - `type: Literal["billing_error"]`

              - `"billing_error"`

          - `class BetaPermissionError: …`

            - `message: str`

            - `type: Literal["permission_error"]`

              - `"permission_error"`

          - `class BetaNotFoundError: …`

            - `message: str`

            - `type: Literal["not_found_error"]`

              - `"not_found_error"`

          - `class BetaRateLimitError: …`

            - `message: str`

            - `type: Literal["rate_limit_error"]`

              - `"rate_limit_error"`

          - `class BetaGatewayTimeoutError: …`

            - `message: str`

            - `type: Literal["timeout_error"]`

              - `"timeout_error"`

          - `class BetaAPIError: …`

            - `message: str`

            - `type: Literal["api_error"]`

              - `"api_error"`

          - `class BetaOverloadedError: …`

            - `message: str`

            - `type: Literal["overloaded_error"]`

              - `"overloaded_error"`

        - `request_id: Optional[str]`

        - `type: Literal["error"]`

          - `"error"`

      - `type: Literal["errored"]`

        - `"errored"`

    - `class BetaMessageBatchCanceledResult: …`

      - `type: Literal["canceled"]`

        - `"canceled"`

    - `class BetaMessageBatchExpiredResult: …`

      - `type: Literal["expired"]`

        - `"expired"`

### Beta Message Batch Request Counts

- `class BetaMessageBatchRequestCounts: …`

  - `canceled: int`

    Number of requests in the Message Batch that have been canceled.

    This is zero until processing of the entire Message Batch has ended.

  - `errored: int`

    Number of requests in the Message Batch that encountered an error.

    This is zero until processing of the entire Message Batch has ended.

  - `expired: int`

    Number of requests in the Message Batch that have expired.

    This is zero until processing of the entire Message Batch has ended.

  - `processing: int`

    Number of requests in the Message Batch that are processing.

  - `succeeded: int`

    Number of requests in the Message Batch that have completed successfully.

    This is zero until processing of the entire Message Batch has ended.

### Beta Message Batch Result

- `BetaMessageBatchResult`

  Processing result for this request.

  Contains a Message output if processing was successful, an error response if processing failed, or the reason why processing was not attempted, such as cancellation or expiration.

  - `class BetaMessageBatchSucceededResult: …`

    - `message: BetaMessage`

      - `id: str`

        Unique object identifier.

        The format and length of IDs may change over time.

      - `container: Optional[BetaContainer]`

        Information about the container used in the request (for the code execution tool)

        - `id: str`

          Identifier for the container used in this request

        - `expires_at: datetime`

          The time at which the container will expire.

        - `skills: Optional[List[BetaSkill]]`

          Skills loaded in the container

          - `skill_id: str`

            Skill ID

          - `type: Literal["anthropic", "custom"]`

            Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

            - `"anthropic"`

            - `"custom"`

          - `version: str`

            Skill version or 'latest' for most recent version

      - `content: List[BetaContentBlock]`

        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 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.

        For example, if the input `messages` were:

        ```json
        [
          {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
          {"role": "assistant", "content": "The best answer is ("}
        ]
        ```

        Then the response `content` might be:

        ```json
        [{"type": "text", "text": "B)"}]
        ```

        - `class BetaTextBlock: …`

          - `citations: Optional[List[BetaTextCitation]]`

            Citations supporting the text block.

            The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

            - `class BetaCitationCharLocation: …`

              - `cited_text: str`

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_char_index: int`

              - `file_id: Optional[str]`

              - `start_char_index: int`

              - `type: Literal["char_location"]`

                - `"char_location"`

            - `class BetaCitationPageLocation: …`

              - `cited_text: str`

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_page_number: int`

              - `file_id: Optional[str]`

              - `start_page_number: int`

              - `type: Literal["page_location"]`

                - `"page_location"`

            - `class BetaCitationContentBlockLocation: …`

              - `cited_text: str`

                The full text of the cited block range, concatenated.

                Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

              - `document_index: int`

              - `document_title: Optional[str]`

              - `end_block_index: int`

                Exclusive 0-based end index of the cited block range in the source's `content` array.

                Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

              - `file_id: Optional[str]`

              - `start_block_index: int`

                0-based index of the first cited block in the source's `content` array.

              - `type: Literal["content_block_location"]`

                - `"content_block_location"`

            - `class BetaCitationsWebSearchResultLocation: …`

              - `cited_text: str`

              - `encrypted_index: str`

              - `title: Optional[str]`

              - `type: Literal["web_search_result_location"]`

                - `"web_search_result_location"`

              - `url: str`

            - `class BetaCitationSearchResultLocation: …`

              - `cited_text: str`

                The full text of the cited block range, concatenated.

                Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

              - `end_block_index: int`

                Exclusive 0-based end index of the cited block range in the source's `content` array.

                Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

              - `search_result_index: int`

                0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

                Counted separately from `document_index`; server-side web search results are not included in this count.

              - `source: str`

              - `start_block_index: int`

                0-based index of the first cited block in the source's `content` array.

              - `title: Optional[str]`

              - `type: Literal["search_result_location"]`

                - `"search_result_location"`

          - `text: str`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaThinkingBlock: …`

          - `signature: str`

          - `thinking: str`

          - `type: Literal["thinking"]`

            - `"thinking"`

        - `class BetaRedactedThinkingBlock: …`

          - `data: str`

          - `type: Literal["redacted_thinking"]`

            - `"redacted_thinking"`

        - `class BetaToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: str`

          - `type: Literal["tool_use"]`

            - `"tool_use"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

              - `type: Literal["direct"]`

                - `"direct"`

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

              - `tool_id: str`

              - `type: Literal["code_execution_20250825"]`

                - `"code_execution_20250825"`

            - `class BetaServerToolCaller20260120: …`

              - `tool_id: str`

              - `type: Literal["code_execution_20260120"]`

                - `"code_execution_20260120"`

        - `class BetaServerToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

            - `"advisor"`

            - `"web_search"`

            - `"web_fetch"`

            - `"code_execution"`

            - `"bash_code_execution"`

            - `"text_editor_code_execution"`

            - `"tool_search_tool_regex"`

            - `"tool_search_tool_bm25"`

          - `type: Literal["server_tool_use"]`

            - `"server_tool_use"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaWebSearchToolResultBlock: …`

          - `content: BetaWebSearchToolResultBlockContent`

            - `class BetaWebSearchToolResultError: …`

              - `error_code: BetaWebSearchToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"max_uses_exceeded"`

                - `"too_many_requests"`

                - `"query_too_long"`

                - `"request_too_large"`

              - `type: Literal["web_search_tool_result_error"]`

                - `"web_search_tool_result_error"`

            - `List[BetaWebSearchResultBlock]`

              - `encrypted_content: str`

              - `page_age: Optional[str]`

              - `title: str`

              - `type: Literal["web_search_result"]`

                - `"web_search_result"`

              - `url: str`

          - `tool_use_id: str`

          - `type: Literal["web_search_tool_result"]`

            - `"web_search_tool_result"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaWebFetchToolResultBlock: …`

          - `content: Content`

            - `class BetaWebFetchToolResultErrorBlock: …`

              - `error_code: BetaWebFetchToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"url_too_long"`

                - `"url_not_allowed"`

                - `"url_not_in_prior_context"`

                - `"url_not_accessible"`

                - `"unsupported_content_type"`

                - `"too_many_requests"`

                - `"max_uses_exceeded"`

                - `"unavailable"`

              - `type: Literal["web_fetch_tool_result_error"]`

                - `"web_fetch_tool_result_error"`

            - `class BetaWebFetchBlock: …`

              - `content: BetaDocumentBlock`

                - `citations: Optional[BetaCitationConfig]`

                  Citation configuration for the document

                  - `enabled: bool`

                - `source: Source`

                  - `class BetaBase64PDFSource: …`

                    - `data: str`

                    - `media_type: Literal["application/pdf"]`

                      - `"application/pdf"`

                    - `type: Literal["base64"]`

                      - `"base64"`

                  - `class BetaPlainTextSource: …`

                    - `data: str`

                    - `media_type: Literal["text/plain"]`

                      - `"text/plain"`

                    - `type: Literal["text"]`

                      - `"text"`

                - `title: Optional[str]`

                  The title of the document

                - `type: Literal["document"]`

                  - `"document"`

              - `retrieved_at: Optional[str]`

                ISO 8601 timestamp when the content was retrieved

              - `type: Literal["web_fetch_result"]`

                - `"web_fetch_result"`

              - `url: str`

                Fetched content URL

          - `tool_use_id: str`

          - `type: Literal["web_fetch_tool_result"]`

            - `"web_fetch_tool_result"`

          - `caller: Optional[Caller]`

            Tool invocation directly from the model.

            - `class BetaDirectCaller: …`

              Tool invocation directly from the model.

            - `class BetaServerToolCaller: …`

              Tool invocation generated by a server-side tool.

            - `class BetaServerToolCaller20260120: …`

        - `class BetaAdvisorToolResultBlock: …`

          - `content: Content`

            - `class BetaAdvisorToolResultError: …`

              - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

                - `"max_uses_exceeded"`

                - `"prompt_too_long"`

                - `"too_many_requests"`

                - `"overloaded"`

                - `"unavailable"`

                - `"execution_time_exceeded"`

              - `type: Literal["advisor_tool_result_error"]`

                - `"advisor_tool_result_error"`

            - `class BetaAdvisorResultBlock: …`

              - `stop_reason: Optional[str]`

                The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

              - `text: str`

              - `type: Literal["advisor_result"]`

                - `"advisor_result"`

            - `class BetaAdvisorRedactedResultBlock: …`

              - `encrypted_content: str`

                Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

              - `stop_reason: Optional[str]`

                The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

              - `type: Literal["advisor_redacted_result"]`

                - `"advisor_redacted_result"`

          - `tool_use_id: str`

          - `type: Literal["advisor_tool_result"]`

            - `"advisor_tool_result"`

        - `class BetaCodeExecutionToolResultBlock: …`

          - `content: BetaCodeExecutionToolResultBlockContent`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `class BetaCodeExecutionToolResultError: …`

              - `error_code: BetaCodeExecutionToolResultErrorCode`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

              - `type: Literal["code_execution_tool_result_error"]`

                - `"code_execution_tool_result_error"`

            - `class BetaCodeExecutionResultBlock: …`

              - `content: List[BetaCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["code_execution_output"]`

                  - `"code_execution_output"`

              - `return_code: int`

              - `stderr: str`

              - `stdout: str`

              - `type: Literal["code_execution_result"]`

                - `"code_execution_result"`

            - `class BetaEncryptedCodeExecutionResultBlock: …`

              Code execution result with encrypted stdout for PFC + web_search results.

              - `content: List[BetaCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["code_execution_output"]`

              - `encrypted_stdout: str`

              - `return_code: int`

              - `stderr: str`

              - `type: Literal["encrypted_code_execution_result"]`

                - `"encrypted_code_execution_result"`

          - `tool_use_id: str`

          - `type: Literal["code_execution_tool_result"]`

            - `"code_execution_tool_result"`

        - `class BetaBashCodeExecutionToolResultBlock: …`

          - `content: Content`

            - `class BetaBashCodeExecutionToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

                - `"output_file_too_large"`

              - `type: Literal["bash_code_execution_tool_result_error"]`

                - `"bash_code_execution_tool_result_error"`

            - `class BetaBashCodeExecutionResultBlock: …`

              - `content: List[BetaBashCodeExecutionOutputBlock]`

                - `file_id: str`

                - `type: Literal["bash_code_execution_output"]`

                  - `"bash_code_execution_output"`

              - `return_code: int`

              - `stderr: str`

              - `stdout: str`

              - `type: Literal["bash_code_execution_result"]`

                - `"bash_code_execution_result"`

          - `tool_use_id: str`

          - `type: Literal["bash_code_execution_tool_result"]`

            - `"bash_code_execution_tool_result"`

        - `class BetaTextEditorCodeExecutionToolResultBlock: …`

          - `content: Content`

            - `class BetaTextEditorCodeExecutionToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

                - `"file_not_found"`

              - `error_message: Optional[str]`

              - `type: Literal["text_editor_code_execution_tool_result_error"]`

                - `"text_editor_code_execution_tool_result_error"`

            - `class BetaTextEditorCodeExecutionViewResultBlock: …`

              - `content: str`

              - `file_type: Literal["text", "image", "pdf"]`

                - `"text"`

                - `"image"`

                - `"pdf"`

              - `num_lines: Optional[int]`

              - `start_line: Optional[int]`

              - `total_lines: Optional[int]`

              - `type: Literal["text_editor_code_execution_view_result"]`

                - `"text_editor_code_execution_view_result"`

            - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

              - `is_file_update: bool`

              - `type: Literal["text_editor_code_execution_create_result"]`

                - `"text_editor_code_execution_create_result"`

            - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

              - `lines: Optional[List[str]]`

              - `new_lines: Optional[int]`

              - `new_start: Optional[int]`

              - `old_lines: Optional[int]`

              - `old_start: Optional[int]`

              - `type: Literal["text_editor_code_execution_str_replace_result"]`

                - `"text_editor_code_execution_str_replace_result"`

          - `tool_use_id: str`

          - `type: Literal["text_editor_code_execution_tool_result"]`

            - `"text_editor_code_execution_tool_result"`

        - `class BetaToolSearchToolResultBlock: …`

          - `content: Content`

            - `class BetaToolSearchToolResultError: …`

              - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

                - `"invalid_tool_input"`

                - `"unavailable"`

                - `"too_many_requests"`

                - `"execution_time_exceeded"`

              - `error_message: Optional[str]`

              - `type: Literal["tool_search_tool_result_error"]`

                - `"tool_search_tool_result_error"`

            - `class BetaToolSearchToolSearchResultBlock: …`

              - `tool_references: List[BetaToolReferenceBlock]`

                - `tool_name: str`

                - `type: Literal["tool_reference"]`

                  - `"tool_reference"`

              - `type: Literal["tool_search_tool_search_result"]`

                - `"tool_search_tool_search_result"`

          - `tool_use_id: str`

          - `type: Literal["tool_search_tool_result"]`

            - `"tool_search_tool_result"`

        - `class BetaMCPToolUseBlock: …`

          - `id: str`

          - `input: Dict[str, object]`

          - `name: str`

            The name of the MCP tool

          - `server_name: str`

            The name of the MCP server

          - `type: Literal["mcp_tool_use"]`

            - `"mcp_tool_use"`

        - `class BetaMCPToolResultBlock: …`

          - `content: Union[str, List[BetaTextBlock]]`

            - `str`

            - `List[BetaTextBlock]`

              - `citations: Optional[List[BetaTextCitation]]`

                Citations supporting the text block.

                The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

              - `text: str`

              - `type: Literal["text"]`

          - `is_error: bool`

          - `tool_use_id: str`

          - `type: Literal["mcp_tool_result"]`

            - `"mcp_tool_result"`

        - `class BetaContainerUploadBlock: …`

          Response model for a file uploaded to the container.

          - `file_id: str`

          - `type: Literal["container_upload"]`

            - `"container_upload"`

        - `class BetaCompactionBlock: …`

          A compaction block returned when autocompact is triggered.

          When content is None, it indicates the compaction failed to produce a valid
          summary (e.g., malformed output from the model). Clients may round-trip
          compaction blocks with null content; the server treats them as no-ops.

          - `content: Optional[str]`

            Summary of compacted content, or null if compaction failed

          - `encrypted_content: Optional[str]`

            Opaque metadata from prior compaction, to be round-tripped verbatim

          - `type: Literal["compaction"]`

            - `"compaction"`

      - `context_management: Optional[BetaContextManagementResponse]`

        Context management response.

        Information about context management strategies applied during the request.

        - `applied_edits: List[AppliedEdit]`

          List of context management edits that were applied.

          - `class BetaClearToolUses20250919EditResponse: …`

            - `cleared_input_tokens: int`

              Number of input tokens cleared by this edit.

            - `cleared_tool_uses: int`

              Number of tool uses that were cleared.

            - `type: Literal["clear_tool_uses_20250919"]`

              The type of context management edit applied.

              - `"clear_tool_uses_20250919"`

          - `class BetaClearThinking20251015EditResponse: …`

            - `cleared_input_tokens: int`

              Number of input tokens cleared by this edit.

            - `cleared_thinking_turns: int`

              Number of thinking turns that were cleared.

            - `type: Literal["clear_thinking_20251015"]`

              The type of context management edit applied.

              - `"clear_thinking_20251015"`

      - `diagnostics: Optional[BetaDiagnostics]`

        Response envelope for request-level diagnostics. Present (possibly
        null) whenever the caller supplied `diagnostics` on the request.

        - `cache_miss_reason: Optional[CacheMissReason]`

          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.

          - `class BetaCacheMissModelChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["model_changed"]`

              - `"model_changed"`

          - `class BetaCacheMissSystemChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["system_changed"]`

              - `"system_changed"`

          - `class BetaCacheMissToolsChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["tools_changed"]`

              - `"tools_changed"`

          - `class BetaCacheMissMessagesChanged: …`

            - `cache_missed_input_tokens: int`

              Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

            - `type: Literal["messages_changed"]`

              - `"messages_changed"`

          - `class BetaCacheMissPreviousMessageNotFound: …`

            - `type: Literal["previous_message_not_found"]`

              - `"previous_message_not_found"`

          - `class BetaCacheMissUnavailable: …`

            - `type: Literal["unavailable"]`

              - `"unavailable"`

      - `model: Model`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

          The model that will complete your prompt.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
          - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
          - `claude-opus-4-1` - Exceptional model for specialized complex tasks
          - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
          - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
          - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-mythos-preview"`

            New class of intelligence, strongest in coding and cybersecurity

          - `"claude-opus-4-6"`

            Frontier intelligence for long-running agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

          - `"claude-opus-4-1"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-1-20250805"`

            Exceptional model for specialized complex tasks

          - `"claude-opus-4-0"`

            Powerful model for complex tasks

          - `"claude-opus-4-20250514"`

            Powerful model for complex tasks

          - `"claude-sonnet-4-0"`

            High-performance model with extended thinking

          - `"claude-sonnet-4-20250514"`

            High-performance model with extended thinking

          - `"claude-3-haiku-20240307"`

            Fast and cost-effective model

        - `str`

      - `role: Literal["assistant"]`

        Conversational role of the generated message.

        This will always be `"assistant"`.

        - `"assistant"`

      - `stop_details: Optional[BetaRefusalStopDetails]`

        Structured information about a refusal.

        - `category: Optional[Literal["cyber", "bio"]]`

          The policy category that triggered the refusal.

          `null` when the refusal doesn't map to a named category.

          - `"cyber"`

          - `"bio"`

        - `explanation: Optional[str]`

          Human-readable explanation of the refusal.

          This text is not guaranteed to be stable. `null` when no explanation is available for the category.

        - `type: Literal["refusal"]`

          - `"refusal"`

      - `stop_reason: Optional[BetaStopReason]`

        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 maximum
        * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
        * `"tool_use"`: the model invoked one or more tools
        * `"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.
        * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

        In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

        - `"end_turn"`

        - `"max_tokens"`

        - `"stop_sequence"`

        - `"tool_use"`

        - `"pause_turn"`

        - `"compaction"`

        - `"refusal"`

        - `"model_context_window_exceeded"`

      - `stop_sequence: Optional[str]`

        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.

      - `type: Literal["message"]`

        Object type.

        For Messages, this is always `"message"`.

        - `"message"`

      - `usage: BetaUsage`

        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 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.

        For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

        Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

        - `cache_creation: Optional[BetaCacheCreation]`

          Breakdown of cached tokens by TTL

          - `ephemeral_1h_input_tokens: int`

            The number of input tokens used to create the 1 hour cache entry.

          - `ephemeral_5m_input_tokens: int`

            The number of input tokens used to create the 5 minute cache entry.

        - `cache_creation_input_tokens: Optional[int]`

          The number of input tokens used to create the cache entry.

        - `cache_read_input_tokens: Optional[int]`

          The number of input tokens read from the cache.

        - `inference_geo: Optional[str]`

          The geographic region where inference was performed for this request.

        - `input_tokens: int`

          The number of input tokens which were used.

        - `iterations: Optional[BetaIterationsUsage]`

          Per-iteration token usage breakdown.

          Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

          - Determine which iterations exceeded long context thresholds (>=200k tokens)
          - Calculate the true context window size from the last iteration
          - Understand token accumulation across server-side tool use loops

          - `class BetaMessageIterationUsage: …`

            Token usage for a sampling iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["message"]`

              Usage for a sampling iteration

              - `"message"`

          - `class BetaCompactionIterationUsage: …`

            Token usage for a compaction iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["compaction"]`

              Usage for a compaction iteration

              - `"compaction"`

          - `class BetaAdvisorMessageIterationUsage: …`

            Token usage for an advisor sub-inference iteration.

            - `cache_creation: Optional[BetaCacheCreation]`

              Breakdown of cached tokens by TTL

            - `cache_creation_input_tokens: int`

              The number of input tokens used to create the cache entry.

            - `cache_read_input_tokens: int`

              The number of input tokens read from the cache.

            - `input_tokens: int`

              The number of input tokens which were used.

            - `model: Model`

              The model that will complete your prompt.

              See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `output_tokens: int`

              The number of output tokens which were used.

            - `type: Literal["advisor_message"]`

              Usage for an advisor sub-inference iteration

              - `"advisor_message"`

        - `output_tokens: int`

          The number of output tokens which were used.

        - `output_tokens_details: Optional[BetaOutputTokensDetails]`

          Breakdown of output tokens by category.

          `output_tokens` remains the inclusive, authoritative total used for billing.
          This object provides a read-only decomposition for observability — for example,
          how many of the billed output tokens were spent on internal reasoning that may
          have been summarized before being returned to you.

          - `thinking_tokens: int`

            Number of output tokens the model generated as internal reasoning, including
            the thinking-block delimiter tokens.

            Reflects the raw reasoning the model produced, not the (possibly shorter)
            summarized thinking text returned in the response body. Computed by
            re-tokenizing the raw reasoning text, so it may differ from the model's exact
            generation count by a small number of tokens. Always ≤ `output_tokens`;
            `output_tokens - thinking_tokens` approximates the non-reasoning output.

        - `server_tool_use: Optional[BetaServerToolUsage]`

          The number of server tool requests.

          - `web_fetch_requests: int`

            The number of web fetch tool requests.

          - `web_search_requests: int`

            The number of web search tool requests.

        - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

          If the request used the priority, standard, or batch tier.

          - `"standard"`

          - `"priority"`

          - `"batch"`

        - `speed: Optional[Literal["standard", "fast"]]`

          The inference speed mode used for this request.

          - `"standard"`

          - `"fast"`

    - `type: Literal["succeeded"]`

      - `"succeeded"`

  - `class BetaMessageBatchErroredResult: …`

    - `error: BetaErrorResponse`

      - `error: BetaError`

        - `class BetaInvalidRequestError: …`

          - `message: str`

          - `type: Literal["invalid_request_error"]`

            - `"invalid_request_error"`

        - `class BetaAuthenticationError: …`

          - `message: str`

          - `type: Literal["authentication_error"]`

            - `"authentication_error"`

        - `class BetaBillingError: …`

          - `message: str`

          - `type: Literal["billing_error"]`

            - `"billing_error"`

        - `class BetaPermissionError: …`

          - `message: str`

          - `type: Literal["permission_error"]`

            - `"permission_error"`

        - `class BetaNotFoundError: …`

          - `message: str`

          - `type: Literal["not_found_error"]`

            - `"not_found_error"`

        - `class BetaRateLimitError: …`

          - `message: str`

          - `type: Literal["rate_limit_error"]`

            - `"rate_limit_error"`

        - `class BetaGatewayTimeoutError: …`

          - `message: str`

          - `type: Literal["timeout_error"]`

            - `"timeout_error"`

        - `class BetaAPIError: …`

          - `message: str`

          - `type: Literal["api_error"]`

            - `"api_error"`

        - `class BetaOverloadedError: …`

          - `message: str`

          - `type: Literal["overloaded_error"]`

            - `"overloaded_error"`

      - `request_id: Optional[str]`

      - `type: Literal["error"]`

        - `"error"`

    - `type: Literal["errored"]`

      - `"errored"`

  - `class BetaMessageBatchCanceledResult: …`

    - `type: Literal["canceled"]`

      - `"canceled"`

  - `class BetaMessageBatchExpiredResult: …`

    - `type: Literal["expired"]`

      - `"expired"`

### Beta Message Batch Succeeded Result

- `class BetaMessageBatchSucceededResult: …`

  - `message: BetaMessage`

    - `id: str`

      Unique object identifier.

      The format and length of IDs may change over time.

    - `container: Optional[BetaContainer]`

      Information about the container used in the request (for the code execution tool)

      - `id: str`

        Identifier for the container used in this request

      - `expires_at: datetime`

        The time at which the container will expire.

      - `skills: Optional[List[BetaSkill]]`

        Skills loaded in the container

        - `skill_id: str`

          Skill ID

        - `type: Literal["anthropic", "custom"]`

          Type of skill - either 'anthropic' (built-in) or 'custom' (user-defined)

          - `"anthropic"`

          - `"custom"`

        - `version: str`

          Skill version or 'latest' for most recent version

    - `content: List[BetaContentBlock]`

      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 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.

      For example, if the input `messages` were:

      ```json
      [
        {"role": "user", "content": "What's the Greek name for Sun? (A) Sol (B) Helios (C) Sun"},
        {"role": "assistant", "content": "The best answer is ("}
      ]
      ```

      Then the response `content` might be:

      ```json
      [{"type": "text", "text": "B)"}]
      ```

      - `class BetaTextBlock: …`

        - `citations: Optional[List[BetaTextCitation]]`

          Citations supporting the text block.

          The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

          - `class BetaCitationCharLocation: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_char_index: int`

            - `file_id: Optional[str]`

            - `start_char_index: int`

            - `type: Literal["char_location"]`

              - `"char_location"`

          - `class BetaCitationPageLocation: …`

            - `cited_text: str`

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_page_number: int`

            - `file_id: Optional[str]`

            - `start_page_number: int`

            - `type: Literal["page_location"]`

              - `"page_location"`

          - `class BetaCitationContentBlockLocation: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `document_index: int`

            - `document_title: Optional[str]`

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `file_id: Optional[str]`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `type: Literal["content_block_location"]`

              - `"content_block_location"`

          - `class BetaCitationsWebSearchResultLocation: …`

            - `cited_text: str`

            - `encrypted_index: str`

            - `title: Optional[str]`

            - `type: Literal["web_search_result_location"]`

              - `"web_search_result_location"`

            - `url: str`

          - `class BetaCitationSearchResultLocation: …`

            - `cited_text: str`

              The full text of the cited block range, concatenated.

              Always equals the contents of `content[start_block_index:end_block_index]` joined together. The text block is the minimal citable unit; this field is never a substring of a single block. Not counted toward output tokens, and not counted toward input tokens when sent back in subsequent turns.

            - `end_block_index: int`

              Exclusive 0-based end index of the cited block range in the source's `content` array.

              Always greater than `start_block_index`; a single-block citation has `end_block_index = start_block_index + 1`.

            - `search_result_index: int`

              0-based index of the cited search result among all `search_result` content blocks in the request, in the order they appear across messages and tool results.

              Counted separately from `document_index`; server-side web search results are not included in this count.

            - `source: str`

            - `start_block_index: int`

              0-based index of the first cited block in the source's `content` array.

            - `title: Optional[str]`

            - `type: Literal["search_result_location"]`

              - `"search_result_location"`

        - `text: str`

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaThinkingBlock: …`

        - `signature: str`

        - `thinking: str`

        - `type: Literal["thinking"]`

          - `"thinking"`

      - `class BetaRedactedThinkingBlock: …`

        - `data: str`

        - `type: Literal["redacted_thinking"]`

          - `"redacted_thinking"`

      - `class BetaToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

        - `type: Literal["tool_use"]`

          - `"tool_use"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

            - `type: Literal["direct"]`

              - `"direct"`

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

            - `tool_id: str`

            - `type: Literal["code_execution_20250825"]`

              - `"code_execution_20250825"`

          - `class BetaServerToolCaller20260120: …`

            - `tool_id: str`

            - `type: Literal["code_execution_20260120"]`

              - `"code_execution_20260120"`

      - `class BetaServerToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: Literal["advisor", "web_search", "web_fetch", 5 more]`

          - `"advisor"`

          - `"web_search"`

          - `"web_fetch"`

          - `"code_execution"`

          - `"bash_code_execution"`

          - `"text_editor_code_execution"`

          - `"tool_search_tool_regex"`

          - `"tool_search_tool_bm25"`

        - `type: Literal["server_tool_use"]`

          - `"server_tool_use"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebSearchToolResultBlock: …`

        - `content: BetaWebSearchToolResultBlockContent`

          - `class BetaWebSearchToolResultError: …`

            - `error_code: BetaWebSearchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"max_uses_exceeded"`

              - `"too_many_requests"`

              - `"query_too_long"`

              - `"request_too_large"`

            - `type: Literal["web_search_tool_result_error"]`

              - `"web_search_tool_result_error"`

          - `List[BetaWebSearchResultBlock]`

            - `encrypted_content: str`

            - `page_age: Optional[str]`

            - `title: str`

            - `type: Literal["web_search_result"]`

              - `"web_search_result"`

            - `url: str`

        - `tool_use_id: str`

        - `type: Literal["web_search_tool_result"]`

          - `"web_search_tool_result"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaWebFetchToolResultBlock: …`

        - `content: Content`

          - `class BetaWebFetchToolResultErrorBlock: …`

            - `error_code: BetaWebFetchToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"url_too_long"`

              - `"url_not_allowed"`

              - `"url_not_in_prior_context"`

              - `"url_not_accessible"`

              - `"unsupported_content_type"`

              - `"too_many_requests"`

              - `"max_uses_exceeded"`

              - `"unavailable"`

            - `type: Literal["web_fetch_tool_result_error"]`

              - `"web_fetch_tool_result_error"`

          - `class BetaWebFetchBlock: …`

            - `content: BetaDocumentBlock`

              - `citations: Optional[BetaCitationConfig]`

                Citation configuration for the document

                - `enabled: bool`

              - `source: Source`

                - `class BetaBase64PDFSource: …`

                  - `data: str`

                  - `media_type: Literal["application/pdf"]`

                    - `"application/pdf"`

                  - `type: Literal["base64"]`

                    - `"base64"`

                - `class BetaPlainTextSource: …`

                  - `data: str`

                  - `media_type: Literal["text/plain"]`

                    - `"text/plain"`

                  - `type: Literal["text"]`

                    - `"text"`

              - `title: Optional[str]`

                The title of the document

              - `type: Literal["document"]`

                - `"document"`

            - `retrieved_at: Optional[str]`

              ISO 8601 timestamp when the content was retrieved

            - `type: Literal["web_fetch_result"]`

              - `"web_fetch_result"`

            - `url: str`

              Fetched content URL

        - `tool_use_id: str`

        - `type: Literal["web_fetch_tool_result"]`

          - `"web_fetch_tool_result"`

        - `caller: Optional[Caller]`

          Tool invocation directly from the model.

          - `class BetaDirectCaller: …`

            Tool invocation directly from the model.

          - `class BetaServerToolCaller: …`

            Tool invocation generated by a server-side tool.

          - `class BetaServerToolCaller20260120: …`

      - `class BetaAdvisorToolResultBlock: …`

        - `content: Content`

          - `class BetaAdvisorToolResultError: …`

            - `error_code: Literal["max_uses_exceeded", "prompt_too_long", "too_many_requests", 3 more]`

              - `"max_uses_exceeded"`

              - `"prompt_too_long"`

              - `"too_many_requests"`

              - `"overloaded"`

              - `"unavailable"`

              - `"execution_time_exceeded"`

            - `type: Literal["advisor_tool_result_error"]`

              - `"advisor_tool_result_error"`

          - `class BetaAdvisorResultBlock: …`

            - `stop_reason: Optional[str]`

              The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`). `max_tokens` indicates the advisor's output was truncated at the tool's `max_tokens` value or the advisor model's policy cap.

            - `text: str`

            - `type: Literal["advisor_result"]`

              - `"advisor_result"`

          - `class BetaAdvisorRedactedResultBlock: …`

            - `encrypted_content: str`

              Opaque blob containing the advisor's output. Round-trip verbatim; do not inspect or modify.

            - `stop_reason: Optional[str]`

              The advisor sub-inference's stop reason (same values as the top-level message `stop_reason`).

            - `type: Literal["advisor_redacted_result"]`

              - `"advisor_redacted_result"`

        - `tool_use_id: str`

        - `type: Literal["advisor_tool_result"]`

          - `"advisor_tool_result"`

      - `class BetaCodeExecutionToolResultBlock: …`

        - `content: BetaCodeExecutionToolResultBlockContent`

          Code execution result with encrypted stdout for PFC + web_search results.

          - `class BetaCodeExecutionToolResultError: …`

            - `error_code: BetaCodeExecutionToolResultErrorCode`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `type: Literal["code_execution_tool_result_error"]`

              - `"code_execution_tool_result_error"`

          - `class BetaCodeExecutionResultBlock: …`

            - `content: List[BetaCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

                - `"code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["code_execution_result"]`

              - `"code_execution_result"`

          - `class BetaEncryptedCodeExecutionResultBlock: …`

            Code execution result with encrypted stdout for PFC + web_search results.

            - `content: List[BetaCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["code_execution_output"]`

            - `encrypted_stdout: str`

            - `return_code: int`

            - `stderr: str`

            - `type: Literal["encrypted_code_execution_result"]`

              - `"encrypted_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["code_execution_tool_result"]`

          - `"code_execution_tool_result"`

      - `class BetaBashCodeExecutionToolResultBlock: …`

        - `content: Content`

          - `class BetaBashCodeExecutionToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"output_file_too_large"`

            - `type: Literal["bash_code_execution_tool_result_error"]`

              - `"bash_code_execution_tool_result_error"`

          - `class BetaBashCodeExecutionResultBlock: …`

            - `content: List[BetaBashCodeExecutionOutputBlock]`

              - `file_id: str`

              - `type: Literal["bash_code_execution_output"]`

                - `"bash_code_execution_output"`

            - `return_code: int`

            - `stderr: str`

            - `stdout: str`

            - `type: Literal["bash_code_execution_result"]`

              - `"bash_code_execution_result"`

        - `tool_use_id: str`

        - `type: Literal["bash_code_execution_tool_result"]`

          - `"bash_code_execution_tool_result"`

      - `class BetaTextEditorCodeExecutionToolResultBlock: …`

        - `content: Content`

          - `class BetaTextEditorCodeExecutionToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", 2 more]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

              - `"file_not_found"`

            - `error_message: Optional[str]`

            - `type: Literal["text_editor_code_execution_tool_result_error"]`

              - `"text_editor_code_execution_tool_result_error"`

          - `class BetaTextEditorCodeExecutionViewResultBlock: …`

            - `content: str`

            - `file_type: Literal["text", "image", "pdf"]`

              - `"text"`

              - `"image"`

              - `"pdf"`

            - `num_lines: Optional[int]`

            - `start_line: Optional[int]`

            - `total_lines: Optional[int]`

            - `type: Literal["text_editor_code_execution_view_result"]`

              - `"text_editor_code_execution_view_result"`

          - `class BetaTextEditorCodeExecutionCreateResultBlock: …`

            - `is_file_update: bool`

            - `type: Literal["text_editor_code_execution_create_result"]`

              - `"text_editor_code_execution_create_result"`

          - `class BetaTextEditorCodeExecutionStrReplaceResultBlock: …`

            - `lines: Optional[List[str]]`

            - `new_lines: Optional[int]`

            - `new_start: Optional[int]`

            - `old_lines: Optional[int]`

            - `old_start: Optional[int]`

            - `type: Literal["text_editor_code_execution_str_replace_result"]`

              - `"text_editor_code_execution_str_replace_result"`

        - `tool_use_id: str`

        - `type: Literal["text_editor_code_execution_tool_result"]`

          - `"text_editor_code_execution_tool_result"`

      - `class BetaToolSearchToolResultBlock: …`

        - `content: Content`

          - `class BetaToolSearchToolResultError: …`

            - `error_code: Literal["invalid_tool_input", "unavailable", "too_many_requests", "execution_time_exceeded"]`

              - `"invalid_tool_input"`

              - `"unavailable"`

              - `"too_many_requests"`

              - `"execution_time_exceeded"`

            - `error_message: Optional[str]`

            - `type: Literal["tool_search_tool_result_error"]`

              - `"tool_search_tool_result_error"`

          - `class BetaToolSearchToolSearchResultBlock: …`

            - `tool_references: List[BetaToolReferenceBlock]`

              - `tool_name: str`

              - `type: Literal["tool_reference"]`

                - `"tool_reference"`

            - `type: Literal["tool_search_tool_search_result"]`

              - `"tool_search_tool_search_result"`

        - `tool_use_id: str`

        - `type: Literal["tool_search_tool_result"]`

          - `"tool_search_tool_result"`

      - `class BetaMCPToolUseBlock: …`

        - `id: str`

        - `input: Dict[str, object]`

        - `name: str`

          The name of the MCP tool

        - `server_name: str`

          The name of the MCP server

        - `type: Literal["mcp_tool_use"]`

          - `"mcp_tool_use"`

      - `class BetaMCPToolResultBlock: …`

        - `content: Union[str, List[BetaTextBlock]]`

          - `str`

          - `List[BetaTextBlock]`

            - `citations: Optional[List[BetaTextCitation]]`

              Citations supporting the text block.

              The type of citation returned will depend on the type of document being cited. Citing a PDF results in `page_location`, plain text results in `char_location`, and content document results in `content_block_location`.

            - `text: str`

            - `type: Literal["text"]`

        - `is_error: bool`

        - `tool_use_id: str`

        - `type: Literal["mcp_tool_result"]`

          - `"mcp_tool_result"`

      - `class BetaContainerUploadBlock: …`

        Response model for a file uploaded to the container.

        - `file_id: str`

        - `type: Literal["container_upload"]`

          - `"container_upload"`

      - `class BetaCompactionBlock: …`

        A compaction block returned when autocompact is triggered.

        When content is None, it indicates the compaction failed to produce a valid
        summary (e.g., malformed output from the model). Clients may round-trip
        compaction blocks with null content; the server treats them as no-ops.

        - `content: Optional[str]`

          Summary of compacted content, or null if compaction failed

        - `encrypted_content: Optional[str]`

          Opaque metadata from prior compaction, to be round-tripped verbatim

        - `type: Literal["compaction"]`

          - `"compaction"`

    - `context_management: Optional[BetaContextManagementResponse]`

      Context management response.

      Information about context management strategies applied during the request.

      - `applied_edits: List[AppliedEdit]`

        List of context management edits that were applied.

        - `class BetaClearToolUses20250919EditResponse: …`

          - `cleared_input_tokens: int`

            Number of input tokens cleared by this edit.

          - `cleared_tool_uses: int`

            Number of tool uses that were cleared.

          - `type: Literal["clear_tool_uses_20250919"]`

            The type of context management edit applied.

            - `"clear_tool_uses_20250919"`

        - `class BetaClearThinking20251015EditResponse: …`

          - `cleared_input_tokens: int`

            Number of input tokens cleared by this edit.

          - `cleared_thinking_turns: int`

            Number of thinking turns that were cleared.

          - `type: Literal["clear_thinking_20251015"]`

            The type of context management edit applied.

            - `"clear_thinking_20251015"`

    - `diagnostics: Optional[BetaDiagnostics]`

      Response envelope for request-level diagnostics. Present (possibly
      null) whenever the caller supplied `diagnostics` on the request.

      - `cache_miss_reason: Optional[CacheMissReason]`

        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.

        - `class BetaCacheMissModelChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["model_changed"]`

            - `"model_changed"`

        - `class BetaCacheMissSystemChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["system_changed"]`

            - `"system_changed"`

        - `class BetaCacheMissToolsChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["tools_changed"]`

            - `"tools_changed"`

        - `class BetaCacheMissMessagesChanged: …`

          - `cache_missed_input_tokens: int`

            Approximate number of input tokens that would have been read from cache had the prefix matched the previous request.

          - `type: Literal["messages_changed"]`

            - `"messages_changed"`

        - `class BetaCacheMissPreviousMessageNotFound: …`

          - `type: Literal["previous_message_not_found"]`

            - `"previous_message_not_found"`

        - `class BetaCacheMissUnavailable: …`

          - `type: Literal["unavailable"]`

            - `"unavailable"`

    - `model: Model`

      The model that will complete your prompt.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-mythos-preview", 15 more]`

        The model that will complete your prompt.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-mythos-preview` - New class of intelligence, strongest in coding and cybersecurity
        - `claude-opus-4-6` - Frontier intelligence for long-running agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding
        - `claude-opus-4-1` - Exceptional model for specialized complex tasks
        - `claude-opus-4-1-20250805` - Exceptional model for specialized complex tasks
        - `claude-opus-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-opus-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-0` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-sonnet-4-20250514` - Deprecated: Will reach end-of-life on June 15th, 2026. Please migrate to a newer model. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.
        - `claude-3-haiku-20240307` - Deprecated: Will reach end-of-life on April 20th, 2026. Please migrate to claude-haiku-4-5. Visit https://docs.anthropic.com/en/docs/resources/model-deprecations for more information.

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-mythos-preview"`

          New class of intelligence, strongest in coding and cybersecurity

        - `"claude-opus-4-6"`

          Frontier intelligence for long-running agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

        - `"claude-opus-4-1"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-1-20250805"`

          Exceptional model for specialized complex tasks

        - `"claude-opus-4-0"`

          Powerful model for complex tasks

        - `"claude-opus-4-20250514"`

          Powerful model for complex tasks

        - `"claude-sonnet-4-0"`

          High-performance model with extended thinking

        - `"claude-sonnet-4-20250514"`

          High-performance model with extended thinking

        - `"claude-3-haiku-20240307"`

          Fast and cost-effective model

      - `str`

    - `role: Literal["assistant"]`

      Conversational role of the generated message.

      This will always be `"assistant"`.

      - `"assistant"`

    - `stop_details: Optional[BetaRefusalStopDetails]`

      Structured information about a refusal.

      - `category: Optional[Literal["cyber", "bio"]]`

        The policy category that triggered the refusal.

        `null` when the refusal doesn't map to a named category.

        - `"cyber"`

        - `"bio"`

      - `explanation: Optional[str]`

        Human-readable explanation of the refusal.

        This text is not guaranteed to be stable. `null` when no explanation is available for the category.

      - `type: Literal["refusal"]`

        - `"refusal"`

    - `stop_reason: Optional[BetaStopReason]`

      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 maximum
      * `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
      * `"tool_use"`: the model invoked one or more tools
      * `"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.
      * `"refusal"`: when streaming classifiers intervene to handle potential policy violations

      In non-streaming mode this value is always non-null. In streaming mode, it is null in the `message_start` event and non-null otherwise.

      - `"end_turn"`

      - `"max_tokens"`

      - `"stop_sequence"`

      - `"tool_use"`

      - `"pause_turn"`

      - `"compaction"`

      - `"refusal"`

      - `"model_context_window_exceeded"`

    - `stop_sequence: Optional[str]`

      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.

    - `type: Literal["message"]`

      Object type.

      For Messages, this is always `"message"`.

      - `"message"`

    - `usage: BetaUsage`

      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 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.

      For example, `output_tokens` will be non-zero, even for an empty string response from Claude.

      Total input tokens in a request is the summation of `input_tokens`, `cache_creation_input_tokens`, and `cache_read_input_tokens`.

      - `cache_creation: Optional[BetaCacheCreation]`

        Breakdown of cached tokens by TTL

        - `ephemeral_1h_input_tokens: int`

          The number of input tokens used to create the 1 hour cache entry.

        - `ephemeral_5m_input_tokens: int`

          The number of input tokens used to create the 5 minute cache entry.

      - `cache_creation_input_tokens: Optional[int]`

        The number of input tokens used to create the cache entry.

      - `cache_read_input_tokens: Optional[int]`

        The number of input tokens read from the cache.

      - `inference_geo: Optional[str]`

        The geographic region where inference was performed for this request.

      - `input_tokens: int`

        The number of input tokens which were used.

      - `iterations: Optional[BetaIterationsUsage]`

        Per-iteration token usage breakdown.

        Each entry represents one sampling iteration, with its own input/output token counts and cache statistics. This allows you to:

        - Determine which iterations exceeded long context thresholds (>=200k tokens)
        - Calculate the true context window size from the last iteration
        - Understand token accumulation across server-side tool use loops

        - `class BetaMessageIterationUsage: …`

          Token usage for a sampling iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["message"]`

            Usage for a sampling iteration

            - `"message"`

        - `class BetaCompactionIterationUsage: …`

          Token usage for a compaction iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["compaction"]`

            Usage for a compaction iteration

            - `"compaction"`

        - `class BetaAdvisorMessageIterationUsage: …`

          Token usage for an advisor sub-inference iteration.

          - `cache_creation: Optional[BetaCacheCreation]`

            Breakdown of cached tokens by TTL

          - `cache_creation_input_tokens: int`

            The number of input tokens used to create the cache entry.

          - `cache_read_input_tokens: int`

            The number of input tokens read from the cache.

          - `input_tokens: int`

            The number of input tokens which were used.

          - `model: Model`

            The model that will complete your prompt.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `output_tokens: int`

            The number of output tokens which were used.

          - `type: Literal["advisor_message"]`

            Usage for an advisor sub-inference iteration

            - `"advisor_message"`

      - `output_tokens: int`

        The number of output tokens which were used.

      - `output_tokens_details: Optional[BetaOutputTokensDetails]`

        Breakdown of output tokens by category.

        `output_tokens` remains the inclusive, authoritative total used for billing.
        This object provides a read-only decomposition for observability — for example,
        how many of the billed output tokens were spent on internal reasoning that may
        have been summarized before being returned to you.

        - `thinking_tokens: int`

          Number of output tokens the model generated as internal reasoning, including
          the thinking-block delimiter tokens.

          Reflects the raw reasoning the model produced, not the (possibly shorter)
          summarized thinking text returned in the response body. Computed by
          re-tokenizing the raw reasoning text, so it may differ from the model's exact
          generation count by a small number of tokens. Always ≤ `output_tokens`;
          `output_tokens - thinking_tokens` approximates the non-reasoning output.

      - `server_tool_use: Optional[BetaServerToolUsage]`

        The number of server tool requests.

        - `web_fetch_requests: int`

          The number of web fetch tool requests.

        - `web_search_requests: int`

          The number of web search tool requests.

      - `service_tier: Optional[Literal["standard", "priority", "batch"]]`

        If the request used the priority, standard, or batch tier.

        - `"standard"`

        - `"priority"`

        - `"batch"`

      - `speed: Optional[Literal["standard", "fast"]]`

        The inference speed mode used for this request.

        - `"standard"`

        - `"fast"`

  - `type: Literal["succeeded"]`

    - `"succeeded"`

# Agents

## Create Agent

`beta.agents.create(AgentCreateParams**kwargs)  -> BetaManagedAgentsAgent`

**post** `/v1/agents`

Create Agent

### Parameters

- `model: Model`

  Model identifier. Accepts the [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison), e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration control

  - `Union[Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more], str]`

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-6` - Most intelligent model for building agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-6"`

        Most intelligent model for building agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

    - `str`

  - `class BetaManagedAgentsModelConfigParams: …`

    An object that defines additional configuration control over model use

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

- `name: str`

  Human-readable name for the agent. 1-256 characters.

- `description: Optional[str]`

  Description of what the agent does. Up to 2048 characters.

- `mcp_servers: Optional[Iterable[BetaManagedAgentsURLMCPServerParams]]`

  MCP servers this agent connects to. Maximum 20. Names must be unique within the array.

  - `name: str`

    Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters.

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

    Endpoint URL for the MCP server.

- `metadata: Optional[Dict[str, str]]`

  Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

- `multiagent: Optional[BetaManagedAgentsMultiagentParams]`

  A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the `agents` roster.

  - `agents: Sequence[BetaManagedAgentsMultiagentRosterEntryParams]`

    Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to allow recursive self-invocation. Entries must reference distinct agents (after resolving `self` and string forms); at most one `self`. Referenced agents must exist, must not be archived, and must not themselves have `multiagent` set (depth limit 1).

    - `str`

    - `class BetaManagedAgentsAgentParams: …`

      Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

      - `id: str`

        The `agent` ID.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: Optional[int]`

        The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

    - `class BetaManagedAgentsMultiagentSelfParams: …`

      Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

      - `type: Literal["self"]`

        - `"self"`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

- `skills: Optional[Iterable[BetaManagedAgentsSkillParams]]`

  Skills available to the agent. Maximum 20.

  - `class BetaManagedAgentsAnthropicSkillParams: …`

    An Anthropic-managed skill.

    - `skill_id: str`

      Identifier of the Anthropic skill (e.g., "xlsx").

    - `type: Literal["anthropic"]`

      - `"anthropic"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

  - `class BetaManagedAgentsCustomSkillParams: …`

    A user-created custom skill.

    - `skill_id: str`

      Tagged ID of the custom skill (e.g., "skill_01XJ5...").

    - `type: Literal["custom"]`

      - `"custom"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

- `system: Optional[str]`

  System prompt for the agent. Up to 100,000 characters.

- `tools: Optional[Iterable[Tool]]`

  Tool configurations available to the agent. Maximum of 128 tools across all toolsets allowed.

  - `class BetaManagedAgentsAgentToolset20260401Params: …`

    Configuration for built-in agent tools. Use this to enable or disable groups of tools available to the agent.

    - `type: Literal["agent_toolset_20260401"]`

      - `"agent_toolset_20260401"`

    - `configs: Optional[List[BetaManagedAgentsAgentToolConfigParams]]`

      Per-tool configuration overrides.

      - `name: Literal["bash", "edit", "read", 5 more]`

        Built-in agent tool identifier.

        - `"bash"`

        - `"edit"`

        - `"read"`

        - `"write"`

        - `"glob"`

        - `"grep"`

        - `"web_fetch"`

        - `"web_search"`

      - `enabled: Optional[bool]`

        Whether this tool is enabled and available to Claude. Overrides the default_config setting.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

          - `type: Literal["always_allow"]`

            - `"always_allow"`

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

          - `type: Literal["always_ask"]`

            - `"always_ask"`

    - `default_config: Optional[BetaManagedAgentsAgentToolsetDefaultConfigParams]`

      Default configuration for all tools in a toolset.

      - `enabled: Optional[bool]`

        Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

  - `class BetaManagedAgentsMCPToolsetParams: …`

    Configuration for tools from an MCP server defined in `mcp_servers`.

    - `mcp_server_name: str`

      Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters.

    - `type: Literal["mcp_toolset"]`

      - `"mcp_toolset"`

    - `configs: Optional[List[BetaManagedAgentsMCPToolConfigParams]]`

      Per-tool configuration overrides.

      - `name: str`

        Name of the MCP tool to configure. 1-128 characters.

      - `enabled: Optional[bool]`

        Whether this tool is enabled. Overrides the `default_config` setting.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

    - `default_config: Optional[BetaManagedAgentsMCPToolsetDefaultConfigParams]`

      Default configuration for all tools from an MCP server.

      - `enabled: Optional[bool]`

        Whether tools are enabled by default. Defaults to true if not specified.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

  - `class BetaManagedAgentsCustomToolParams: …`

    A custom tool that is executed by the API client rather than the agent. When the agent calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle, waiting for the client to provide the result via a `user.custom_tool_result` event.

    - `description: str`

      Description of what the tool does, shown to the agent to help it decide when to use the tool. 1-1024 characters.

    - `input_schema: BetaManagedAgentsCustomToolInputSchema`

      JSON Schema for custom tool input parameters.

      - `properties: Optional[Dict[str, object]]`

        JSON Schema properties defining the tool's input parameters.

      - `required: Optional[List[str]]`

        List of required property names.

      - `type: Optional[Literal["object"]]`

        Must be 'object' for tool input schemas.

        - `"object"`

    - `name: str`

      Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens.

    - `type: Literal["custom"]`

      - `"custom"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_agent = client.beta.agents.create(
    model="claude-sonnet-4-6",
    name="My First Agent",
)
print(beta_managed_agents_agent.id)
```

#### Response

```json
{
  "id": "agent_011CZkYpogX7uDKUyvBTophP",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "description": "A general-purpose starter agent.",
  "mcp_servers": [
    {
      "name": "example-mcp",
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse"
    }
  ],
  "metadata": {
    "foo": "bar"
  },
  "model": {
    "id": "claude-sonnet-4-6",
    "speed": "standard"
  },
  "multiagent": {
    "agents": [
      {
        "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
        "type": "agent",
        "version": 1
      }
    ],
    "type": "coordinator"
  },
  "name": "My First Agent",
  "skills": [
    {
      "skill_id": "xlsx",
      "type": "anthropic",
      "version": "1"
    },
    {
      "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
      "type": "custom",
      "version": "2"
    }
  ],
  "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
  "tools": [
    {
      "configs": [
        {
          "enabled": true,
          "name": "bash",
          "permission_policy": {
            "type": "always_allow"
          }
        }
      ],
      "default_config": {
        "enabled": true,
        "permission_policy": {
          "type": "always_ask"
        }
      },
      "type": "agent_toolset_20260401"
    }
  ],
  "type": "agent",
  "updated_at": "2026-03-15T10:00:00Z",
  "version": 1
}
```

## List Agents

`beta.agents.list(AgentListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsAgent]`

**get** `/v1/agents`

List Agents

### Parameters

- `created_at_gte: Optional[Union[str, datetime]]`

  Return agents created at or after this time (inclusive).

- `created_at_lte: Optional[Union[str, datetime]]`

  Return agents created at or before this time (inclusive).

- `include_archived: Optional[bool]`

  Include archived agents in results. Defaults to false.

- `limit: Optional[int]`

  Maximum results per page. Default 20, maximum 100.

- `page: Optional[str]`

  Opaque pagination cursor from a previous response.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.agents.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "agent_011CZkYpogX7uDKUyvBTophP",
      "archived_at": null,
      "created_at": "2026-03-15T10:00:00Z",
      "description": "A general-purpose starter agent.",
      "mcp_servers": [
        {
          "name": "example-mcp",
          "type": "url",
          "url": "https://example-server.modelcontextprotocol.io/sse"
        }
      ],
      "metadata": {
        "foo": "bar"
      },
      "model": {
        "id": "claude-sonnet-4-6",
        "speed": "standard"
      },
      "multiagent": {
        "agents": [
          {
            "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
            "type": "agent",
            "version": 1
          }
        ],
        "type": "coordinator"
      },
      "name": "My First Agent",
      "skills": [
        {
          "skill_id": "xlsx",
          "type": "anthropic",
          "version": "1"
        },
        {
          "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
          "type": "custom",
          "version": "2"
        }
      ],
      "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
      "tools": [
        {
          "configs": [
            {
              "enabled": true,
              "name": "bash",
              "permission_policy": {
                "type": "always_allow"
              }
            }
          ],
          "default_config": {
            "enabled": true,
            "permission_policy": {
              "type": "always_ask"
            }
          },
          "type": "agent_toolset_20260401"
        }
      ],
      "type": "agent",
      "updated_at": "2026-03-15T10:00:00Z",
      "version": 1
    }
  ],
  "next_page": "next_page"
}
```

## Get Agent

`beta.agents.retrieve(stragent_id, AgentRetrieveParams**kwargs)  -> BetaManagedAgentsAgent`

**get** `/v1/agents/{agent_id}`

Get Agent

### Parameters

- `agent_id: str`

- `version: Optional[int]`

  Agent version. Omit for the most recent version. Must be at least 1 if specified.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_agent = client.beta.agents.retrieve(
    agent_id="agent_011CZkYpogX7uDKUyvBTophP",
)
print(beta_managed_agents_agent.id)
```

#### Response

```json
{
  "id": "agent_011CZkYpogX7uDKUyvBTophP",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "description": "A general-purpose starter agent.",
  "mcp_servers": [
    {
      "name": "example-mcp",
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse"
    }
  ],
  "metadata": {
    "foo": "bar"
  },
  "model": {
    "id": "claude-sonnet-4-6",
    "speed": "standard"
  },
  "multiagent": {
    "agents": [
      {
        "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
        "type": "agent",
        "version": 1
      }
    ],
    "type": "coordinator"
  },
  "name": "My First Agent",
  "skills": [
    {
      "skill_id": "xlsx",
      "type": "anthropic",
      "version": "1"
    },
    {
      "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
      "type": "custom",
      "version": "2"
    }
  ],
  "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
  "tools": [
    {
      "configs": [
        {
          "enabled": true,
          "name": "bash",
          "permission_policy": {
            "type": "always_allow"
          }
        }
      ],
      "default_config": {
        "enabled": true,
        "permission_policy": {
          "type": "always_ask"
        }
      },
      "type": "agent_toolset_20260401"
    }
  ],
  "type": "agent",
  "updated_at": "2026-03-15T10:00:00Z",
  "version": 1
}
```

## Update Agent

`beta.agents.update(stragent_id, AgentUpdateParams**kwargs)  -> BetaManagedAgentsAgent`

**post** `/v1/agents/{agent_id}`

Update Agent

### Parameters

- `agent_id: str`

- `version: int`

  The agent's current version, used to prevent concurrent overwrites. Obtain this value from a create or retrieve response. The request fails if this does not match the server's current version.

- `description: Optional[str]`

  Description. Up to 2048 characters. Omit to preserve; send empty string or null to clear.

- `mcp_servers: Optional[Iterable[BetaManagedAgentsURLMCPServerParams]]`

  MCP servers. Full replacement. Omit to preserve; send empty array or null to clear. Names must be unique. Maximum 20.

  - `name: str`

    Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters.

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

    Endpoint URL for the MCP server.

- `metadata: Optional[Dict[str, Optional[str]]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars.

- `model: Optional[Model]`

  Model identifier. Accepts the [model string](https://platform.claude.com/docs/en/about-claude/models/overview#latest-models-comparison), e.g. `claude-opus-4-6`, or a `model_config` object for additional configuration control. Omit to preserve. Cannot be cleared.

  - `Union[Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more], str]`

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-6` - Most intelligent model for building agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-6"`

        Most intelligent model for building agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

    - `str`

  - `class BetaManagedAgentsModelConfigParams: …`

    An object that defines additional configuration control over model use

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

- `multiagent: Optional[BetaManagedAgentsMultiagentParams]`

  A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the `agents` roster.

  - `agents: Sequence[BetaManagedAgentsMultiagentRosterEntryParams]`

    Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to allow recursive self-invocation. Entries must reference distinct agents (after resolving `self` and string forms); at most one `self`. Referenced agents must exist, must not be archived, and must not themselves have `multiagent` set (depth limit 1).

    - `str`

    - `class BetaManagedAgentsAgentParams: …`

      Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

      - `id: str`

        The `agent` ID.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: Optional[int]`

        The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

    - `class BetaManagedAgentsMultiagentSelfParams: …`

      Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

      - `type: Literal["self"]`

        - `"self"`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

- `name: Optional[str]`

  Human-readable name. 1-256 characters. Omit to preserve. Cannot be cleared.

- `skills: Optional[Iterable[BetaManagedAgentsSkillParams]]`

  Skills. Full replacement. Omit to preserve; send empty array or null to clear. Maximum 20.

  - `class BetaManagedAgentsAnthropicSkillParams: …`

    An Anthropic-managed skill.

    - `skill_id: str`

      Identifier of the Anthropic skill (e.g., "xlsx").

    - `type: Literal["anthropic"]`

      - `"anthropic"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

  - `class BetaManagedAgentsCustomSkillParams: …`

    A user-created custom skill.

    - `skill_id: str`

      Tagged ID of the custom skill (e.g., "skill_01XJ5...").

    - `type: Literal["custom"]`

      - `"custom"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

- `system: Optional[str]`

  System prompt. Up to 100,000 characters. Omit to preserve; send empty string or null to clear.

- `tools: Optional[Iterable[Tool]]`

  Tool configurations available to the agent. Full replacement. Omit to preserve; send empty array or null to clear. Maximum of 128 tools across all toolsets allowed.

  - `class BetaManagedAgentsAgentToolset20260401Params: …`

    Configuration for built-in agent tools. Use this to enable or disable groups of tools available to the agent.

    - `type: Literal["agent_toolset_20260401"]`

      - `"agent_toolset_20260401"`

    - `configs: Optional[List[BetaManagedAgentsAgentToolConfigParams]]`

      Per-tool configuration overrides.

      - `name: Literal["bash", "edit", "read", 5 more]`

        Built-in agent tool identifier.

        - `"bash"`

        - `"edit"`

        - `"read"`

        - `"write"`

        - `"glob"`

        - `"grep"`

        - `"web_fetch"`

        - `"web_search"`

      - `enabled: Optional[bool]`

        Whether this tool is enabled and available to Claude. Overrides the default_config setting.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

          - `type: Literal["always_allow"]`

            - `"always_allow"`

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

          - `type: Literal["always_ask"]`

            - `"always_ask"`

    - `default_config: Optional[BetaManagedAgentsAgentToolsetDefaultConfigParams]`

      Default configuration for all tools in a toolset.

      - `enabled: Optional[bool]`

        Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

  - `class BetaManagedAgentsMCPToolsetParams: …`

    Configuration for tools from an MCP server defined in `mcp_servers`.

    - `mcp_server_name: str`

      Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters.

    - `type: Literal["mcp_toolset"]`

      - `"mcp_toolset"`

    - `configs: Optional[List[BetaManagedAgentsMCPToolConfigParams]]`

      Per-tool configuration overrides.

      - `name: str`

        Name of the MCP tool to configure. 1-128 characters.

      - `enabled: Optional[bool]`

        Whether this tool is enabled. Overrides the `default_config` setting.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

    - `default_config: Optional[BetaManagedAgentsMCPToolsetDefaultConfigParams]`

      Default configuration for all tools from an MCP server.

      - `enabled: Optional[bool]`

        Whether tools are enabled by default. Defaults to true if not specified.

      - `permission_policy: Optional[PermissionPolicy]`

        Permission policy for tool execution.

        - `class BetaManagedAgentsAlwaysAllowPolicy: …`

          Tool calls are automatically approved without user confirmation.

        - `class BetaManagedAgentsAlwaysAskPolicy: …`

          Tool calls require user confirmation before execution.

  - `class BetaManagedAgentsCustomToolParams: …`

    A custom tool that is executed by the API client rather than the agent. When the agent calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle, waiting for the client to provide the result via a `user.custom_tool_result` event.

    - `description: str`

      Description of what the tool does, shown to the agent to help it decide when to use the tool. 1-1024 characters.

    - `input_schema: BetaManagedAgentsCustomToolInputSchema`

      JSON Schema for custom tool input parameters.

      - `properties: Optional[Dict[str, object]]`

        JSON Schema properties defining the tool's input parameters.

      - `required: Optional[List[str]]`

        List of required property names.

      - `type: Optional[Literal["object"]]`

        Must be 'object' for tool input schemas.

        - `"object"`

    - `name: str`

      Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens.

    - `type: Literal["custom"]`

      - `"custom"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_agent = client.beta.agents.update(
    agent_id="agent_011CZkYpogX7uDKUyvBTophP",
    version=1,
)
print(beta_managed_agents_agent.id)
```

#### Response

```json
{
  "id": "agent_011CZkYpogX7uDKUyvBTophP",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "description": "A general-purpose starter agent.",
  "mcp_servers": [
    {
      "name": "example-mcp",
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse"
    }
  ],
  "metadata": {
    "foo": "bar"
  },
  "model": {
    "id": "claude-sonnet-4-6",
    "speed": "standard"
  },
  "multiagent": {
    "agents": [
      {
        "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
        "type": "agent",
        "version": 1
      }
    ],
    "type": "coordinator"
  },
  "name": "My First Agent",
  "skills": [
    {
      "skill_id": "xlsx",
      "type": "anthropic",
      "version": "1"
    },
    {
      "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
      "type": "custom",
      "version": "2"
    }
  ],
  "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
  "tools": [
    {
      "configs": [
        {
          "enabled": true,
          "name": "bash",
          "permission_policy": {
            "type": "always_allow"
          }
        }
      ],
      "default_config": {
        "enabled": true,
        "permission_policy": {
          "type": "always_ask"
        }
      },
      "type": "agent_toolset_20260401"
    }
  ],
  "type": "agent",
  "updated_at": "2026-03-15T10:00:00Z",
  "version": 1
}
```

## Archive Agent

`beta.agents.archive(stragent_id, AgentArchiveParams**kwargs)  -> BetaManagedAgentsAgent`

**post** `/v1/agents/{agent_id}/archive`

Archive Agent

### Parameters

- `agent_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_agent = client.beta.agents.archive(
    agent_id="agent_011CZkYpogX7uDKUyvBTophP",
)
print(beta_managed_agents_agent.id)
```

#### Response

```json
{
  "id": "agent_011CZkYpogX7uDKUyvBTophP",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "description": "A general-purpose starter agent.",
  "mcp_servers": [
    {
      "name": "example-mcp",
      "type": "url",
      "url": "https://example-server.modelcontextprotocol.io/sse"
    }
  ],
  "metadata": {
    "foo": "bar"
  },
  "model": {
    "id": "claude-sonnet-4-6",
    "speed": "standard"
  },
  "multiagent": {
    "agents": [
      {
        "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
        "type": "agent",
        "version": 1
      }
    ],
    "type": "coordinator"
  },
  "name": "My First Agent",
  "skills": [
    {
      "skill_id": "xlsx",
      "type": "anthropic",
      "version": "1"
    },
    {
      "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
      "type": "custom",
      "version": "2"
    }
  ],
  "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
  "tools": [
    {
      "configs": [
        {
          "enabled": true,
          "name": "bash",
          "permission_policy": {
            "type": "always_allow"
          }
        }
      ],
      "default_config": {
        "enabled": true,
        "permission_policy": {
          "type": "always_ask"
        }
      },
      "type": "agent_toolset_20260401"
    }
  ],
  "type": "agent",
  "updated_at": "2026-03-15T10:00:00Z",
  "version": 1
}
```

## Domain Types

### Beta Managed Agents Agent

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Beta Managed Agents Agent Reference

- `class BetaManagedAgentsAgentReference: …`

  A resolved agent reference with a concrete version.

  - `id: str`

  - `type: Literal["agent"]`

    - `"agent"`

  - `version: int`

### Beta Managed Agents Agent Tool Config

- `class BetaManagedAgentsAgentToolConfig: …`

  Configuration for a specific agent tool.

  - `enabled: bool`

  - `name: Literal["bash", "edit", "read", 5 more]`

    Built-in agent tool identifier.

    - `"bash"`

    - `"edit"`

    - `"read"`

    - `"write"`

    - `"glob"`

    - `"grep"`

    - `"web_fetch"`

    - `"web_search"`

  - `permission_policy: PermissionPolicy`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents Agent Tool Config Params

- `class BetaManagedAgentsAgentToolConfigParams: …`

  Configuration override for a specific tool within a toolset.

  - `name: Literal["bash", "edit", "read", 5 more]`

    Built-in agent tool identifier.

    - `"bash"`

    - `"edit"`

    - `"read"`

    - `"write"`

    - `"glob"`

    - `"grep"`

    - `"web_fetch"`

    - `"web_search"`

  - `enabled: Optional[bool]`

    Whether this tool is enabled and available to Claude. Overrides the default_config setting.

  - `permission_policy: Optional[PermissionPolicy]`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents Agent Toolset Default Config

- `class BetaManagedAgentsAgentToolsetDefaultConfig: …`

  Resolved default configuration for agent tools.

  - `enabled: bool`

  - `permission_policy: PermissionPolicy`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents Agent Toolset Default Config Params

- `class BetaManagedAgentsAgentToolsetDefaultConfigParams: …`

  Default configuration for all tools in a toolset.

  - `enabled: Optional[bool]`

    Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

  - `permission_policy: Optional[PermissionPolicy]`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents Agent Toolset20260401

- `class BetaManagedAgentsAgentToolset20260401: …`

  - `configs: List[BetaManagedAgentsAgentToolConfig]`

    - `enabled: bool`

    - `name: Literal["bash", "edit", "read", 5 more]`

      Built-in agent tool identifier.

      - `"bash"`

      - `"edit"`

      - `"read"`

      - `"write"`

      - `"glob"`

      - `"grep"`

      - `"web_fetch"`

      - `"web_search"`

    - `permission_policy: PermissionPolicy`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

        - `type: Literal["always_allow"]`

          - `"always_allow"`

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

        - `type: Literal["always_ask"]`

          - `"always_ask"`

  - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

    Resolved default configuration for agent tools.

    - `enabled: bool`

    - `permission_policy: PermissionPolicy`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

  - `type: Literal["agent_toolset_20260401"]`

    - `"agent_toolset_20260401"`

### Beta Managed Agents Agent Toolset20260401 Bash Input

- `class BetaManagedAgentsAgentToolset20260401BashInput: …`

  Input payload for the `bash` tool of the
  `agent_toolset_20260401` toolset. All fields are optional;
  a normal invocation supplies `command`, while `restart=true`
  (with no `command`) reboots the runner-side bash session.

  - `command: Optional[str]`

    Shell command to execute. Omit only when `restart` is true.

  - `restart: Optional[bool]`

    When true, restart the persistent bash session instead of
    running a command. Subsequent calls without `restart` will
    run against the fresh session.

  - `timeout_ms: Optional[int]`

    Per-call timeout in milliseconds. Defaults to the
    runner-wide tool timeout when omitted or zero.

### Beta Managed Agents Agent Toolset20260401 Edit Input

- `class BetaManagedAgentsAgentToolset20260401EditInput: …`

  Input payload for the `edit` tool. Performs a string
  replacement in the named file; by default `old_string` must
  occur exactly once.

  - `file_path: str`

    Path of the file to edit.

  - `new_string: str`

    Replacement text.

  - `old_string: str`

    Substring to find and replace.

  - `replace_all: Optional[bool]`

    When true, replace every occurrence of `old_string`
    instead of requiring a unique match.

### Beta Managed Agents Agent Toolset20260401 Glob Input

- `class BetaManagedAgentsAgentToolset20260401GlobInput: …`

  Input payload for the `glob` tool. Returns paths matching a
  doublestar glob pattern, newest first.

  - `pattern: str`

    Doublestar glob pattern (e.g. `**/*.go`). Absolute patterns
    are only permitted when the runner is configured to allow
    them.

  - `path: Optional[str]`

    Optional directory root to search under. Defaults to the
    runner's working directory.

### Beta Managed Agents Agent Toolset20260401 Grep Input

- `class BetaManagedAgentsAgentToolset20260401GrepInput: …`

  Input payload for the `grep` tool. Searches file contents for
  a regular expression, returning matching lines.

  - `pattern: str`

    Regular expression to search for.

  - `path: Optional[str]`

    Optional directory root to search under. Defaults to the
    runner's working directory.

### Beta Managed Agents Agent Toolset20260401 Params

- `class BetaManagedAgentsAgentToolset20260401Params: …`

  Configuration for built-in agent tools. Use this to enable or disable groups of tools available to the agent.

  - `type: Literal["agent_toolset_20260401"]`

    - `"agent_toolset_20260401"`

  - `configs: Optional[List[BetaManagedAgentsAgentToolConfigParams]]`

    Per-tool configuration overrides.

    - `name: Literal["bash", "edit", "read", 5 more]`

      Built-in agent tool identifier.

      - `"bash"`

      - `"edit"`

      - `"read"`

      - `"write"`

      - `"glob"`

      - `"grep"`

      - `"web_fetch"`

      - `"web_search"`

    - `enabled: Optional[bool]`

      Whether this tool is enabled and available to Claude. Overrides the default_config setting.

    - `permission_policy: Optional[PermissionPolicy]`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

        - `type: Literal["always_allow"]`

          - `"always_allow"`

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

        - `type: Literal["always_ask"]`

          - `"always_ask"`

  - `default_config: Optional[BetaManagedAgentsAgentToolsetDefaultConfigParams]`

    Default configuration for all tools in a toolset.

    - `enabled: Optional[bool]`

      Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

    - `permission_policy: Optional[PermissionPolicy]`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

### Beta Managed Agents Agent Toolset20260401 Read Input

- `class BetaManagedAgentsAgentToolset20260401ReadInput: …`

  Input payload for the `read` tool. Reads file contents
  relative to the runner's working directory (or absolute when
  the runner permits).

  - `file_path: str`

    Path of the file to read.

  - `view_range: Optional[List[int]]`

    Optional `[start_line, end_line]` 1-indexed inclusive
    range. When omitted the entire file is returned.
    `end_line` of 0 or negative means "to end of file".

### Beta Managed Agents Agent Toolset20260401 Write Input

- `class BetaManagedAgentsAgentToolset20260401WriteInput: …`

  Input payload for the `write` tool. Writes (overwriting) the
  entire file contents.

  - `content: str`

    Full file contents to write.

  - `file_path: str`

    Path of the file to write.

### Beta Managed Agents Always Allow Policy

- `class BetaManagedAgentsAlwaysAllowPolicy: …`

  Tool calls are automatically approved without user confirmation.

  - `type: Literal["always_allow"]`

    - `"always_allow"`

### Beta Managed Agents Always Ask Policy

- `class BetaManagedAgentsAlwaysAskPolicy: …`

  Tool calls require user confirmation before execution.

  - `type: Literal["always_ask"]`

    - `"always_ask"`

### Beta Managed Agents Anthropic Skill

- `class BetaManagedAgentsAnthropicSkill: …`

  A resolved Anthropic-managed skill.

  - `skill_id: str`

  - `type: Literal["anthropic"]`

    - `"anthropic"`

  - `version: str`

### Beta Managed Agents Anthropic Skill Params

- `class BetaManagedAgentsAnthropicSkillParams: …`

  An Anthropic-managed skill.

  - `skill_id: str`

    Identifier of the Anthropic skill (e.g., "xlsx").

  - `type: Literal["anthropic"]`

    - `"anthropic"`

  - `version: Optional[str]`

    Version to pin. Defaults to latest if omitted.

### Beta Managed Agents Custom Skill

- `class BetaManagedAgentsCustomSkill: …`

  A resolved user-created custom skill.

  - `skill_id: str`

  - `type: Literal["custom"]`

    - `"custom"`

  - `version: str`

### Beta Managed Agents Custom Skill Params

- `class BetaManagedAgentsCustomSkillParams: …`

  A user-created custom skill.

  - `skill_id: str`

    Tagged ID of the custom skill (e.g., "skill_01XJ5...").

  - `type: Literal["custom"]`

    - `"custom"`

  - `version: Optional[str]`

    Version to pin. Defaults to latest if omitted.

### Beta Managed Agents Custom Tool

- `class BetaManagedAgentsCustomTool: …`

  A custom tool as returned in API responses.

  - `description: str`

  - `input_schema: BetaManagedAgentsCustomToolInputSchema`

    JSON Schema for custom tool input parameters.

    - `properties: Optional[Dict[str, object]]`

      JSON Schema properties defining the tool's input parameters.

    - `required: Optional[List[str]]`

      List of required property names.

    - `type: Optional[Literal["object"]]`

      Must be 'object' for tool input schemas.

      - `"object"`

  - `name: str`

  - `type: Literal["custom"]`

    - `"custom"`

### Beta Managed Agents Custom Tool Input Schema

- `class BetaManagedAgentsCustomToolInputSchema: …`

  JSON Schema for custom tool input parameters.

  - `properties: Optional[Dict[str, object]]`

    JSON Schema properties defining the tool's input parameters.

  - `required: Optional[List[str]]`

    List of required property names.

  - `type: Optional[Literal["object"]]`

    Must be 'object' for tool input schemas.

    - `"object"`

### Beta Managed Agents Custom Tool Params

- `class BetaManagedAgentsCustomToolParams: …`

  A custom tool that is executed by the API client rather than the agent. When the agent calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle, waiting for the client to provide the result via a `user.custom_tool_result` event.

  - `description: str`

    Description of what the tool does, shown to the agent to help it decide when to use the tool. 1-1024 characters.

  - `input_schema: BetaManagedAgentsCustomToolInputSchema`

    JSON Schema for custom tool input parameters.

    - `properties: Optional[Dict[str, object]]`

      JSON Schema properties defining the tool's input parameters.

    - `required: Optional[List[str]]`

      List of required property names.

    - `type: Optional[Literal["object"]]`

      Must be 'object' for tool input schemas.

      - `"object"`

  - `name: str`

    Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens.

  - `type: Literal["custom"]`

    - `"custom"`

### Beta Managed Agents MCP Server URL Definition

- `class BetaManagedAgentsMCPServerURLDefinition: …`

  URL-based MCP server connection as returned in API responses.

  - `name: str`

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

### Beta Managed Agents MCP Tool Config

- `class BetaManagedAgentsMCPToolConfig: …`

  Resolved configuration for a specific MCP tool.

  - `enabled: bool`

  - `name: str`

  - `permission_policy: PermissionPolicy`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents MCP Tool Config Params

- `class BetaManagedAgentsMCPToolConfigParams: …`

  Configuration override for a specific MCP tool.

  - `name: str`

    Name of the MCP tool to configure. 1-128 characters.

  - `enabled: Optional[bool]`

    Whether this tool is enabled. Overrides the `default_config` setting.

  - `permission_policy: Optional[PermissionPolicy]`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents MCP Toolset

- `class BetaManagedAgentsMCPToolset: …`

  - `configs: List[BetaManagedAgentsMCPToolConfig]`

    - `enabled: bool`

    - `name: str`

    - `permission_policy: PermissionPolicy`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

        - `type: Literal["always_allow"]`

          - `"always_allow"`

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

        - `type: Literal["always_ask"]`

          - `"always_ask"`

  - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

    Resolved default configuration for all tools from an MCP server.

    - `enabled: bool`

    - `permission_policy: PermissionPolicy`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

  - `mcp_server_name: str`

  - `type: Literal["mcp_toolset"]`

    - `"mcp_toolset"`

### Beta Managed Agents MCP Toolset Default Config

- `class BetaManagedAgentsMCPToolsetDefaultConfig: …`

  Resolved default configuration for all tools from an MCP server.

  - `enabled: bool`

  - `permission_policy: PermissionPolicy`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents MCP Toolset Default Config Params

- `class BetaManagedAgentsMCPToolsetDefaultConfigParams: …`

  Default configuration for all tools from an MCP server.

  - `enabled: Optional[bool]`

    Whether tools are enabled by default. Defaults to true if not specified.

  - `permission_policy: Optional[PermissionPolicy]`

    Permission policy for tool execution.

    - `class BetaManagedAgentsAlwaysAllowPolicy: …`

      Tool calls are automatically approved without user confirmation.

      - `type: Literal["always_allow"]`

        - `"always_allow"`

    - `class BetaManagedAgentsAlwaysAskPolicy: …`

      Tool calls require user confirmation before execution.

      - `type: Literal["always_ask"]`

        - `"always_ask"`

### Beta Managed Agents MCP Toolset Params

- `class BetaManagedAgentsMCPToolsetParams: …`

  Configuration for tools from an MCP server defined in `mcp_servers`.

  - `mcp_server_name: str`

    Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters.

  - `type: Literal["mcp_toolset"]`

    - `"mcp_toolset"`

  - `configs: Optional[List[BetaManagedAgentsMCPToolConfigParams]]`

    Per-tool configuration overrides.

    - `name: str`

      Name of the MCP tool to configure. 1-128 characters.

    - `enabled: Optional[bool]`

      Whether this tool is enabled. Overrides the `default_config` setting.

    - `permission_policy: Optional[PermissionPolicy]`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

        - `type: Literal["always_allow"]`

          - `"always_allow"`

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

        - `type: Literal["always_ask"]`

          - `"always_ask"`

  - `default_config: Optional[BetaManagedAgentsMCPToolsetDefaultConfigParams]`

    Default configuration for all tools from an MCP server.

    - `enabled: Optional[bool]`

      Whether tools are enabled by default. Defaults to true if not specified.

    - `permission_policy: Optional[PermissionPolicy]`

      Permission policy for tool execution.

      - `class BetaManagedAgentsAlwaysAllowPolicy: …`

        Tool calls are automatically approved without user confirmation.

      - `class BetaManagedAgentsAlwaysAskPolicy: …`

        Tool calls require user confirmation before execution.

### Beta Managed Agents Model

- `Union[Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more], str]`

  The model that will power your agent.

  See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

  - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

    The model that will power your agent.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
    - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
    - `claude-opus-4-6` - Most intelligent model for building agents and coding
    - `claude-sonnet-4-6` - Best combination of speed and intelligence
    - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
    - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
    - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
    - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
    - `claude-sonnet-4-5` - High-performance model for agents and coding
    - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

    - `"claude-opus-4-8"`

      Frontier intelligence for long-running agents and coding

    - `"claude-opus-4-7"`

      Frontier intelligence for long-running agents and coding

    - `"claude-opus-4-6"`

      Most intelligent model for building agents and coding

    - `"claude-sonnet-4-6"`

      Best combination of speed and intelligence

    - `"claude-haiku-4-5"`

      Fastest model with near-frontier intelligence

    - `"claude-haiku-4-5-20251001"`

      Fastest model with near-frontier intelligence

    - `"claude-opus-4-5"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-opus-4-5-20251101"`

      Premium model combining maximum intelligence with practical performance

    - `"claude-sonnet-4-5"`

      High-performance model for agents and coding

    - `"claude-sonnet-4-5-20250929"`

      High-performance model for agents and coding

  - `str`

### Beta Managed Agents Model Config

- `class BetaManagedAgentsModelConfig: …`

  Model identifier and configuration.

  - `id: BetaManagedAgentsModel`

    The model that will power your agent.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-6` - Most intelligent model for building agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-6"`

        Most intelligent model for building agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

    - `str`

  - `speed: Optional[Literal["standard", "fast"]]`

    Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

    - `"standard"`

    - `"fast"`

### Beta Managed Agents Model Config Params

- `class BetaManagedAgentsModelConfigParams: …`

  An object that defines additional configuration control over model use

  - `id: BetaManagedAgentsModel`

    The model that will power your agent.

    See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

    - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
      - `claude-opus-4-6` - Most intelligent model for building agents and coding
      - `claude-sonnet-4-6` - Best combination of speed and intelligence
      - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
      - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
      - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
      - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
      - `claude-sonnet-4-5` - High-performance model for agents and coding
      - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

      - `"claude-opus-4-8"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-7"`

        Frontier intelligence for long-running agents and coding

      - `"claude-opus-4-6"`

        Most intelligent model for building agents and coding

      - `"claude-sonnet-4-6"`

        Best combination of speed and intelligence

      - `"claude-haiku-4-5"`

        Fastest model with near-frontier intelligence

      - `"claude-haiku-4-5-20251001"`

        Fastest model with near-frontier intelligence

      - `"claude-opus-4-5"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-opus-4-5-20251101"`

        Premium model combining maximum intelligence with practical performance

      - `"claude-sonnet-4-5"`

        High-performance model for agents and coding

      - `"claude-sonnet-4-5-20250929"`

        High-performance model for agents and coding

    - `str`

  - `speed: Optional[Literal["standard", "fast"]]`

    Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

    - `"standard"`

    - `"fast"`

### Beta Managed Agents Multiagent Coordinator

- `class BetaManagedAgentsMultiagentCoordinator: …`

  Resolved coordinator topology with a concrete agent roster.

  - `agents: List[BetaManagedAgentsAgentReference]`

    Agents the coordinator may spawn as session threads, each resolved to a specific version.

    - `id: str`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

### Beta Managed Agents Multiagent Coordinator Params

- `class BetaManagedAgentsMultiagentCoordinatorParams: …`

  A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the `agents` roster.

  - `agents: List[BetaManagedAgentsMultiagentRosterEntryParams]`

    Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to allow recursive self-invocation. Entries must reference distinct agents (after resolving `self` and string forms); at most one `self`. Referenced agents must exist, must not be archived, and must not themselves have `multiagent` set (depth limit 1).

    - `str`

    - `class BetaManagedAgentsAgentParams: …`

      Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

      - `id: str`

        The `agent` ID.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: Optional[int]`

        The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

    - `class BetaManagedAgentsMultiagentSelfParams: …`

      Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

      - `type: Literal["self"]`

        - `"self"`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

### Beta Managed Agents Multiagent Self Params

- `class BetaManagedAgentsMultiagentSelfParams: …`

  Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

  - `type: Literal["self"]`

    - `"self"`

### Beta Managed Agents Session Thread Agent

- `class BetaManagedAgentsSessionThreadAgent: …`

  Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.

  - `id: str`

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `version: int`

### Beta Managed Agents Skill Params

- `BetaManagedAgentsSkillParams`

  Skill to load in the session container.

  - `class BetaManagedAgentsAnthropicSkillParams: …`

    An Anthropic-managed skill.

    - `skill_id: str`

      Identifier of the Anthropic skill (e.g., "xlsx").

    - `type: Literal["anthropic"]`

      - `"anthropic"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

  - `class BetaManagedAgentsCustomSkillParams: …`

    A user-created custom skill.

    - `skill_id: str`

      Tagged ID of the custom skill (e.g., "skill_01XJ5...").

    - `type: Literal["custom"]`

      - `"custom"`

    - `version: Optional[str]`

      Version to pin. Defaults to latest if omitted.

### Beta Managed Agents URL MCP Server Params

- `class BetaManagedAgentsURLMCPServerParams: …`

  URL-based MCP server connection.

  - `name: str`

    Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters.

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

    Endpoint URL for the MCP server.

# Versions

## List Agent Versions

`beta.agents.versions.list(stragent_id, VersionListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsAgent]`

**get** `/v1/agents/{agent_id}/versions`

List Agent Versions

### Parameters

- `agent_id: str`

- `limit: Optional[int]`

  Maximum results per page. Default 20, maximum 100.

- `page: Optional[str]`

  Opaque pagination cursor.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsAgent: …`

  A Managed Agents `agent`.

  - `id: str`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `metadata: Dict[str, str]`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsMultiagent]`

    Resolved coordinator topology with a concrete agent roster.

    - `agents: List[BetaManagedAgentsAgentReference]`

      Agents the coordinator may spawn as session threads, each resolved to a specific version.

      - `id: str`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

      - `skill_id: str`

      - `type: Literal["anthropic"]`

        - `"anthropic"`

      - `version: str`

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

      - `skill_id: str`

      - `type: Literal["custom"]`

        - `"custom"`

      - `version: str`

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

      - `configs: List[BetaManagedAgentsAgentToolConfig]`

        - `enabled: bool`

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

        Resolved default configuration for agent tools.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

    - `class BetaManagedAgentsMCPToolset: …`

      - `configs: List[BetaManagedAgentsMCPToolConfig]`

        - `enabled: bool`

        - `name: str`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

        Resolved default configuration for all tools from an MCP server.

        - `enabled: bool`

        - `permission_policy: PermissionPolicy`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `mcp_server_name: str`

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

      - `description: str`

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

      - `type: Literal["custom"]`

        - `"custom"`

  - `type: Literal["agent"]`

    - `"agent"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `version: int`

    The agent's current version. Starts at 1 and increments when the agent is modified.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.agents.versions.list(
    agent_id="agent_011CZkYpogX7uDKUyvBTophP",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "agent_011CZkYpogX7uDKUyvBTophP",
      "archived_at": null,
      "created_at": "2026-03-15T10:00:00Z",
      "description": "A general-purpose starter agent.",
      "mcp_servers": [
        {
          "name": "example-mcp",
          "type": "url",
          "url": "https://example-server.modelcontextprotocol.io/sse"
        }
      ],
      "metadata": {
        "foo": "bar"
      },
      "model": {
        "id": "claude-sonnet-4-6",
        "speed": "standard"
      },
      "multiagent": {
        "agents": [
          {
            "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
            "type": "agent",
            "version": 1
          }
        ],
        "type": "coordinator"
      },
      "name": "My First Agent",
      "skills": [
        {
          "skill_id": "xlsx",
          "type": "anthropic",
          "version": "1"
        },
        {
          "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
          "type": "custom",
          "version": "2"
        }
      ],
      "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
      "tools": [
        {
          "configs": [
            {
              "enabled": true,
              "name": "bash",
              "permission_policy": {
                "type": "always_allow"
              }
            }
          ],
          "default_config": {
            "enabled": true,
            "permission_policy": {
              "type": "always_ask"
            }
          },
          "type": "agent_toolset_20260401"
        }
      ],
      "type": "agent",
      "updated_at": "2026-03-15T10:00:00Z",
      "version": 1
    }
  ],
  "next_page": "next_page"
}
```

# Environments

## Create Environment

`beta.environments.create(EnvironmentCreateParams**kwargs)  -> BetaEnvironment`

**post** `/v1/environments`

Create a new environment with the specified configuration.

### Parameters

- `name: str`

  Human-readable name for the environment

- `config: Optional[Config]`

  Environment configuration

  - `class BetaCloudConfigParams: …`

    Request params for `cloud` environment configuration.

    Fields default to null; on update, omitted fields preserve the
    existing value.

    - `type: Literal["cloud"]`

      Environment type

      - `"cloud"`

    - `networking: Optional[Networking]`

      Network configuration policy. Omit on update to preserve the existing value.

      - `class BetaUnrestrictedNetwork: …`

        Unrestricted network access.

        - `type: Literal["unrestricted"]`

          Network policy type

          - `"unrestricted"`

      - `class BetaLimitedNetworkParams: …`

        Limited network request params.

        Fields default to null; on update, omitted fields preserve the
        existing value.

        - `type: Literal["limited"]`

          Network policy type

          - `"limited"`

        - `allow_mcp_servers: Optional[bool]`

          Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`.

        - `allow_package_managers: Optional[bool]`

          Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false`.

        - `allowed_hosts: Optional[List[str]]`

          Specifies domains the container can reach.

    - `packages: Optional[BetaPackagesParams]`

      Specify packages (and optionally their versions) available in this environment.

      When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.

      - `apt: Optional[List[str]]`

        Ubuntu/Debian packages to install

      - `cargo: Optional[List[str]]`

        Rust packages to install

      - `gem: Optional[List[str]]`

        Ruby packages to install

      - `go: Optional[List[str]]`

        Go packages to install

      - `npm: Optional[List[str]]`

        Node.js packages to install

      - `pip: Optional[List[str]]`

        Python packages to install

      - `type: Optional[Literal["packages"]]`

        Package configuration type

        - `"packages"`

  - `class BetaSelfHostedConfigParams: …`

    Request params for `self_hosted` environment configuration.

    - `type: Literal["self_hosted"]`

      Environment type

      - `"self_hosted"`

- `description: Optional[str]`

  Optional description of the environment

- `metadata: Optional[Dict[str, str]]`

  User-provided metadata key-value pairs

- `scope: Optional[Literal["organization", "account"]]`

  The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only. Only applicable for self-hosted environments. If not specified, defaults based on organization type.

  - `"organization"`

  - `"account"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_environment = client.beta.environments.create(
    name="python-data-analysis",
)
print(beta_environment.id)
```

#### Response

```json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "archived_at": null,
  "config": {
    "networking": {
      "allow_mcp_servers": false,
      "allow_package_managers": true,
      "allowed_hosts": [
        "api.example.com"
      ],
      "type": "limited"
    },
    "packages": {
      "apt": [
        "string"
      ],
      "cargo": [
        "string"
      ],
      "gem": [
        "string"
      ],
      "go": [
        "string"
      ],
      "npm": [
        "string"
      ],
      "pip": [
        "pandas",
        "numpy"
      ],
      "type": "packages"
    },
    "type": "cloud"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "description": "Python environment with data-analysis packages.",
  "metadata": {},
  "name": "python-data-analysis",
  "type": "environment",
  "updated_at": "2026-03-15T10:00:00Z",
  "scope": "organization"
}
```

## List Environments

`beta.environments.list(EnvironmentListParams**kwargs)  -> SyncPageCursor[BetaEnvironment]`

**get** `/v1/environments`

List environments with pagination support.

### Parameters

- `include_archived: Optional[bool]`

  Include archived environments in the response

- `limit: Optional[int]`

  Maximum number of environments to return

- `page: Optional[str]`

  Opaque cursor from previous response for pagination. Pass the `next_page` value from the previous response.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.environments.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
      "archived_at": null,
      "config": {
        "networking": {
          "allow_mcp_servers": false,
          "allow_package_managers": true,
          "allowed_hosts": [
            "api.example.com"
          ],
          "type": "limited"
        },
        "packages": {
          "apt": [
            "string"
          ],
          "cargo": [
            "string"
          ],
          "gem": [
            "string"
          ],
          "go": [
            "string"
          ],
          "npm": [
            "string"
          ],
          "pip": [
            "pandas",
            "numpy"
          ],
          "type": "packages"
        },
        "type": "cloud"
      },
      "created_at": "2026-03-15T10:00:00Z",
      "description": "Python environment with data-analysis packages.",
      "metadata": {},
      "name": "python-data-analysis",
      "type": "environment",
      "updated_at": "2026-03-15T10:00:00Z",
      "scope": "organization"
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Environment

`beta.environments.retrieve(strenvironment_id, EnvironmentRetrieveParams**kwargs)  -> BetaEnvironment`

**get** `/v1/environments/{environment_id}`

Retrieve a specific environment by ID.

### Parameters

- `environment_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_environment = client.beta.environments.retrieve(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_environment.id)
```

#### Response

```json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "archived_at": null,
  "config": {
    "networking": {
      "allow_mcp_servers": false,
      "allow_package_managers": true,
      "allowed_hosts": [
        "api.example.com"
      ],
      "type": "limited"
    },
    "packages": {
      "apt": [
        "string"
      ],
      "cargo": [
        "string"
      ],
      "gem": [
        "string"
      ],
      "go": [
        "string"
      ],
      "npm": [
        "string"
      ],
      "pip": [
        "pandas",
        "numpy"
      ],
      "type": "packages"
    },
    "type": "cloud"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "description": "Python environment with data-analysis packages.",
  "metadata": {},
  "name": "python-data-analysis",
  "type": "environment",
  "updated_at": "2026-03-15T10:00:00Z",
  "scope": "organization"
}
```

## Update Environment

`beta.environments.update(strenvironment_id, EnvironmentUpdateParams**kwargs)  -> BetaEnvironment`

**post** `/v1/environments/{environment_id}`

Update an existing environment's configuration.

### Parameters

- `environment_id: str`

- `config: Optional[Config]`

  Updated environment configuration

  - `class BetaCloudConfigParams: …`

    Request params for `cloud` environment configuration.

    Fields default to null; on update, omitted fields preserve the
    existing value.

    - `type: Literal["cloud"]`

      Environment type

      - `"cloud"`

    - `networking: Optional[Networking]`

      Network configuration policy. Omit on update to preserve the existing value.

      - `class BetaUnrestrictedNetwork: …`

        Unrestricted network access.

        - `type: Literal["unrestricted"]`

          Network policy type

          - `"unrestricted"`

      - `class BetaLimitedNetworkParams: …`

        Limited network request params.

        Fields default to null; on update, omitted fields preserve the
        existing value.

        - `type: Literal["limited"]`

          Network policy type

          - `"limited"`

        - `allow_mcp_servers: Optional[bool]`

          Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`.

        - `allow_package_managers: Optional[bool]`

          Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false`.

        - `allowed_hosts: Optional[List[str]]`

          Specifies domains the container can reach.

    - `packages: Optional[BetaPackagesParams]`

      Specify packages (and optionally their versions) available in this environment.

      When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.

      - `apt: Optional[List[str]]`

        Ubuntu/Debian packages to install

      - `cargo: Optional[List[str]]`

        Rust packages to install

      - `gem: Optional[List[str]]`

        Ruby packages to install

      - `go: Optional[List[str]]`

        Go packages to install

      - `npm: Optional[List[str]]`

        Node.js packages to install

      - `pip: Optional[List[str]]`

        Python packages to install

      - `type: Optional[Literal["packages"]]`

        Package configuration type

        - `"packages"`

  - `class BetaSelfHostedConfigParams: …`

    Request params for `self_hosted` environment configuration.

    - `type: Literal["self_hosted"]`

      Environment type

      - `"self_hosted"`

- `description: Optional[str]`

  Updated description of the environment

- `metadata: Optional[Dict[str, Optional[str]]]`

  User-provided metadata key-value pairs. Set a value to null or empty string to delete the key.

- `name: Optional[str]`

  Updated name for the environment

- `scope: Optional[Literal["organization", "account"]]`

  The visibility scope for this environment. 'organization' makes the environment visible to all accounts. 'account' restricts visibility to the owning account only.

  - `"organization"`

  - `"account"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_environment = client.beta.environments.update(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_environment.id)
```

#### Response

```json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "archived_at": null,
  "config": {
    "networking": {
      "allow_mcp_servers": false,
      "allow_package_managers": true,
      "allowed_hosts": [
        "api.example.com"
      ],
      "type": "limited"
    },
    "packages": {
      "apt": [
        "string"
      ],
      "cargo": [
        "string"
      ],
      "gem": [
        "string"
      ],
      "go": [
        "string"
      ],
      "npm": [
        "string"
      ],
      "pip": [
        "pandas",
        "numpy"
      ],
      "type": "packages"
    },
    "type": "cloud"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "description": "Python environment with data-analysis packages.",
  "metadata": {},
  "name": "python-data-analysis",
  "type": "environment",
  "updated_at": "2026-03-15T10:00:00Z",
  "scope": "organization"
}
```

## Delete Environment

`beta.environments.delete(strenvironment_id, EnvironmentDeleteParams**kwargs)  -> BetaEnvironmentDeleteResponse`

**delete** `/v1/environments/{environment_id}`

Delete an environment by ID. Returns a confirmation of the deletion.

### Parameters

- `environment_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironmentDeleteResponse: …`

  Response after deleting an environment.

  - `id: str`

    Environment identifier

  - `type: Literal["environment_deleted"]`

    The type of response

    - `"environment_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_environment_delete_response = client.beta.environments.delete(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_environment_delete_response.id)
```

#### Response

```json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "type": "environment_deleted"
}
```

## Archive Environment

`beta.environments.archive(strenvironment_id, EnvironmentArchiveParams**kwargs)  -> BetaEnvironment`

**post** `/v1/environments/{environment_id}/archive`

Archive an environment by ID. Archived environments cannot be used to create new sessions.

### Parameters

- `environment_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_environment = client.beta.environments.archive(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_environment.id)
```

#### Response

```json
{
  "id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "archived_at": null,
  "config": {
    "networking": {
      "allow_mcp_servers": false,
      "allow_package_managers": true,
      "allowed_hosts": [
        "api.example.com"
      ],
      "type": "limited"
    },
    "packages": {
      "apt": [
        "string"
      ],
      "cargo": [
        "string"
      ],
      "gem": [
        "string"
      ],
      "go": [
        "string"
      ],
      "npm": [
        "string"
      ],
      "pip": [
        "pandas",
        "numpy"
      ],
      "type": "packages"
    },
    "type": "cloud"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "description": "Python environment with data-analysis packages.",
  "metadata": {},
  "name": "python-data-analysis",
  "type": "environment",
  "updated_at": "2026-03-15T10:00:00Z",
  "scope": "organization"
}
```

## Domain Types

### Beta Cloud Config

- `class BetaCloudConfig: …`

  `cloud` environment configuration.

  - `networking: Networking`

    Network configuration policy.

    - `class BetaUnrestrictedNetwork: …`

      Unrestricted network access.

      - `type: Literal["unrestricted"]`

        Network policy type

        - `"unrestricted"`

    - `class BetaLimitedNetwork: …`

      Limited network access.

      - `allow_mcp_servers: bool`

        Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

      - `allow_package_managers: bool`

        Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

      - `allowed_hosts: List[str]`

        Specifies domains the container can reach.

      - `type: Literal["limited"]`

        Network policy type

        - `"limited"`

  - `packages: BetaPackages`

    Package manager configuration.

    - `apt: List[str]`

      Ubuntu/Debian packages to install

    - `cargo: List[str]`

      Rust packages to install

    - `gem: List[str]`

      Ruby packages to install

    - `go: List[str]`

      Go packages to install

    - `npm: List[str]`

      Node.js packages to install

    - `pip: List[str]`

      Python packages to install

    - `type: Optional[Literal["packages"]]`

      Package configuration type

      - `"packages"`

  - `type: Literal["cloud"]`

    Environment type

    - `"cloud"`

### Beta Cloud Config Params

- `class BetaCloudConfigParams: …`

  Request params for `cloud` environment configuration.

  Fields default to null; on update, omitted fields preserve the
  existing value.

  - `type: Literal["cloud"]`

    Environment type

    - `"cloud"`

  - `networking: Optional[Networking]`

    Network configuration policy. Omit on update to preserve the existing value.

    - `class BetaUnrestrictedNetwork: …`

      Unrestricted network access.

      - `type: Literal["unrestricted"]`

        Network policy type

        - `"unrestricted"`

    - `class BetaLimitedNetworkParams: …`

      Limited network request params.

      Fields default to null; on update, omitted fields preserve the
      existing value.

      - `type: Literal["limited"]`

        Network policy type

        - `"limited"`

      - `allow_mcp_servers: Optional[bool]`

        Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`.

      - `allow_package_managers: Optional[bool]`

        Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false`.

      - `allowed_hosts: Optional[List[str]]`

        Specifies domains the container can reach.

  - `packages: Optional[BetaPackagesParams]`

    Specify packages (and optionally their versions) available in this environment.

    When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.

    - `apt: Optional[List[str]]`

      Ubuntu/Debian packages to install

    - `cargo: Optional[List[str]]`

      Rust packages to install

    - `gem: Optional[List[str]]`

      Ruby packages to install

    - `go: Optional[List[str]]`

      Go packages to install

    - `npm: Optional[List[str]]`

      Node.js packages to install

    - `pip: Optional[List[str]]`

      Python packages to install

    - `type: Optional[Literal["packages"]]`

      Package configuration type

      - `"packages"`

### Beta Environment

- `class BetaEnvironment: …`

  Unified Environment resource for both cloud and self-hosted environments.

  - `id: str`

    Environment identifier (e.g., 'env_...')

  - `archived_at: Optional[str]`

    RFC 3339 timestamp when environment was archived, or null if not archived

  - `config: Config`

    Environment configuration (either Anthropic Cloud or self-hosted)

    - `class BetaCloudConfig: …`

      `cloud` environment configuration.

      - `networking: Networking`

        Network configuration policy.

        - `class BetaUnrestrictedNetwork: …`

          Unrestricted network access.

          - `type: Literal["unrestricted"]`

            Network policy type

            - `"unrestricted"`

        - `class BetaLimitedNetwork: …`

          Limited network access.

          - `allow_mcp_servers: bool`

            Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

          - `allow_package_managers: bool`

            Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

          - `allowed_hosts: List[str]`

            Specifies domains the container can reach.

          - `type: Literal["limited"]`

            Network policy type

            - `"limited"`

      - `packages: BetaPackages`

        Package manager configuration.

        - `apt: List[str]`

          Ubuntu/Debian packages to install

        - `cargo: List[str]`

          Rust packages to install

        - `gem: List[str]`

          Ruby packages to install

        - `go: List[str]`

          Go packages to install

        - `npm: List[str]`

          Node.js packages to install

        - `pip: List[str]`

          Python packages to install

        - `type: Optional[Literal["packages"]]`

          Package configuration type

          - `"packages"`

      - `type: Literal["cloud"]`

        Environment type

        - `"cloud"`

    - `class BetaSelfHostedConfig: …`

      Configuration for self-hosted environments.

      - `type: Literal["self_hosted"]`

        Environment type

        - `"self_hosted"`

  - `created_at: str`

    RFC 3339 timestamp when environment was created

  - `description: str`

    User-provided description for the environment

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs

  - `name: str`

    Human-readable name for the environment

  - `type: Literal["environment"]`

    The type of object (always 'environment')

    - `"environment"`

  - `updated_at: str`

    RFC 3339 timestamp when environment was last updated

  - `scope: Optional[Literal["organization", "account"]]`

    The visibility scope for this environment. 'organization' means visible to all accounts. 'account' means visible only to the owning account.

    - `"organization"`

    - `"account"`

### Beta Environment Delete Response

- `class BetaEnvironmentDeleteResponse: …`

  Response after deleting an environment.

  - `id: str`

    Environment identifier

  - `type: Literal["environment_deleted"]`

    The type of response

    - `"environment_deleted"`

### Beta Limited Network

- `class BetaLimitedNetwork: …`

  Limited network access.

  - `allow_mcp_servers: bool`

    Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array.

  - `allow_package_managers: bool`

    Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array.

  - `allowed_hosts: List[str]`

    Specifies domains the container can reach.

  - `type: Literal["limited"]`

    Network policy type

    - `"limited"`

### Beta Limited Network Params

- `class BetaLimitedNetworkParams: …`

  Limited network request params.

  Fields default to null; on update, omitted fields preserve the
  existing value.

  - `type: Literal["limited"]`

    Network policy type

    - `"limited"`

  - `allow_mcp_servers: Optional[bool]`

    Permits outbound access to MCP server endpoints configured on the agent, beyond those listed in the `allowed_hosts` array. Defaults to `false`.

  - `allow_package_managers: Optional[bool]`

    Permits outbound access to public package registries (PyPI, npm, etc.) beyond those listed in the `allowed_hosts` array. Defaults to `false`.

  - `allowed_hosts: Optional[List[str]]`

    Specifies domains the container can reach.

### Beta Packages

- `class BetaPackages: …`

  Packages (and their versions) available in this environment.

  - `apt: List[str]`

    Ubuntu/Debian packages to install

  - `cargo: List[str]`

    Rust packages to install

  - `gem: List[str]`

    Ruby packages to install

  - `go: List[str]`

    Go packages to install

  - `npm: List[str]`

    Node.js packages to install

  - `pip: List[str]`

    Python packages to install

  - `type: Optional[Literal["packages"]]`

    Package configuration type

    - `"packages"`

### Beta Packages Params

- `class BetaPackagesParams: …`

  Specify packages (and optionally their versions) available in this environment.

  When versioning, use the version semantics relevant for the package manager, e.g. for `pip` use `package==1.0.0`. You are responsible for validating the package and version exist. Unversioned installs the latest.

  - `apt: Optional[List[str]]`

    Ubuntu/Debian packages to install

  - `cargo: Optional[List[str]]`

    Rust packages to install

  - `gem: Optional[List[str]]`

    Ruby packages to install

  - `go: Optional[List[str]]`

    Go packages to install

  - `npm: Optional[List[str]]`

    Node.js packages to install

  - `pip: Optional[List[str]]`

    Python packages to install

  - `type: Optional[Literal["packages"]]`

    Package configuration type

    - `"packages"`

### Beta Self Hosted Config

- `class BetaSelfHostedConfig: …`

  Configuration for self-hosted environments.

  - `type: Literal["self_hosted"]`

    Environment type

    - `"self_hosted"`

### Beta Self Hosted Config Params

- `class BetaSelfHostedConfigParams: …`

  Request params for `self_hosted` environment configuration.

  - `type: Literal["self_hosted"]`

    Environment type

    - `"self_hosted"`

### Beta Unrestricted Network

- `class BetaUnrestrictedNetwork: …`

  Unrestricted network access.

  - `type: Literal["unrestricted"]`

    Network policy type

    - `"unrestricted"`

# Work

## Get Work Item

`beta.environments.work.retrieve(strwork_id, WorkRetrieveParams**kwargs)  -> BetaSelfHostedWork`

**get** `/v1/environments/{environment_id}/work/{work_id}`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Retrieve detailed information about a specific work item.

### Parameters

- `environment_id: str`

- `work_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work = client.beta.environments.work.retrieve(
    work_id="work_id",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work.id)
```

#### Response

```json
{
  "id": "id",
  "acknowledged_at": "acknowledged_at",
  "created_at": "created_at",
  "data": {
    "id": "id",
    "type": "session"
  },
  "environment_id": "environment_id",
  "latest_heartbeat_at": "latest_heartbeat_at",
  "metadata": {
    "foo": "string"
  },
  "started_at": "started_at",
  "state": "queued",
  "stop_requested_at": "stop_requested_at",
  "stopped_at": "stopped_at",
  "type": "work"
}
```

## Poll for Work

`beta.environments.work.poll(strenvironment_id, WorkPollParams**kwargs)  -> BetaSelfHostedWork`

**get** `/v1/environments/{environment_id}/work/poll`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Long poll for work items in the queue.

### Parameters

- `environment_id: str`

- `block_ms: Optional[int]`

  How long to wait for work to arrive before returning. Must be 1-999 in milliseconds. Defaults to non-blocking (returns immediately if no work is available).

- `reclaim_older_than_ms: Optional[int]`

  Reclaim unacknowledged work items older than this many milliseconds. If omitted, uses the default (5000ms).

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

- `anthropic_worker_id: Optional[str]`

  Unique identifier for the specific worker polling, used to track aggregated environment-level work metrics in Console

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work = client.beta.environments.work.poll(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work.id)
```

#### Response

```json
{
  "id": "id",
  "acknowledged_at": "acknowledged_at",
  "created_at": "created_at",
  "data": {
    "id": "id",
    "type": "session"
  },
  "environment_id": "environment_id",
  "latest_heartbeat_at": "latest_heartbeat_at",
  "metadata": {
    "foo": "string"
  },
  "started_at": "started_at",
  "state": "queued",
  "stop_requested_at": "stop_requested_at",
  "stopped_at": "stopped_at",
  "type": "work"
}
```

## Acknowledge Work

`beta.environments.work.ack(strwork_id, WorkAckParams**kwargs)  -> BetaSelfHostedWork`

**post** `/v1/environments/{environment_id}/work/{work_id}/ack`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Acknowledge receipt of a work item, transitioning it from 'queued' to 'starting' and removing it from the queue.

### Parameters

- `environment_id: str`

- `work_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work = client.beta.environments.work.ack(
    work_id="work_id",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work.id)
```

#### Response

```json
{
  "id": "id",
  "acknowledged_at": "acknowledged_at",
  "created_at": "created_at",
  "data": {
    "id": "id",
    "type": "session"
  },
  "environment_id": "environment_id",
  "latest_heartbeat_at": "latest_heartbeat_at",
  "metadata": {
    "foo": "string"
  },
  "started_at": "started_at",
  "state": "queued",
  "stop_requested_at": "stop_requested_at",
  "stopped_at": "stopped_at",
  "type": "work"
}
```

## Record Heartbeat

`beta.environments.work.heartbeat(strwork_id, WorkHeartbeatParams**kwargs)  -> BetaSelfHostedWorkHeartbeatResponse`

**post** `/v1/environments/{environment_id}/work/{work_id}/heartbeat`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Record a heartbeat for a work item to maintain the lease.

### Parameters

- `environment_id: str`

- `work_id: str`

- `desired_ttl_seconds: Optional[int]`

  Desired TTL in seconds

- `expected_last_heartbeat: Optional[str]`

  Expected last_heartbeat for conditional update (optimistic concurrency). Use literal 'NO_HEARTBEAT' to claim an unclaimed lease (first heartbeat). For subsequent heartbeats, echo the server's previous last_heartbeat value exactly. Returns 412 Precondition Failed if the actual value doesn't match.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWorkHeartbeatResponse: …`

  Response after recording a heartbeat for a work item.

  - `last_heartbeat: str`

    RFC 3339 timestamp of the actual heartbeat from DB

  - `lease_extended: bool`

    Whether the heartbeat succeeded in extending the lease

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item (active/stopping/stopped)

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `ttl_seconds: int`

    Effective TTL applied to the lease

  - `type: Literal["work_heartbeat"]`

    The type of response

    - `"work_heartbeat"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work_heartbeat_response = client.beta.environments.work.heartbeat(
    work_id="work_id",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work_heartbeat_response.last_heartbeat)
```

#### Response

```json
{
  "last_heartbeat": "last_heartbeat",
  "lease_extended": true,
  "state": "queued",
  "ttl_seconds": 0,
  "type": "work_heartbeat"
}
```

## Stop Work

`beta.environments.work.stop(strwork_id, WorkStopParams**kwargs)  -> BetaSelfHostedWork`

**post** `/v1/environments/{environment_id}/work/{work_id}/stop`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Stop a work item, initiating graceful or forced shutdown.

### Parameters

- `environment_id: str`

- `work_id: str`

- `force: Optional[bool]`

  If true, immediately stop work without graceful shutdown

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work = client.beta.environments.work.stop(
    work_id="work_id",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work.id)
```

#### Response

```json
{
  "id": "id",
  "acknowledged_at": "acknowledged_at",
  "created_at": "created_at",
  "data": {
    "id": "id",
    "type": "session"
  },
  "environment_id": "environment_id",
  "latest_heartbeat_at": "latest_heartbeat_at",
  "metadata": {
    "foo": "string"
  },
  "started_at": "started_at",
  "state": "queued",
  "stop_requested_at": "stop_requested_at",
  "stopped_at": "stopped_at",
  "type": "work"
}
```

## List Work Items

`beta.environments.work.list(strenvironment_id, WorkListParams**kwargs)  -> SyncPageCursor[BetaSelfHostedWork]`

**get** `/v1/environments/{environment_id}/work`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

List work items in an environment.

### Parameters

- `environment_id: str`

- `limit: Optional[int]`

  Maximum number of work items to return

- `page: Optional[str]`

  Opaque cursor from previous response for pagination

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.environments.work.list(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "acknowledged_at": "acknowledged_at",
      "created_at": "created_at",
      "data": {
        "id": "id",
        "type": "session"
      },
      "environment_id": "environment_id",
      "latest_heartbeat_at": "latest_heartbeat_at",
      "metadata": {
        "foo": "string"
      },
      "started_at": "started_at",
      "state": "queued",
      "stop_requested_at": "stop_requested_at",
      "stopped_at": "stopped_at",
      "type": "work"
    }
  ],
  "next_page": "next_page"
}
```

## Update Work Item

`beta.environments.work.update(strwork_id, WorkUpdateParams**kwargs)  -> BetaSelfHostedWork`

**post** `/v1/environments/{environment_id}/work/{work_id}`

Note: these endpoints are called automatically by the pre-built environment worker provided in the SDKs and CLI, for orchestrating sessions with self-hosted sandbox environments. They are included here as a reference; you do not need to invoke them directly.

Update work item metadata with merge semantics.

### Parameters

- `environment_id: str`

- `work_id: str`

- `metadata: Dict[str, Optional[str]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work = client.beta.environments.work.update(
    work_id="work_id",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
    metadata={
        "foo": "string"
    },
)
print(beta_self_hosted_work.id)
```

#### Response

```json
{
  "id": "id",
  "acknowledged_at": "acknowledged_at",
  "created_at": "created_at",
  "data": {
    "id": "id",
    "type": "session"
  },
  "environment_id": "environment_id",
  "latest_heartbeat_at": "latest_heartbeat_at",
  "metadata": {
    "foo": "string"
  },
  "started_at": "started_at",
  "state": "queued",
  "stop_requested_at": "stop_requested_at",
  "stopped_at": "stopped_at",
  "type": "work"
}
```

## Get Queue Statistics

`beta.environments.work.stats(strenvironment_id, WorkStatsParams**kwargs)  -> BetaSelfHostedWorkQueueStats`

**get** `/v1/environments/{environment_id}/work/stats`

Get statistics about the work queue for an environment.

### Parameters

- `environment_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaSelfHostedWorkQueueStats: …`

  Statistics about the work queue for an environment.

  Uses Redis Stream consumer group metrics for O(1) queries.

  - `depth: int`

    Number of work items waiting to be picked up (lag from consumer group)

  - `oldest_queued_at: Optional[str]`

    RFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty

  - `pending: int`

    Number of work items being processed (polled but not acknowledged)

  - `type: Literal["work_queue_stats"]`

    The type of object

    - `"work_queue_stats"`

  - `workers_polling: Optional[int]`

    Number of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_self_hosted_work_queue_stats = client.beta.environments.work.stats(
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_self_hosted_work_queue_stats.depth)
```

#### Response

```json
{
  "depth": 0,
  "oldest_queued_at": "oldest_queued_at",
  "pending": 0,
  "type": "work_queue_stats",
  "workers_polling": 0
}
```

## Domain Types

### Beta Self Hosted Work

- `class BetaSelfHostedWork: …`

  Work resource representing a unit of work in a self-hosted environment.

  Work items are queued when sessions are created or when long-dormant sessions
  receive new messages. The environment worker polls for work to execute in a
  self-hosted sandbox.

  - `id: str`

    Work identifier (e.g., 'work_...')

  - `acknowledged_at: Optional[str]`

    RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

  - `created_at: str`

    RFC 3339 timestamp when work was created

  - `data: BetaSessionWorkData`

    The actual work to be performed

    - `id: str`

      Session identifier (e.g., 'session_...')

    - `type: Literal["session"]`

      Type of work data

      - `"session"`

  - `environment_id: str`

    Environment identifier this work belongs to (e.g., `env_...`)

  - `latest_heartbeat_at: Optional[str]`

    RFC 3339 timestamp of the most recent heartbeat

  - `metadata: Dict[str, str]`

    User-provided metadata key-value pairs associated with this work item

  - `started_at: Optional[str]`

    RFC 3339 timestamp when work execution started

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `stop_requested_at: Optional[str]`

    RFC 3339 timestamp when stop was requested

  - `stopped_at: Optional[str]`

    RFC 3339 timestamp when work execution stopped

  - `type: Literal["work"]`

    The type of object (always 'work')

    - `"work"`

### Beta Self Hosted Work Heartbeat Response

- `class BetaSelfHostedWorkHeartbeatResponse: …`

  Response after recording a heartbeat for a work item.

  - `last_heartbeat: str`

    RFC 3339 timestamp of the actual heartbeat from DB

  - `lease_extended: bool`

    Whether the heartbeat succeeded in extending the lease

  - `state: Literal["queued", "starting", "active", 2 more]`

    Current state of the work item (active/stopping/stopped)

    - `"queued"`

    - `"starting"`

    - `"active"`

    - `"stopping"`

    - `"stopped"`

  - `ttl_seconds: int`

    Effective TTL applied to the lease

  - `type: Literal["work_heartbeat"]`

    The type of response

    - `"work_heartbeat"`

### Beta Self Hosted Work List Response

- `class BetaSelfHostedWorkListResponse: …`

  Response when listing work items with cursor-based pagination.

  - `data: List[BetaSelfHostedWork]`

    List of work items

    - `id: str`

      Work identifier (e.g., 'work_...')

    - `acknowledged_at: Optional[str]`

      RFC 3339 timestamp when the work item was acknowledged and assigned to a self-hosted sandbox

    - `created_at: str`

      RFC 3339 timestamp when work was created

    - `data: BetaSessionWorkData`

      The actual work to be performed

      - `id: str`

        Session identifier (e.g., 'session_...')

      - `type: Literal["session"]`

        Type of work data

        - `"session"`

    - `environment_id: str`

      Environment identifier this work belongs to (e.g., `env_...`)

    - `latest_heartbeat_at: Optional[str]`

      RFC 3339 timestamp of the most recent heartbeat

    - `metadata: Dict[str, str]`

      User-provided metadata key-value pairs associated with this work item

    - `started_at: Optional[str]`

      RFC 3339 timestamp when work execution started

    - `state: Literal["queued", "starting", "active", 2 more]`

      Current state of the work item

      - `"queued"`

      - `"starting"`

      - `"active"`

      - `"stopping"`

      - `"stopped"`

    - `stop_requested_at: Optional[str]`

      RFC 3339 timestamp when stop was requested

    - `stopped_at: Optional[str]`

      RFC 3339 timestamp when work execution stopped

    - `type: Literal["work"]`

      The type of object (always 'work')

      - `"work"`

  - `next_page: Optional[str]`

    Opaque cursor for fetching the next page of results

### Beta Self Hosted Work Queue Stats

- `class BetaSelfHostedWorkQueueStats: …`

  Statistics about the work queue for an environment.

  Uses Redis Stream consumer group metrics for O(1) queries.

  - `depth: int`

    Number of work items waiting to be picked up (lag from consumer group)

  - `oldest_queued_at: Optional[str]`

    RFC 3339 timestamp of oldest item in the work stream (includes both queued and pending items), null if stream empty

  - `pending: int`

    Number of work items being processed (polled but not acknowledged)

  - `type: Literal["work_queue_stats"]`

    The type of object

    - `"work_queue_stats"`

  - `workers_polling: Optional[int]`

    Number of workers that have polled for work in the last 30 seconds. Requires worker_id to be sent with poll requests.

### Beta Self Hosted Work Stop Request

- `class BetaSelfHostedWorkStopRequest: …`

  Request to stop a work item.

  - `force: Optional[bool]`

    If true, immediately stop work without graceful shutdown

### Beta Self Hosted Work Update Request

- `class BetaSelfHostedWorkUpdateRequest: …`

  Request to update work item metadata.

  - `metadata: Dict[str, Optional[str]]`

    Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve existing metadata.

### Beta Session Work Data

- `class BetaSessionWorkData: …`

  Work data for session work items.

  This resource type is used when work represents a session that needs to be executed
  in a self-hosted environment.

  - `id: str`

    Session identifier (e.g., 'session_...')

  - `type: Literal["session"]`

    Type of work data

    - `"session"`

# Sessions

## Create Session

`beta.sessions.create(SessionCreateParams**kwargs)  -> BetaManagedAgentsSession`

**post** `/v1/sessions`

Create Session

### Parameters

- `agent: Agent`

  Agent identifier. Accepts the `agent` ID string, which pins the latest version for the session, or an `agent` object with both id and version specified.

  - `str`

  - `class BetaManagedAgentsAgentParams: …`

    Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

    - `id: str`

      The `agent` ID.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: Optional[int]`

      The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

- `environment_id: str`

  ID of the `environment` defining the container configuration for this session.

- `metadata: Optional[Dict[str, str]]`

  Arbitrary key-value metadata attached to the session. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

- `resources: Optional[Iterable[Resource]]`

  Resources (e.g. repositories, files) to mount into the session's container.

  - `class BetaManagedAgentsGitHubRepositoryResourceParams: …`

    Mount a GitHub repository into the session's container.

    - `authorization_token: str`

      GitHub authorization token used to clone the repository.

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `url: str`

      Github URL of the repository

    - `checkout: Optional[Checkout]`

      Branch or commit to check out. Defaults to the repository's default branch.

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

    - `mount_path: Optional[str]`

      Mount path in the container. Defaults to `/workspace/<repo-name>`.

  - `class BetaManagedAgentsFileResourceParams: …`

    Mount a file uploaded via the Files API into the session.

    - `file_id: str`

      ID of a previously uploaded file.

    - `type: Literal["file"]`

      - `"file"`

    - `mount_path: Optional[str]`

      Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.

  - `class BetaManagedAgentsMemoryStoreResourceParam: …`

    Parameters for attaching a memory store to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

- `title: Optional[str]`

  Human-readable session title.

- `vault_ids: Optional[Sequence[str]]`

  Vault IDs for stored credentials the agent can use during the session.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session = client.beta.sessions.create(
    agent="agent_011CZkYpogX7uDKUyvBTophP",
    environment_id="env_011CZkZ9X2dpNyB7HsEFoRfW",
)
print(beta_managed_agents_session.id)
```

#### Response

```json
{
  "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "agent": {
    "id": "agent_011CZkYpogX7uDKUyvBTophP",
    "description": "A general-purpose starter agent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "multiagent": {
      "agents": [
        {
          "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
          "description": "A focused research subagent.",
          "mcp_servers": [
            {
              "name": "example-mcp",
              "type": "url",
              "url": "https://example-server.modelcontextprotocol.io/sse"
            }
          ],
          "model": {
            "id": "claude-sonnet-4-6",
            "speed": "standard"
          },
          "name": "Researcher",
          "skills": [
            {
              "skill_id": "xlsx",
              "type": "anthropic",
              "version": "1"
            }
          ],
          "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
          "tools": [
            {
              "configs": [
                {
                  "enabled": true,
                  "name": "bash",
                  "permission_policy": {
                    "type": "always_allow"
                  }
                }
              ],
              "default_config": {
                "enabled": true,
                "permission_policy": {
                  "type": "always_ask"
                }
              },
              "type": "agent_toolset_20260401"
            }
          ],
          "type": "agent",
          "version": 1
        }
      ],
      "type": "coordinator"
    },
    "name": "My First Agent",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      },
      {
        "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
        "type": "custom",
        "version": "2"
      }
    ],
    "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "metadata": {},
  "outcome_evaluations": [
    {
      "completed_at": "2026-03-15T10:02:31Z",
      "description": "Produce a 2-page summary as summary.md",
      "explanation": "All five sections present with inline citations.",
      "iteration": 0,
      "outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
      "result": "satisfied",
      "type": "outcome_evaluation"
    }
  ],
  "resources": [
    {
      "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
      "created_at": "2026-03-15T10:00:00Z",
      "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "mount_path": "/uploads/receipt.pdf",
      "type": "file",
      "updated_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
      "created_at": "2026-03-15T10:00:00Z",
      "mount_path": "/workspace/example-repo",
      "type": "github_repository",
      "updated_at": "2026-03-15T10:00:00Z",
      "url": "https://github.com/example-org/example-repo",
      "checkout": {
        "name": "main",
        "type": "branch"
      }
    }
  ],
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "status": "idle",
  "title": "Order #1234 inquiry",
  "type": "session",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  },
  "vault_ids": [
    "vlt_011CZkZDLs7fYzm1hXNPeRjv"
  ]
}
```

## List Sessions

`beta.sessions.list(SessionListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsSession]`

**get** `/v1/sessions`

List Sessions

### Parameters

- `agent_id: Optional[str]`

  Filter sessions created with this agent ID.

- `agent_version: Optional[int]`

  Filter by agent version. Only applies when agent_id is also set.

- `created_at_gt: Optional[Union[str, datetime]]`

  Return sessions created after this time (exclusive).

- `created_at_gte: Optional[Union[str, datetime]]`

  Return sessions created at or after this time (inclusive).

- `created_at_lt: Optional[Union[str, datetime]]`

  Return sessions created before this time (exclusive).

- `created_at_lte: Optional[Union[str, datetime]]`

  Return sessions created at or before this time (inclusive).

- `include_archived: Optional[bool]`

  When true, includes archived sessions. Default: false (exclude archived).

- `limit: Optional[int]`

  Maximum number of results to return.

- `memory_store_id: Optional[str]`

  Filter sessions whose resources contain a memory_store with this memory store ID.

- `order: Optional[Literal["asc", "desc"]]`

  Sort direction for results, ordered by created_at. Defaults to desc (newest first).

  - `"asc"`

  - `"desc"`

- `page: Optional[str]`

  Opaque pagination cursor from a previous response's next_page.

- `statuses: Optional[List[Literal["rescheduling", "running", "idle", "terminated"]]]`

  Filter by session status. Repeat the parameter to match any of multiple statuses.

  - `"rescheduling"`

  - `"running"`

  - `"idle"`

  - `"terminated"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.sessions.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
      "agent": {
        "id": "agent_011CZkYpogX7uDKUyvBTophP",
        "description": "A general-purpose starter agent.",
        "mcp_servers": [
          {
            "name": "example-mcp",
            "type": "url",
            "url": "https://example-server.modelcontextprotocol.io/sse"
          }
        ],
        "model": {
          "id": "claude-sonnet-4-6",
          "speed": "standard"
        },
        "multiagent": {
          "agents": [
            {
              "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
              "description": "A focused research subagent.",
              "mcp_servers": [
                {
                  "name": "example-mcp",
                  "type": "url",
                  "url": "https://example-server.modelcontextprotocol.io/sse"
                }
              ],
              "model": {
                "id": "claude-sonnet-4-6",
                "speed": "standard"
              },
              "name": "Researcher",
              "skills": [
                {
                  "skill_id": "xlsx",
                  "type": "anthropic",
                  "version": "1"
                }
              ],
              "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
              "tools": [
                {
                  "configs": [
                    {
                      "enabled": true,
                      "name": "bash",
                      "permission_policy": {
                        "type": "always_allow"
                      }
                    }
                  ],
                  "default_config": {
                    "enabled": true,
                    "permission_policy": {
                      "type": "always_ask"
                    }
                  },
                  "type": "agent_toolset_20260401"
                }
              ],
              "type": "agent",
              "version": 1
            }
          ],
          "type": "coordinator"
        },
        "name": "My First Agent",
        "skills": [
          {
            "skill_id": "xlsx",
            "type": "anthropic",
            "version": "1"
          },
          {
            "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
            "type": "custom",
            "version": "2"
          }
        ],
        "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
        "tools": [
          {
            "configs": [
              {
                "enabled": true,
                "name": "bash",
                "permission_policy": {
                  "type": "always_allow"
                }
              }
            ],
            "default_config": {
              "enabled": true,
              "permission_policy": {
                "type": "always_ask"
              }
            },
            "type": "agent_toolset_20260401"
          }
        ],
        "type": "agent",
        "version": 1
      },
      "archived_at": null,
      "created_at": "2026-03-15T10:00:00Z",
      "environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
      "metadata": {},
      "outcome_evaluations": [
        {
          "completed_at": "2026-03-15T10:02:31Z",
          "description": "Produce a 2-page summary as summary.md",
          "explanation": "All five sections present with inline citations.",
          "iteration": 0,
          "outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
          "result": "satisfied",
          "type": "outcome_evaluation"
        }
      ],
      "resources": [
        {
          "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
          "created_at": "2026-03-15T10:00:00Z",
          "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
          "mount_path": "/uploads/receipt.pdf",
          "type": "file",
          "updated_at": "2026-03-15T10:00:00Z"
        },
        {
          "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
          "created_at": "2026-03-15T10:00:00Z",
          "mount_path": "/workspace/example-repo",
          "type": "github_repository",
          "updated_at": "2026-03-15T10:00:00Z",
          "url": "https://github.com/example-org/example-repo",
          "checkout": {
            "name": "main",
            "type": "branch"
          }
        }
      ],
      "stats": {
        "active_seconds": 0,
        "duration_seconds": 0
      },
      "status": "idle",
      "title": "Order #1234 inquiry",
      "type": "session",
      "updated_at": "2026-03-15T10:00:00Z",
      "usage": {
        "cache_creation": {
          "ephemeral_1h_input_tokens": 0,
          "ephemeral_5m_input_tokens": 0
        },
        "cache_read_input_tokens": 0,
        "input_tokens": 0,
        "output_tokens": 0
      },
      "vault_ids": [
        "vlt_011CZkZDLs7fYzm1hXNPeRjv"
      ]
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Session

`beta.sessions.retrieve(strsession_id, SessionRetrieveParams**kwargs)  -> BetaManagedAgentsSession`

**get** `/v1/sessions/{session_id}`

Get Session

### Parameters

- `session_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session = client.beta.sessions.retrieve(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_session.id)
```

#### Response

```json
{
  "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "agent": {
    "id": "agent_011CZkYpogX7uDKUyvBTophP",
    "description": "A general-purpose starter agent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "multiagent": {
      "agents": [
        {
          "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
          "description": "A focused research subagent.",
          "mcp_servers": [
            {
              "name": "example-mcp",
              "type": "url",
              "url": "https://example-server.modelcontextprotocol.io/sse"
            }
          ],
          "model": {
            "id": "claude-sonnet-4-6",
            "speed": "standard"
          },
          "name": "Researcher",
          "skills": [
            {
              "skill_id": "xlsx",
              "type": "anthropic",
              "version": "1"
            }
          ],
          "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
          "tools": [
            {
              "configs": [
                {
                  "enabled": true,
                  "name": "bash",
                  "permission_policy": {
                    "type": "always_allow"
                  }
                }
              ],
              "default_config": {
                "enabled": true,
                "permission_policy": {
                  "type": "always_ask"
                }
              },
              "type": "agent_toolset_20260401"
            }
          ],
          "type": "agent",
          "version": 1
        }
      ],
      "type": "coordinator"
    },
    "name": "My First Agent",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      },
      {
        "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
        "type": "custom",
        "version": "2"
      }
    ],
    "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "metadata": {},
  "outcome_evaluations": [
    {
      "completed_at": "2026-03-15T10:02:31Z",
      "description": "Produce a 2-page summary as summary.md",
      "explanation": "All five sections present with inline citations.",
      "iteration": 0,
      "outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
      "result": "satisfied",
      "type": "outcome_evaluation"
    }
  ],
  "resources": [
    {
      "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
      "created_at": "2026-03-15T10:00:00Z",
      "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "mount_path": "/uploads/receipt.pdf",
      "type": "file",
      "updated_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
      "created_at": "2026-03-15T10:00:00Z",
      "mount_path": "/workspace/example-repo",
      "type": "github_repository",
      "updated_at": "2026-03-15T10:00:00Z",
      "url": "https://github.com/example-org/example-repo",
      "checkout": {
        "name": "main",
        "type": "branch"
      }
    }
  ],
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "status": "idle",
  "title": "Order #1234 inquiry",
  "type": "session",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  },
  "vault_ids": [
    "vlt_011CZkZDLs7fYzm1hXNPeRjv"
  ]
}
```

## Update Session

`beta.sessions.update(strsession_id, SessionUpdateParams**kwargs)  -> BetaManagedAgentsSession`

**post** `/v1/sessions/{session_id}`

Update Session

### Parameters

- `session_id: str`

- `agent: Optional[BetaManagedAgentsSessionAgentUpdateParam]`

  Mid-session agent configuration update. Only `tools` and `mcp_servers` are updatable. Full replacement: the provided array becomes the new value. To preserve existing entries, GET the session, modify the array, and POST it back.

  - `mcp_servers: Optional[List[BetaManagedAgentsURLMCPServerParams]]`

    Replacement MCP server list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve.

    - `name: str`

      Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters.

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

      Endpoint URL for the MCP server.

  - `tools: Optional[List[Tool]]`

    Replacement tool list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve.

    - `class BetaManagedAgentsAgentToolset20260401Params: …`

      Configuration for built-in agent tools. Use this to enable or disable groups of tools available to the agent.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

      - `configs: Optional[List[BetaManagedAgentsAgentToolConfigParams]]`

        Per-tool configuration overrides.

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `enabled: Optional[bool]`

          Whether this tool is enabled and available to Claude. Overrides the default_config setting.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: Optional[BetaManagedAgentsAgentToolsetDefaultConfigParams]`

        Default configuration for all tools in a toolset.

        - `enabled: Optional[bool]`

          Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

    - `class BetaManagedAgentsMCPToolsetParams: …`

      Configuration for tools from an MCP server defined in `mcp_servers`.

      - `mcp_server_name: str`

        Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters.

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

      - `configs: Optional[List[BetaManagedAgentsMCPToolConfigParams]]`

        Per-tool configuration overrides.

        - `name: str`

          Name of the MCP tool to configure. 1-128 characters.

        - `enabled: Optional[bool]`

          Whether this tool is enabled. Overrides the `default_config` setting.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: Optional[BetaManagedAgentsMCPToolsetDefaultConfigParams]`

        Default configuration for all tools from an MCP server.

        - `enabled: Optional[bool]`

          Whether tools are enabled by default. Defaults to true if not specified.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

    - `class BetaManagedAgentsCustomToolParams: …`

      A custom tool that is executed by the API client rather than the agent. When the agent calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle, waiting for the client to provide the result via a `user.custom_tool_result` event.

      - `description: str`

        Description of what the tool does, shown to the agent to help it decide when to use the tool. 1-1024 characters.

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

        Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens.

      - `type: Literal["custom"]`

        - `"custom"`

- `metadata: Optional[Dict[str, Optional[str]]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve.

- `title: Optional[str]`

  Human-readable session title.

- `vault_ids: Optional[Sequence[str]]`

  Vault IDs (`vlt_*`) to attach to the session. Not yet supported; requests setting this field are rejected. Reserved for future use.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session = client.beta.sessions.update(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_session.id)
```

#### Response

```json
{
  "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "agent": {
    "id": "agent_011CZkYpogX7uDKUyvBTophP",
    "description": "A general-purpose starter agent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "multiagent": {
      "agents": [
        {
          "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
          "description": "A focused research subagent.",
          "mcp_servers": [
            {
              "name": "example-mcp",
              "type": "url",
              "url": "https://example-server.modelcontextprotocol.io/sse"
            }
          ],
          "model": {
            "id": "claude-sonnet-4-6",
            "speed": "standard"
          },
          "name": "Researcher",
          "skills": [
            {
              "skill_id": "xlsx",
              "type": "anthropic",
              "version": "1"
            }
          ],
          "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
          "tools": [
            {
              "configs": [
                {
                  "enabled": true,
                  "name": "bash",
                  "permission_policy": {
                    "type": "always_allow"
                  }
                }
              ],
              "default_config": {
                "enabled": true,
                "permission_policy": {
                  "type": "always_ask"
                }
              },
              "type": "agent_toolset_20260401"
            }
          ],
          "type": "agent",
          "version": 1
        }
      ],
      "type": "coordinator"
    },
    "name": "My First Agent",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      },
      {
        "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
        "type": "custom",
        "version": "2"
      }
    ],
    "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "metadata": {},
  "outcome_evaluations": [
    {
      "completed_at": "2026-03-15T10:02:31Z",
      "description": "Produce a 2-page summary as summary.md",
      "explanation": "All five sections present with inline citations.",
      "iteration": 0,
      "outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
      "result": "satisfied",
      "type": "outcome_evaluation"
    }
  ],
  "resources": [
    {
      "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
      "created_at": "2026-03-15T10:00:00Z",
      "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "mount_path": "/uploads/receipt.pdf",
      "type": "file",
      "updated_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
      "created_at": "2026-03-15T10:00:00Z",
      "mount_path": "/workspace/example-repo",
      "type": "github_repository",
      "updated_at": "2026-03-15T10:00:00Z",
      "url": "https://github.com/example-org/example-repo",
      "checkout": {
        "name": "main",
        "type": "branch"
      }
    }
  ],
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "status": "idle",
  "title": "Order #1234 inquiry",
  "type": "session",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  },
  "vault_ids": [
    "vlt_011CZkZDLs7fYzm1hXNPeRjv"
  ]
}
```

## Delete Session

`beta.sessions.delete(strsession_id, SessionDeleteParams**kwargs)  -> BetaManagedAgentsDeletedSession`

**delete** `/v1/sessions/{session_id}`

Delete Session

### Parameters

- `session_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeletedSession: …`

  Confirmation that a `session` has been permanently deleted.

  - `id: str`

  - `type: Literal["session_deleted"]`

    - `"session_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_deleted_session = client.beta.sessions.delete(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_deleted_session.id)
```

#### Response

```json
{
  "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "type": "session_deleted"
}
```

## Archive Session

`beta.sessions.archive(strsession_id, SessionArchiveParams**kwargs)  -> BetaManagedAgentsSession`

**post** `/v1/sessions/{session_id}/archive`

Archive Session

### Parameters

- `session_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session = client.beta.sessions.archive(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_session.id)
```

#### Response

```json
{
  "id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "agent": {
    "id": "agent_011CZkYpogX7uDKUyvBTophP",
    "description": "A general-purpose starter agent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "multiagent": {
      "agents": [
        {
          "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
          "description": "A focused research subagent.",
          "mcp_servers": [
            {
              "name": "example-mcp",
              "type": "url",
              "url": "https://example-server.modelcontextprotocol.io/sse"
            }
          ],
          "model": {
            "id": "claude-sonnet-4-6",
            "speed": "standard"
          },
          "name": "Researcher",
          "skills": [
            {
              "skill_id": "xlsx",
              "type": "anthropic",
              "version": "1"
            }
          ],
          "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
          "tools": [
            {
              "configs": [
                {
                  "enabled": true,
                  "name": "bash",
                  "permission_policy": {
                    "type": "always_allow"
                  }
                }
              ],
              "default_config": {
                "enabled": true,
                "permission_policy": {
                  "type": "always_ask"
                }
              },
              "type": "agent_toolset_20260401"
            }
          ],
          "type": "agent",
          "version": 1
        }
      ],
      "type": "coordinator"
    },
    "name": "My First Agent",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      },
      {
        "skill_id": "skill_011CZkZFNu9hAbo3jZPRgTlx",
        "type": "custom",
        "version": "2"
      }
    ],
    "system": "You are a general-purpose agent that can research, write code, run commands, and use connected tools to complete the user's task end to end.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "environment_id": "env_011CZkZ9X2dpNyB7HsEFoRfW",
  "metadata": {},
  "outcome_evaluations": [
    {
      "completed_at": "2026-03-15T10:02:31Z",
      "description": "Produce a 2-page summary as summary.md",
      "explanation": "All five sections present with inline citations.",
      "iteration": 0,
      "outcome_id": "outc_011CZkZRSw2kEfs6ncTVljxP",
      "result": "satisfied",
      "type": "outcome_evaluation"
    }
  ],
  "resources": [
    {
      "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
      "created_at": "2026-03-15T10:00:00Z",
      "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "mount_path": "/uploads/receipt.pdf",
      "type": "file",
      "updated_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
      "created_at": "2026-03-15T10:00:00Z",
      "mount_path": "/workspace/example-repo",
      "type": "github_repository",
      "updated_at": "2026-03-15T10:00:00Z",
      "url": "https://github.com/example-org/example-repo",
      "checkout": {
        "name": "main",
        "type": "branch"
      }
    }
  ],
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0
  },
  "status": "idle",
  "title": "Order #1234 inquiry",
  "type": "session",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  },
  "vault_ids": [
    "vlt_011CZkZDLs7fYzm1hXNPeRjv"
  ]
}
```

## Domain Types

### Beta Managed Agents Agent Params

- `class BetaManagedAgentsAgentParams: …`

  Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

  - `id: str`

    The `agent` ID.

  - `type: Literal["agent"]`

    - `"agent"`

  - `version: Optional[int]`

    The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

### Beta Managed Agents Branch Checkout

- `class BetaManagedAgentsBranchCheckout: …`

  - `name: str`

    Branch name to check out.

  - `type: Literal["branch"]`

    - `"branch"`

### Beta Managed Agents Cache Creation Usage

- `class BetaManagedAgentsCacheCreationUsage: …`

  Prompt-cache creation token usage broken down by cache lifetime.

  - `ephemeral_1h_input_tokens: Optional[int]`

    Tokens used to create 1-hour ephemeral cache entries.

  - `ephemeral_5m_input_tokens: Optional[int]`

    Tokens used to create 5-minute ephemeral cache entries.

### Beta Managed Agents Commit Checkout

- `class BetaManagedAgentsCommitCheckout: …`

  - `sha: str`

    Full commit SHA to check out.

  - `type: Literal["commit"]`

    - `"commit"`

### Beta Managed Agents Deleted Session

- `class BetaManagedAgentsDeletedSession: …`

  Confirmation that a `session` has been permanently deleted.

  - `id: str`

  - `type: Literal["session_deleted"]`

    - `"session_deleted"`

### Beta Managed Agents File Resource Params

- `class BetaManagedAgentsFileResourceParams: …`

  Mount a file uploaded via the Files API into the session.

  - `file_id: str`

    ID of a previously uploaded file.

  - `type: Literal["file"]`

    - `"file"`

  - `mount_path: Optional[str]`

    Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.

### Beta Managed Agents GitHub Repository Resource Params

- `class BetaManagedAgentsGitHubRepositoryResourceParams: …`

  Mount a GitHub repository into the session's container.

  - `authorization_token: str`

    GitHub authorization token used to clone the repository.

  - `type: Literal["github_repository"]`

    - `"github_repository"`

  - `url: str`

    Github URL of the repository

  - `checkout: Optional[Checkout]`

    Branch or commit to check out. Defaults to the repository's default branch.

    - `class BetaManagedAgentsBranchCheckout: …`

      - `name: str`

        Branch name to check out.

      - `type: Literal["branch"]`

        - `"branch"`

    - `class BetaManagedAgentsCommitCheckout: …`

      - `sha: str`

        Full commit SHA to check out.

      - `type: Literal["commit"]`

        - `"commit"`

  - `mount_path: Optional[str]`

    Mount path in the container. Defaults to `/workspace/<repo-name>`.

### Beta Managed Agents Memory Store Resource Param

- `class BetaManagedAgentsMemoryStoreResourceParam: …`

  Parameters for attaching a memory store to an agent session.

  - `memory_store_id: str`

    The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `access: Optional[Literal["read_write", "read_only"]]`

    Access mode for an attached memory store.

    - `"read_write"`

    - `"read_only"`

  - `instructions: Optional[str]`

    Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

### Beta Managed Agents Multiagent

- `class BetaManagedAgentsMultiagent: …`

  Resolved coordinator topology with a concrete agent roster.

  - `agents: List[BetaManagedAgentsAgentReference]`

    Agents the coordinator may spawn as session threads, each resolved to a specific version.

    - `id: str`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

### Beta Managed Agents Multiagent Params

- `class BetaManagedAgentsMultiagentParams: …`

  A coordinator topology: the session's primary thread orchestrates work by spawning session threads, each running an agent drawn from the `agents` roster.

  - `agents: Sequence[BetaManagedAgentsMultiagentRosterEntryParams]`

    Agents the coordinator may spawn as session threads. 1–20 entries. Each entry is an agent ID string, a versioned `{"type":"agent","id","version"}` reference, or `{"type":"self"}` to allow recursive self-invocation. Entries must reference distinct agents (after resolving `self` and string forms); at most one `self`. Referenced agents must exist, must not be archived, and must not themselves have `multiagent` set (depth limit 1).

    - `str`

    - `class BetaManagedAgentsAgentParams: …`

      Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

      - `id: str`

        The `agent` ID.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: Optional[int]`

        The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

    - `class BetaManagedAgentsMultiagentSelfParams: …`

      Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

      - `type: Literal["self"]`

        - `"self"`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

### Beta Managed Agents Multiagent Roster Entry Params

- `BetaManagedAgentsMultiagentRosterEntryParams`

  An entry in a multiagent roster: an agent ID string, a versioned agent reference, or `self`.

  - `str`

  - `class BetaManagedAgentsAgentParams: …`

    Specification for an Agent. Provide a specific `version` or use the short-form `agent="agent_id"` for the most recent version

    - `id: str`

      The `agent` ID.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: Optional[int]`

      The specific `agent` version to use. Omit to use the latest version. Must be at least 1 if specified.

  - `class BetaManagedAgentsMultiagentSelfParams: …`

    Sentinel roster entry meaning "the agent that owns this configuration". Resolved server-side to a concrete agent reference.

    - `type: Literal["self"]`

      - `"self"`

### Beta Managed Agents Outcome Evaluation Resource

- `class BetaManagedAgentsOutcomeEvaluationResource: …`

  Evaluation state for a single outcome defined via a define_outcome event.

  - `completed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: str`

    What the agent should produce.

  - `explanation: Optional[str]`

    Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

  - `iteration: int`

    0-indexed revision cycle the outcome is currently on.

  - `outcome_id: str`

    Server-generated outc_ ID for this outcome.

  - `result: str`

    Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

  - `type: Literal["outcome_evaluation"]`

    - `"outcome_evaluation"`

### Beta Managed Agents Session

- `class BetaManagedAgentsSession: …`

  A Managed Agents `session`.

  - `id: str`

  - `agent: BetaManagedAgentsSessionAgent`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `environment_id: str`

  - `metadata: Dict[str, str]`

  - `outcome_evaluations: List[BetaManagedAgentsOutcomeEvaluationResource]`

    Per-outcome evaluation state. One entry per define_outcome event sent to the session.

    - `completed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `description: str`

      What the agent should produce.

    - `explanation: Optional[str]`

      Grader's verdict text from the most recent evaluation. For satisfied, explains why criteria are met; for needs_revision (intermediate), what's missing; for failed, why unrecoverable.

    - `iteration: int`

      0-indexed revision cycle the outcome is currently on.

    - `outcome_id: str`

      Server-generated outc_ ID for this outcome.

    - `result: str`

      Current evaluation state. `pending` before the agent begins work; `running` while producing or revising; `evaluating` while the grader scores; `satisfied`/`max_iterations_reached`/`failed`/`interrupted` are terminal.

    - `type: Literal["outcome_evaluation"]`

      - `"outcome_evaluation"`

  - `resources: List[BetaManagedAgentsSessionResource]`

    - `class BetaManagedAgentsGitHubRepositoryResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `mount_path: str`

      - `type: Literal["github_repository"]`

        - `"github_repository"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

      - `url: str`

      - `checkout: Optional[Checkout]`

        - `class BetaManagedAgentsBranchCheckout: …`

          - `name: str`

            Branch name to check out.

          - `type: Literal["branch"]`

            - `"branch"`

        - `class BetaManagedAgentsCommitCheckout: …`

          - `sha: str`

            Full commit SHA to check out.

          - `type: Literal["commit"]`

            - `"commit"`

    - `class BetaManagedAgentsFileResource: …`

      - `id: str`

      - `created_at: datetime`

        A timestamp in RFC 3339 format

      - `file_id: str`

      - `mount_path: str`

      - `type: Literal["file"]`

        - `"file"`

      - `updated_at: datetime`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsMemoryStoreResource: …`

      A memory store attached to an agent session.

      - `memory_store_id: str`

        The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

      - `type: Literal["memory_store"]`

        - `"memory_store"`

      - `access: Optional[Literal["read_write", "read_only"]]`

        Access mode for an attached memory store.

        - `"read_write"`

        - `"read_only"`

      - `description: Optional[str]`

        Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

      - `instructions: Optional[str]`

        Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

      - `mount_path: Optional[str]`

        Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

      - `name: Optional[str]`

        Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

  - `stats: BetaManagedAgentsSessionStats`

    Timing statistics for a session.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the session spent in running status. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

  - `status: Literal["rescheduling", "running", "idle", "terminated"]`

    SessionStatus enum

    - `"rescheduling"`

    - `"running"`

    - `"idle"`

    - `"terminated"`

  - `title: Optional[str]`

  - `type: Literal["session"]`

    - `"session"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: BetaManagedAgentsSessionUsage`

    Cumulative token usage for a session across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

  - `vault_ids: List[str]`

    Vault IDs attached to the session at creation. Empty when no vaults were supplied.

### Beta Managed Agents Session Agent

- `class BetaManagedAgentsSessionAgent: …`

  Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

  - `id: str`

  - `description: Optional[str]`

  - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

    - `name: str`

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

  - `model: BetaManagedAgentsModelConfig`

    Model identifier and configuration.

    - `id: BetaManagedAgentsModel`

      The model that will power your agent.

      See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

      - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
        - `claude-opus-4-6` - Most intelligent model for building agents and coding
        - `claude-sonnet-4-6` - Best combination of speed and intelligence
        - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
        - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
        - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
        - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
        - `claude-sonnet-4-5` - High-performance model for agents and coding
        - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

        - `"claude-opus-4-8"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-7"`

          Frontier intelligence for long-running agents and coding

        - `"claude-opus-4-6"`

          Most intelligent model for building agents and coding

        - `"claude-sonnet-4-6"`

          Best combination of speed and intelligence

        - `"claude-haiku-4-5"`

          Fastest model with near-frontier intelligence

        - `"claude-haiku-4-5-20251001"`

          Fastest model with near-frontier intelligence

        - `"claude-opus-4-5"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-opus-4-5-20251101"`

          Premium model combining maximum intelligence with practical performance

        - `"claude-sonnet-4-5"`

          High-performance model for agents and coding

        - `"claude-sonnet-4-5-20250929"`

          High-performance model for agents and coding

      - `str`

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

    Resolved coordinator topology with full agent definitions for each roster member.

    - `agents: List[BetaManagedAgentsSessionThreadAgent]`

      Full `agent` definitions the coordinator may spawn as session threads.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

          - `skill_id: str`

          - `type: Literal["anthropic"]`

            - `"anthropic"`

          - `version: str`

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

          - `skill_id: str`

          - `type: Literal["custom"]`

            - `"custom"`

          - `version: str`

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

          - `configs: List[BetaManagedAgentsAgentToolConfig]`

            - `enabled: bool`

            - `name: Literal["bash", "edit", "read", 5 more]`

              Built-in agent tool identifier.

              - `"bash"`

              - `"edit"`

              - `"read"`

              - `"write"`

              - `"glob"`

              - `"grep"`

              - `"web_fetch"`

              - `"web_search"`

            - `permission_policy: PermissionPolicy`

              Permission policy for tool execution.

              - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                Tool calls are automatically approved without user confirmation.

                - `type: Literal["always_allow"]`

                  - `"always_allow"`

              - `class BetaManagedAgentsAlwaysAskPolicy: …`

                Tool calls require user confirmation before execution.

                - `type: Literal["always_ask"]`

                  - `"always_ask"`

          - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

            Resolved default configuration for agent tools.

            - `enabled: bool`

            - `permission_policy: PermissionPolicy`

              Permission policy for tool execution.

              - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                Tool calls are automatically approved without user confirmation.

              - `class BetaManagedAgentsAlwaysAskPolicy: …`

                Tool calls require user confirmation before execution.

          - `type: Literal["agent_toolset_20260401"]`

            - `"agent_toolset_20260401"`

        - `class BetaManagedAgentsMCPToolset: …`

          - `configs: List[BetaManagedAgentsMCPToolConfig]`

            - `enabled: bool`

            - `name: str`

            - `permission_policy: PermissionPolicy`

              Permission policy for tool execution.

              - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                Tool calls are automatically approved without user confirmation.

              - `class BetaManagedAgentsAlwaysAskPolicy: …`

                Tool calls require user confirmation before execution.

          - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

            Resolved default configuration for all tools from an MCP server.

            - `enabled: bool`

            - `permission_policy: PermissionPolicy`

              Permission policy for tool execution.

              - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                Tool calls are automatically approved without user confirmation.

              - `class BetaManagedAgentsAlwaysAskPolicy: …`

                Tool calls require user confirmation before execution.

          - `mcp_server_name: str`

          - `type: Literal["mcp_toolset"]`

            - `"mcp_toolset"`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

          - `description: str`

          - `input_schema: BetaManagedAgentsCustomToolInputSchema`

            JSON Schema for custom tool input parameters.

            - `properties: Optional[Dict[str, object]]`

              JSON Schema properties defining the tool's input parameters.

            - `required: Optional[List[str]]`

              List of required property names.

            - `type: Optional[Literal["object"]]`

              Must be 'object' for tool input schemas.

              - `"object"`

          - `name: str`

          - `type: Literal["custom"]`

            - `"custom"`

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `type: Literal["coordinator"]`

      - `"coordinator"`

  - `name: str`

  - `skills: List[Skill]`

    - `class BetaManagedAgentsAnthropicSkill: …`

      A resolved Anthropic-managed skill.

    - `class BetaManagedAgentsCustomSkill: …`

      A resolved user-created custom skill.

  - `system: Optional[str]`

  - `tools: List[Tool]`

    - `class BetaManagedAgentsAgentToolset20260401: …`

    - `class BetaManagedAgentsMCPToolset: …`

    - `class BetaManagedAgentsCustomTool: …`

      A custom tool as returned in API responses.

  - `type: Literal["agent"]`

    - `"agent"`

  - `version: int`

### Beta Managed Agents Session Agent Update

- `class BetaManagedAgentsSessionAgentUpdate: …`

  Mid-session agent configuration update. Only `tools` and `mcp_servers` are updatable. Full replacement: the provided array becomes the new value. To preserve existing entries, GET the session, modify the array, and POST it back.

  - `mcp_servers: Optional[List[BetaManagedAgentsURLMCPServerParams]]`

    Replacement MCP server list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve.

    - `name: str`

      Unique name for this server, referenced by mcp_toolset configurations. 1-255 characters.

    - `type: Literal["url"]`

      - `"url"`

    - `url: str`

      Endpoint URL for the MCP server.

  - `tools: Optional[List[Tool]]`

    Replacement tool list. Full replacement: the provided array becomes the new value. Send an empty array to clear; omit to preserve.

    - `class BetaManagedAgentsAgentToolset20260401Params: …`

      Configuration for built-in agent tools. Use this to enable or disable groups of tools available to the agent.

      - `type: Literal["agent_toolset_20260401"]`

        - `"agent_toolset_20260401"`

      - `configs: Optional[List[BetaManagedAgentsAgentToolConfigParams]]`

        Per-tool configuration overrides.

        - `name: Literal["bash", "edit", "read", 5 more]`

          Built-in agent tool identifier.

          - `"bash"`

          - `"edit"`

          - `"read"`

          - `"write"`

          - `"glob"`

          - `"grep"`

          - `"web_fetch"`

          - `"web_search"`

        - `enabled: Optional[bool]`

          Whether this tool is enabled and available to Claude. Overrides the default_config setting.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

            - `type: Literal["always_allow"]`

              - `"always_allow"`

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

            - `type: Literal["always_ask"]`

              - `"always_ask"`

      - `default_config: Optional[BetaManagedAgentsAgentToolsetDefaultConfigParams]`

        Default configuration for all tools in a toolset.

        - `enabled: Optional[bool]`

          Whether tools are enabled and available to Claude by default. Defaults to true if not specified.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

    - `class BetaManagedAgentsMCPToolsetParams: …`

      Configuration for tools from an MCP server defined in `mcp_servers`.

      - `mcp_server_name: str`

        Name of the MCP server. Must match a server name from the mcp_servers array. 1-255 characters.

      - `type: Literal["mcp_toolset"]`

        - `"mcp_toolset"`

      - `configs: Optional[List[BetaManagedAgentsMCPToolConfigParams]]`

        Per-tool configuration overrides.

        - `name: str`

          Name of the MCP tool to configure. 1-128 characters.

        - `enabled: Optional[bool]`

          Whether this tool is enabled. Overrides the `default_config` setting.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

      - `default_config: Optional[BetaManagedAgentsMCPToolsetDefaultConfigParams]`

        Default configuration for all tools from an MCP server.

        - `enabled: Optional[bool]`

          Whether tools are enabled by default. Defaults to true if not specified.

        - `permission_policy: Optional[PermissionPolicy]`

          Permission policy for tool execution.

          - `class BetaManagedAgentsAlwaysAllowPolicy: …`

            Tool calls are automatically approved without user confirmation.

          - `class BetaManagedAgentsAlwaysAskPolicy: …`

            Tool calls require user confirmation before execution.

    - `class BetaManagedAgentsCustomToolParams: …`

      A custom tool that is executed by the API client rather than the agent. When the agent calls this tool, an `agent.custom_tool_use` event is emitted and the session goes idle, waiting for the client to provide the result via a `user.custom_tool_result` event.

      - `description: str`

        Description of what the tool does, shown to the agent to help it decide when to use the tool. 1-1024 characters.

      - `input_schema: BetaManagedAgentsCustomToolInputSchema`

        JSON Schema for custom tool input parameters.

        - `properties: Optional[Dict[str, object]]`

          JSON Schema properties defining the tool's input parameters.

        - `required: Optional[List[str]]`

          List of required property names.

        - `type: Optional[Literal["object"]]`

          Must be 'object' for tool input schemas.

          - `"object"`

      - `name: str`

        Unique name for the tool. 1-128 characters; letters, digits, underscores, and hyphens.

      - `type: Literal["custom"]`

        - `"custom"`

### Beta Managed Agents Session Multiagent Coordinator

- `class BetaManagedAgentsSessionMultiagentCoordinator: …`

  Resolved coordinator topology with full agent definitions for each roster member.

  - `agents: List[BetaManagedAgentsSessionThreadAgent]`

    Full `agent` definitions the coordinator may spawn as session threads.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

        - `skill_id: str`

        - `type: Literal["anthropic"]`

          - `"anthropic"`

        - `version: str`

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

        - `skill_id: str`

        - `type: Literal["custom"]`

          - `"custom"`

        - `version: str`

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

        - `configs: List[BetaManagedAgentsAgentToolConfig]`

          - `enabled: bool`

          - `name: Literal["bash", "edit", "read", 5 more]`

            Built-in agent tool identifier.

            - `"bash"`

            - `"edit"`

            - `"read"`

            - `"write"`

            - `"glob"`

            - `"grep"`

            - `"web_fetch"`

            - `"web_search"`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

              - `type: Literal["always_allow"]`

                - `"always_allow"`

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

              - `type: Literal["always_ask"]`

                - `"always_ask"`

        - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

          Resolved default configuration for agent tools.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `type: Literal["agent_toolset_20260401"]`

          - `"agent_toolset_20260401"`

      - `class BetaManagedAgentsMCPToolset: …`

        - `configs: List[BetaManagedAgentsMCPToolConfig]`

          - `enabled: bool`

          - `name: str`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

          Resolved default configuration for all tools from an MCP server.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `mcp_server_name: str`

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

        - `description: str`

        - `input_schema: BetaManagedAgentsCustomToolInputSchema`

          JSON Schema for custom tool input parameters.

          - `properties: Optional[Dict[str, object]]`

            JSON Schema properties defining the tool's input parameters.

          - `required: Optional[List[str]]`

            List of required property names.

          - `type: Optional[Literal["object"]]`

            Must be 'object' for tool input schemas.

            - `"object"`

        - `name: str`

        - `type: Literal["custom"]`

          - `"custom"`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `type: Literal["coordinator"]`

    - `"coordinator"`

### Beta Managed Agents Session Stats

- `class BetaManagedAgentsSessionStats: …`

  Timing statistics for a session.

  - `active_seconds: Optional[float]`

    Cumulative time in seconds the session spent in running status. Excludes idle time.

  - `duration_seconds: Optional[float]`

    Elapsed time since session creation in seconds. For terminated sessions, frozen at the final update.

### Beta Managed Agents Session Updated Event

- `class BetaManagedAgentsSessionUpdatedEvent: …`

  Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.updated"]`

    - `"session.updated"`

  - `agent: Optional[BetaManagedAgentsSessionAgent]`

    Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

      Resolved coordinator topology with full agent definitions for each roster member.

      - `agents: List[BetaManagedAgentsSessionThreadAgent]`

        Full `agent` definitions the coordinator may spawn as session threads.

        - `id: str`

        - `description: Optional[str]`

        - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

          - `name: str`

          - `type: Literal["url"]`

          - `url: str`

        - `model: BetaManagedAgentsModelConfig`

          Model identifier and configuration.

        - `name: str`

        - `skills: List[Skill]`

          - `class BetaManagedAgentsAnthropicSkill: …`

            A resolved Anthropic-managed skill.

            - `skill_id: str`

            - `type: Literal["anthropic"]`

              - `"anthropic"`

            - `version: str`

          - `class BetaManagedAgentsCustomSkill: …`

            A resolved user-created custom skill.

            - `skill_id: str`

            - `type: Literal["custom"]`

              - `"custom"`

            - `version: str`

        - `system: Optional[str]`

        - `tools: List[Tool]`

          - `class BetaManagedAgentsAgentToolset20260401: …`

            - `configs: List[BetaManagedAgentsAgentToolConfig]`

              - `enabled: bool`

              - `name: Literal["bash", "edit", "read", 5 more]`

                Built-in agent tool identifier.

                - `"bash"`

                - `"edit"`

                - `"read"`

                - `"write"`

                - `"glob"`

                - `"grep"`

                - `"web_fetch"`

                - `"web_search"`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                  - `type: Literal["always_allow"]`

                    - `"always_allow"`

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

                  - `type: Literal["always_ask"]`

                    - `"always_ask"`

            - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

              Resolved default configuration for agent tools.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `type: Literal["agent_toolset_20260401"]`

              - `"agent_toolset_20260401"`

          - `class BetaManagedAgentsMCPToolset: …`

            - `configs: List[BetaManagedAgentsMCPToolConfig]`

              - `enabled: bool`

              - `name: str`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

              Resolved default configuration for all tools from an MCP server.

              - `enabled: bool`

              - `permission_policy: PermissionPolicy`

                Permission policy for tool execution.

                - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                  Tool calls are automatically approved without user confirmation.

                - `class BetaManagedAgentsAlwaysAskPolicy: …`

                  Tool calls require user confirmation before execution.

            - `mcp_server_name: str`

            - `type: Literal["mcp_toolset"]`

              - `"mcp_toolset"`

          - `class BetaManagedAgentsCustomTool: …`

            A custom tool as returned in API responses.

            - `description: str`

            - `input_schema: BetaManagedAgentsCustomToolInputSchema`

              JSON Schema for custom tool input parameters.

              - `properties: Optional[Dict[str, object]]`

                JSON Schema properties defining the tool's input parameters.

              - `required: Optional[List[str]]`

                List of required property names.

              - `type: Optional[Literal["object"]]`

                Must be 'object' for tool input schemas.

                - `"object"`

            - `name: str`

            - `type: Literal["custom"]`

              - `"custom"`

        - `type: Literal["agent"]`

          - `"agent"`

        - `version: int`

      - `type: Literal["coordinator"]`

        - `"coordinator"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

      - `class BetaManagedAgentsMCPToolset: …`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `metadata: Optional[Dict[str, str]]`

    The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

  - `title: Optional[str]`

    The session's new title. Present only when the update changed it.

### Beta Managed Agents Session Usage

- `class BetaManagedAgentsSessionUsage: …`

  Cumulative token usage for a session across all turns.

  - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

    Prompt-cache creation token usage broken down by cache lifetime.

    - `ephemeral_1h_input_tokens: Optional[int]`

      Tokens used to create 1-hour ephemeral cache entries.

    - `ephemeral_5m_input_tokens: Optional[int]`

      Tokens used to create 5-minute ephemeral cache entries.

  - `cache_read_input_tokens: Optional[int]`

    Total tokens read from prompt cache.

  - `input_tokens: Optional[int]`

    Total input tokens consumed across all turns.

  - `output_tokens: Optional[int]`

    Total output tokens generated across all turns.

### Beta Managed Agents User Tool Result Event

- `class BetaManagedAgentsUserToolResultEvent: …`

  Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

  - `id: str`

    Unique identifier for this event.

  - `tool_use_id: str`

    The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.tool_result"]`

    - `"user.tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

  - `processed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `session_thread_id: Optional[str]`

    Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

# Events

## List Events

`beta.sessions.events.list(strsession_id, EventListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsSessionEvent]`

**get** `/v1/sessions/{session_id}/events`

List Events

### Parameters

- `session_id: str`

- `created_at_gt: Optional[Union[str, datetime]]`

  Return events created after this time (exclusive).

- `created_at_gte: Optional[Union[str, datetime]]`

  Return events created at or after this time (inclusive).

- `created_at_lt: Optional[Union[str, datetime]]`

  Return events created before this time (exclusive).

- `created_at_lte: Optional[Union[str, datetime]]`

  Return events created at or before this time (inclusive).

- `limit: Optional[int]`

  Query parameter for limit

- `order: Optional[Literal["asc", "desc"]]`

  Sort direction for results, ordered by created_at. Defaults to asc (chronological).

  - `"asc"`

  - `"desc"`

- `page: Optional[str]`

  Opaque pagination cursor from a previous response's next_page.

- `types: Optional[Sequence[str]]`

  Filter by event type. Values match the `type` field on returned events (for example, `user.message` or `agent.tool_use`). Omit to return all event types.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsSessionEvent`

  Union type for all event types in a session.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.sessions.events.list(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
page = page.data[0]
print(page)
```

#### Response

```json
{
  "data": [
    {
      "id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
      "content": [
        {
          "text": "Where is my order #1234?",
          "type": "text"
        }
      ],
      "type": "user.message",
      "processed_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sevt_011CZkZHPq1jCdq5lbRTjiVnz",
      "content": [
        {
          "text": "Let me look up order #1234 for you.",
          "type": "text"
        }
      ],
      "processed_at": "2026-03-15T10:00:00Z",
      "type": "agent.message"
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Send Events

`beta.sessions.events.send(strsession_id, EventSendParams**kwargs)  -> BetaManagedAgentsSendSessionEvents`

**post** `/v1/sessions/{session_id}/events`

Send Events

### Parameters

- `session_id: str`

- `events: Iterable[BetaManagedAgentsEventParams]`

  Events to send to the `session`.

  - `class BetaManagedAgentsUserMessageEventParams: …`

    Parameters for sending a user message to the session.

    - `content: List[Content]`

      Array of content blocks for the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

  - `class BetaManagedAgentsUserInterruptEventParams: …`

    Parameters for sending an interrupt to pause the agent.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEventParams: …`

    Parameters for confirming or denying a tool execution request.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

  - `class BetaManagedAgentsUserCustomToolResultEventParams: …`

    Parameters for providing the result of a custom tool execution.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsUserDefineOutcomeEventParams: …`

    Parameters for defining an outcome the agent should work toward. The agent begins work on receipt.

    - `description: str`

      What the agent should produce. This is the task specification.

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubricParams: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubricParams: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

    - `max_iterations: Optional[int]`

      Eval→revision cycles before giving up. Default 3, max 20.

  - `class BetaManagedAgentsUserToolResultEventParams: …`

    Parameters for providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSendSessionEvents: …`

  Events that were successfully sent to the session.

  - `data: Optional[List[Data]]`

    Sent events

    - `class BetaManagedAgentsUserMessageEvent: …`

      A user message event in the session conversation.

      - `id: str`

        Unique identifier for this event.

      - `content: List[Content]`

        Array of content blocks comprising the user message.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

          - `source: Source`

            Union type for image source variants.

            - `class BetaManagedAgentsBase64ImageSource: …`

              Base64-encoded image data.

              - `data: str`

                Base64-encoded image data.

              - `media_type: str`

                MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

              - `type: Literal["base64"]`

                - `"base64"`

            - `class BetaManagedAgentsURLImageSource: …`

              Image referenced by URL.

              - `type: Literal["url"]`

                - `"url"`

              - `url: str`

                URL of the image to fetch.

            - `class BetaManagedAgentsFileImageSource: …`

              Image referenced by file ID.

              - `file_id: str`

                ID of a previously uploaded file.

              - `type: Literal["file"]`

                - `"file"`

          - `type: Literal["image"]`

            - `"image"`

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

          - `source: Source`

            Union type for document source variants.

            - `class BetaManagedAgentsBase64DocumentSource: …`

              Base64-encoded document data.

              - `data: str`

                Base64-encoded document data.

              - `media_type: str`

                MIME type of the document (e.g., "application/pdf").

              - `type: Literal["base64"]`

                - `"base64"`

            - `class BetaManagedAgentsPlainTextDocumentSource: …`

              Plain text document content.

              - `data: str`

                The plain text content.

              - `media_type: Literal["text/plain"]`

                MIME type of the text content. Must be "text/plain".

                - `"text/plain"`

              - `type: Literal["text"]`

                - `"text"`

            - `class BetaManagedAgentsURLDocumentSource: …`

              Document referenced by URL.

              - `type: Literal["url"]`

                - `"url"`

              - `url: str`

                URL of the document to fetch.

            - `class BetaManagedAgentsFileDocumentSource: …`

              Document referenced by file ID.

              - `file_id: str`

                ID of a previously uploaded file.

              - `type: Literal["file"]`

                - `"file"`

          - `type: Literal["document"]`

            - `"document"`

          - `context: Optional[str]`

            Additional context about the document for the model.

          - `title: Optional[str]`

            The title of the document.

      - `type: Literal["user.message"]`

        - `"user.message"`

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsUserInterruptEvent: …`

      An interrupt event that pauses agent execution and returns control to the user.

      - `id: str`

        Unique identifier for this event.

      - `type: Literal["user.interrupt"]`

        - `"user.interrupt"`

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

    - `class BetaManagedAgentsUserToolConfirmationEvent: …`

      A tool confirmation event that approves or denies a pending tool execution.

      - `id: str`

        Unique identifier for this event.

      - `result: Literal["allow", "deny"]`

        UserToolConfirmationResult enum

        - `"allow"`

        - `"deny"`

      - `tool_use_id: str`

        The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.tool_confirmation"]`

        - `"user.tool_confirmation"`

      - `deny_message: Optional[str]`

        Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

    - `class BetaManagedAgentsUserCustomToolResultEvent: …`

      Event sent by the client providing the result of a custom tool execution.

      - `id: str`

        Unique identifier for this event.

      - `custom_tool_use_id: str`

        The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.custom_tool_result"]`

        - `"user.custom_tool_result"`

      - `content: Optional[List[Content]]`

        The result content returned by the tool.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `class BetaManagedAgentsSearchResultBlock: …`

          A block containing a web search result.

          - `citations: BetaManagedAgentsSearchResultCitations`

            Citation settings for a search result.

            - `enabled: bool`

              Whether citations are enabled for this search result.

          - `content: List[BetaManagedAgentsSearchResultContent]`

            Array of text content blocks from the search result.

            - `text: str`

              The text content.

            - `type: Literal["text"]`

              - `"text"`

          - `source: str`

            The URL source of the search result.

          - `title: str`

            The title of the search result.

          - `type: Literal["search_result"]`

            - `"search_result"`

      - `is_error: Optional[bool]`

        Whether the tool execution resulted in an error.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

    - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

      Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

      - `id: str`

        Unique identifier for this event.

      - `description: str`

        What the agent should produce. Copied from the input event.

      - `max_iterations: Optional[int]`

        Evaluate-then-revise cycles before giving up. Default 3, max 20.

      - `outcome_id: str`

        Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

      - `processed_at: datetime`

        A timestamp in RFC 3339 format

      - `rubric: Rubric`

        Rubric for grading the quality of an outcome.

        - `class BetaManagedAgentsFileRubric: …`

          Rubric referenced by a file uploaded via the Files API.

          - `file_id: str`

            ID of the rubric file.

          - `type: Literal["file"]`

            - `"file"`

        - `class BetaManagedAgentsTextRubric: …`

          Rubric content provided inline as text.

          - `content: str`

            Rubric content. Plain text or markdown — the grader treats it as freeform text.

          - `type: Literal["text"]`

            - `"text"`

      - `type: Literal["user.define_outcome"]`

        - `"user.define_outcome"`

    - `class BetaManagedAgentsUserToolResultEvent: …`

      Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

      - `id: str`

        Unique identifier for this event.

      - `tool_use_id: str`

        The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.tool_result"]`

        - `"user.tool_result"`

      - `content: Optional[List[Content]]`

        The result content returned by the tool.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `class BetaManagedAgentsSearchResultBlock: …`

          A block containing a web search result.

      - `is_error: Optional[bool]`

        Whether the tool execution resulted in an error.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_send_session_events = client.beta.sessions.events.send(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
    events=[{
        "content": [{
            "text": "Where is my order #1234?",
            "type": "text",
        }],
        "type": "user.message",
    }],
)
print(beta_managed_agents_send_session_events.data)
```

#### Response

```json
{
  "data": [
    {
      "id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
      "content": [
        {
          "text": "Where is my order #1234?",
          "type": "text"
        }
      ],
      "type": "user.message",
      "processed_at": "2026-03-15T10:00:00Z"
    }
  ]
}
```

## Stream Events

`beta.sessions.events.stream(strsession_id, EventStreamParams**kwargs)  -> BetaManagedAgentsStreamSessionEvents`

**get** `/v1/sessions/{session_id}/events/stream`

Stream Events

### Parameters

- `session_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsStreamSessionEvents`

  Server-sent event in the session stream.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
for event in client.beta.sessions.events.stream(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
):
  print(event)
```

#### Response

```json
{
  "id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
  "content": [
    {
      "text": "Where is my order #1234?",
      "type": "text"
    }
  ],
  "type": "user.message",
  "processed_at": "2026-03-15T10:00:00Z"
}
```

## Domain Types

### Beta Managed Agents Agent Custom Tool Use Event

- `class BetaManagedAgentsAgentCustomToolUseEvent: …`

  Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

  - `id: str`

    Unique identifier for this event.

  - `input: Dict[str, object]`

    Input parameters for the tool call.

  - `name: str`

    Name of the custom tool being called.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.custom_tool_use"]`

    - `"agent.custom_tool_use"`

  - `session_thread_id: Optional[str]`

    When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

### Beta Managed Agents Agent MCP Tool Result Event

- `class BetaManagedAgentsAgentMCPToolResultEvent: …`

  Event representing the result of an MCP tool execution.

  - `id: str`

    Unique identifier for this event.

  - `mcp_tool_use_id: str`

    The id of the `agent.mcp_tool_use` event this result corresponds to.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.mcp_tool_result"]`

    - `"agent.mcp_tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

### Beta Managed Agents Agent MCP Tool Use Event

- `class BetaManagedAgentsAgentMCPToolUseEvent: …`

  Event emitted when the agent invokes a tool provided by an MCP server.

  - `id: str`

    Unique identifier for this event.

  - `input: Dict[str, object]`

    Input parameters for the tool call.

  - `mcp_server_name: str`

    Name of the MCP server providing the tool.

  - `name: str`

    Name of the MCP tool being used.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.mcp_tool_use"]`

    - `"agent.mcp_tool_use"`

  - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

    AgentEvaluatedPermission enum

    - `"allow"`

    - `"ask"`

    - `"deny"`

  - `session_thread_id: Optional[str]`

    When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

### Beta Managed Agents Agent Message Event

- `class BetaManagedAgentsAgentMessageEvent: …`

  An agent response event in the session conversation.

  - `id: str`

    Unique identifier for this event.

  - `content: List[BetaManagedAgentsTextBlock]`

    Array of text blocks comprising the agent response.

    - `text: str`

      The text content.

    - `type: Literal["text"]`

      - `"text"`

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.message"]`

    - `"agent.message"`

### Beta Managed Agents Agent Thinking Event

- `class BetaManagedAgentsAgentThinkingEvent: …`

  Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.thinking"]`

    - `"agent.thinking"`

### Beta Managed Agents Agent Thread Context Compacted Event

- `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

  Indicates that context compaction (summarization) occurred during the session.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.thread_context_compacted"]`

    - `"agent.thread_context_compacted"`

### Beta Managed Agents Agent Thread Message Received Event

- `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

  Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

  - `id: str`

    Unique identifier for this event.

  - `content: List[Content]`

    Message content blocks.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

  - `from_session_thread_id: str`

    Public `sthr_` ID of the thread that sent the message.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.thread_message_received"]`

    - `"agent.thread_message_received"`

  - `from_agent_name: Optional[str]`

    Name of the callable agent this message came from. Absent when received from the primary agent.

### Beta Managed Agents Agent Thread Message Sent Event

- `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

  Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

  - `id: str`

    Unique identifier for this event.

  - `content: List[Content]`

    Message content blocks.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `to_session_thread_id: str`

    Public `sthr_` ID of the thread the message was sent to.

  - `type: Literal["agent.thread_message_sent"]`

    - `"agent.thread_message_sent"`

  - `to_agent_name: Optional[str]`

    Name of the callable agent this message was sent to. Absent when sent to the primary agent.

### Beta Managed Agents Agent Tool Result Event

- `class BetaManagedAgentsAgentToolResultEvent: …`

  Event representing the result of an agent tool execution.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `tool_use_id: str`

    The id of the `agent.tool_use` event this result corresponds to.

  - `type: Literal["agent.tool_result"]`

    - `"agent.tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

### Beta Managed Agents Agent Tool Use Event

- `class BetaManagedAgentsAgentToolUseEvent: …`

  Event emitted when the agent invokes a built-in agent tool.

  - `id: str`

    Unique identifier for this event.

  - `input: Dict[str, object]`

    Input parameters for the tool call.

  - `name: str`

    Name of the agent tool being used.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["agent.tool_use"]`

    - `"agent.tool_use"`

  - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

    AgentEvaluatedPermission enum

    - `"allow"`

    - `"ask"`

    - `"deny"`

  - `session_thread_id: Optional[str]`

    When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

### Beta Managed Agents Base64 Document Source

- `class BetaManagedAgentsBase64DocumentSource: …`

  Base64-encoded document data.

  - `data: str`

    Base64-encoded document data.

  - `media_type: str`

    MIME type of the document (e.g., "application/pdf").

  - `type: Literal["base64"]`

    - `"base64"`

### Beta Managed Agents Base64 Image Source

- `class BetaManagedAgentsBase64ImageSource: …`

  Base64-encoded image data.

  - `data: str`

    Base64-encoded image data.

  - `media_type: str`

    MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

  - `type: Literal["base64"]`

    - `"base64"`

### Beta Managed Agents Billing Error

- `class BetaManagedAgentsBillingError: …`

  The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["billing_error"]`

    - `"billing_error"`

### Beta Managed Agents Document Block

- `class BetaManagedAgentsDocumentBlock: …`

  Document content, either specified directly as base64 data, as text, or as a reference via a URL.

  - `source: Source`

    Union type for document source variants.

    - `class BetaManagedAgentsBase64DocumentSource: …`

      Base64-encoded document data.

      - `data: str`

        Base64-encoded document data.

      - `media_type: str`

        MIME type of the document (e.g., "application/pdf").

      - `type: Literal["base64"]`

        - `"base64"`

    - `class BetaManagedAgentsPlainTextDocumentSource: …`

      Plain text document content.

      - `data: str`

        The plain text content.

      - `media_type: Literal["text/plain"]`

        MIME type of the text content. Must be "text/plain".

        - `"text/plain"`

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsURLDocumentSource: …`

      Document referenced by URL.

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

        URL of the document to fetch.

    - `class BetaManagedAgentsFileDocumentSource: …`

      Document referenced by file ID.

      - `file_id: str`

        ID of a previously uploaded file.

      - `type: Literal["file"]`

        - `"file"`

  - `type: Literal["document"]`

    - `"document"`

  - `context: Optional[str]`

    Additional context about the document for the model.

  - `title: Optional[str]`

    The title of the document.

### Beta Managed Agents Event Params

- `BetaManagedAgentsEventParams`

  Union type for event parameters that can be sent to a session.

  - `class BetaManagedAgentsUserMessageEventParams: …`

    Parameters for sending a user message to the session.

    - `content: List[Content]`

      Array of content blocks for the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

  - `class BetaManagedAgentsUserInterruptEventParams: …`

    Parameters for sending an interrupt to pause the agent.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEventParams: …`

    Parameters for confirming or denying a tool execution request.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

  - `class BetaManagedAgentsUserCustomToolResultEventParams: …`

    Parameters for providing the result of a custom tool execution.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsUserDefineOutcomeEventParams: …`

    Parameters for defining an outcome the agent should work toward. The agent begins work on receipt.

    - `description: str`

      What the agent should produce. This is the task specification.

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubricParams: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubricParams: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

    - `max_iterations: Optional[int]`

      Eval→revision cycles before giving up. Default 3, max 20.

  - `class BetaManagedAgentsUserToolResultEventParams: …`

    Parameters for providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

### Beta Managed Agents File Document Source

- `class BetaManagedAgentsFileDocumentSource: …`

  Document referenced by file ID.

  - `file_id: str`

    ID of a previously uploaded file.

  - `type: Literal["file"]`

    - `"file"`

### Beta Managed Agents File Image Source

- `class BetaManagedAgentsFileImageSource: …`

  Image referenced by file ID.

  - `file_id: str`

    ID of a previously uploaded file.

  - `type: Literal["file"]`

    - `"file"`

### Beta Managed Agents File Rubric

- `class BetaManagedAgentsFileRubric: …`

  Rubric referenced by a file uploaded via the Files API.

  - `file_id: str`

    ID of the rubric file.

  - `type: Literal["file"]`

    - `"file"`

### Beta Managed Agents File Rubric Params

- `class BetaManagedAgentsFileRubricParams: …`

  Rubric referenced by a file uploaded via the Files API.

  - `file_id: str`

    ID of the rubric file.

  - `type: Literal["file"]`

    - `"file"`

### Beta Managed Agents Image Block

- `class BetaManagedAgentsImageBlock: …`

  Image content specified directly as base64 data or as a reference via a URL.

  - `source: Source`

    Union type for image source variants.

    - `class BetaManagedAgentsBase64ImageSource: …`

      Base64-encoded image data.

      - `data: str`

        Base64-encoded image data.

      - `media_type: str`

        MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

      - `type: Literal["base64"]`

        - `"base64"`

    - `class BetaManagedAgentsURLImageSource: …`

      Image referenced by URL.

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

        URL of the image to fetch.

    - `class BetaManagedAgentsFileImageSource: …`

      Image referenced by file ID.

      - `file_id: str`

        ID of a previously uploaded file.

      - `type: Literal["file"]`

        - `"file"`

  - `type: Literal["image"]`

    - `"image"`

### Beta Managed Agents MCP Authentication Failed Error

- `class BetaManagedAgentsMCPAuthenticationFailedError: …`

  Authentication to an MCP server failed.

  - `mcp_server_name: str`

    Name of the MCP server that failed authentication.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["mcp_authentication_failed_error"]`

    - `"mcp_authentication_failed_error"`

### Beta Managed Agents MCP Connection Failed Error

- `class BetaManagedAgentsMCPConnectionFailedError: …`

  Failed to connect to an MCP server.

  - `mcp_server_name: str`

    Name of the MCP server that failed to connect.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["mcp_connection_failed_error"]`

    - `"mcp_connection_failed_error"`

### Beta Managed Agents Model Overloaded Error

- `class BetaManagedAgentsModelOverloadedError: …`

  The model is currently overloaded. Emitted after automatic retries are exhausted.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["model_overloaded_error"]`

    - `"model_overloaded_error"`

### Beta Managed Agents Model Rate Limited Error

- `class BetaManagedAgentsModelRateLimitedError: …`

  The model request was rate-limited.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["model_rate_limited_error"]`

    - `"model_rate_limited_error"`

### Beta Managed Agents Model Request Failed Error

- `class BetaManagedAgentsModelRequestFailedError: …`

  A model request failed for a reason other than overload or rate-limiting.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["model_request_failed_error"]`

    - `"model_request_failed_error"`

### Beta Managed Agents Plain Text Document Source

- `class BetaManagedAgentsPlainTextDocumentSource: …`

  Plain text document content.

  - `data: str`

    The plain text content.

  - `media_type: Literal["text/plain"]`

    MIME type of the text content. Must be "text/plain".

    - `"text/plain"`

  - `type: Literal["text"]`

    - `"text"`

### Beta Managed Agents Retry Status Exhausted

- `class BetaManagedAgentsRetryStatusExhausted: …`

  This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

  - `type: Literal["exhausted"]`

    - `"exhausted"`

### Beta Managed Agents Retry Status Retrying

- `class BetaManagedAgentsRetryStatusRetrying: …`

  The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

  - `type: Literal["retrying"]`

    - `"retrying"`

### Beta Managed Agents Retry Status Terminal

- `class BetaManagedAgentsRetryStatusTerminal: …`

  The session encountered a terminal error and will transition to `terminated` state.

  - `type: Literal["terminal"]`

    - `"terminal"`

### Beta Managed Agents Search Result Block

- `class BetaManagedAgentsSearchResultBlock: …`

  A block containing a web search result.

  - `citations: BetaManagedAgentsSearchResultCitations`

    Citation settings for a search result.

    - `enabled: bool`

      Whether citations are enabled for this search result.

  - `content: List[BetaManagedAgentsSearchResultContent]`

    Array of text content blocks from the search result.

    - `text: str`

      The text content.

    - `type: Literal["text"]`

      - `"text"`

  - `source: str`

    The URL source of the search result.

  - `title: str`

    The title of the search result.

  - `type: Literal["search_result"]`

    - `"search_result"`

### Beta Managed Agents Search Result Citations

- `class BetaManagedAgentsSearchResultCitations: …`

  Citation settings for a search result.

  - `enabled: bool`

    Whether citations are enabled for this search result.

### Beta Managed Agents Search Result Content

- `class BetaManagedAgentsSearchResultContent: …`

  Text content within a search result.

  - `text: str`

    The text content.

  - `type: Literal["text"]`

    - `"text"`

### Beta Managed Agents Send Session Events

- `class BetaManagedAgentsSendSessionEvents: …`

  Events that were successfully sent to the session.

  - `data: Optional[List[Data]]`

    Sent events

    - `class BetaManagedAgentsUserMessageEvent: …`

      A user message event in the session conversation.

      - `id: str`

        Unique identifier for this event.

      - `content: List[Content]`

        Array of content blocks comprising the user message.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

          - `source: Source`

            Union type for image source variants.

            - `class BetaManagedAgentsBase64ImageSource: …`

              Base64-encoded image data.

              - `data: str`

                Base64-encoded image data.

              - `media_type: str`

                MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

              - `type: Literal["base64"]`

                - `"base64"`

            - `class BetaManagedAgentsURLImageSource: …`

              Image referenced by URL.

              - `type: Literal["url"]`

                - `"url"`

              - `url: str`

                URL of the image to fetch.

            - `class BetaManagedAgentsFileImageSource: …`

              Image referenced by file ID.

              - `file_id: str`

                ID of a previously uploaded file.

              - `type: Literal["file"]`

                - `"file"`

          - `type: Literal["image"]`

            - `"image"`

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

          - `source: Source`

            Union type for document source variants.

            - `class BetaManagedAgentsBase64DocumentSource: …`

              Base64-encoded document data.

              - `data: str`

                Base64-encoded document data.

              - `media_type: str`

                MIME type of the document (e.g., "application/pdf").

              - `type: Literal["base64"]`

                - `"base64"`

            - `class BetaManagedAgentsPlainTextDocumentSource: …`

              Plain text document content.

              - `data: str`

                The plain text content.

              - `media_type: Literal["text/plain"]`

                MIME type of the text content. Must be "text/plain".

                - `"text/plain"`

              - `type: Literal["text"]`

                - `"text"`

            - `class BetaManagedAgentsURLDocumentSource: …`

              Document referenced by URL.

              - `type: Literal["url"]`

                - `"url"`

              - `url: str`

                URL of the document to fetch.

            - `class BetaManagedAgentsFileDocumentSource: …`

              Document referenced by file ID.

              - `file_id: str`

                ID of a previously uploaded file.

              - `type: Literal["file"]`

                - `"file"`

          - `type: Literal["document"]`

            - `"document"`

          - `context: Optional[str]`

            Additional context about the document for the model.

          - `title: Optional[str]`

            The title of the document.

      - `type: Literal["user.message"]`

        - `"user.message"`

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

    - `class BetaManagedAgentsUserInterruptEvent: …`

      An interrupt event that pauses agent execution and returns control to the user.

      - `id: str`

        Unique identifier for this event.

      - `type: Literal["user.interrupt"]`

        - `"user.interrupt"`

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

    - `class BetaManagedAgentsUserToolConfirmationEvent: …`

      A tool confirmation event that approves or denies a pending tool execution.

      - `id: str`

        Unique identifier for this event.

      - `result: Literal["allow", "deny"]`

        UserToolConfirmationResult enum

        - `"allow"`

        - `"deny"`

      - `tool_use_id: str`

        The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.tool_confirmation"]`

        - `"user.tool_confirmation"`

      - `deny_message: Optional[str]`

        Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

    - `class BetaManagedAgentsUserCustomToolResultEvent: …`

      Event sent by the client providing the result of a custom tool execution.

      - `id: str`

        Unique identifier for this event.

      - `custom_tool_use_id: str`

        The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.custom_tool_result"]`

        - `"user.custom_tool_result"`

      - `content: Optional[List[Content]]`

        The result content returned by the tool.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `class BetaManagedAgentsSearchResultBlock: …`

          A block containing a web search result.

          - `citations: BetaManagedAgentsSearchResultCitations`

            Citation settings for a search result.

            - `enabled: bool`

              Whether citations are enabled for this search result.

          - `content: List[BetaManagedAgentsSearchResultContent]`

            Array of text content blocks from the search result.

            - `text: str`

              The text content.

            - `type: Literal["text"]`

              - `"text"`

          - `source: str`

            The URL source of the search result.

          - `title: str`

            The title of the search result.

          - `type: Literal["search_result"]`

            - `"search_result"`

      - `is_error: Optional[bool]`

        Whether the tool execution resulted in an error.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

    - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

      Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

      - `id: str`

        Unique identifier for this event.

      - `description: str`

        What the agent should produce. Copied from the input event.

      - `max_iterations: Optional[int]`

        Evaluate-then-revise cycles before giving up. Default 3, max 20.

      - `outcome_id: str`

        Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

      - `processed_at: datetime`

        A timestamp in RFC 3339 format

      - `rubric: Rubric`

        Rubric for grading the quality of an outcome.

        - `class BetaManagedAgentsFileRubric: …`

          Rubric referenced by a file uploaded via the Files API.

          - `file_id: str`

            ID of the rubric file.

          - `type: Literal["file"]`

            - `"file"`

        - `class BetaManagedAgentsTextRubric: …`

          Rubric content provided inline as text.

          - `content: str`

            Rubric content. Plain text or markdown — the grader treats it as freeform text.

          - `type: Literal["text"]`

            - `"text"`

      - `type: Literal["user.define_outcome"]`

        - `"user.define_outcome"`

    - `class BetaManagedAgentsUserToolResultEvent: …`

      Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

      - `id: str`

        Unique identifier for this event.

      - `tool_use_id: str`

        The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

      - `type: Literal["user.tool_result"]`

        - `"user.tool_result"`

      - `content: Optional[List[Content]]`

        The result content returned by the tool.

        - `class BetaManagedAgentsTextBlock: …`

          Regular text content.

        - `class BetaManagedAgentsImageBlock: …`

          Image content specified directly as base64 data or as a reference via a URL.

        - `class BetaManagedAgentsDocumentBlock: …`

          Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `class BetaManagedAgentsSearchResultBlock: …`

          A block containing a web search result.

      - `is_error: Optional[bool]`

        Whether the tool execution resulted in an error.

      - `processed_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `session_thread_id: Optional[str]`

        Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

### Beta Managed Agents Session Deleted Event

- `class BetaManagedAgentsSessionDeletedEvent: …`

  Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.deleted"]`

    - `"session.deleted"`

### Beta Managed Agents Session End Turn

- `class BetaManagedAgentsSessionEndTurn: …`

  The agent completed its turn naturally and is ready for the next user message.

  - `type: Literal["end_turn"]`

    - `"end_turn"`

### Beta Managed Agents Session Error Event

- `class BetaManagedAgentsSessionErrorEvent: …`

  An error event indicating a problem occurred during session execution.

  - `id: str`

    Unique identifier for this event.

  - `error: Error`

    An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

    - `class BetaManagedAgentsUnknownError: …`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `type: Literal["retrying"]`

            - `"retrying"`

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `type: Literal["exhausted"]`

            - `"exhausted"`

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

          - `type: Literal["terminal"]`

            - `"terminal"`

      - `type: Literal["unknown_error"]`

        - `"unknown_error"`

    - `class BetaManagedAgentsModelOverloadedError: …`

      The model is currently overloaded. Emitted after automatic retries are exhausted.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["model_overloaded_error"]`

        - `"model_overloaded_error"`

    - `class BetaManagedAgentsModelRateLimitedError: …`

      The model request was rate-limited.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["model_rate_limited_error"]`

        - `"model_rate_limited_error"`

    - `class BetaManagedAgentsModelRequestFailedError: …`

      A model request failed for a reason other than overload or rate-limiting.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["model_request_failed_error"]`

        - `"model_request_failed_error"`

    - `class BetaManagedAgentsMCPConnectionFailedError: …`

      Failed to connect to an MCP server.

      - `mcp_server_name: str`

        Name of the MCP server that failed to connect.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["mcp_connection_failed_error"]`

        - `"mcp_connection_failed_error"`

    - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

      Authentication to an MCP server failed.

      - `mcp_server_name: str`

        Name of the MCP server that failed authentication.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["mcp_authentication_failed_error"]`

        - `"mcp_authentication_failed_error"`

    - `class BetaManagedAgentsBillingError: …`

      The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

      - `message: str`

        Human-readable error description.

      - `retry_status: RetryStatus`

        What the client should do next in response to this error.

        - `class BetaManagedAgentsRetryStatusRetrying: …`

          The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

        - `class BetaManagedAgentsRetryStatusExhausted: …`

          This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

        - `class BetaManagedAgentsRetryStatusTerminal: …`

          The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["billing_error"]`

        - `"billing_error"`

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.error"]`

    - `"session.error"`

### Beta Managed Agents Session Event

- `BetaManagedAgentsSessionEvent`

  Union type for all event types in a session.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Beta Managed Agents Session Requires Action

- `class BetaManagedAgentsSessionRequiresAction: …`

  The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

  - `event_ids: List[str]`

    The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

  - `type: Literal["requires_action"]`

    - `"requires_action"`

### Beta Managed Agents Session Retries Exhausted

- `class BetaManagedAgentsSessionRetriesExhausted: …`

  The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

  - `type: Literal["retries_exhausted"]`

    - `"retries_exhausted"`

### Beta Managed Agents Session Status Idle Event

- `class BetaManagedAgentsSessionStatusIdleEvent: …`

  Indicates the agent has paused and is awaiting user input.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `stop_reason: StopReason`

    The agent completed its turn naturally and is ready for the next user message.

    - `class BetaManagedAgentsSessionEndTurn: …`

      The agent completed its turn naturally and is ready for the next user message.

      - `type: Literal["end_turn"]`

        - `"end_turn"`

    - `class BetaManagedAgentsSessionRequiresAction: …`

      The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `event_ids: List[str]`

        The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

      - `type: Literal["requires_action"]`

        - `"requires_action"`

    - `class BetaManagedAgentsSessionRetriesExhausted: …`

      The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

      - `type: Literal["retries_exhausted"]`

        - `"retries_exhausted"`

  - `type: Literal["session.status_idle"]`

    - `"session.status_idle"`

### Beta Managed Agents Session Status Rescheduled Event

- `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

  Indicates the session is recovering from an error state and is rescheduled for execution.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.status_rescheduled"]`

    - `"session.status_rescheduled"`

### Beta Managed Agents Session Status Running Event

- `class BetaManagedAgentsSessionStatusRunningEvent: …`

  Indicates the session is actively running and the agent is working.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.status_running"]`

    - `"session.status_running"`

### Beta Managed Agents Session Status Terminated Event

- `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

  Indicates the session has terminated, either due to an error or completion.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["session.status_terminated"]`

    - `"session.status_terminated"`

### Beta Managed Agents Session Thread Created Event

- `class BetaManagedAgentsSessionThreadCreatedEvent: …`

  Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

  - `id: str`

    Unique identifier for this event.

  - `agent_name: str`

    Name of the callable agent the thread runs.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `session_thread_id: str`

    Public `sthr_` ID of the newly created thread.

  - `type: Literal["session.thread_created"]`

    - `"session.thread_created"`

### Beta Managed Agents Session Thread Status Idle Event

- `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

  A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

  - `id: str`

    Unique identifier for this event.

  - `agent_name: str`

    Name of the agent the thread runs.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `session_thread_id: str`

    Public sthr_ ID of the thread that went idle.

  - `stop_reason: StopReason`

    The agent completed its turn naturally and is ready for the next user message.

    - `class BetaManagedAgentsSessionEndTurn: …`

      The agent completed its turn naturally and is ready for the next user message.

      - `type: Literal["end_turn"]`

        - `"end_turn"`

    - `class BetaManagedAgentsSessionRequiresAction: …`

      The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `event_ids: List[str]`

        The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

      - `type: Literal["requires_action"]`

        - `"requires_action"`

    - `class BetaManagedAgentsSessionRetriesExhausted: …`

      The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

      - `type: Literal["retries_exhausted"]`

        - `"retries_exhausted"`

  - `type: Literal["session.thread_status_idle"]`

    - `"session.thread_status_idle"`

### Beta Managed Agents Session Thread Status Rescheduled Event

- `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

  A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

  - `id: str`

    Unique identifier for this event.

  - `agent_name: str`

    Name of the agent the thread runs.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `session_thread_id: str`

    Public sthr_ ID of the thread that is retrying.

  - `type: Literal["session.thread_status_rescheduled"]`

    - `"session.thread_status_rescheduled"`

### Beta Managed Agents Session Thread Status Running Event

- `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

  A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

  - `id: str`

    Unique identifier for this event.

  - `agent_name: str`

    Name of the agent the thread runs.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `session_thread_id: str`

    Public sthr_ ID of the thread that started running.

  - `type: Literal["session.thread_status_running"]`

    - `"session.thread_status_running"`

### Beta Managed Agents Session Thread Status Terminated Event

- `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

  A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

  - `id: str`

    Unique identifier for this event.

  - `agent_name: str`

    Name of the agent the thread runs.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `session_thread_id: str`

    Public sthr_ ID of the thread that terminated.

  - `type: Literal["session.thread_status_terminated"]`

    - `"session.thread_status_terminated"`

### Beta Managed Agents Span Model Request End Event

- `class BetaManagedAgentsSpanModelRequestEndEvent: …`

  Emitted when a model request completes.

  - `id: str`

    Unique identifier for this event.

  - `is_error: Optional[bool]`

    Whether the model request resulted in an error.

  - `model_request_start_id: str`

    The id of the corresponding `span.model_request_start` event.

  - `model_usage: BetaManagedAgentsSpanModelUsage`

    Token usage for a single model request.

    - `cache_creation_input_tokens: int`

      Tokens used to create prompt cache in this request.

    - `cache_read_input_tokens: int`

      Tokens read from prompt cache in this request.

    - `input_tokens: int`

      Input tokens consumed by this request.

    - `output_tokens: int`

      Output tokens generated by this request.

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["span.model_request_end"]`

    - `"span.model_request_end"`

### Beta Managed Agents Span Model Request Start Event

- `class BetaManagedAgentsSpanModelRequestStartEvent: …`

  Emitted when a model request is initiated by the agent.

  - `id: str`

    Unique identifier for this event.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["span.model_request_start"]`

    - `"span.model_request_start"`

### Beta Managed Agents Span Model Usage

- `class BetaManagedAgentsSpanModelUsage: …`

  Token usage for a single model request.

  - `cache_creation_input_tokens: int`

    Tokens used to create prompt cache in this request.

  - `cache_read_input_tokens: int`

    Tokens read from prompt cache in this request.

  - `input_tokens: int`

    Input tokens consumed by this request.

  - `output_tokens: int`

    Output tokens generated by this request.

  - `speed: Optional[Literal["standard", "fast"]]`

    Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

    - `"standard"`

    - `"fast"`

### Beta Managed Agents Span Outcome Evaluation End Event

- `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

  Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

  - `id: str`

    Unique identifier for this event.

  - `explanation: str`

    Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

  - `iteration: int`

    0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

  - `outcome_evaluation_start_id: str`

    The id of the corresponding `span.outcome_evaluation_start` event.

  - `outcome_id: str`

    The `outc_` ID of the outcome being evaluated.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `result: str`

    Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

  - `type: Literal["span.outcome_evaluation_end"]`

    - `"span.outcome_evaluation_end"`

  - `usage: BetaManagedAgentsSpanModelUsage`

    Token usage for a single model request.

    - `cache_creation_input_tokens: int`

      Tokens used to create prompt cache in this request.

    - `cache_read_input_tokens: int`

      Tokens read from prompt cache in this request.

    - `input_tokens: int`

      Input tokens consumed by this request.

    - `output_tokens: int`

      Output tokens generated by this request.

    - `speed: Optional[Literal["standard", "fast"]]`

      Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

      - `"standard"`

      - `"fast"`

### Beta Managed Agents Span Outcome Evaluation Ongoing Event

- `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

  Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

  - `id: str`

    Unique identifier for this event.

  - `iteration: int`

    0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

  - `outcome_id: str`

    The `outc_` ID of the outcome being evaluated.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["span.outcome_evaluation_ongoing"]`

    - `"span.outcome_evaluation_ongoing"`

### Beta Managed Agents Span Outcome Evaluation Start Event

- `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

  Emitted when an outcome evaluation cycle begins.

  - `id: str`

    Unique identifier for this event.

  - `iteration: int`

    0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

  - `outcome_id: str`

    The `outc_` ID of the outcome being evaluated.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["span.outcome_evaluation_start"]`

    - `"span.outcome_evaluation_start"`

### Beta Managed Agents Stream Session Events

- `BetaManagedAgentsStreamSessionEvents`

  Server-sent event in the session stream.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Beta Managed Agents Text Block

- `class BetaManagedAgentsTextBlock: …`

  Regular text content.

  - `text: str`

    The text content.

  - `type: Literal["text"]`

    - `"text"`

### Beta Managed Agents Text Rubric

- `class BetaManagedAgentsTextRubric: …`

  Rubric content provided inline as text.

  - `content: str`

    Rubric content. Plain text or markdown — the grader treats it as freeform text.

  - `type: Literal["text"]`

    - `"text"`

### Beta Managed Agents Text Rubric Params

- `class BetaManagedAgentsTextRubricParams: …`

  Rubric content provided inline as text.

  - `content: str`

    Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters.

  - `type: Literal["text"]`

    - `"text"`

### Beta Managed Agents Unknown Error

- `class BetaManagedAgentsUnknownError: …`

  An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

  - `message: str`

    Human-readable error description.

  - `retry_status: RetryStatus`

    What the client should do next in response to this error.

    - `class BetaManagedAgentsRetryStatusRetrying: …`

      The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

      - `type: Literal["retrying"]`

        - `"retrying"`

    - `class BetaManagedAgentsRetryStatusExhausted: …`

      This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

      - `type: Literal["exhausted"]`

        - `"exhausted"`

    - `class BetaManagedAgentsRetryStatusTerminal: …`

      The session encountered a terminal error and will transition to `terminated` state.

      - `type: Literal["terminal"]`

        - `"terminal"`

  - `type: Literal["unknown_error"]`

    - `"unknown_error"`

### Beta Managed Agents URL Document Source

- `class BetaManagedAgentsURLDocumentSource: …`

  Document referenced by URL.

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

    URL of the document to fetch.

### Beta Managed Agents URL Image Source

- `class BetaManagedAgentsURLImageSource: …`

  Image referenced by URL.

  - `type: Literal["url"]`

    - `"url"`

  - `url: str`

    URL of the image to fetch.

### Beta Managed Agents User Custom Tool Result Event

- `class BetaManagedAgentsUserCustomToolResultEvent: …`

  Event sent by the client providing the result of a custom tool execution.

  - `id: str`

    Unique identifier for this event.

  - `custom_tool_use_id: str`

    The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.custom_tool_result"]`

    - `"user.custom_tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

  - `processed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `session_thread_id: Optional[str]`

    Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

### Beta Managed Agents User Custom Tool Result Event Params

- `class BetaManagedAgentsUserCustomToolResultEventParams: …`

  Parameters for providing the result of a custom tool execution.

  - `custom_tool_use_id: str`

    The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.custom_tool_result"]`

    - `"user.custom_tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

### Beta Managed Agents User Define Outcome Event

- `class BetaManagedAgentsUserDefineOutcomeEvent: …`

  Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

  - `id: str`

    Unique identifier for this event.

  - `description: str`

    What the agent should produce. Copied from the input event.

  - `max_iterations: Optional[int]`

    Evaluate-then-revise cycles before giving up. Default 3, max 20.

  - `outcome_id: str`

    Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

  - `processed_at: datetime`

    A timestamp in RFC 3339 format

  - `rubric: Rubric`

    Rubric for grading the quality of an outcome.

    - `class BetaManagedAgentsFileRubric: …`

      Rubric referenced by a file uploaded via the Files API.

      - `file_id: str`

        ID of the rubric file.

      - `type: Literal["file"]`

        - `"file"`

    - `class BetaManagedAgentsTextRubric: …`

      Rubric content provided inline as text.

      - `content: str`

        Rubric content. Plain text or markdown — the grader treats it as freeform text.

      - `type: Literal["text"]`

        - `"text"`

  - `type: Literal["user.define_outcome"]`

    - `"user.define_outcome"`

### Beta Managed Agents User Define Outcome Event Params

- `class BetaManagedAgentsUserDefineOutcomeEventParams: …`

  Parameters for defining an outcome the agent should work toward. The agent begins work on receipt.

  - `description: str`

    What the agent should produce. This is the task specification.

  - `rubric: Rubric`

    Rubric for grading the quality of an outcome.

    - `class BetaManagedAgentsFileRubricParams: …`

      Rubric referenced by a file uploaded via the Files API.

      - `file_id: str`

        ID of the rubric file.

      - `type: Literal["file"]`

        - `"file"`

    - `class BetaManagedAgentsTextRubricParams: …`

      Rubric content provided inline as text.

      - `content: str`

        Rubric content. Plain text or markdown — the grader treats it as freeform text. Maximum 262144 characters.

      - `type: Literal["text"]`

        - `"text"`

  - `type: Literal["user.define_outcome"]`

    - `"user.define_outcome"`

  - `max_iterations: Optional[int]`

    Eval→revision cycles before giving up. Default 3, max 20.

### Beta Managed Agents User Interrupt Event

- `class BetaManagedAgentsUserInterruptEvent: …`

  An interrupt event that pauses agent execution and returns control to the user.

  - `id: str`

    Unique identifier for this event.

  - `type: Literal["user.interrupt"]`

    - `"user.interrupt"`

  - `processed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `session_thread_id: Optional[str]`

    If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

### Beta Managed Agents User Interrupt Event Params

- `class BetaManagedAgentsUserInterruptEventParams: …`

  Parameters for sending an interrupt to pause the agent.

  - `type: Literal["user.interrupt"]`

    - `"user.interrupt"`

  - `session_thread_id: Optional[str]`

    If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

### Beta Managed Agents User Message Event

- `class BetaManagedAgentsUserMessageEvent: …`

  A user message event in the session conversation.

  - `id: str`

    Unique identifier for this event.

  - `content: List[Content]`

    Array of content blocks comprising the user message.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

  - `type: Literal["user.message"]`

    - `"user.message"`

  - `processed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

### Beta Managed Agents User Message Event Params

- `class BetaManagedAgentsUserMessageEventParams: …`

  Parameters for sending a user message to the session.

  - `content: List[Content]`

    Array of content blocks for the user message.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

  - `type: Literal["user.message"]`

    - `"user.message"`

### Beta Managed Agents User Tool Confirmation Event

- `class BetaManagedAgentsUserToolConfirmationEvent: …`

  A tool confirmation event that approves or denies a pending tool execution.

  - `id: str`

    Unique identifier for this event.

  - `result: Literal["allow", "deny"]`

    UserToolConfirmationResult enum

    - `"allow"`

    - `"deny"`

  - `tool_use_id: str`

    The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.tool_confirmation"]`

    - `"user.tool_confirmation"`

  - `deny_message: Optional[str]`

    Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

  - `processed_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `session_thread_id: Optional[str]`

    When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

### Beta Managed Agents User Tool Confirmation Event Params

- `class BetaManagedAgentsUserToolConfirmationEventParams: …`

  Parameters for confirming or denying a tool execution request.

  - `result: Literal["allow", "deny"]`

    UserToolConfirmationResult enum

    - `"allow"`

    - `"deny"`

  - `tool_use_id: str`

    The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.tool_confirmation"]`

    - `"user.tool_confirmation"`

  - `deny_message: Optional[str]`

    Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

### Beta Managed Agents User Tool Result Event Params

- `class BetaManagedAgentsUserToolResultEventParams: …`

  Parameters for providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

  - `tool_use_id: str`

    The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

  - `type: Literal["user.tool_result"]`

    - `"user.tool_result"`

  - `content: Optional[List[Content]]`

    The result content returned by the tool.

    - `class BetaManagedAgentsTextBlock: …`

      Regular text content.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

        - `"text"`

    - `class BetaManagedAgentsImageBlock: …`

      Image content specified directly as base64 data or as a reference via a URL.

      - `source: Source`

        Union type for image source variants.

        - `class BetaManagedAgentsBase64ImageSource: …`

          Base64-encoded image data.

          - `data: str`

            Base64-encoded image data.

          - `media_type: str`

            MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsURLImageSource: …`

          Image referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the image to fetch.

        - `class BetaManagedAgentsFileImageSource: …`

          Image referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["image"]`

        - `"image"`

    - `class BetaManagedAgentsDocumentBlock: …`

      Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `source: Source`

        Union type for document source variants.

        - `class BetaManagedAgentsBase64DocumentSource: …`

          Base64-encoded document data.

          - `data: str`

            Base64-encoded document data.

          - `media_type: str`

            MIME type of the document (e.g., "application/pdf").

          - `type: Literal["base64"]`

            - `"base64"`

        - `class BetaManagedAgentsPlainTextDocumentSource: …`

          Plain text document content.

          - `data: str`

            The plain text content.

          - `media_type: Literal["text/plain"]`

            MIME type of the text content. Must be "text/plain".

            - `"text/plain"`

          - `type: Literal["text"]`

            - `"text"`

        - `class BetaManagedAgentsURLDocumentSource: …`

          Document referenced by URL.

          - `type: Literal["url"]`

            - `"url"`

          - `url: str`

            URL of the document to fetch.

        - `class BetaManagedAgentsFileDocumentSource: …`

          Document referenced by file ID.

          - `file_id: str`

            ID of a previously uploaded file.

          - `type: Literal["file"]`

            - `"file"`

      - `type: Literal["document"]`

        - `"document"`

      - `context: Optional[str]`

        Additional context about the document for the model.

      - `title: Optional[str]`

        The title of the document.

    - `class BetaManagedAgentsSearchResultBlock: …`

      A block containing a web search result.

      - `citations: BetaManagedAgentsSearchResultCitations`

        Citation settings for a search result.

        - `enabled: bool`

          Whether citations are enabled for this search result.

      - `content: List[BetaManagedAgentsSearchResultContent]`

        Array of text content blocks from the search result.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `source: str`

        The URL source of the search result.

      - `title: str`

        The title of the search result.

      - `type: Literal["search_result"]`

        - `"search_result"`

  - `is_error: Optional[bool]`

    Whether the tool execution resulted in an error.

# Resources

## Add Session Resource

`beta.sessions.resources.add(strsession_id, ResourceAddParams**kwargs)  -> BetaManagedAgentsFileResource`

**post** `/v1/sessions/{session_id}/resources`

Add Session Resource

### Parameters

- `session_id: str`

- `file_id: str`

  ID of a previously uploaded file.

- `type: Literal["file"]`

  - `"file"`

- `mount_path: Optional[str]`

  Mount path in the container. Defaults to `/mnt/session/uploads/<file_id>`.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsFileResource: …`

  - `id: str`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `file_id: str`

  - `mount_path: str`

  - `type: Literal["file"]`

    - `"file"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_file_resource = client.beta.sessions.resources.add(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
    file_id="file_011CNha8iCJcU1wXNR6q4V8w",
    type="file",
)
print(beta_managed_agents_file_resource.id)
```

#### Response

```json
{
  "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
  "created_at": "2026-03-15T10:00:00Z",
  "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
  "mount_path": "/uploads/receipt.pdf",
  "type": "file",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

## List Session Resources

`beta.sessions.resources.list(strsession_id, ResourceListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsSessionResource]`

**get** `/v1/sessions/{session_id}/resources`

List Session Resources

### Parameters

- `session_id: str`

- `limit: Optional[int]`

  Maximum number of resources to return per page (max 1000). If omitted, returns all resources.

- `page: Optional[str]`

  Opaque cursor from a previous response's next_page field.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsSessionResource`

  A memory store attached to an agent session.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.sessions.resources.list(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
page = page.data[0]
print(page)
```

#### Response

```json
{
  "data": [
    {
      "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
      "created_at": "2026-03-15T10:00:00Z",
      "file_id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "mount_path": "/uploads/receipt.pdf",
      "type": "file",
      "updated_at": "2026-03-15T10:00:00Z"
    },
    {
      "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
      "created_at": "2026-03-15T10:00:00Z",
      "mount_path": "/workspace/example-repo",
      "type": "github_repository",
      "updated_at": "2026-03-15T10:00:00Z",
      "url": "https://github.com/example-org/example-repo",
      "checkout": {
        "name": "main",
        "type": "branch"
      }
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Session Resource

`beta.sessions.resources.retrieve(strresource_id, ResourceRetrieveParams**kwargs)  -> ResourceRetrieveResponse`

**get** `/v1/sessions/{session_id}/resources/{resource_id}`

Get Session Resource

### Parameters

- `session_id: str`

- `resource_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `ResourceRetrieveResponse`

  The requested session resource.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
resource = client.beta.sessions.resources.retrieve(
    resource_id="sesrsc_011CZkZBJq5dWxk9fVLNcPht",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(resource)
```

#### Response

```json
{
  "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
  "created_at": "2026-03-15T10:00:00Z",
  "mount_path": "/workspace/example-repo",
  "type": "github_repository",
  "updated_at": "2026-03-15T10:00:00Z",
  "url": "https://github.com/example-org/example-repo",
  "checkout": {
    "name": "main",
    "type": "branch"
  }
}
```

## Update Session Resource

`beta.sessions.resources.update(strresource_id, ResourceUpdateParams**kwargs)  -> ResourceUpdateResponse`

**post** `/v1/sessions/{session_id}/resources/{resource_id}`

Update Session Resource

### Parameters

- `session_id: str`

- `resource_id: str`

- `authorization_token: str`

  New authorization token for the resource. Currently only `github_repository` resources support token rotation.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `ResourceUpdateResponse`

  The updated session resource.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
resource = client.beta.sessions.resources.update(
    resource_id="sesrsc_011CZkZBJq5dWxk9fVLNcPht",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
    authorization_token="ghp_exampletoken",
)
print(resource)
```

#### Response

```json
{
  "id": "sesrsc_011CZkZCKr6eXyl0gWMOdQiu",
  "created_at": "2026-03-15T10:00:00Z",
  "mount_path": "/workspace/example-repo",
  "type": "github_repository",
  "updated_at": "2026-03-15T10:00:00Z",
  "url": "https://github.com/example-org/example-repo",
  "checkout": {
    "name": "main",
    "type": "branch"
  }
}
```

## Delete Session Resource

`beta.sessions.resources.delete(strresource_id, ResourceDeleteParams**kwargs)  -> BetaManagedAgentsDeleteSessionResource`

**delete** `/v1/sessions/{session_id}/resources/{resource_id}`

Delete Session Resource

### Parameters

- `session_id: str`

- `resource_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeleteSessionResource: …`

  Confirmation of resource deletion.

  - `id: str`

  - `type: Literal["session_resource_deleted"]`

    - `"session_resource_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_delete_session_resource = client.beta.sessions.resources.delete(
    resource_id="sesrsc_011CZkZBJq5dWxk9fVLNcPht",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_delete_session_resource.id)
```

#### Response

```json
{
  "id": "sesrsc_011CZkZBJq5dWxk9fVLNcPht",
  "type": "session_resource_deleted"
}
```

## Domain Types

### Beta Managed Agents Delete Session Resource

- `class BetaManagedAgentsDeleteSessionResource: …`

  Confirmation of resource deletion.

  - `id: str`

  - `type: Literal["session_resource_deleted"]`

    - `"session_resource_deleted"`

### Beta Managed Agents File Resource

- `class BetaManagedAgentsFileResource: …`

  - `id: str`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `file_id: str`

  - `mount_path: str`

  - `type: Literal["file"]`

    - `"file"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Beta Managed Agents GitHub Repository Resource

- `class BetaManagedAgentsGitHubRepositoryResource: …`

  - `id: str`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `mount_path: str`

  - `type: Literal["github_repository"]`

    - `"github_repository"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `url: str`

  - `checkout: Optional[Checkout]`

    - `class BetaManagedAgentsBranchCheckout: …`

      - `name: str`

        Branch name to check out.

      - `type: Literal["branch"]`

        - `"branch"`

    - `class BetaManagedAgentsCommitCheckout: …`

      - `sha: str`

        Full commit SHA to check out.

      - `type: Literal["commit"]`

        - `"commit"`

### Beta Managed Agents Memory Store Resource

- `class BetaManagedAgentsMemoryStoreResource: …`

  A memory store attached to an agent session.

  - `memory_store_id: str`

    The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `access: Optional[Literal["read_write", "read_only"]]`

    Access mode for an attached memory store.

    - `"read_write"`

    - `"read_only"`

  - `description: Optional[str]`

    Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

  - `instructions: Optional[str]`

    Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

  - `mount_path: Optional[str]`

    Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

  - `name: Optional[str]`

    Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Beta Managed Agents Session Resource

- `BetaManagedAgentsSessionResource`

  A memory store attached to an agent session.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Resource Retrieve Response

- `ResourceRetrieveResponse`

  The requested session resource.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

### Resource Update Response

- `ResourceUpdateResponse`

  The updated session resource.

  - `class BetaManagedAgentsGitHubRepositoryResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `mount_path: str`

    - `type: Literal["github_repository"]`

      - `"github_repository"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `url: str`

    - `checkout: Optional[Checkout]`

      - `class BetaManagedAgentsBranchCheckout: …`

        - `name: str`

          Branch name to check out.

        - `type: Literal["branch"]`

          - `"branch"`

      - `class BetaManagedAgentsCommitCheckout: …`

        - `sha: str`

          Full commit SHA to check out.

        - `type: Literal["commit"]`

          - `"commit"`

  - `class BetaManagedAgentsFileResource: …`

    - `id: str`

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `file_id: str`

    - `mount_path: str`

    - `type: Literal["file"]`

      - `"file"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsMemoryStoreResource: …`

    A memory store attached to an agent session.

    - `memory_store_id: str`

      The memory store ID (memstore_...). Must belong to the caller's organization and workspace.

    - `type: Literal["memory_store"]`

      - `"memory_store"`

    - `access: Optional[Literal["read_write", "read_only"]]`

      Access mode for an attached memory store.

      - `"read_write"`

      - `"read_only"`

    - `description: Optional[str]`

      Description of the memory store, snapshotted at attach time. Rendered into the agent's system prompt. Empty string when the store has no description.

    - `instructions: Optional[str]`

      Per-attachment guidance for the agent on how to use this store. Rendered into the memory section of the system prompt. Max 4096 chars.

    - `mount_path: Optional[str]`

      Filesystem path where the store is mounted in the session container, e.g. /mnt/memory/user-preferences. Derived from the store's name. Output-only.

    - `name: Optional[str]`

      Display name of the memory store, snapshotted at attach time. Later edits to the store's name do not propagate to this resource.

# Threads

## List Session Threads

`beta.sessions.threads.list(strsession_id, ThreadListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsSessionThread]`

**get** `/v1/sessions/{session_id}/threads`

List Session Threads

### Parameters

- `session_id: str`

- `limit: Optional[int]`

  Maximum results per page. Defaults to 1000.

- `page: Optional[str]`

  Opaque pagination cursor from a previous response's next_page. Forward-only.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSessionThread: …`

  An execution thread within a `session`. Each session has one primary thread plus zero or more child threads spawned by the coordinator.

  - `id: str`

    Unique identifier for this thread.

  - `agent: BetaManagedAgentsSessionThreadAgent`

    Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

        - `skill_id: str`

        - `type: Literal["anthropic"]`

          - `"anthropic"`

        - `version: str`

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

        - `skill_id: str`

        - `type: Literal["custom"]`

          - `"custom"`

        - `version: str`

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

        - `configs: List[BetaManagedAgentsAgentToolConfig]`

          - `enabled: bool`

          - `name: Literal["bash", "edit", "read", 5 more]`

            Built-in agent tool identifier.

            - `"bash"`

            - `"edit"`

            - `"read"`

            - `"write"`

            - `"glob"`

            - `"grep"`

            - `"web_fetch"`

            - `"web_search"`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

              - `type: Literal["always_allow"]`

                - `"always_allow"`

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

              - `type: Literal["always_ask"]`

                - `"always_ask"`

        - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

          Resolved default configuration for agent tools.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `type: Literal["agent_toolset_20260401"]`

          - `"agent_toolset_20260401"`

      - `class BetaManagedAgentsMCPToolset: …`

        - `configs: List[BetaManagedAgentsMCPToolConfig]`

          - `enabled: bool`

          - `name: str`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

          Resolved default configuration for all tools from an MCP server.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `mcp_server_name: str`

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

        - `description: str`

        - `input_schema: BetaManagedAgentsCustomToolInputSchema`

          JSON Schema for custom tool input parameters.

          - `properties: Optional[Dict[str, object]]`

            JSON Schema properties defining the tool's input parameters.

          - `required: Optional[List[str]]`

            List of required property names.

          - `type: Optional[Literal["object"]]`

            Must be 'object' for tool input schemas.

            - `"object"`

        - `name: str`

        - `type: Literal["custom"]`

          - `"custom"`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `parent_thread_id: Optional[str]`

    Parent thread that spawned this thread. Null for the primary thread.

  - `session_id: str`

    The session this thread belongs to.

  - `stats: Optional[BetaManagedAgentsSessionThreadStats]`

    Timing statistics for a session thread.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the thread spent actively running. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.

    - `startup_seconds: Optional[float]`

      Time in seconds for the thread to begin running. Zero for child threads, which start immediately.

  - `status: BetaManagedAgentsSessionThreadStatus`

    SessionThreadStatus enum

    - `"running"`

    - `"idle"`

    - `"rescheduling"`

    - `"terminated"`

  - `type: Literal["session_thread"]`

    - `"session_thread"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: Optional[BetaManagedAgentsSessionThreadUsage]`

    Cumulative token usage for a session thread across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.sessions.threads.list(
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "sthr_011CZkZVWa6oIjw0rgXZpnBt",
      "agent": {
        "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
        "description": "A focused research subagent.",
        "mcp_servers": [
          {
            "name": "example-mcp",
            "type": "url",
            "url": "https://example-server.modelcontextprotocol.io/sse"
          }
        ],
        "model": {
          "id": "claude-sonnet-4-6",
          "speed": "standard"
        },
        "name": "Researcher",
        "skills": [
          {
            "skill_id": "xlsx",
            "type": "anthropic",
            "version": "1"
          }
        ],
        "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
        "tools": [
          {
            "configs": [
              {
                "enabled": true,
                "name": "bash",
                "permission_policy": {
                  "type": "always_allow"
                }
              }
            ],
            "default_config": {
              "enabled": true,
              "permission_policy": {
                "type": "always_ask"
              }
            },
            "type": "agent_toolset_20260401"
          }
        ],
        "type": "agent",
        "version": 1
      },
      "archived_at": null,
      "created_at": "2026-03-15T10:00:00Z",
      "parent_thread_id": null,
      "session_id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
      "stats": {
        "active_seconds": 0,
        "duration_seconds": 0,
        "startup_seconds": 0
      },
      "status": "idle",
      "type": "session_thread",
      "updated_at": "2026-03-15T10:00:00Z",
      "usage": {
        "cache_creation": {
          "ephemeral_1h_input_tokens": 0,
          "ephemeral_5m_input_tokens": 0
        },
        "cache_read_input_tokens": 0,
        "input_tokens": 0,
        "output_tokens": 0
      }
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Session Thread

`beta.sessions.threads.retrieve(strthread_id, ThreadRetrieveParams**kwargs)  -> BetaManagedAgentsSessionThread`

**get** `/v1/sessions/{session_id}/threads/{thread_id}`

Get Session Thread

### Parameters

- `session_id: str`

- `thread_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSessionThread: …`

  An execution thread within a `session`. Each session has one primary thread plus zero or more child threads spawned by the coordinator.

  - `id: str`

    Unique identifier for this thread.

  - `agent: BetaManagedAgentsSessionThreadAgent`

    Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

        - `skill_id: str`

        - `type: Literal["anthropic"]`

          - `"anthropic"`

        - `version: str`

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

        - `skill_id: str`

        - `type: Literal["custom"]`

          - `"custom"`

        - `version: str`

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

        - `configs: List[BetaManagedAgentsAgentToolConfig]`

          - `enabled: bool`

          - `name: Literal["bash", "edit", "read", 5 more]`

            Built-in agent tool identifier.

            - `"bash"`

            - `"edit"`

            - `"read"`

            - `"write"`

            - `"glob"`

            - `"grep"`

            - `"web_fetch"`

            - `"web_search"`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

              - `type: Literal["always_allow"]`

                - `"always_allow"`

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

              - `type: Literal["always_ask"]`

                - `"always_ask"`

        - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

          Resolved default configuration for agent tools.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `type: Literal["agent_toolset_20260401"]`

          - `"agent_toolset_20260401"`

      - `class BetaManagedAgentsMCPToolset: …`

        - `configs: List[BetaManagedAgentsMCPToolConfig]`

          - `enabled: bool`

          - `name: str`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

          Resolved default configuration for all tools from an MCP server.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `mcp_server_name: str`

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

        - `description: str`

        - `input_schema: BetaManagedAgentsCustomToolInputSchema`

          JSON Schema for custom tool input parameters.

          - `properties: Optional[Dict[str, object]]`

            JSON Schema properties defining the tool's input parameters.

          - `required: Optional[List[str]]`

            List of required property names.

          - `type: Optional[Literal["object"]]`

            Must be 'object' for tool input schemas.

            - `"object"`

        - `name: str`

        - `type: Literal["custom"]`

          - `"custom"`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `parent_thread_id: Optional[str]`

    Parent thread that spawned this thread. Null for the primary thread.

  - `session_id: str`

    The session this thread belongs to.

  - `stats: Optional[BetaManagedAgentsSessionThreadStats]`

    Timing statistics for a session thread.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the thread spent actively running. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.

    - `startup_seconds: Optional[float]`

      Time in seconds for the thread to begin running. Zero for child threads, which start immediately.

  - `status: BetaManagedAgentsSessionThreadStatus`

    SessionThreadStatus enum

    - `"running"`

    - `"idle"`

    - `"rescheduling"`

    - `"terminated"`

  - `type: Literal["session_thread"]`

    - `"session_thread"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: Optional[BetaManagedAgentsSessionThreadUsage]`

    Cumulative token usage for a session thread across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session_thread = client.beta.sessions.threads.retrieve(
    thread_id="sthr_011CZkZVWa6oIjw0rgXZpnBt",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_session_thread.id)
```

#### Response

```json
{
  "id": "sthr_011CZkZVWa6oIjw0rgXZpnBt",
  "agent": {
    "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
    "description": "A focused research subagent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "name": "Researcher",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      }
    ],
    "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "parent_thread_id": null,
  "session_id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0,
    "startup_seconds": 0
  },
  "status": "idle",
  "type": "session_thread",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## Archive Session Thread

`beta.sessions.threads.archive(strthread_id, ThreadArchiveParams**kwargs)  -> BetaManagedAgentsSessionThread`

**post** `/v1/sessions/{session_id}/threads/{thread_id}/archive`

Archive Session Thread

### Parameters

- `session_id: str`

- `thread_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsSessionThread: …`

  An execution thread within a `session`. Each session has one primary thread plus zero or more child threads spawned by the coordinator.

  - `id: str`

    Unique identifier for this thread.

  - `agent: BetaManagedAgentsSessionThreadAgent`

    Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

        - `skill_id: str`

        - `type: Literal["anthropic"]`

          - `"anthropic"`

        - `version: str`

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

        - `skill_id: str`

        - `type: Literal["custom"]`

          - `"custom"`

        - `version: str`

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

        - `configs: List[BetaManagedAgentsAgentToolConfig]`

          - `enabled: bool`

          - `name: Literal["bash", "edit", "read", 5 more]`

            Built-in agent tool identifier.

            - `"bash"`

            - `"edit"`

            - `"read"`

            - `"write"`

            - `"glob"`

            - `"grep"`

            - `"web_fetch"`

            - `"web_search"`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

              - `type: Literal["always_allow"]`

                - `"always_allow"`

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

              - `type: Literal["always_ask"]`

                - `"always_ask"`

        - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

          Resolved default configuration for agent tools.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `type: Literal["agent_toolset_20260401"]`

          - `"agent_toolset_20260401"`

      - `class BetaManagedAgentsMCPToolset: …`

        - `configs: List[BetaManagedAgentsMCPToolConfig]`

          - `enabled: bool`

          - `name: str`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

          Resolved default configuration for all tools from an MCP server.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `mcp_server_name: str`

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

        - `description: str`

        - `input_schema: BetaManagedAgentsCustomToolInputSchema`

          JSON Schema for custom tool input parameters.

          - `properties: Optional[Dict[str, object]]`

            JSON Schema properties defining the tool's input parameters.

          - `required: Optional[List[str]]`

            List of required property names.

          - `type: Optional[Literal["object"]]`

            Must be 'object' for tool input schemas.

            - `"object"`

        - `name: str`

        - `type: Literal["custom"]`

          - `"custom"`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `parent_thread_id: Optional[str]`

    Parent thread that spawned this thread. Null for the primary thread.

  - `session_id: str`

    The session this thread belongs to.

  - `stats: Optional[BetaManagedAgentsSessionThreadStats]`

    Timing statistics for a session thread.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the thread spent actively running. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.

    - `startup_seconds: Optional[float]`

      Time in seconds for the thread to begin running. Zero for child threads, which start immediately.

  - `status: BetaManagedAgentsSessionThreadStatus`

    SessionThreadStatus enum

    - `"running"`

    - `"idle"`

    - `"rescheduling"`

    - `"terminated"`

  - `type: Literal["session_thread"]`

    - `"session_thread"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: Optional[BetaManagedAgentsSessionThreadUsage]`

    Cumulative token usage for a session thread across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_session_thread = client.beta.sessions.threads.archive(
    thread_id="sthr_011CZkZVWa6oIjw0rgXZpnBt",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
print(beta_managed_agents_session_thread.id)
```

#### Response

```json
{
  "id": "sthr_011CZkZVWa6oIjw0rgXZpnBt",
  "agent": {
    "id": "agent_011CZkYqphY8vELVzwCUpqiQ",
    "description": "A focused research subagent.",
    "mcp_servers": [
      {
        "name": "example-mcp",
        "type": "url",
        "url": "https://example-server.modelcontextprotocol.io/sse"
      }
    ],
    "model": {
      "id": "claude-sonnet-4-6",
      "speed": "standard"
    },
    "name": "Researcher",
    "skills": [
      {
        "skill_id": "xlsx",
        "type": "anthropic",
        "version": "1"
      }
    ],
    "system": "You are a research subagent that gathers and summarises sources for the coordinating agent.",
    "tools": [
      {
        "configs": [
          {
            "enabled": true,
            "name": "bash",
            "permission_policy": {
              "type": "always_allow"
            }
          }
        ],
        "default_config": {
          "enabled": true,
          "permission_policy": {
            "type": "always_ask"
          }
        },
        "type": "agent_toolset_20260401"
      }
    ],
    "type": "agent",
    "version": 1
  },
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "parent_thread_id": null,
  "session_id": "sesn_011CZkZAtmR3yMPDzynEDxu7",
  "stats": {
    "active_seconds": 0,
    "duration_seconds": 0,
    "startup_seconds": 0
  },
  "status": "idle",
  "type": "session_thread",
  "updated_at": "2026-03-15T10:00:00Z",
  "usage": {
    "cache_creation": {
      "ephemeral_1h_input_tokens": 0,
      "ephemeral_5m_input_tokens": 0
    },
    "cache_read_input_tokens": 0,
    "input_tokens": 0,
    "output_tokens": 0
  }
}
```

## Domain Types

### Beta Managed Agents Session Thread

- `class BetaManagedAgentsSessionThread: …`

  An execution thread within a `session`. Each session has one primary thread plus zero or more child threads spawned by the coordinator.

  - `id: str`

    Unique identifier for this thread.

  - `agent: BetaManagedAgentsSessionThreadAgent`

    Resolved `agent` definition for a single `session_thread`. Snapshot of the agent at thread creation time. The multiagent roster is not repeated here; read it from `Session.agent`.

    - `id: str`

    - `description: Optional[str]`

    - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

      - `name: str`

      - `type: Literal["url"]`

        - `"url"`

      - `url: str`

    - `model: BetaManagedAgentsModelConfig`

      Model identifier and configuration.

      - `id: BetaManagedAgentsModel`

        The model that will power your agent.

        See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

        - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
          - `claude-opus-4-6` - Most intelligent model for building agents and coding
          - `claude-sonnet-4-6` - Best combination of speed and intelligence
          - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
          - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
          - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
          - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
          - `claude-sonnet-4-5` - High-performance model for agents and coding
          - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

          - `"claude-opus-4-8"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-7"`

            Frontier intelligence for long-running agents and coding

          - `"claude-opus-4-6"`

            Most intelligent model for building agents and coding

          - `"claude-sonnet-4-6"`

            Best combination of speed and intelligence

          - `"claude-haiku-4-5"`

            Fastest model with near-frontier intelligence

          - `"claude-haiku-4-5-20251001"`

            Fastest model with near-frontier intelligence

          - `"claude-opus-4-5"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-opus-4-5-20251101"`

            Premium model combining maximum intelligence with practical performance

          - `"claude-sonnet-4-5"`

            High-performance model for agents and coding

          - `"claude-sonnet-4-5-20250929"`

            High-performance model for agents and coding

        - `str`

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

    - `name: str`

    - `skills: List[Skill]`

      - `class BetaManagedAgentsAnthropicSkill: …`

        A resolved Anthropic-managed skill.

        - `skill_id: str`

        - `type: Literal["anthropic"]`

          - `"anthropic"`

        - `version: str`

      - `class BetaManagedAgentsCustomSkill: …`

        A resolved user-created custom skill.

        - `skill_id: str`

        - `type: Literal["custom"]`

          - `"custom"`

        - `version: str`

    - `system: Optional[str]`

    - `tools: List[Tool]`

      - `class BetaManagedAgentsAgentToolset20260401: …`

        - `configs: List[BetaManagedAgentsAgentToolConfig]`

          - `enabled: bool`

          - `name: Literal["bash", "edit", "read", 5 more]`

            Built-in agent tool identifier.

            - `"bash"`

            - `"edit"`

            - `"read"`

            - `"write"`

            - `"glob"`

            - `"grep"`

            - `"web_fetch"`

            - `"web_search"`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

              - `type: Literal["always_allow"]`

                - `"always_allow"`

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

              - `type: Literal["always_ask"]`

                - `"always_ask"`

        - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

          Resolved default configuration for agent tools.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `type: Literal["agent_toolset_20260401"]`

          - `"agent_toolset_20260401"`

      - `class BetaManagedAgentsMCPToolset: …`

        - `configs: List[BetaManagedAgentsMCPToolConfig]`

          - `enabled: bool`

          - `name: str`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

          Resolved default configuration for all tools from an MCP server.

          - `enabled: bool`

          - `permission_policy: PermissionPolicy`

            Permission policy for tool execution.

            - `class BetaManagedAgentsAlwaysAllowPolicy: …`

              Tool calls are automatically approved without user confirmation.

            - `class BetaManagedAgentsAlwaysAskPolicy: …`

              Tool calls require user confirmation before execution.

        - `mcp_server_name: str`

        - `type: Literal["mcp_toolset"]`

          - `"mcp_toolset"`

      - `class BetaManagedAgentsCustomTool: …`

        A custom tool as returned in API responses.

        - `description: str`

        - `input_schema: BetaManagedAgentsCustomToolInputSchema`

          JSON Schema for custom tool input parameters.

          - `properties: Optional[Dict[str, object]]`

            JSON Schema properties defining the tool's input parameters.

          - `required: Optional[List[str]]`

            List of required property names.

          - `type: Optional[Literal["object"]]`

            Must be 'object' for tool input schemas.

            - `"object"`

        - `name: str`

        - `type: Literal["custom"]`

          - `"custom"`

    - `type: Literal["agent"]`

      - `"agent"`

    - `version: int`

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `parent_thread_id: Optional[str]`

    Parent thread that spawned this thread. Null for the primary thread.

  - `session_id: str`

    The session this thread belongs to.

  - `stats: Optional[BetaManagedAgentsSessionThreadStats]`

    Timing statistics for a session thread.

    - `active_seconds: Optional[float]`

      Cumulative time in seconds the thread spent actively running. Excludes idle time.

    - `duration_seconds: Optional[float]`

      Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.

    - `startup_seconds: Optional[float]`

      Time in seconds for the thread to begin running. Zero for child threads, which start immediately.

  - `status: BetaManagedAgentsSessionThreadStatus`

    SessionThreadStatus enum

    - `"running"`

    - `"idle"`

    - `"rescheduling"`

    - `"terminated"`

  - `type: Literal["session_thread"]`

    - `"session_thread"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `usage: Optional[BetaManagedAgentsSessionThreadUsage]`

    Cumulative token usage for a session thread across all turns.

    - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

      Prompt-cache creation token usage broken down by cache lifetime.

      - `ephemeral_1h_input_tokens: Optional[int]`

        Tokens used to create 1-hour ephemeral cache entries.

      - `ephemeral_5m_input_tokens: Optional[int]`

        Tokens used to create 5-minute ephemeral cache entries.

    - `cache_read_input_tokens: Optional[int]`

      Total tokens read from prompt cache.

    - `input_tokens: Optional[int]`

      Total input tokens consumed across all turns.

    - `output_tokens: Optional[int]`

      Total output tokens generated across all turns.

### Beta Managed Agents Session Thread Stats

- `class BetaManagedAgentsSessionThreadStats: …`

  Timing statistics for a session thread.

  - `active_seconds: Optional[float]`

    Cumulative time in seconds the thread spent actively running. Excludes idle time.

  - `duration_seconds: Optional[float]`

    Elapsed time since thread creation in seconds. For archived threads, frozen at the final update.

  - `startup_seconds: Optional[float]`

    Time in seconds for the thread to begin running. Zero for child threads, which start immediately.

### Beta Managed Agents Session Thread Status

- `Literal["running", "idle", "rescheduling", "terminated"]`

  SessionThreadStatus enum

  - `"running"`

  - `"idle"`

  - `"rescheduling"`

  - `"terminated"`

### Beta Managed Agents Session Thread Usage

- `class BetaManagedAgentsSessionThreadUsage: …`

  Cumulative token usage for a session thread across all turns.

  - `cache_creation: Optional[BetaManagedAgentsCacheCreationUsage]`

    Prompt-cache creation token usage broken down by cache lifetime.

    - `ephemeral_1h_input_tokens: Optional[int]`

      Tokens used to create 1-hour ephemeral cache entries.

    - `ephemeral_5m_input_tokens: Optional[int]`

      Tokens used to create 5-minute ephemeral cache entries.

  - `cache_read_input_tokens: Optional[int]`

    Total tokens read from prompt cache.

  - `input_tokens: Optional[int]`

    Total input tokens consumed across all turns.

  - `output_tokens: Optional[int]`

    Total output tokens generated across all turns.

### Beta Managed Agents Stream Session Thread Events

- `BetaManagedAgentsStreamSessionThreadEvents`

  Server-sent event in a single thread's stream.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

# Events

## List Session Thread Events

`beta.sessions.threads.events.list(strthread_id, EventListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsSessionEvent]`

**get** `/v1/sessions/{session_id}/threads/{thread_id}/events`

List Session Thread Events

### Parameters

- `session_id: str`

- `thread_id: str`

- `limit: Optional[int]`

  Query parameter for limit

- `page: Optional[str]`

  Query parameter for page

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsSessionEvent`

  Union type for all event types in a session.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.sessions.threads.events.list(
    thread_id="sthr_011CZkZVWa6oIjw0rgXZpnBt",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
)
page = page.data[0]
print(page)
```

#### Response

```json
{
  "data": [
    {
      "id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
      "content": [
        {
          "text": "Where is my order #1234?",
          "type": "text"
        }
      ],
      "type": "user.message",
      "processed_at": "2026-03-15T10:00:00Z"
    }
  ],
  "next_page": "next_page"
}
```

## Stream Session Thread Events

`beta.sessions.threads.events.stream(strthread_id, EventStreamParams**kwargs)  -> BetaManagedAgentsStreamSessionThreadEvents`

**get** `/v1/sessions/{session_id}/threads/{thread_id}/stream`

Stream Session Thread Events

### Parameters

- `session_id: str`

- `thread_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsStreamSessionThreadEvents`

  Server-sent event in a single thread's stream.

  - `class BetaManagedAgentsUserMessageEvent: …`

    A user message event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Array of content blocks comprising the user message.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

        - `text: str`

          The text content.

        - `type: Literal["text"]`

          - `"text"`

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

        - `source: Source`

          Union type for image source variants.

          - `class BetaManagedAgentsBase64ImageSource: …`

            Base64-encoded image data.

            - `data: str`

              Base64-encoded image data.

            - `media_type: str`

              MIME type of the image (e.g., "image/png", "image/jpeg", "image/gif", "image/webp").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsURLImageSource: …`

            Image referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the image to fetch.

          - `class BetaManagedAgentsFileImageSource: …`

            Image referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["image"]`

          - `"image"`

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

        - `source: Source`

          Union type for document source variants.

          - `class BetaManagedAgentsBase64DocumentSource: …`

            Base64-encoded document data.

            - `data: str`

              Base64-encoded document data.

            - `media_type: str`

              MIME type of the document (e.g., "application/pdf").

            - `type: Literal["base64"]`

              - `"base64"`

          - `class BetaManagedAgentsPlainTextDocumentSource: …`

            Plain text document content.

            - `data: str`

              The plain text content.

            - `media_type: Literal["text/plain"]`

              MIME type of the text content. Must be "text/plain".

              - `"text/plain"`

            - `type: Literal["text"]`

              - `"text"`

          - `class BetaManagedAgentsURLDocumentSource: …`

            Document referenced by URL.

            - `type: Literal["url"]`

              - `"url"`

            - `url: str`

              URL of the document to fetch.

          - `class BetaManagedAgentsFileDocumentSource: …`

            Document referenced by file ID.

            - `file_id: str`

              ID of a previously uploaded file.

            - `type: Literal["file"]`

              - `"file"`

        - `type: Literal["document"]`

          - `"document"`

        - `context: Optional[str]`

          Additional context about the document for the model.

        - `title: Optional[str]`

          The title of the document.

    - `type: Literal["user.message"]`

      - `"user.message"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

  - `class BetaManagedAgentsUserInterruptEvent: …`

    An interrupt event that pauses agent execution and returns control to the user.

    - `id: str`

      Unique identifier for this event.

    - `type: Literal["user.interrupt"]`

      - `"user.interrupt"`

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      If absent, interrupts every non-archived thread in a multiagent session (or the primary alone in a single-agent session). If present, interrupts only the named thread.

  - `class BetaManagedAgentsUserToolConfirmationEvent: …`

    A tool confirmation event that approves or denies a pending tool execution.

    - `id: str`

      Unique identifier for this event.

    - `result: Literal["allow", "deny"]`

      UserToolConfirmationResult enum

      - `"allow"`

      - `"deny"`

    - `tool_use_id: str`

      The id of the `agent.tool_use` or `agent.mcp_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_confirmation"]`

      - `"user.tool_confirmation"`

    - `deny_message: Optional[str]`

      Optional message providing context for a 'deny' decision. Only allowed when result is 'deny'.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      When set, the confirmation routes to this subagent's thread rather than the primary. Echo this from the `session_thread_id` on the `agent.tool_use` or `agent.mcp_tool_use` event that prompted the approval.

  - `class BetaManagedAgentsUserCustomToolResultEvent: …`

    Event sent by the client providing the result of a custom tool execution.

    - `id: str`

      Unique identifier for this event.

    - `custom_tool_use_id: str`

      The id of the `agent.custom_tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.custom_tool_result"]`

      - `"user.custom_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

        - `citations: BetaManagedAgentsSearchResultCitations`

          Citation settings for a search result.

          - `enabled: bool`

            Whether citations are enabled for this search result.

        - `content: List[BetaManagedAgentsSearchResultContent]`

          Array of text content blocks from the search result.

          - `text: str`

            The text content.

          - `type: Literal["text"]`

            - `"text"`

        - `source: str`

          The URL source of the search result.

        - `title: str`

          The title of the search result.

        - `type: Literal["search_result"]`

          - `"search_result"`

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.custom_tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsAgentCustomToolUseEvent: …`

    Event emitted when the agent calls a custom tool. The session goes idle until the client sends a `user.custom_tool_result` event with the result.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the custom tool being called.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.custom_tool_use"]`

      - `"agent.custom_tool_use"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its custom tool use on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.custom_tool_result` event to route the result back.

  - `class BetaManagedAgentsAgentMessageEvent: …`

    An agent response event in the session conversation.

    - `id: str`

      Unique identifier for this event.

    - `content: List[BetaManagedAgentsTextBlock]`

      Array of text blocks comprising the agent response.

      - `text: str`

        The text content.

      - `type: Literal["text"]`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.message"]`

      - `"agent.message"`

  - `class BetaManagedAgentsAgentThinkingEvent: …`

    Indicates the agent is making forward progress via extended thinking. A progress signal, not a content carrier.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thinking"]`

      - `"agent.thinking"`

  - `class BetaManagedAgentsAgentMCPToolUseEvent: …`

    Event emitted when the agent invokes a tool provided by an MCP server.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `mcp_server_name: str`

      Name of the MCP server providing the tool.

    - `name: str`

      Name of the MCP tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_use"]`

      - `"agent.mcp_tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentMCPToolResultEvent: …`

    Event representing the result of an MCP tool execution.

    - `id: str`

      Unique identifier for this event.

    - `mcp_tool_use_id: str`

      The id of the `agent.mcp_tool_use` event this result corresponds to.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.mcp_tool_result"]`

      - `"agent.mcp_tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentToolUseEvent: …`

    Event emitted when the agent invokes a built-in agent tool.

    - `id: str`

      Unique identifier for this event.

    - `input: Dict[str, object]`

      Input parameters for the tool call.

    - `name: str`

      Name of the agent tool being used.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.tool_use"]`

      - `"agent.tool_use"`

    - `evaluated_permission: Optional[Literal["allow", "ask", "deny"]]`

      AgentEvaluatedPermission enum

      - `"allow"`

      - `"ask"`

      - `"deny"`

    - `session_thread_id: Optional[str]`

      When set, this event was cross-posted from a subagent's thread to surface its permission request on the primary thread's stream. Empty on the thread's own events. Echo this on a `user.tool_confirmation` event to route the approval back.

  - `class BetaManagedAgentsAgentToolResultEvent: …`

    Event representing the result of an agent tool execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to.

    - `type: Literal["agent.tool_result"]`

      - `"agent.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

  - `class BetaManagedAgentsAgentThreadMessageReceivedEvent: …`

    Delivery event written to the target thread's input stream when an agent-to-agent message arrives.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `from_session_thread_id: str`

      Public `sthr_` ID of the thread that sent the message.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_message_received"]`

      - `"agent.thread_message_received"`

    - `from_agent_name: Optional[str]`

      Name of the callable agent this message came from. Absent when received from the primary agent.

  - `class BetaManagedAgentsAgentThreadMessageSentEvent: …`

    Observability event emitted to the sender's output stream when an agent-to-agent message is sent.

    - `id: str`

      Unique identifier for this event.

    - `content: List[Content]`

      Message content blocks.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `to_session_thread_id: str`

      Public `sthr_` ID of the thread the message was sent to.

    - `type: Literal["agent.thread_message_sent"]`

      - `"agent.thread_message_sent"`

    - `to_agent_name: Optional[str]`

      Name of the callable agent this message was sent to. Absent when sent to the primary agent.

  - `class BetaManagedAgentsAgentThreadContextCompactedEvent: …`

    Indicates that context compaction (summarization) occurred during the session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["agent.thread_context_compacted"]`

      - `"agent.thread_context_compacted"`

  - `class BetaManagedAgentsSessionErrorEvent: …`

    An error event indicating a problem occurred during session execution.

    - `id: str`

      Unique identifier for this event.

    - `error: Error`

      An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

      - `class BetaManagedAgentsUnknownError: …`

        An unknown or unexpected error occurred during session execution. A fallback variant; clients that don't recognize a new error code can match on `retry_status` and `message` alone.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

            - `type: Literal["retrying"]`

              - `"retrying"`

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

            - `type: Literal["exhausted"]`

              - `"exhausted"`

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

            - `type: Literal["terminal"]`

              - `"terminal"`

        - `type: Literal["unknown_error"]`

          - `"unknown_error"`

      - `class BetaManagedAgentsModelOverloadedError: …`

        The model is currently overloaded. Emitted after automatic retries are exhausted.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_overloaded_error"]`

          - `"model_overloaded_error"`

      - `class BetaManagedAgentsModelRateLimitedError: …`

        The model request was rate-limited.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_rate_limited_error"]`

          - `"model_rate_limited_error"`

      - `class BetaManagedAgentsModelRequestFailedError: …`

        A model request failed for a reason other than overload or rate-limiting.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["model_request_failed_error"]`

          - `"model_request_failed_error"`

      - `class BetaManagedAgentsMCPConnectionFailedError: …`

        Failed to connect to an MCP server.

        - `mcp_server_name: str`

          Name of the MCP server that failed to connect.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_connection_failed_error"]`

          - `"mcp_connection_failed_error"`

      - `class BetaManagedAgentsMCPAuthenticationFailedError: …`

        Authentication to an MCP server failed.

        - `mcp_server_name: str`

          Name of the MCP server that failed authentication.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["mcp_authentication_failed_error"]`

          - `"mcp_authentication_failed_error"`

      - `class BetaManagedAgentsBillingError: …`

        The caller's organization or workspace cannot make model requests — out of credits or spend limit reached. Retrying with the same credentials will not succeed; the caller must resolve the billing state.

        - `message: str`

          Human-readable error description.

        - `retry_status: RetryStatus`

          What the client should do next in response to this error.

          - `class BetaManagedAgentsRetryStatusRetrying: …`

            The server is retrying automatically. Client should wait; the same error type may fire again as retrying, then once as exhausted when the retry budget runs out.

          - `class BetaManagedAgentsRetryStatusExhausted: …`

            This turn is dead; queued inputs are flushed and the session returns to idle. Client may send a new prompt.

          - `class BetaManagedAgentsRetryStatusTerminal: …`

            The session encountered a terminal error and will transition to `terminated` state.

        - `type: Literal["billing_error"]`

          - `"billing_error"`

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.error"]`

      - `"session.error"`

  - `class BetaManagedAgentsSessionStatusRescheduledEvent: …`

    Indicates the session is recovering from an error state and is rescheduled for execution.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

  - `class BetaManagedAgentsSessionStatusRunningEvent: …`

    Indicates the session is actively running and the agent is working.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_running"]`

      - `"session.status_running"`

  - `class BetaManagedAgentsSessionStatusIdleEvent: …`

    Indicates the agent has paused and is awaiting user input.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

        - `type: Literal["end_turn"]`

          - `"end_turn"`

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

        - `event_ids: List[str]`

          The ids of events the agent is blocked on. Resolving fewer than all re-emits `session.status_idle` with the remainder.

        - `type: Literal["requires_action"]`

          - `"requires_action"`

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

        - `type: Literal["retries_exhausted"]`

          - `"retries_exhausted"`

    - `type: Literal["session.status_idle"]`

      - `"session.status_idle"`

  - `class BetaManagedAgentsSessionStatusTerminatedEvent: …`

    Indicates the session has terminated, either due to an error or completion.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

  - `class BetaManagedAgentsSessionThreadCreatedEvent: …`

    Emitted when a subagent is spawned as a new thread. Written to the parent thread's output stream so clients observing the session see child creation.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the callable agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public `sthr_` ID of the newly created thread.

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationStartEvent: …`

    Emitted when an outcome evaluation cycle begins.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle. 0 is the first evaluation; 1 is the re-evaluation after the first revision; etc.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_start"]`

      - `"span.outcome_evaluation_start"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationEndEvent: …`

    Emitted when an outcome evaluation cycle completes. Carries the verdict and aggregate token usage. A verdict of `needs_revision` means another evaluation cycle follows; `satisfied`, `max_iterations_reached`, `failed`, or `interrupted` are terminal — no further evaluation cycles follow.

    - `id: str`

      Unique identifier for this event.

    - `explanation: str`

      Human-readable explanation of the verdict. For `needs_revision`, describes which criteria failed and why.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_evaluation_start_id: str`

      The id of the corresponding `span.outcome_evaluation_start` event.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `result: str`

      Evaluation verdict. 'satisfied': criteria met, session goes idle. 'needs_revision': criteria not met, another revision cycle follows. 'max_iterations_reached': evaluation budget exhausted with criteria still unmet — one final acknowledgment turn follows before the session goes idle, but no further evaluation runs. 'failed': grader determined the rubric does not apply to the deliverables. 'interrupted': user sent an interrupt while evaluation was in progress.

    - `type: Literal["span.outcome_evaluation_end"]`

      - `"span.outcome_evaluation_end"`

    - `usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

      - `cache_creation_input_tokens: int`

        Tokens used to create prompt cache in this request.

      - `cache_read_input_tokens: int`

        Tokens read from prompt cache in this request.

      - `input_tokens: int`

        Input tokens consumed by this request.

      - `output_tokens: int`

        Output tokens generated by this request.

      - `speed: Optional[Literal["standard", "fast"]]`

        Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

        - `"standard"`

        - `"fast"`

  - `class BetaManagedAgentsSpanModelRequestStartEvent: …`

    Emitted when a model request is initiated by the agent.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_start"]`

      - `"span.model_request_start"`

  - `class BetaManagedAgentsSpanModelRequestEndEvent: …`

    Emitted when a model request completes.

    - `id: str`

      Unique identifier for this event.

    - `is_error: Optional[bool]`

      Whether the model request resulted in an error.

    - `model_request_start_id: str`

      The id of the corresponding `span.model_request_start` event.

    - `model_usage: BetaManagedAgentsSpanModelUsage`

      Token usage for a single model request.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.model_request_end"]`

      - `"span.model_request_end"`

  - `class BetaManagedAgentsSpanOutcomeEvaluationOngoingEvent: …`

    Periodic heartbeat emitted while an outcome evaluation cycle is in progress. Distinguishes 'evaluation is actively running' from 'evaluation is stuck' between the corresponding `span.outcome_evaluation_start` and `span.outcome_evaluation_end` events.

    - `id: str`

      Unique identifier for this event.

    - `iteration: int`

      0-indexed revision cycle, matching the corresponding `span.outcome_evaluation_start`.

    - `outcome_id: str`

      The `outc_` ID of the outcome being evaluated.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["span.outcome_evaluation_ongoing"]`

      - `"span.outcome_evaluation_ongoing"`

  - `class BetaManagedAgentsUserDefineOutcomeEvent: …`

    Echo of a `user.define_outcome` input event. Carries the server-generated `outcome_id` that subsequent `span.outcome_evaluation_*` events reference.

    - `id: str`

      Unique identifier for this event.

    - `description: str`

      What the agent should produce. Copied from the input event.

    - `max_iterations: Optional[int]`

      Evaluate-then-revise cycles before giving up. Default 3, max 20.

    - `outcome_id: str`

      Server-generated `outc_` ID for this outcome. Referenced by `span.outcome_evaluation_*` events and the session's `outcome_evaluations` list.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `rubric: Rubric`

      Rubric for grading the quality of an outcome.

      - `class BetaManagedAgentsFileRubric: …`

        Rubric referenced by a file uploaded via the Files API.

        - `file_id: str`

          ID of the rubric file.

        - `type: Literal["file"]`

          - `"file"`

      - `class BetaManagedAgentsTextRubric: …`

        Rubric content provided inline as text.

        - `content: str`

          Rubric content. Plain text or markdown — the grader treats it as freeform text.

        - `type: Literal["text"]`

          - `"text"`

    - `type: Literal["user.define_outcome"]`

      - `"user.define_outcome"`

  - `class BetaManagedAgentsSessionDeletedEvent: …`

    Emitted when a session has been deleted. Terminates any active event stream — no further events will be emitted for this session.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

  - `class BetaManagedAgentsSessionThreadStatusRunningEvent: …`

    A session thread has begun executing. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that started running.

    - `type: Literal["session.thread_status_running"]`

      - `"session.thread_status_running"`

  - `class BetaManagedAgentsSessionThreadStatusIdleEvent: …`

    A session thread has yielded and is awaiting input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that went idle.

    - `stop_reason: StopReason`

      The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionEndTurn: …`

        The agent completed its turn naturally and is ready for the next user message.

      - `class BetaManagedAgentsSessionRequiresAction: …`

        The agent is idle waiting on one or more blocking user-input events (tool confirmation, custom tool result, etc.). Resolving all of them transitions the session back to running.

      - `class BetaManagedAgentsSessionRetriesExhausted: …`

        The turn ended because the retry budget was exhausted (`max_iterations` hit or an error escalated to `retry_status: 'exhausted'`).

    - `type: Literal["session.thread_status_idle"]`

      - `"session.thread_status_idle"`

  - `class BetaManagedAgentsSessionThreadStatusTerminatedEvent: …`

    A session thread has terminated and will accept no further input. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that terminated.

    - `type: Literal["session.thread_status_terminated"]`

      - `"session.thread_status_terminated"`

  - `class BetaManagedAgentsUserToolResultEvent: …`

    Event sent by the client providing the result of an agent-toolset tool execution. Only valid on `self_hosted` environments, where sandbox-routed tools are executed by the client rather than the server.

    - `id: str`

      Unique identifier for this event.

    - `tool_use_id: str`

      The id of the `agent.tool_use` event this result corresponds to, which can be found in the last `session.status_idle` [event's](https://platform.claude.com/docs/en/api/beta/sessions/events/list#beta_managed_agents_session_requires_action.event_ids) `stop_reason.event_ids` field.

    - `type: Literal["user.tool_result"]`

      - `"user.tool_result"`

    - `content: Optional[List[Content]]`

      The result content returned by the tool.

      - `class BetaManagedAgentsTextBlock: …`

        Regular text content.

      - `class BetaManagedAgentsImageBlock: …`

        Image content specified directly as base64 data or as a reference via a URL.

      - `class BetaManagedAgentsDocumentBlock: …`

        Document content, either specified directly as base64 data, as text, or as a reference via a URL.

      - `class BetaManagedAgentsSearchResultBlock: …`

        A block containing a web search result.

    - `is_error: Optional[bool]`

      Whether the tool execution resulted in an error.

    - `processed_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `session_thread_id: Optional[str]`

      Routes this result to a subagent thread. Copy from the `agent.tool_use` event's `session_thread_id`.

  - `class BetaManagedAgentsSessionThreadStatusRescheduledEvent: …`

    A session thread hit a transient error and is retrying automatically. Emitted on the thread's own stream and cross-posted to the primary stream for child threads.

    - `id: str`

      Unique identifier for this event.

    - `agent_name: str`

      Name of the agent the thread runs.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `session_thread_id: str`

      Public sthr_ ID of the thread that is retrying.

    - `type: Literal["session.thread_status_rescheduled"]`

      - `"session.thread_status_rescheduled"`

  - `class BetaManagedAgentsSessionUpdatedEvent: …`

    Emitted when an UpdateSession request changed at least one field. Carries only the fields that changed; absent fields were not part of the update. The new configuration applies from the next turn.

    - `id: str`

      Unique identifier for this event.

    - `processed_at: datetime`

      A timestamp in RFC 3339 format

    - `type: Literal["session.updated"]`

      - `"session.updated"`

    - `agent: Optional[BetaManagedAgentsSessionAgent]`

      Resolved `agent` definition for a `session`. Snapshot of the `agent` at `session` creation time.

      - `id: str`

      - `description: Optional[str]`

      - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

        - `name: str`

        - `type: Literal["url"]`

          - `"url"`

        - `url: str`

      - `model: BetaManagedAgentsModelConfig`

        Model identifier and configuration.

        - `id: BetaManagedAgentsModel`

          The model that will power your agent.

          See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

          - `Literal["claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", 7 more]`

            The model that will power your agent.

            See [models](https://docs.anthropic.com/en/docs/models-overview) for additional details and options.

            - `claude-opus-4-8` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-7` - Frontier intelligence for long-running agents and coding
            - `claude-opus-4-6` - Most intelligent model for building agents and coding
            - `claude-sonnet-4-6` - Best combination of speed and intelligence
            - `claude-haiku-4-5` - Fastest model with near-frontier intelligence
            - `claude-haiku-4-5-20251001` - Fastest model with near-frontier intelligence
            - `claude-opus-4-5` - Premium model combining maximum intelligence with practical performance
            - `claude-opus-4-5-20251101` - Premium model combining maximum intelligence with practical performance
            - `claude-sonnet-4-5` - High-performance model for agents and coding
            - `claude-sonnet-4-5-20250929` - High-performance model for agents and coding

            - `"claude-opus-4-8"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-7"`

              Frontier intelligence for long-running agents and coding

            - `"claude-opus-4-6"`

              Most intelligent model for building agents and coding

            - `"claude-sonnet-4-6"`

              Best combination of speed and intelligence

            - `"claude-haiku-4-5"`

              Fastest model with near-frontier intelligence

            - `"claude-haiku-4-5-20251001"`

              Fastest model with near-frontier intelligence

            - `"claude-opus-4-5"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-opus-4-5-20251101"`

              Premium model combining maximum intelligence with practical performance

            - `"claude-sonnet-4-5"`

              High-performance model for agents and coding

            - `"claude-sonnet-4-5-20250929"`

              High-performance model for agents and coding

          - `str`

        - `speed: Optional[Literal["standard", "fast"]]`

          Inference speed mode. `fast` provides significantly faster output token generation at premium pricing. Not all models support `fast`; invalid combinations are rejected at create time.

          - `"standard"`

          - `"fast"`

      - `multiagent: Optional[BetaManagedAgentsSessionMultiagentCoordinator]`

        Resolved coordinator topology with full agent definitions for each roster member.

        - `agents: List[BetaManagedAgentsSessionThreadAgent]`

          Full `agent` definitions the coordinator may spawn as session threads.

          - `id: str`

          - `description: Optional[str]`

          - `mcp_servers: List[BetaManagedAgentsMCPServerURLDefinition]`

            - `name: str`

            - `type: Literal["url"]`

            - `url: str`

          - `model: BetaManagedAgentsModelConfig`

            Model identifier and configuration.

          - `name: str`

          - `skills: List[Skill]`

            - `class BetaManagedAgentsAnthropicSkill: …`

              A resolved Anthropic-managed skill.

              - `skill_id: str`

              - `type: Literal["anthropic"]`

                - `"anthropic"`

              - `version: str`

            - `class BetaManagedAgentsCustomSkill: …`

              A resolved user-created custom skill.

              - `skill_id: str`

              - `type: Literal["custom"]`

                - `"custom"`

              - `version: str`

          - `system: Optional[str]`

          - `tools: List[Tool]`

            - `class BetaManagedAgentsAgentToolset20260401: …`

              - `configs: List[BetaManagedAgentsAgentToolConfig]`

                - `enabled: bool`

                - `name: Literal["bash", "edit", "read", 5 more]`

                  Built-in agent tool identifier.

                  - `"bash"`

                  - `"edit"`

                  - `"read"`

                  - `"write"`

                  - `"glob"`

                  - `"grep"`

                  - `"web_fetch"`

                  - `"web_search"`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                    - `type: Literal["always_allow"]`

                      - `"always_allow"`

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

                    - `type: Literal["always_ask"]`

                      - `"always_ask"`

              - `default_config: BetaManagedAgentsAgentToolsetDefaultConfig`

                Resolved default configuration for agent tools.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `type: Literal["agent_toolset_20260401"]`

                - `"agent_toolset_20260401"`

            - `class BetaManagedAgentsMCPToolset: …`

              - `configs: List[BetaManagedAgentsMCPToolConfig]`

                - `enabled: bool`

                - `name: str`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `default_config: BetaManagedAgentsMCPToolsetDefaultConfig`

                Resolved default configuration for all tools from an MCP server.

                - `enabled: bool`

                - `permission_policy: PermissionPolicy`

                  Permission policy for tool execution.

                  - `class BetaManagedAgentsAlwaysAllowPolicy: …`

                    Tool calls are automatically approved without user confirmation.

                  - `class BetaManagedAgentsAlwaysAskPolicy: …`

                    Tool calls require user confirmation before execution.

              - `mcp_server_name: str`

              - `type: Literal["mcp_toolset"]`

                - `"mcp_toolset"`

            - `class BetaManagedAgentsCustomTool: …`

              A custom tool as returned in API responses.

              - `description: str`

              - `input_schema: BetaManagedAgentsCustomToolInputSchema`

                JSON Schema for custom tool input parameters.

                - `properties: Optional[Dict[str, object]]`

                  JSON Schema properties defining the tool's input parameters.

                - `required: Optional[List[str]]`

                  List of required property names.

                - `type: Optional[Literal["object"]]`

                  Must be 'object' for tool input schemas.

                  - `"object"`

              - `name: str`

              - `type: Literal["custom"]`

                - `"custom"`

          - `type: Literal["agent"]`

            - `"agent"`

          - `version: int`

        - `type: Literal["coordinator"]`

          - `"coordinator"`

      - `name: str`

      - `skills: List[Skill]`

        - `class BetaManagedAgentsAnthropicSkill: …`

          A resolved Anthropic-managed skill.

        - `class BetaManagedAgentsCustomSkill: …`

          A resolved user-created custom skill.

      - `system: Optional[str]`

      - `tools: List[Tool]`

        - `class BetaManagedAgentsAgentToolset20260401: …`

        - `class BetaManagedAgentsMCPToolset: …`

        - `class BetaManagedAgentsCustomTool: …`

          A custom tool as returned in API responses.

      - `type: Literal["agent"]`

        - `"agent"`

      - `version: int`

    - `metadata: Optional[Dict[str, str]]`

      The session's full metadata bag after the update. Present when the update set non-empty metadata; absent when metadata was unchanged or cleared to empty.

    - `title: Optional[str]`

      The session's new title. Present only when the update changed it.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
for event in client.beta.sessions.threads.events.stream(
    thread_id="sthr_011CZkZVWa6oIjw0rgXZpnBt",
    session_id="sesn_011CZkZAtmR3yMPDzynEDxu7",
):
  print(event)
```

#### Response

```json
{
  "id": "sevt_011CZkZGOp0iBcp4kaQSihUmy",
  "content": [
    {
      "text": "Where is my order #1234?",
      "type": "text"
    }
  ],
  "type": "user.message",
  "processed_at": "2026-03-15T10:00:00Z"
}
```

# Vaults

## Create Vault

`beta.vaults.create(VaultCreateParams**kwargs)  -> BetaManagedAgentsVault`

**post** `/v1/vaults`

Create Vault

### Parameters

- `display_name: str`

  Human-readable name for the vault. 1-255 characters.

- `metadata: Optional[Dict[str, str]]`

  Arbitrary key-value metadata to attach to the vault. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_vault = client.beta.vaults.create(
    display_name="Example vault",
)
print(beta_managed_agents_vault.id)
```

#### Response

```json
{
  "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "display_name": "Example vault",
  "metadata": {
    "environment": "production"
  },
  "type": "vault",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

## List Vaults

`beta.vaults.list(VaultListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsVault]`

**get** `/v1/vaults`

List Vaults

### Parameters

- `include_archived: Optional[bool]`

  Whether to include archived vaults in the results.

- `limit: Optional[int]`

  Maximum number of vaults to return per page. Defaults to 20, maximum 100.

- `page: Optional[str]`

  Opaque pagination token from a previous `list_vaults` response.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.vaults.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
      "archived_at": null,
      "created_at": "2026-03-15T10:00:00Z",
      "display_name": "Example vault",
      "metadata": {
        "environment": "production"
      },
      "type": "vault",
      "updated_at": "2026-03-15T10:00:00Z"
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Vault

`beta.vaults.retrieve(strvault_id, VaultRetrieveParams**kwargs)  -> BetaManagedAgentsVault`

**get** `/v1/vaults/{vault_id}`

Get Vault

### Parameters

- `vault_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_vault = client.beta.vaults.retrieve(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_vault.id)
```

#### Response

```json
{
  "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "display_name": "Example vault",
  "metadata": {
    "environment": "production"
  },
  "type": "vault",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

## Update Vault

`beta.vaults.update(strvault_id, VaultUpdateParams**kwargs)  -> BetaManagedAgentsVault`

**post** `/v1/vaults/{vault_id}`

Update Vault

### Parameters

- `vault_id: str`

- `display_name: Optional[str]`

  Updated human-readable name for the vault. 1-255 characters.

- `metadata: Optional[Dict[str, Optional[str]]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_vault = client.beta.vaults.update(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_vault.id)
```

#### Response

```json
{
  "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "display_name": "Example vault",
  "metadata": {
    "environment": "production"
  },
  "type": "vault",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

## Delete Vault

`beta.vaults.delete(strvault_id, VaultDeleteParams**kwargs)  -> BetaManagedAgentsDeletedVault`

**delete** `/v1/vaults/{vault_id}`

Delete Vault

### Parameters

- `vault_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeletedVault: …`

  Confirmation of a deleted vault.

  - `id: str`

    Unique identifier of the deleted vault.

  - `type: Literal["vault_deleted"]`

    - `"vault_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_deleted_vault = client.beta.vaults.delete(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_deleted_vault.id)
```

#### Response

```json
{
  "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "type": "vault_deleted"
}
```

## Archive Vault

`beta.vaults.archive(strvault_id, VaultArchiveParams**kwargs)  -> BetaManagedAgentsVault`

**post** `/v1/vaults/{vault_id}/archive`

Archive Vault

### Parameters

- `vault_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_vault = client.beta.vaults.archive(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_vault.id)
```

#### Response

```json
{
  "id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "archived_at": null,
  "created_at": "2026-03-15T10:00:00Z",
  "display_name": "Example vault",
  "metadata": {
    "environment": "production"
  },
  "type": "vault",
  "updated_at": "2026-03-15T10:00:00Z"
}
```

## Domain Types

### Beta Managed Agents Deleted Vault

- `class BetaManagedAgentsDeletedVault: …`

  Confirmation of a deleted vault.

  - `id: str`

    Unique identifier of the deleted vault.

  - `type: Literal["vault_deleted"]`

    - `"vault_deleted"`

### Beta Managed Agents Vault

- `class BetaManagedAgentsVault: …`

  A vault that stores credentials for use by agents during sessions.

  - `id: str`

    Unique identifier for the vault.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `display_name: str`

    Human-readable name for the vault.

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the vault.

  - `type: Literal["vault"]`

    - `"vault"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

# Credentials

## Create Credential

`beta.vaults.credentials.create(strvault_id, CredentialCreateParams**kwargs)  -> BetaManagedAgentsCredential`

**post** `/v1/vaults/{vault_id}/credentials`

Create Credential

### Parameters

- `vault_id: str`

- `auth: Auth`

  Authentication details for creating a credential.

  - `class BetaManagedAgentsMCPOAuthCreateParams: …`

    Parameters for creating an MCP OAuth credential.

    - `access_token: str`

      OAuth access token.

    - `mcp_server_url: str`

      URL of the MCP server this credential authenticates against.

    - `type: Literal["mcp_oauth"]`

      - `"mcp_oauth"`

    - `expires_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshParams]`

      OAuth refresh token parameters for creating a credential with refresh support.

      - `client_id: str`

        OAuth client ID.

      - `refresh_token: str`

        OAuth refresh token.

      - `token_endpoint: str`

        Token endpoint URL used to refresh the access token.

      - `token_endpoint_auth: TokenEndpointAuth`

        Token endpoint requires no client authentication.

        - `class BetaManagedAgentsTokenEndpointAuthNoneParam: …`

          Token endpoint requires no client authentication.

          - `type: Literal["none"]`

            - `"none"`

        - `class BetaManagedAgentsTokenEndpointAuthBasicParam: …`

          Token endpoint uses HTTP Basic authentication with client credentials.

          - `client_secret: str`

            OAuth client secret.

          - `type: Literal["client_secret_basic"]`

            - `"client_secret_basic"`

        - `class BetaManagedAgentsTokenEndpointAuthPostParam: …`

          Token endpoint uses POST body authentication with client credentials.

          - `client_secret: str`

            OAuth client secret.

          - `type: Literal["client_secret_post"]`

            - `"client_secret_post"`

      - `resource: Optional[str]`

        OAuth resource indicator.

      - `scope: Optional[str]`

        OAuth scope for the refresh request.

  - `class BetaManagedAgentsStaticBearerCreateParams: …`

    Parameters for creating a static bearer token credential.

    - `token: str`

      Static bearer token value.

    - `mcp_server_url: str`

      URL of the MCP server this credential authenticates against.

    - `type: Literal["static_bearer"]`

      - `"static_bearer"`

- `display_name: Optional[str]`

  Human-readable name for the credential. Up to 255 characters.

- `metadata: Optional[Dict[str, str]]`

  Arbitrary key-value metadata to attach to the credential. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_credential = client.beta.vaults.credentials.create(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
    auth={
        "token": "bearer_exampletoken",
        "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
        "type": "static_bearer",
    },
)
print(beta_managed_agents_credential.id)
```

#### Response

```json
{
  "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "archived_at": null,
  "auth": {
    "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
    "type": "static_bearer"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {
    "environment": "production"
  },
  "type": "vault_credential",
  "updated_at": "2026-03-15T10:00:00Z",
  "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "display_name": "Example credential"
}
```

## List Credentials

`beta.vaults.credentials.list(strvault_id, CredentialListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsCredential]`

**get** `/v1/vaults/{vault_id}/credentials`

List Credentials

### Parameters

- `vault_id: str`

- `include_archived: Optional[bool]`

  Whether to include archived credentials in the results.

- `limit: Optional[int]`

  Maximum number of credentials to return per page. Defaults to 20, maximum 100.

- `page: Optional[str]`

  Opaque pagination token from a previous `list_credentials` response.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.vaults.credentials.list(
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
      "archived_at": null,
      "auth": {
        "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
        "type": "static_bearer"
      },
      "created_at": "2026-03-15T10:00:00Z",
      "metadata": {
        "environment": "production"
      },
      "type": "vault_credential",
      "updated_at": "2026-03-15T10:00:00Z",
      "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
      "display_name": "Example credential"
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Credential

`beta.vaults.credentials.retrieve(strcredential_id, CredentialRetrieveParams**kwargs)  -> BetaManagedAgentsCredential`

**get** `/v1/vaults/{vault_id}/credentials/{credential_id}`

Get Credential

### Parameters

- `vault_id: str`

- `credential_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_credential = client.beta.vaults.credentials.retrieve(
    credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_credential.id)
```

#### Response

```json
{
  "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "archived_at": null,
  "auth": {
    "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
    "type": "static_bearer"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {
    "environment": "production"
  },
  "type": "vault_credential",
  "updated_at": "2026-03-15T10:00:00Z",
  "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "display_name": "Example credential"
}
```

## Update Credential

`beta.vaults.credentials.update(strcredential_id, CredentialUpdateParams**kwargs)  -> BetaManagedAgentsCredential`

**post** `/v1/vaults/{vault_id}/credentials/{credential_id}`

Update Credential

### Parameters

- `vault_id: str`

- `credential_id: str`

- `auth: Optional[Auth]`

  Updated authentication details for a credential.

  - `class BetaManagedAgentsMCPOAuthUpdateParams: …`

    Parameters for updating an MCP OAuth credential. The `mcp_server_url` is immutable.

    - `type: Literal["mcp_oauth"]`

      - `"mcp_oauth"`

    - `access_token: Optional[str]`

      Updated OAuth access token.

    - `expires_at: Optional[datetime]`

      A timestamp in RFC 3339 format

    - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshUpdateParams]`

      Parameters for updating OAuth refresh token configuration.

      - `refresh_token: Optional[str]`

        Updated OAuth refresh token.

      - `scope: Optional[str]`

        Updated OAuth scope for the refresh request.

      - `token_endpoint_auth: Optional[TokenEndpointAuth]`

        Updated HTTP Basic authentication parameters for the token endpoint.

        - `class BetaManagedAgentsTokenEndpointAuthBasicUpdateParam: …`

          Updated HTTP Basic authentication parameters for the token endpoint.

          - `type: Literal["client_secret_basic"]`

            - `"client_secret_basic"`

          - `client_secret: Optional[str]`

            Updated OAuth client secret.

        - `class BetaManagedAgentsTokenEndpointAuthPostUpdateParam: …`

          Updated POST body authentication parameters for the token endpoint.

          - `type: Literal["client_secret_post"]`

            - `"client_secret_post"`

          - `client_secret: Optional[str]`

            Updated OAuth client secret.

  - `class BetaManagedAgentsStaticBearerUpdateParams: …`

    Parameters for updating a static bearer token credential. The `mcp_server_url` is immutable.

    - `type: Literal["static_bearer"]`

      - `"static_bearer"`

    - `token: Optional[str]`

      Updated static bearer token value.

- `display_name: Optional[str]`

  Updated human-readable name for the credential. 1-255 characters.

- `metadata: Optional[Dict[str, Optional[str]]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omitted keys are preserved.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_credential = client.beta.vaults.credentials.update(
    credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_credential.id)
```

#### Response

```json
{
  "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "archived_at": null,
  "auth": {
    "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
    "type": "static_bearer"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {
    "environment": "production"
  },
  "type": "vault_credential",
  "updated_at": "2026-03-15T10:00:00Z",
  "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "display_name": "Example credential"
}
```

## Delete Credential

`beta.vaults.credentials.delete(strcredential_id, CredentialDeleteParams**kwargs)  -> BetaManagedAgentsDeletedCredential`

**delete** `/v1/vaults/{vault_id}/credentials/{credential_id}`

Delete Credential

### Parameters

- `vault_id: str`

- `credential_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeletedCredential: …`

  Confirmation of a deleted credential.

  - `id: str`

    Unique identifier of the deleted credential.

  - `type: Literal["vault_credential_deleted"]`

    - `"vault_credential_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_deleted_credential = client.beta.vaults.credentials.delete(
    credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_deleted_credential.id)
```

#### Response

```json
{
  "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "type": "vault_credential_deleted"
}
```

## Archive Credential

`beta.vaults.credentials.archive(strcredential_id, CredentialArchiveParams**kwargs)  -> BetaManagedAgentsCredential`

**post** `/v1/vaults/{vault_id}/credentials/{credential_id}/archive`

Archive Credential

### Parameters

- `vault_id: str`

- `credential_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_credential = client.beta.vaults.credentials.archive(
    credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_credential.id)
```

#### Response

```json
{
  "id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "archived_at": null,
  "auth": {
    "mcp_server_url": "https://example-server.modelcontextprotocol.io/sse",
    "type": "static_bearer"
  },
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {
    "environment": "production"
  },
  "type": "vault_credential",
  "updated_at": "2026-03-15T10:00:00Z",
  "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv",
  "display_name": "Example credential"
}
```

## Validate Credential

`beta.vaults.credentials.mcp_oauth_validate(strcredential_id, CredentialMCPOAuthValidateParams**kwargs)  -> BetaManagedAgentsCredentialValidation`

**post** `/v1/vaults/{vault_id}/credentials/{credential_id}/mcp_oauth_validate`

Validate Credential

### Parameters

- `vault_id: str`

- `credential_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsCredentialValidation: …`

  Result of live-probing a credential against its configured MCP server.

  - `credential_id: str`

    Unique identifier of the credential that was validated.

  - `has_refresh_token: bool`

    Whether the credential has a refresh token configured.

  - `mcp_probe: Optional[BetaManagedAgentsMCPProbe]`

    The failing step of an MCP validation probe.

    - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

      An HTTP response captured during a credential validation probe.

      - `body: str`

        Response body. May be truncated and has sensitive values scrubbed.

      - `body_truncated: bool`

        Whether `body` was truncated.

      - `content_type: str`

        Value of the `Content-Type` response header.

      - `status_code: int`

        HTTP status code.

    - `method: str`

      The MCP method that failed (for example `initialize` or `tools/list`).

  - `refresh: Optional[BetaManagedAgentsRefreshObject]`

    Outcome of a refresh-token exchange attempted during credential validation.

    - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

      An HTTP response captured during a credential validation probe.

    - `status: Literal["succeeded", "failed", "connect_error", "no_refresh_token"]`

      Outcome of a refresh-token exchange attempted during credential validation.

      - `"succeeded"`

      - `"failed"`

      - `"connect_error"`

      - `"no_refresh_token"`

  - `status: BetaManagedAgentsCredentialValidationStatus`

    Overall verdict of a credential validation probe.

    - `"valid"`

    - `"invalid"`

    - `"unknown"`

  - `type: Literal["vault_credential_validation"]`

    - `"vault_credential_validation"`

  - `validated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault containing the credential.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_credential_validation = client.beta.vaults.credentials.mcp_oauth_validate(
    credential_id="vcrd_011CZkZEMt8gZan2iYOQfSkw",
    vault_id="vlt_011CZkZDLs7fYzm1hXNPeRjv",
)
print(beta_managed_agents_credential_validation.credential_id)
```

#### Response

```json
{
  "credential_id": "vcrd_011CZkZEMt8gZan2iYOQfSkw",
  "has_refresh_token": true,
  "mcp_probe": {
    "http_response": {
      "body": "body",
      "body_truncated": true,
      "content_type": "content_type",
      "status_code": 0
    },
    "method": "method"
  },
  "refresh": {
    "http_response": {
      "body": "body",
      "body_truncated": true,
      "content_type": "content_type",
      "status_code": 0
    },
    "status": "succeeded"
  },
  "status": "valid",
  "type": "vault_credential_validation",
  "validated_at": "2026-03-15T10:00:00Z",
  "vault_id": "vlt_011CZkZDLs7fYzm1hXNPeRjv"
}
```

## Domain Types

### Beta Managed Agents Credential

- `class BetaManagedAgentsCredential: …`

  A credential stored in a vault. Sensitive fields are never returned in responses.

  - `id: str`

    Unique identifier for the credential.

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `auth: Auth`

    Authentication details for a credential.

    - `class BetaManagedAgentsMCPOAuthAuthResponse: …`

      OAuth credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["mcp_oauth"]`

        - `"mcp_oauth"`

      - `expires_at: Optional[datetime]`

        A timestamp in RFC 3339 format

      - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

        OAuth refresh token configuration returned in credential responses.

        - `client_id: str`

          OAuth client ID.

        - `token_endpoint: str`

          Token endpoint URL used to refresh the access token.

        - `token_endpoint_auth: TokenEndpointAuth`

          Token endpoint requires no client authentication.

          - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

            Token endpoint requires no client authentication.

            - `type: Literal["none"]`

              - `"none"`

          - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

            Token endpoint uses HTTP Basic authentication with client credentials.

            - `type: Literal["client_secret_basic"]`

              - `"client_secret_basic"`

          - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

            Token endpoint uses POST body authentication with client credentials.

            - `type: Literal["client_secret_post"]`

              - `"client_secret_post"`

        - `resource: Optional[str]`

          OAuth resource indicator.

        - `scope: Optional[str]`

          OAuth scope for the refresh request.

    - `class BetaManagedAgentsStaticBearerAuthResponse: …`

      Static bearer token credential details for an MCP server.

      - `mcp_server_url: str`

        URL of the MCP server this credential authenticates against.

      - `type: Literal["static_bearer"]`

        - `"static_bearer"`

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata attached to the credential.

  - `type: Literal["vault_credential"]`

    - `"vault_credential"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault this credential belongs to.

  - `display_name: Optional[str]`

    Human-readable name for the credential.

### Beta Managed Agents Credential Validation

- `class BetaManagedAgentsCredentialValidation: …`

  Result of live-probing a credential against its configured MCP server.

  - `credential_id: str`

    Unique identifier of the credential that was validated.

  - `has_refresh_token: bool`

    Whether the credential has a refresh token configured.

  - `mcp_probe: Optional[BetaManagedAgentsMCPProbe]`

    The failing step of an MCP validation probe.

    - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

      An HTTP response captured during a credential validation probe.

      - `body: str`

        Response body. May be truncated and has sensitive values scrubbed.

      - `body_truncated: bool`

        Whether `body` was truncated.

      - `content_type: str`

        Value of the `Content-Type` response header.

      - `status_code: int`

        HTTP status code.

    - `method: str`

      The MCP method that failed (for example `initialize` or `tools/list`).

  - `refresh: Optional[BetaManagedAgentsRefreshObject]`

    Outcome of a refresh-token exchange attempted during credential validation.

    - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

      An HTTP response captured during a credential validation probe.

    - `status: Literal["succeeded", "failed", "connect_error", "no_refresh_token"]`

      Outcome of a refresh-token exchange attempted during credential validation.

      - `"succeeded"`

      - `"failed"`

      - `"connect_error"`

      - `"no_refresh_token"`

  - `status: BetaManagedAgentsCredentialValidationStatus`

    Overall verdict of a credential validation probe.

    - `"valid"`

    - `"invalid"`

    - `"unknown"`

  - `type: Literal["vault_credential_validation"]`

    - `"vault_credential_validation"`

  - `validated_at: datetime`

    A timestamp in RFC 3339 format

  - `vault_id: str`

    Identifier of the vault containing the credential.

### Beta Managed Agents Credential Validation Status

- `Literal["valid", "invalid", "unknown"]`

  Overall verdict of a credential validation probe.

  - `"valid"`

  - `"invalid"`

  - `"unknown"`

### Beta Managed Agents Deleted Credential

- `class BetaManagedAgentsDeletedCredential: …`

  Confirmation of a deleted credential.

  - `id: str`

    Unique identifier of the deleted credential.

  - `type: Literal["vault_credential_deleted"]`

    - `"vault_credential_deleted"`

### Beta Managed Agents MCP OAuth Auth Response

- `class BetaManagedAgentsMCPOAuthAuthResponse: …`

  OAuth credential details for an MCP server.

  - `mcp_server_url: str`

    URL of the MCP server this credential authenticates against.

  - `type: Literal["mcp_oauth"]`

    - `"mcp_oauth"`

  - `expires_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshResponse]`

    OAuth refresh token configuration returned in credential responses.

    - `client_id: str`

      OAuth client ID.

    - `token_endpoint: str`

      Token endpoint URL used to refresh the access token.

    - `token_endpoint_auth: TokenEndpointAuth`

      Token endpoint requires no client authentication.

      - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

        Token endpoint requires no client authentication.

        - `type: Literal["none"]`

          - `"none"`

      - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

        Token endpoint uses HTTP Basic authentication with client credentials.

        - `type: Literal["client_secret_basic"]`

          - `"client_secret_basic"`

      - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

        Token endpoint uses POST body authentication with client credentials.

        - `type: Literal["client_secret_post"]`

          - `"client_secret_post"`

    - `resource: Optional[str]`

      OAuth resource indicator.

    - `scope: Optional[str]`

      OAuth scope for the refresh request.

### Beta Managed Agents MCP OAuth Create Params

- `class BetaManagedAgentsMCPOAuthCreateParams: …`

  Parameters for creating an MCP OAuth credential.

  - `access_token: str`

    OAuth access token.

  - `mcp_server_url: str`

    URL of the MCP server this credential authenticates against.

  - `type: Literal["mcp_oauth"]`

    - `"mcp_oauth"`

  - `expires_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshParams]`

    OAuth refresh token parameters for creating a credential with refresh support.

    - `client_id: str`

      OAuth client ID.

    - `refresh_token: str`

      OAuth refresh token.

    - `token_endpoint: str`

      Token endpoint URL used to refresh the access token.

    - `token_endpoint_auth: TokenEndpointAuth`

      Token endpoint requires no client authentication.

      - `class BetaManagedAgentsTokenEndpointAuthNoneParam: …`

        Token endpoint requires no client authentication.

        - `type: Literal["none"]`

          - `"none"`

      - `class BetaManagedAgentsTokenEndpointAuthBasicParam: …`

        Token endpoint uses HTTP Basic authentication with client credentials.

        - `client_secret: str`

          OAuth client secret.

        - `type: Literal["client_secret_basic"]`

          - `"client_secret_basic"`

      - `class BetaManagedAgentsTokenEndpointAuthPostParam: …`

        Token endpoint uses POST body authentication with client credentials.

        - `client_secret: str`

          OAuth client secret.

        - `type: Literal["client_secret_post"]`

          - `"client_secret_post"`

    - `resource: Optional[str]`

      OAuth resource indicator.

    - `scope: Optional[str]`

      OAuth scope for the refresh request.

### Beta Managed Agents MCP OAuth Refresh Params

- `class BetaManagedAgentsMCPOAuthRefreshParams: …`

  OAuth refresh token parameters for creating a credential with refresh support.

  - `client_id: str`

    OAuth client ID.

  - `refresh_token: str`

    OAuth refresh token.

  - `token_endpoint: str`

    Token endpoint URL used to refresh the access token.

  - `token_endpoint_auth: TokenEndpointAuth`

    Token endpoint requires no client authentication.

    - `class BetaManagedAgentsTokenEndpointAuthNoneParam: …`

      Token endpoint requires no client authentication.

      - `type: Literal["none"]`

        - `"none"`

    - `class BetaManagedAgentsTokenEndpointAuthBasicParam: …`

      Token endpoint uses HTTP Basic authentication with client credentials.

      - `client_secret: str`

        OAuth client secret.

      - `type: Literal["client_secret_basic"]`

        - `"client_secret_basic"`

    - `class BetaManagedAgentsTokenEndpointAuthPostParam: …`

      Token endpoint uses POST body authentication with client credentials.

      - `client_secret: str`

        OAuth client secret.

      - `type: Literal["client_secret_post"]`

        - `"client_secret_post"`

  - `resource: Optional[str]`

    OAuth resource indicator.

  - `scope: Optional[str]`

    OAuth scope for the refresh request.

### Beta Managed Agents MCP OAuth Refresh Response

- `class BetaManagedAgentsMCPOAuthRefreshResponse: …`

  OAuth refresh token configuration returned in credential responses.

  - `client_id: str`

    OAuth client ID.

  - `token_endpoint: str`

    Token endpoint URL used to refresh the access token.

  - `token_endpoint_auth: TokenEndpointAuth`

    Token endpoint requires no client authentication.

    - `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

      Token endpoint requires no client authentication.

      - `type: Literal["none"]`

        - `"none"`

    - `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

      Token endpoint uses HTTP Basic authentication with client credentials.

      - `type: Literal["client_secret_basic"]`

        - `"client_secret_basic"`

    - `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

      Token endpoint uses POST body authentication with client credentials.

      - `type: Literal["client_secret_post"]`

        - `"client_secret_post"`

  - `resource: Optional[str]`

    OAuth resource indicator.

  - `scope: Optional[str]`

    OAuth scope for the refresh request.

### Beta Managed Agents MCP OAuth Refresh Update Params

- `class BetaManagedAgentsMCPOAuthRefreshUpdateParams: …`

  Parameters for updating OAuth refresh token configuration.

  - `refresh_token: Optional[str]`

    Updated OAuth refresh token.

  - `scope: Optional[str]`

    Updated OAuth scope for the refresh request.

  - `token_endpoint_auth: Optional[TokenEndpointAuth]`

    Updated HTTP Basic authentication parameters for the token endpoint.

    - `class BetaManagedAgentsTokenEndpointAuthBasicUpdateParam: …`

      Updated HTTP Basic authentication parameters for the token endpoint.

      - `type: Literal["client_secret_basic"]`

        - `"client_secret_basic"`

      - `client_secret: Optional[str]`

        Updated OAuth client secret.

    - `class BetaManagedAgentsTokenEndpointAuthPostUpdateParam: …`

      Updated POST body authentication parameters for the token endpoint.

      - `type: Literal["client_secret_post"]`

        - `"client_secret_post"`

      - `client_secret: Optional[str]`

        Updated OAuth client secret.

### Beta Managed Agents MCP OAuth Update Params

- `class BetaManagedAgentsMCPOAuthUpdateParams: …`

  Parameters for updating an MCP OAuth credential. The `mcp_server_url` is immutable.

  - `type: Literal["mcp_oauth"]`

    - `"mcp_oauth"`

  - `access_token: Optional[str]`

    Updated OAuth access token.

  - `expires_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `refresh: Optional[BetaManagedAgentsMCPOAuthRefreshUpdateParams]`

    Parameters for updating OAuth refresh token configuration.

    - `refresh_token: Optional[str]`

      Updated OAuth refresh token.

    - `scope: Optional[str]`

      Updated OAuth scope for the refresh request.

    - `token_endpoint_auth: Optional[TokenEndpointAuth]`

      Updated HTTP Basic authentication parameters for the token endpoint.

      - `class BetaManagedAgentsTokenEndpointAuthBasicUpdateParam: …`

        Updated HTTP Basic authentication parameters for the token endpoint.

        - `type: Literal["client_secret_basic"]`

          - `"client_secret_basic"`

        - `client_secret: Optional[str]`

          Updated OAuth client secret.

      - `class BetaManagedAgentsTokenEndpointAuthPostUpdateParam: …`

        Updated POST body authentication parameters for the token endpoint.

        - `type: Literal["client_secret_post"]`

          - `"client_secret_post"`

        - `client_secret: Optional[str]`

          Updated OAuth client secret.

### Beta Managed Agents MCP Probe

- `class BetaManagedAgentsMCPProbe: …`

  The failing step of an MCP validation probe.

  - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

    An HTTP response captured during a credential validation probe.

    - `body: str`

      Response body. May be truncated and has sensitive values scrubbed.

    - `body_truncated: bool`

      Whether `body` was truncated.

    - `content_type: str`

      Value of the `Content-Type` response header.

    - `status_code: int`

      HTTP status code.

  - `method: str`

    The MCP method that failed (for example `initialize` or `tools/list`).

### Beta Managed Agents Refresh HTTP Response

- `class BetaManagedAgentsRefreshHTTPResponse: …`

  An HTTP response captured during a credential validation probe.

  - `body: str`

    Response body. May be truncated and has sensitive values scrubbed.

  - `body_truncated: bool`

    Whether `body` was truncated.

  - `content_type: str`

    Value of the `Content-Type` response header.

  - `status_code: int`

    HTTP status code.

### Beta Managed Agents Refresh Object

- `class BetaManagedAgentsRefreshObject: …`

  Outcome of a refresh-token exchange attempted during credential validation.

  - `http_response: Optional[BetaManagedAgentsRefreshHTTPResponse]`

    An HTTP response captured during a credential validation probe.

    - `body: str`

      Response body. May be truncated and has sensitive values scrubbed.

    - `body_truncated: bool`

      Whether `body` was truncated.

    - `content_type: str`

      Value of the `Content-Type` response header.

    - `status_code: int`

      HTTP status code.

  - `status: Literal["succeeded", "failed", "connect_error", "no_refresh_token"]`

    Outcome of a refresh-token exchange attempted during credential validation.

    - `"succeeded"`

    - `"failed"`

    - `"connect_error"`

    - `"no_refresh_token"`

### Beta Managed Agents Static Bearer Auth Response

- `class BetaManagedAgentsStaticBearerAuthResponse: …`

  Static bearer token credential details for an MCP server.

  - `mcp_server_url: str`

    URL of the MCP server this credential authenticates against.

  - `type: Literal["static_bearer"]`

    - `"static_bearer"`

### Beta Managed Agents Static Bearer Create Params

- `class BetaManagedAgentsStaticBearerCreateParams: …`

  Parameters for creating a static bearer token credential.

  - `token: str`

    Static bearer token value.

  - `mcp_server_url: str`

    URL of the MCP server this credential authenticates against.

  - `type: Literal["static_bearer"]`

    - `"static_bearer"`

### Beta Managed Agents Static Bearer Update Params

- `class BetaManagedAgentsStaticBearerUpdateParams: …`

  Parameters for updating a static bearer token credential. The `mcp_server_url` is immutable.

  - `type: Literal["static_bearer"]`

    - `"static_bearer"`

  - `token: Optional[str]`

    Updated static bearer token value.

### Beta Managed Agents Token Endpoint Auth Basic Param

- `class BetaManagedAgentsTokenEndpointAuthBasicParam: …`

  Token endpoint uses HTTP Basic authentication with client credentials.

  - `client_secret: str`

    OAuth client secret.

  - `type: Literal["client_secret_basic"]`

    - `"client_secret_basic"`

### Beta Managed Agents Token Endpoint Auth Basic Response

- `class BetaManagedAgentsTokenEndpointAuthBasicResponse: …`

  Token endpoint uses HTTP Basic authentication with client credentials.

  - `type: Literal["client_secret_basic"]`

    - `"client_secret_basic"`

### Beta Managed Agents Token Endpoint Auth Basic Update Param

- `class BetaManagedAgentsTokenEndpointAuthBasicUpdateParam: …`

  Updated HTTP Basic authentication parameters for the token endpoint.

  - `type: Literal["client_secret_basic"]`

    - `"client_secret_basic"`

  - `client_secret: Optional[str]`

    Updated OAuth client secret.

### Beta Managed Agents Token Endpoint Auth None Param

- `class BetaManagedAgentsTokenEndpointAuthNoneParam: …`

  Token endpoint requires no client authentication.

  - `type: Literal["none"]`

    - `"none"`

### Beta Managed Agents Token Endpoint Auth None Response

- `class BetaManagedAgentsTokenEndpointAuthNoneResponse: …`

  Token endpoint requires no client authentication.

  - `type: Literal["none"]`

    - `"none"`

### Beta Managed Agents Token Endpoint Auth Post Param

- `class BetaManagedAgentsTokenEndpointAuthPostParam: …`

  Token endpoint uses POST body authentication with client credentials.

  - `client_secret: str`

    OAuth client secret.

  - `type: Literal["client_secret_post"]`

    - `"client_secret_post"`

### Beta Managed Agents Token Endpoint Auth Post Response

- `class BetaManagedAgentsTokenEndpointAuthPostResponse: …`

  Token endpoint uses POST body authentication with client credentials.

  - `type: Literal["client_secret_post"]`

    - `"client_secret_post"`

### Beta Managed Agents Token Endpoint Auth Post Update Param

- `class BetaManagedAgentsTokenEndpointAuthPostUpdateParam: …`

  Updated POST body authentication parameters for the token endpoint.

  - `type: Literal["client_secret_post"]`

    - `"client_secret_post"`

  - `client_secret: Optional[str]`

    Updated OAuth client secret.

# Memory Stores

## Create a memory store

`beta.memory_stores.create(MemoryStoreCreateParams**kwargs)  -> BetaManagedAgentsMemoryStore`

**post** `/v1/memory_stores`

Create a memory store

### Parameters

- `name: str`

  Human-readable name for the store. Required; 1–255 characters; no control characters. The mount-path slug under `/mnt/memory/` is derived from this name (lowercased, non-alphanumeric runs collapsed to a hyphen). Names need not be unique within a workspace.

- `description: Optional[str]`

  Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent.

- `metadata: Optional[Dict[str, str]]`

  Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Not visible to the agent.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_store = client.beta.memory_stores.create(
    name="x",
)
print(beta_managed_agents_memory_store.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "type": "memory_store",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "metadata": {
    "foo": "string"
  }
}
```

## List memory stores

`beta.memory_stores.list(MemoryStoreListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsMemoryStore]`

**get** `/v1/memory_stores`

List memory stores

### Parameters

- `created_at_gte: Optional[Union[str, datetime]]`

  Return only stores whose `created_at` is at or after this time (inclusive). Sent on the wire as `created_at[gte]`.

- `created_at_lte: Optional[Union[str, datetime]]`

  Return only stores whose `created_at` is at or before this time (inclusive). Sent on the wire as `created_at[lte]`.

- `include_archived: Optional[bool]`

  When `true`, archived stores are included in the results. Defaults to `false` (archived stores are excluded).

- `limit: Optional[int]`

  Maximum number of stores to return per page. Must be between 1 and 100. Defaults to 20 when omitted.

- `page: Optional[str]`

  Opaque pagination cursor (a `page_...` value). Pass the `next_page` value from a previous response to fetch the next page; omit for the first page.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.memory_stores.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "name": "name",
      "type": "memory_store",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "archived_at": "2019-12-27T18:11:19.117Z",
      "description": "description",
      "metadata": {
        "foo": "string"
      }
    }
  ],
  "next_page": "next_page"
}
```

## Retrieve a memory store

`beta.memory_stores.retrieve(strmemory_store_id, MemoryStoreRetrieveParams**kwargs)  -> BetaManagedAgentsMemoryStore`

**get** `/v1/memory_stores/{memory_store_id}`

Retrieve a memory store

### Parameters

- `memory_store_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_store = client.beta.memory_stores.retrieve(
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory_store.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "type": "memory_store",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "metadata": {
    "foo": "string"
  }
}
```

## Update a memory store

`beta.memory_stores.update(strmemory_store_id, MemoryStoreUpdateParams**kwargs)  -> BetaManagedAgentsMemoryStore`

**post** `/v1/memory_stores/{memory_store_id}`

Update a memory store

### Parameters

- `memory_store_id: str`

- `description: Optional[str]`

  New description for the store, up to 1024 characters. Pass an empty string to clear it.

- `metadata: Optional[Dict[str, Optional[str]]]`

  Metadata patch. Set a key to a string to upsert it, or to null to delete it. Omit the field to preserve. The stored bag is limited to 16 keys (up to 64 chars each) with values up to 512 chars.

- `name: Optional[str]`

  New human-readable name for the store. 1–255 characters; no control characters. Renaming changes the slug used for the store's `mount_path` in sessions created after the update.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_store = client.beta.memory_stores.update(
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory_store.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "type": "memory_store",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "metadata": {
    "foo": "string"
  }
}
```

## Delete a memory store

`beta.memory_stores.delete(strmemory_store_id, MemoryStoreDeleteParams**kwargs)  -> BetaManagedAgentsDeletedMemoryStore`

**delete** `/v1/memory_stores/{memory_store_id}`

Delete a memory store

### Parameters

- `memory_store_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeletedMemoryStore: …`

  Confirmation that a `memory_store` was deleted.

  - `id: str`

    ID of the deleted memory store (a `memstore_...` identifier). The store and all its memories and versions are no longer retrievable.

  - `type: Literal["memory_store_deleted"]`

    - `"memory_store_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_deleted_memory_store = client.beta.memory_stores.delete(
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_deleted_memory_store.id)
```

#### Response

```json
{
  "id": "id",
  "type": "memory_store_deleted"
}
```

## Archive a memory store

`beta.memory_stores.archive(strmemory_store_id, MemoryStoreArchiveParams**kwargs)  -> BetaManagedAgentsMemoryStore`

**post** `/v1/memory_stores/{memory_store_id}/archive`

Archive a memory store

### Parameters

- `memory_store_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_store = client.beta.memory_stores.archive(
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory_store.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "name": "name",
  "type": "memory_store",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "archived_at": "2019-12-27T18:11:19.117Z",
  "description": "description",
  "metadata": {
    "foo": "string"
  }
}
```

## Domain Types

### Beta Managed Agents Deleted Memory Store

- `class BetaManagedAgentsDeletedMemoryStore: …`

  Confirmation that a `memory_store` was deleted.

  - `id: str`

    ID of the deleted memory store (a `memstore_...` identifier). The store and all its memories and versions are no longer retrievable.

  - `type: Literal["memory_store_deleted"]`

    - `"memory_store_deleted"`

### Beta Managed Agents Memory Store

- `class BetaManagedAgentsMemoryStore: …`

  A `memory_store`: a named container for agent memories, scoped to a workspace. Attach a store to a session via `resources[]` to mount it as a directory the agent can read and write.

  - `id: str`

    Unique identifier for the memory store (a `memstore_...` tagged ID). Use this when attaching the store to a session, or in the `{memory_store_id}` path parameter of subsequent calls.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `name: str`

    Human-readable name for the store. 1–255 characters. The store's mount-path slug under `/mnt/memory/` is derived from this name.

  - `type: Literal["memory_store"]`

    - `"memory_store"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `archived_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `description: Optional[str]`

    Free-text description of what the store contains, up to 1024 characters. Included in the agent's system prompt when the store is attached, so word it to be useful to the agent. Empty string when unset.

  - `metadata: Optional[Dict[str, str]]`

    Arbitrary key-value tags for your own bookkeeping (such as the end user a store belongs to). Up to 16 pairs; keys 1–64 characters; values up to 512 characters. Returned on retrieve/list but not filterable.

# Memories

## Create a memory

`beta.memory_stores.memories.create(strmemory_store_id, MemoryCreateParams**kwargs)  -> BetaManagedAgentsMemory`

**post** `/v1/memory_stores/{memory_store_id}/memories`

Create a memory

### Parameters

- `memory_store_id: str`

- `content: Optional[str]`

  UTF-8 text content for the new memory. Maximum 100 kB (102,400 bytes). Required; pass `""` explicitly to create an empty memory.

- `path: str`

  Hierarchical path for the new memory, e.g. `/projects/foo/notes.md`. Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, and must be NFC-normalized. Paths are case-sensitive.

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemory: …`

  A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

  - `id: str`

    Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

  - `content_sha256: str`

    Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

  - `content_size_bytes: int`

    Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_store_id: str`

    ID of the memory store this memory belongs to (a `memstore_...` value).

  - `memory_version_id: str`

    ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

  - `path: str`

    Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

  - `type: Literal["memory"]`

    - `"memory"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `content: Optional[str]`

    The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory = client.beta.memory_stores.memories.create(
    memory_store_id="memory_store_id",
    content="content",
    path="xx",
)
print(beta_managed_agents_memory.id)
```

#### Response

```json
{
  "id": "id",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_store_id": "memory_store_id",
  "memory_version_id": "memory_version_id",
  "path": "path",
  "type": "memory",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "content": "content"
}
```

## List memories

`beta.memory_stores.memories.list(strmemory_store_id, MemoryListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsMemoryListItem]`

**get** `/v1/memory_stores/{memory_store_id}/memories`

List memories

### Parameters

- `memory_store_id: str`

- `depth: Optional[int]`

  Query parameter for depth

- `limit: Optional[int]`

  Query parameter for limit

- `order: Optional[Literal["asc", "desc"]]`

  Query parameter for order

  - `"asc"`

  - `"desc"`

- `order_by: Optional[str]`

  Query parameter for order_by

- `page: Optional[str]`

  Query parameter for page

- `path_prefix: Optional[str]`

  Optional path prefix filter (raw string-prefix match; include a trailing slash for directory-scoped lists). This value appears in request URLs. Do not include secrets or personally identifiable information.

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BetaManagedAgentsMemoryListItem`

  One item in a [List memories](/docs/en/api/beta/memory_stores/memories/list) response: either a `memory` object or, when `depth` is set, a `memory_prefix` rollup marker.

  - `class BetaManagedAgentsMemory: …`

    A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

    - `id: str`

      Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

    - `content_sha256: str`

      Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

    - `content_size_bytes: int`

      Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `memory_store_id: str`

      ID of the memory store this memory belongs to (a `memstore_...` value).

    - `memory_version_id: str`

      ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

    - `path: str`

      Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

    - `type: Literal["memory"]`

      - `"memory"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `content: Optional[str]`

      The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

  - `class BetaManagedAgentsMemoryPrefix: …`

    A rolled-up directory marker returned by [List memories](/docs/en/api/beta/memory_stores/memories/list) when `depth` is set. Indicates that one or more memories exist deeper than the requested depth under this prefix. This is a list-time rollup, not a stored resource; it has no ID and no lifecycle. Each prefix counts toward the page `limit` and interleaves with `memory` items in path order.

    - `path: str`

      The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`). Pass this value as `path_prefix` on a subsequent list call to drill into the directory.

    - `type: Literal["memory_prefix"]`

      - `"memory_prefix"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.memory_stores.memories.list(
    memory_store_id="memory_store_id",
)
page = page.data[0]
print(page)
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "content_sha256": "content_sha256",
      "content_size_bytes": 0,
      "created_at": "2019-12-27T18:11:19.117Z",
      "memory_store_id": "memory_store_id",
      "memory_version_id": "memory_version_id",
      "path": "path",
      "type": "memory",
      "updated_at": "2019-12-27T18:11:19.117Z",
      "content": "content"
    }
  ],
  "next_page": "next_page"
}
```

## Retrieve a memory

`beta.memory_stores.memories.retrieve(strmemory_id, MemoryRetrieveParams**kwargs)  -> BetaManagedAgentsMemory`

**get** `/v1/memory_stores/{memory_store_id}/memories/{memory_id}`

Retrieve a memory

### Parameters

- `memory_store_id: str`

- `memory_id: str`

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemory: …`

  A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

  - `id: str`

    Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

  - `content_sha256: str`

    Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

  - `content_size_bytes: int`

    Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_store_id: str`

    ID of the memory store this memory belongs to (a `memstore_...` value).

  - `memory_version_id: str`

    ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

  - `path: str`

    Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

  - `type: Literal["memory"]`

    - `"memory"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `content: Optional[str]`

    The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory = client.beta.memory_stores.memories.retrieve(
    memory_id="memory_id",
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory.id)
```

#### Response

```json
{
  "id": "id",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_store_id": "memory_store_id",
  "memory_version_id": "memory_version_id",
  "path": "path",
  "type": "memory",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "content": "content"
}
```

## Update a memory

`beta.memory_stores.memories.update(strmemory_id, MemoryUpdateParams**kwargs)  -> BetaManagedAgentsMemory`

**post** `/v1/memory_stores/{memory_store_id}/memories/{memory_id}`

Update a memory

### Parameters

- `memory_store_id: str`

- `memory_id: str`

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `content: Optional[str]`

  New UTF-8 text content for the memory. Maximum 100 kB (102,400 bytes). Omit to leave the content unchanged (e.g., for a rename-only update).

- `path: Optional[str]`

  New path for the memory (a rename). Must start with `/`, contain at least one non-empty segment, and be at most 1,024 bytes. Must not contain empty segments, `.` or `..` segments, control or format characters, and must be NFC-normalized. Paths are case-sensitive. The memory's `id` is preserved across renames. Omit to leave the path unchanged.

- `precondition: Optional[BetaManagedAgentsPreconditionParam]`

  Optimistic-concurrency precondition: the update applies only if the memory's stored `content_sha256` equals the supplied value. On mismatch, the request returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and retry against the fresh state. If the precondition fails but the stored state already exactly matches the requested `content` and `path`, the server returns 200 instead of 409.

  - `type: Literal["content_sha256"]`

    - `"content_sha256"`

  - `content_sha256: Optional[str]`

    Expected `content_sha256` of the stored memory (64 lowercase hexadecimal characters). Typically the `content_sha256` returned by a prior read or list call. Because the server applies no content normalization, clients can also compute this locally as the SHA-256 of the UTF-8 content bytes.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemory: …`

  A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

  - `id: str`

    Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

  - `content_sha256: str`

    Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

  - `content_size_bytes: int`

    Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_store_id: str`

    ID of the memory store this memory belongs to (a `memstore_...` value).

  - `memory_version_id: str`

    ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

  - `path: str`

    Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

  - `type: Literal["memory"]`

    - `"memory"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `content: Optional[str]`

    The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory = client.beta.memory_stores.memories.update(
    memory_id="memory_id",
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory.id)
```

#### Response

```json
{
  "id": "id",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_store_id": "memory_store_id",
  "memory_version_id": "memory_version_id",
  "path": "path",
  "type": "memory",
  "updated_at": "2019-12-27T18:11:19.117Z",
  "content": "content"
}
```

## Delete a memory

`beta.memory_stores.memories.delete(strmemory_id, MemoryDeleteParams**kwargs)  -> BetaManagedAgentsDeletedMemory`

**delete** `/v1/memory_stores/{memory_store_id}/memories/{memory_id}`

Delete a memory

### Parameters

- `memory_store_id: str`

- `memory_id: str`

- `expected_content_sha256: Optional[str]`

  Query parameter for expected_content_sha256

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsDeletedMemory: …`

  Tombstone returned by [Delete a memory](/docs/en/api/beta/memory_stores/memories/delete). The memory's version history persists and remains listable via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) until the store itself is deleted.

  - `id: str`

    ID of the deleted memory (a `mem_...` value).

  - `type: Literal["memory_deleted"]`

    - `"memory_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_deleted_memory = client.beta.memory_stores.memories.delete(
    memory_id="memory_id",
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_deleted_memory.id)
```

#### Response

```json
{
  "id": "id",
  "type": "memory_deleted"
}
```

## Domain Types

### Beta Managed Agents Conflict Error

- `class BetaManagedAgentsConflictError: …`

  - `type: Literal["conflict_error"]`

    - `"conflict_error"`

  - `message: Optional[str]`

### Beta Managed Agents Content Sha256 Precondition

- `class BetaManagedAgentsContentSha256Precondition: …`

  Optimistic-concurrency precondition: the update applies only if the memory's stored `content_sha256` equals the supplied value. On mismatch, the request returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and retry against the fresh state. If the precondition fails but the stored state already exactly matches the requested `content` and `path`, the server returns 200 instead of 409.

  - `type: Literal["content_sha256"]`

    - `"content_sha256"`

  - `content_sha256: Optional[str]`

    Expected `content_sha256` of the stored memory (64 lowercase hexadecimal characters). Typically the `content_sha256` returned by a prior read or list call. Because the server applies no content normalization, clients can also compute this locally as the SHA-256 of the UTF-8 content bytes.

### Beta Managed Agents Deleted Memory

- `class BetaManagedAgentsDeletedMemory: …`

  Tombstone returned by [Delete a memory](/docs/en/api/beta/memory_stores/memories/delete). The memory's version history persists and remains listable via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) until the store itself is deleted.

  - `id: str`

    ID of the deleted memory (a `mem_...` value).

  - `type: Literal["memory_deleted"]`

    - `"memory_deleted"`

### Beta Managed Agents Error

- `BetaManagedAgentsError`

  - `class BetaInvalidRequestError: …`

    - `message: str`

    - `type: Literal["invalid_request_error"]`

      - `"invalid_request_error"`

  - `class BetaAuthenticationError: …`

    - `message: str`

    - `type: Literal["authentication_error"]`

      - `"authentication_error"`

  - `class BetaBillingError: …`

    - `message: str`

    - `type: Literal["billing_error"]`

      - `"billing_error"`

  - `class BetaPermissionError: …`

    - `message: str`

    - `type: Literal["permission_error"]`

      - `"permission_error"`

  - `class BetaNotFoundError: …`

    - `message: str`

    - `type: Literal["not_found_error"]`

      - `"not_found_error"`

  - `class BetaRateLimitError: …`

    - `message: str`

    - `type: Literal["rate_limit_error"]`

      - `"rate_limit_error"`

  - `class BetaGatewayTimeoutError: …`

    - `message: str`

    - `type: Literal["timeout_error"]`

      - `"timeout_error"`

  - `class BetaAPIError: …`

    - `message: str`

    - `type: Literal["api_error"]`

      - `"api_error"`

  - `class BetaOverloadedError: …`

    - `message: str`

    - `type: Literal["overloaded_error"]`

      - `"overloaded_error"`

  - `class BetaManagedAgentsMemoryPreconditionFailedError: …`

    - `type: Literal["memory_precondition_failed_error"]`

      - `"memory_precondition_failed_error"`

    - `message: Optional[str]`

  - `class BetaManagedAgentsMemoryPathConflictError: …`

    - `type: Literal["memory_path_conflict_error"]`

      - `"memory_path_conflict_error"`

    - `conflicting_memory_id: Optional[str]`

    - `conflicting_path: Optional[str]`

    - `message: Optional[str]`

  - `class BetaManagedAgentsConflictError: …`

    - `type: Literal["conflict_error"]`

      - `"conflict_error"`

    - `message: Optional[str]`

### Beta Managed Agents Memory

- `class BetaManagedAgentsMemory: …`

  A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

  - `id: str`

    Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

  - `content_sha256: str`

    Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

  - `content_size_bytes: int`

    Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_store_id: str`

    ID of the memory store this memory belongs to (a `memstore_...` value).

  - `memory_version_id: str`

    ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

  - `path: str`

    Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

  - `type: Literal["memory"]`

    - `"memory"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `content: Optional[str]`

    The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

### Beta Managed Agents Memory List Item

- `BetaManagedAgentsMemoryListItem`

  One item in a [List memories](/docs/en/api/beta/memory_stores/memories/list) response: either a `memory` object or, when `depth` is set, a `memory_prefix` rollup marker.

  - `class BetaManagedAgentsMemory: …`

    A `memory` object: a single text document at a hierarchical path inside a memory store. The `content` field is populated when `view=full` and `null` when `view=basic`; the `content_size_bytes` and `content_sha256` fields are always populated so sync clients can diff without fetching content. Memories are addressed by their `mem_...` ID; the path is the create key and can be changed via update.

    - `id: str`

      Unique identifier for this memory (a `mem_...` value). Stable across renames; use this ID, not the path, to read, update, or delete the memory.

    - `content_sha256: str`

      Lowercase hex SHA-256 digest of the UTF-8 `content` bytes (64 characters). The server applies no normalization, so clients can compute the same hash locally for staleness checks and as the value for a `content_sha256` precondition on update. Always populated, regardless of `view`.

    - `content_size_bytes: int`

      Size of `content` in bytes (the UTF-8 plaintext length). Always populated, regardless of `view`.

    - `created_at: datetime`

      A timestamp in RFC 3339 format

    - `memory_store_id: str`

      ID of the memory store this memory belongs to (a `memstore_...` value).

    - `memory_version_id: str`

      ID of the `memory_version` representing this memory's current content (a `memver_...` value). This is the authoritative head pointer; `memory_version` objects do not carry an `is_latest` flag, so compare against this field instead. Enumerate the full history via [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list).

    - `path: str`

      Hierarchical path of the memory within the store, e.g. `/projects/foo/notes.md`. Always starts with `/`. Paths are case-sensitive and unique within a store. Maximum 1,024 bytes.

    - `type: Literal["memory"]`

      - `"memory"`

    - `updated_at: datetime`

      A timestamp in RFC 3339 format

    - `content: Optional[str]`

      The memory's UTF-8 text content. Populated when `view=full`; `null` when `view=basic`. Maximum 100 kB (102,400 bytes).

  - `class BetaManagedAgentsMemoryPrefix: …`

    A rolled-up directory marker returned by [List memories](/docs/en/api/beta/memory_stores/memories/list) when `depth` is set. Indicates that one or more memories exist deeper than the requested depth under this prefix. This is a list-time rollup, not a stored resource; it has no ID and no lifecycle. Each prefix counts toward the page `limit` and interleaves with `memory` items in path order.

    - `path: str`

      The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`). Pass this value as `path_prefix` on a subsequent list call to drill into the directory.

    - `type: Literal["memory_prefix"]`

      - `"memory_prefix"`

### Beta Managed Agents Memory Path Conflict Error

- `class BetaManagedAgentsMemoryPathConflictError: …`

  - `type: Literal["memory_path_conflict_error"]`

    - `"memory_path_conflict_error"`

  - `conflicting_memory_id: Optional[str]`

  - `conflicting_path: Optional[str]`

  - `message: Optional[str]`

### Beta Managed Agents Memory Precondition Failed Error

- `class BetaManagedAgentsMemoryPreconditionFailedError: …`

  - `type: Literal["memory_precondition_failed_error"]`

    - `"memory_precondition_failed_error"`

  - `message: Optional[str]`

### Beta Managed Agents Memory Prefix

- `class BetaManagedAgentsMemoryPrefix: …`

  A rolled-up directory marker returned by [List memories](/docs/en/api/beta/memory_stores/memories/list) when `depth` is set. Indicates that one or more memories exist deeper than the requested depth under this prefix. This is a list-time rollup, not a stored resource; it has no ID and no lifecycle. Each prefix counts toward the page `limit` and interleaves with `memory` items in path order.

  - `path: str`

    The rolled-up path prefix, including a trailing `/` (e.g. `/projects/foo/`). Pass this value as `path_prefix` on a subsequent list call to drill into the directory.

  - `type: Literal["memory_prefix"]`

    - `"memory_prefix"`

### Beta Managed Agents Memory View

- `Literal["basic", "full"]`

  Selects which projection of a `memory` or `memory_version` the server returns. `basic` returns the object with `content` set to `null`; `full` populates `content`. When omitted, the default is endpoint-specific: retrieve operations default to `full`; list, create, and update operations default to `basic`. Listing with `view=full` caps `limit` at 20.

  - `"basic"`

  - `"full"`

### Beta Managed Agents Precondition

- `class BetaManagedAgentsPrecondition: …`

  Optimistic-concurrency precondition: the update applies only if the memory's stored `content_sha256` equals the supplied value. On mismatch, the request returns `memory_precondition_failed_error` (HTTP 409); re-read the memory and retry against the fresh state. If the precondition fails but the stored state already exactly matches the requested `content` and `path`, the server returns 200 instead of 409.

  - `type: Literal["content_sha256"]`

    - `"content_sha256"`

  - `content_sha256: Optional[str]`

    Expected `content_sha256` of the stored memory (64 lowercase hexadecimal characters). Typically the `content_sha256` returned by a prior read or list call. Because the server applies no content normalization, clients can also compute this locally as the SHA-256 of the UTF-8 content bytes.

# Memory Versions

## List memory versions

`beta.memory_stores.memory_versions.list(strmemory_store_id, MemoryVersionListParams**kwargs)  -> SyncPageCursor[BetaManagedAgentsMemoryVersion]`

**get** `/v1/memory_stores/{memory_store_id}/memory_versions`

List memory versions

### Parameters

- `memory_store_id: str`

- `api_key_id: Optional[str]`

  Query parameter for api_key_id

- `created_at_gte: Optional[Union[str, datetime]]`

  Return versions created at or after this time (inclusive).

- `created_at_lte: Optional[Union[str, datetime]]`

  Return versions created at or before this time (inclusive).

- `limit: Optional[int]`

  Query parameter for limit

- `memory_id: Optional[str]`

  Query parameter for memory_id

- `operation: Optional[BetaManagedAgentsMemoryVersionOperation]`

  Query parameter for operation

  - `"created"`

  - `"modified"`

  - `"deleted"`

- `page: Optional[str]`

  Query parameter for page

- `session_id: Optional[str]`

  Query parameter for session_id

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryVersion: …`

  A `memory_version` object: one immutable, attributed row in a memory's append-only history. Every non-no-op mutation to a memory produces a new version. Versions belong to the store (not the individual memory) and persist after the memory is deleted. Retrieving a redacted version returns 200 with `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`; branch on `redacted_at`, not HTTP status.

  - `id: str`

    Unique identifier for this version (a `memver_...` value).

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_id: str`

    ID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) to retrieve the full lineage including the `deleted` row.

  - `memory_store_id: str`

    ID of the memory store this version belongs to (a `memstore_...` value).

  - `operation: BetaManagedAgentsMemoryVersionOperation`

    The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.

    - `"created"`

    - `"modified"`

    - `"deleted"`

  - `type: Literal["memory_version"]`

    - `"memory_version"`

  - `content: Optional[str]`

    The memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.

  - `content_sha256: Optional[str]`

    Lowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `content_size_bytes: Optional[int]`

    Size of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `created_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

    - `class BetaManagedAgentsSessionActor: …`

      Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

      - `session_id: str`

        ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

      - `type: Literal["session_actor"]`

        - `"session_actor"`

    - `class BetaManagedAgentsAPIActor: …`

      Attribution for a write made directly via the public API (outside of any session).

      - `api_key_id: str`

        ID of the API key that performed the write. This identifies the key, not the secret.

      - `type: Literal["api_actor"]`

        - `"api_actor"`

    - `class BetaManagedAgentsUserActor: …`

      Attribution for a write made by a human user through the Anthropic Console.

      - `type: Literal["user_actor"]`

        - `"user_actor"`

      - `user_id: str`

        ID of the user who performed the write (a `user_...` value).

  - `path: Optional[str]`

    The memory's path at the time of this write. `null` if and only if `redacted_at` is set.

  - `redacted_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `redacted_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.memory_stores.memory_versions.list(
    memory_store_id="memory_store_id",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "id",
      "created_at": "2019-12-27T18:11:19.117Z",
      "memory_id": "memory_id",
      "memory_store_id": "memory_store_id",
      "operation": "created",
      "type": "memory_version",
      "content": "content",
      "content_sha256": "content_sha256",
      "content_size_bytes": 0,
      "created_by": {
        "session_id": "x",
        "type": "session_actor"
      },
      "path": "path",
      "redacted_at": "2019-12-27T18:11:19.117Z",
      "redacted_by": {
        "session_id": "x",
        "type": "session_actor"
      }
    }
  ],
  "next_page": "next_page"
}
```

## Retrieve a memory version

`beta.memory_stores.memory_versions.retrieve(strmemory_version_id, MemoryVersionRetrieveParams**kwargs)  -> BetaManagedAgentsMemoryVersion`

**get** `/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}`

Retrieve a memory version

### Parameters

- `memory_store_id: str`

- `memory_version_id: str`

- `view: Optional[BetaManagedAgentsMemoryView]`

  Query parameter for view

  - `"basic"`

  - `"full"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryVersion: …`

  A `memory_version` object: one immutable, attributed row in a memory's append-only history. Every non-no-op mutation to a memory produces a new version. Versions belong to the store (not the individual memory) and persist after the memory is deleted. Retrieving a redacted version returns 200 with `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`; branch on `redacted_at`, not HTTP status.

  - `id: str`

    Unique identifier for this version (a `memver_...` value).

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_id: str`

    ID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) to retrieve the full lineage including the `deleted` row.

  - `memory_store_id: str`

    ID of the memory store this version belongs to (a `memstore_...` value).

  - `operation: BetaManagedAgentsMemoryVersionOperation`

    The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.

    - `"created"`

    - `"modified"`

    - `"deleted"`

  - `type: Literal["memory_version"]`

    - `"memory_version"`

  - `content: Optional[str]`

    The memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.

  - `content_sha256: Optional[str]`

    Lowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `content_size_bytes: Optional[int]`

    Size of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `created_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

    - `class BetaManagedAgentsSessionActor: …`

      Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

      - `session_id: str`

        ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

      - `type: Literal["session_actor"]`

        - `"session_actor"`

    - `class BetaManagedAgentsAPIActor: …`

      Attribution for a write made directly via the public API (outside of any session).

      - `api_key_id: str`

        ID of the API key that performed the write. This identifies the key, not the secret.

      - `type: Literal["api_actor"]`

        - `"api_actor"`

    - `class BetaManagedAgentsUserActor: …`

      Attribution for a write made by a human user through the Anthropic Console.

      - `type: Literal["user_actor"]`

        - `"user_actor"`

      - `user_id: str`

        ID of the user who performed the write (a `user_...` value).

  - `path: Optional[str]`

    The memory's path at the time of this write. `null` if and only if `redacted_at` is set.

  - `redacted_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `redacted_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_version = client.beta.memory_stores.memory_versions.retrieve(
    memory_version_id="memory_version_id",
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory_version.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_id": "memory_id",
  "memory_store_id": "memory_store_id",
  "operation": "created",
  "type": "memory_version",
  "content": "content",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_by": {
    "session_id": "x",
    "type": "session_actor"
  },
  "path": "path",
  "redacted_at": "2019-12-27T18:11:19.117Z",
  "redacted_by": {
    "session_id": "x",
    "type": "session_actor"
  }
}
```

## Redact a memory version

`beta.memory_stores.memory_versions.redact(strmemory_version_id, MemoryVersionRedactParams**kwargs)  -> BetaManagedAgentsMemoryVersion`

**post** `/v1/memory_stores/{memory_store_id}/memory_versions/{memory_version_id}/redact`

Redact a memory version

### Parameters

- `memory_store_id: str`

- `memory_version_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaManagedAgentsMemoryVersion: …`

  A `memory_version` object: one immutable, attributed row in a memory's append-only history. Every non-no-op mutation to a memory produces a new version. Versions belong to the store (not the individual memory) and persist after the memory is deleted. Retrieving a redacted version returns 200 with `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`; branch on `redacted_at`, not HTTP status.

  - `id: str`

    Unique identifier for this version (a `memver_...` value).

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_id: str`

    ID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) to retrieve the full lineage including the `deleted` row.

  - `memory_store_id: str`

    ID of the memory store this version belongs to (a `memstore_...` value).

  - `operation: BetaManagedAgentsMemoryVersionOperation`

    The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.

    - `"created"`

    - `"modified"`

    - `"deleted"`

  - `type: Literal["memory_version"]`

    - `"memory_version"`

  - `content: Optional[str]`

    The memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.

  - `content_sha256: Optional[str]`

    Lowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `content_size_bytes: Optional[int]`

    Size of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `created_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

    - `class BetaManagedAgentsSessionActor: …`

      Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

      - `session_id: str`

        ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

      - `type: Literal["session_actor"]`

        - `"session_actor"`

    - `class BetaManagedAgentsAPIActor: …`

      Attribution for a write made directly via the public API (outside of any session).

      - `api_key_id: str`

        ID of the API key that performed the write. This identifies the key, not the secret.

      - `type: Literal["api_actor"]`

        - `"api_actor"`

    - `class BetaManagedAgentsUserActor: …`

      Attribution for a write made by a human user through the Anthropic Console.

      - `type: Literal["user_actor"]`

        - `"user_actor"`

      - `user_id: str`

        ID of the user who performed the write (a `user_...` value).

  - `path: Optional[str]`

    The memory's path at the time of this write. `null` if and only if `redacted_at` is set.

  - `redacted_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `redacted_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_managed_agents_memory_version = client.beta.memory_stores.memory_versions.redact(
    memory_version_id="memory_version_id",
    memory_store_id="memory_store_id",
)
print(beta_managed_agents_memory_version.id)
```

#### Response

```json
{
  "id": "id",
  "created_at": "2019-12-27T18:11:19.117Z",
  "memory_id": "memory_id",
  "memory_store_id": "memory_store_id",
  "operation": "created",
  "type": "memory_version",
  "content": "content",
  "content_sha256": "content_sha256",
  "content_size_bytes": 0,
  "created_by": {
    "session_id": "x",
    "type": "session_actor"
  },
  "path": "path",
  "redacted_at": "2019-12-27T18:11:19.117Z",
  "redacted_by": {
    "session_id": "x",
    "type": "session_actor"
  }
}
```

## Domain Types

### Beta Managed Agents Actor

- `BetaManagedAgentsActor`

  Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

  - `class BetaManagedAgentsSessionActor: …`

    Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

    - `session_id: str`

      ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

    - `type: Literal["session_actor"]`

      - `"session_actor"`

  - `class BetaManagedAgentsAPIActor: …`

    Attribution for a write made directly via the public API (outside of any session).

    - `api_key_id: str`

      ID of the API key that performed the write. This identifies the key, not the secret.

    - `type: Literal["api_actor"]`

      - `"api_actor"`

  - `class BetaManagedAgentsUserActor: …`

    Attribution for a write made by a human user through the Anthropic Console.

    - `type: Literal["user_actor"]`

      - `"user_actor"`

    - `user_id: str`

      ID of the user who performed the write (a `user_...` value).

### Beta Managed Agents API Actor

- `class BetaManagedAgentsAPIActor: …`

  Attribution for a write made directly via the public API (outside of any session).

  - `api_key_id: str`

    ID of the API key that performed the write. This identifies the key, not the secret.

  - `type: Literal["api_actor"]`

    - `"api_actor"`

### Beta Managed Agents Memory Version

- `class BetaManagedAgentsMemoryVersion: …`

  A `memory_version` object: one immutable, attributed row in a memory's append-only history. Every non-no-op mutation to a memory produces a new version. Versions belong to the store (not the individual memory) and persist after the memory is deleted. Retrieving a redacted version returns 200 with `content`, `path`, `content_size_bytes`, and `content_sha256` set to `null`; branch on `redacted_at`, not HTTP status.

  - `id: str`

    Unique identifier for this version (a `memver_...` value).

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `memory_id: str`

    ID of the memory this version snapshots (a `mem_...` value). Remains valid after the memory is deleted; pass it as `memory_id` to [List memory versions](/docs/en/api/beta/memory_stores/memory_versions/list) to retrieve the full lineage including the `deleted` row.

  - `memory_store_id: str`

    ID of the memory store this version belongs to (a `memstore_...` value).

  - `operation: BetaManagedAgentsMemoryVersionOperation`

    The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.

    - `"created"`

    - `"modified"`

    - `"deleted"`

  - `type: Literal["memory_version"]`

    - `"memory_version"`

  - `content: Optional[str]`

    The memory's UTF-8 text content as of this version. `null` when `view=basic`, when `operation` is `deleted`, or when `redacted_at` is set.

  - `content_sha256: Optional[str]`

    Lowercase hex SHA-256 digest of `content` as of this version (64 characters). `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `content_size_bytes: Optional[int]`

    Size of `content` in bytes as of this version. `null` when `redacted_at` is set or `operation` is `deleted`. Populated regardless of `view` otherwise.

  - `created_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

    - `class BetaManagedAgentsSessionActor: …`

      Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

      - `session_id: str`

        ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

      - `type: Literal["session_actor"]`

        - `"session_actor"`

    - `class BetaManagedAgentsAPIActor: …`

      Attribution for a write made directly via the public API (outside of any session).

      - `api_key_id: str`

        ID of the API key that performed the write. This identifies the key, not the secret.

      - `type: Literal["api_actor"]`

        - `"api_actor"`

    - `class BetaManagedAgentsUserActor: …`

      Attribution for a write made by a human user through the Anthropic Console.

      - `type: Literal["user_actor"]`

        - `"user_actor"`

      - `user_id: str`

        ID of the user who performed the write (a `user_...` value).

  - `path: Optional[str]`

    The memory's path at the time of this write. `null` if and only if `redacted_at` is set.

  - `redacted_at: Optional[datetime]`

    A timestamp in RFC 3339 format

  - `redacted_by: Optional[BetaManagedAgentsActor]`

    Identifies who performed a write or redact operation. Captured at write time on the `memory_version` row. The API key that created a session is not recorded on agent writes; attribution answers who made the write, not who is ultimately responsible. Look up session provenance separately via the [Sessions API](/docs/en/api/sessions-retrieve).

### Beta Managed Agents Memory Version Operation

- `Literal["created", "modified", "deleted"]`

  The kind of mutation a `memory_version` records. Every non-no-op mutation to a memory appends exactly one version row with one of these values.

  - `"created"`

  - `"modified"`

  - `"deleted"`

### Beta Managed Agents Session Actor

- `class BetaManagedAgentsSessionActor: …`

  Attribution for a write made by an agent during a session, through the mounted filesystem at `/mnt/memory/`.

  - `session_id: str`

    ID of the session that performed the write (a `sesn_...` value). Look up the session via [Retrieve a session](/docs/en/api/sessions-retrieve) for further provenance.

  - `type: Literal["session_actor"]`

    - `"session_actor"`

### Beta Managed Agents User Actor

- `class BetaManagedAgentsUserActor: …`

  Attribution for a write made by a human user through the Anthropic Console.

  - `type: Literal["user_actor"]`

    - `"user_actor"`

  - `user_id: str`

    ID of the user who performed the write (a `user_...` value).

# Files

## Upload File

`beta.files.upload(FileUploadParams**kwargs)  -> FileMetadata`

**post** `/v1/files`

Upload File

### Parameters

- `file: FileTypes`

  The file to upload

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class FileMetadata: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `created_at: datetime`

    RFC 3339 datetime string representing when the file was created.

  - `filename: str`

    Original filename of the uploaded file.

  - `mime_type: str`

    MIME type of the file.

  - `size_bytes: int`

    Size of the file in bytes.

  - `type: Literal["file"]`

    Object type.

    For files, this is always `"file"`.

    - `"file"`

  - `downloadable: Optional[bool]`

    Whether the file can be downloaded.

  - `scope: Optional[BetaFileScope]`

    The scope of this file, indicating the context in which it was created (e.g., a session).

    - `id: str`

      The ID of the scoping resource (e.g., the session ID).

    - `type: Literal["session"]`

      The type of scope (e.g., `"session"`).

      - `"session"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
file_metadata = client.beta.files.upload(
    file=b"Example data",
)
print(file_metadata.id)
```

#### Response

```json
{
  "id": "file_011CNha8iCJcU1wXNR6q4V8w",
  "created_at": "2025-04-15T18:37:24.100435Z",
  "filename": "document.pdf",
  "mime_type": "application/pdf",
  "size_bytes": 102400,
  "type": "file",
  "downloadable": false,
  "scope": {
    "id": "id",
    "type": "session"
  }
}
```

## List Files

`beta.files.list(FileListParams**kwargs)  -> SyncPage[FileMetadata]`

**get** `/v1/files`

List Files

### Parameters

- `after_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately after this object.

- `before_id: Optional[str]`

  ID of the object to use as a cursor for pagination. When provided, returns the page of results immediately before this object.

- `limit: Optional[int]`

  Number of items to return per page.

  Defaults to `20`. Ranges from `1` to `1000`.

- `scope_id: Optional[str]`

  Filter by scope ID. Only returns files associated with the specified scope (e.g., a session ID).

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class FileMetadata: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `created_at: datetime`

    RFC 3339 datetime string representing when the file was created.

  - `filename: str`

    Original filename of the uploaded file.

  - `mime_type: str`

    MIME type of the file.

  - `size_bytes: int`

    Size of the file in bytes.

  - `type: Literal["file"]`

    Object type.

    For files, this is always `"file"`.

    - `"file"`

  - `downloadable: Optional[bool]`

    Whether the file can be downloaded.

  - `scope: Optional[BetaFileScope]`

    The scope of this file, indicating the context in which it was created (e.g., a session).

    - `id: str`

      The ID of the scoping resource (e.g., the session ID).

    - `type: Literal["session"]`

      The type of scope (e.g., `"session"`).

      - `"session"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.files.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "file_011CNha8iCJcU1wXNR6q4V8w",
      "created_at": "2025-04-15T18:37:24.100435Z",
      "filename": "document.pdf",
      "mime_type": "application/pdf",
      "size_bytes": 102400,
      "type": "file",
      "downloadable": false,
      "scope": {
        "id": "id",
        "type": "session"
      }
    }
  ],
  "first_id": "file_011CNha8iCJcU1wXNR6q4V8w",
  "has_more": true,
  "last_id": "file_013Zva2CMHLNnXjNJJKqJ2EF"
}
```

## Download File

`beta.files.download(strfile_id, FileDownloadParams**kwargs)  -> BinaryResponseContent`

**get** `/v1/files/{file_id}/content`

Download File

### Parameters

- `file_id: str`

  ID of the File.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BinaryResponseContent`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
response = client.beta.files.download(
    file_id="file_id",
)
print(response)
content = response.read()
print(content)
```

## Get File Metadata

`beta.files.retrieve_metadata(strfile_id, FileRetrieveMetadataParams**kwargs)  -> FileMetadata`

**get** `/v1/files/{file_id}`

Get File Metadata

### Parameters

- `file_id: str`

  ID of the File.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class FileMetadata: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `created_at: datetime`

    RFC 3339 datetime string representing when the file was created.

  - `filename: str`

    Original filename of the uploaded file.

  - `mime_type: str`

    MIME type of the file.

  - `size_bytes: int`

    Size of the file in bytes.

  - `type: Literal["file"]`

    Object type.

    For files, this is always `"file"`.

    - `"file"`

  - `downloadable: Optional[bool]`

    Whether the file can be downloaded.

  - `scope: Optional[BetaFileScope]`

    The scope of this file, indicating the context in which it was created (e.g., a session).

    - `id: str`

      The ID of the scoping resource (e.g., the session ID).

    - `type: Literal["session"]`

      The type of scope (e.g., `"session"`).

      - `"session"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
file_metadata = client.beta.files.retrieve_metadata(
    file_id="file_id",
)
print(file_metadata.id)
```

#### Response

```json
{
  "id": "file_011CNha8iCJcU1wXNR6q4V8w",
  "created_at": "2025-04-15T18:37:24.100435Z",
  "filename": "document.pdf",
  "mime_type": "application/pdf",
  "size_bytes": 102400,
  "type": "file",
  "downloadable": false,
  "scope": {
    "id": "id",
    "type": "session"
  }
}
```

## Delete File

`beta.files.delete(strfile_id, FileDeleteParams**kwargs)  -> DeletedFile`

**delete** `/v1/files/{file_id}`

Delete File

### Parameters

- `file_id: str`

  ID of the File.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class DeletedFile: …`

  - `id: str`

    ID of the deleted file.

  - `type: Optional[Literal["file_deleted"]]`

    Deleted object type.

    For file deletion, this is always `"file_deleted"`.

    - `"file_deleted"`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
deleted_file = client.beta.files.delete(
    file_id="file_id",
)
print(deleted_file.id)
```

#### Response

```json
{
  "id": "file_011CNha8iCJcU1wXNR6q4V8w",
  "type": "file_deleted"
}
```

## Domain Types

### Beta File Scope

- `class BetaFileScope: …`

  - `id: str`

    The ID of the scoping resource (e.g., the session ID).

  - `type: Literal["session"]`

    The type of scope (e.g., `"session"`).

    - `"session"`

### Deleted File

- `class DeletedFile: …`

  - `id: str`

    ID of the deleted file.

  - `type: Optional[Literal["file_deleted"]]`

    Deleted object type.

    For file deletion, this is always `"file_deleted"`.

    - `"file_deleted"`

### File Metadata

- `class FileMetadata: …`

  - `id: str`

    Unique object identifier.

    The format and length of IDs may change over time.

  - `created_at: datetime`

    RFC 3339 datetime string representing when the file was created.

  - `filename: str`

    Original filename of the uploaded file.

  - `mime_type: str`

    MIME type of the file.

  - `size_bytes: int`

    Size of the file in bytes.

  - `type: Literal["file"]`

    Object type.

    For files, this is always `"file"`.

    - `"file"`

  - `downloadable: Optional[bool]`

    Whether the file can be downloaded.

  - `scope: Optional[BetaFileScope]`

    The scope of this file, indicating the context in which it was created (e.g., a session).

    - `id: str`

      The ID of the scoping resource (e.g., the session ID).

    - `type: Literal["session"]`

      The type of scope (e.g., `"session"`).

      - `"session"`

# Skills

## Create Skill

`beta.skills.create(SkillCreateParams**kwargs)  -> SkillCreateResponse`

**post** `/v1/skills`

Create Skill

### Parameters

- `display_title: Optional[str]`

  Display title for the skill.

  This is a human-readable label that is not included in the prompt sent to the model.

- `files: Optional[Sequence[FileTypes]]`

  Files to upload for the skill.

  All files must be in the same top-level directory and must include a SKILL.md file at the root of that directory.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class SkillCreateResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
skill = client.beta.skills.create()
print(skill.id)
```

#### Response

```json
{
  "id": "skill_01JAbcdefghijklmnopqrstuvw",
  "created_at": "2024-10-30T23:58:27.427722Z",
  "display_title": "My Custom Skill",
  "latest_version": "1759178010641129",
  "source": "custom",
  "type": "type",
  "updated_at": "2024-10-30T23:58:27.427722Z"
}
```

## List Skills

`beta.skills.list(SkillListParams**kwargs)  -> SyncPageCursor[SkillListResponse]`

**get** `/v1/skills`

List Skills

### Parameters

- `limit: Optional[int]`

  Number of results to return per page.

  Maximum value is 100. Defaults to 20.

- `page: Optional[str]`

  Pagination token for fetching a specific page of results.

  Pass the value from a previous response's `next_page` field to get the next page of results.

- `source: Optional[str]`

  Filter skills by source.

  If provided, only skills from the specified source will be returned:

  * `"custom"`: only return user-created skills
  * `"anthropic"`: only return Anthropic-created skills

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class SkillListResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.skills.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "skill_01JAbcdefghijklmnopqrstuvw",
      "created_at": "2024-10-30T23:58:27.427722Z",
      "display_title": "My Custom Skill",
      "latest_version": "1759178010641129",
      "source": "custom",
      "type": "type",
      "updated_at": "2024-10-30T23:58:27.427722Z"
    }
  ],
  "has_more": true,
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get Skill

`beta.skills.retrieve(strskill_id, SkillRetrieveParams**kwargs)  -> SkillRetrieveResponse`

**get** `/v1/skills/{skill_id}`

Get Skill

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class SkillRetrieveResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
skill = client.beta.skills.retrieve(
    skill_id="skill_id",
)
print(skill.id)
```

#### Response

```json
{
  "id": "skill_01JAbcdefghijklmnopqrstuvw",
  "created_at": "2024-10-30T23:58:27.427722Z",
  "display_title": "My Custom Skill",
  "latest_version": "1759178010641129",
  "source": "custom",
  "type": "type",
  "updated_at": "2024-10-30T23:58:27.427722Z"
}
```

## Delete Skill

`beta.skills.delete(strskill_id, SkillDeleteParams**kwargs)  -> SkillDeleteResponse`

**delete** `/v1/skills/{skill_id}`

Delete Skill

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class SkillDeleteResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `type: str`

    Deleted object type.

    For Skills, this is always `"skill_deleted"`.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
skill = client.beta.skills.delete(
    skill_id="skill_id",
)
print(skill.id)
```

#### Response

```json
{
  "id": "skill_01JAbcdefghijklmnopqrstuvw",
  "type": "type"
}
```

## Domain Types

### Skill Create Response

- `class SkillCreateResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Skill List Response

- `class SkillListResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Skill Retrieve Response

- `class SkillRetrieveResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill was created.

  - `display_title: Optional[str]`

    Display title for the skill.

    This is a human-readable label that is not included in the prompt sent to the model.

  - `latest_version: Optional[str]`

    The latest version identifier for the skill.

    This represents the most recent version of the skill that has been created.

  - `source: str`

    Source of the skill.

    This may be one of the following values:

    * `"custom"`: the skill was created by a user
    * `"anthropic"`: the skill was created by Anthropic

  - `type: str`

    Object type.

    For Skills, this is always `"skill"`.

  - `updated_at: str`

    ISO 8601 timestamp of when the skill was last updated.

### Skill Delete Response

- `class SkillDeleteResponse: …`

  - `id: str`

    Unique identifier for the skill.

    The format and length of IDs may change over time.

  - `type: str`

    Deleted object type.

    For Skills, this is always `"skill_deleted"`.

# Versions

## Create Skill Version

`beta.skills.versions.create(strskill_id, VersionCreateParams**kwargs)  -> VersionCreateResponse`

**post** `/v1/skills/{skill_id}/versions`

Create Skill Version

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `files: Optional[Sequence[FileTypes]]`

  Files to upload for the skill.

  All files must be in the same top-level directory and must include a SKILL.md file at the root of that directory.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class VersionCreateResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
version = client.beta.skills.versions.create(
    skill_id="skill_id",
)
print(version.id)
```

#### Response

```json
{
  "id": "skillver_01JAbcdefghijklmnopqrstuvw",
  "created_at": "2024-10-30T23:58:27.427722Z",
  "description": "A custom skill for doing something useful",
  "directory": "my-skill",
  "name": "my-skill",
  "skill_id": "skill_01JAbcdefghijklmnopqrstuvw",
  "type": "type",
  "version": "1759178010641129"
}
```

## List Skill Versions

`beta.skills.versions.list(strskill_id, VersionListParams**kwargs)  -> SyncPageCursor[VersionListResponse]`

**get** `/v1/skills/{skill_id}/versions`

List Skill Versions

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `limit: Optional[int]`

  Number of items to return per page.

  Defaults to `20`. Ranges from `1` to `1000`.

- `page: Optional[str]`

  Optionally set to the `next_page` token from the previous response.

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class VersionListResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.skills.versions.list(
    skill_id="skill_id",
)
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "skillver_01JAbcdefghijklmnopqrstuvw",
      "created_at": "2024-10-30T23:58:27.427722Z",
      "description": "A custom skill for doing something useful",
      "directory": "my-skill",
      "name": "my-skill",
      "skill_id": "skill_01JAbcdefghijklmnopqrstuvw",
      "type": "type",
      "version": "1759178010641129"
    }
  ],
  "has_more": true,
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Download Skill Version Content

`beta.skills.versions.download(strversion, VersionDownloadParams**kwargs)  -> BinaryResponseContent`

**get** `/v1/skills/{skill_id}/versions/{version}/content`

Download a skill version's content as a zip archive.

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `version: str`

  Version identifier for the skill.

  Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `BinaryResponseContent`

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
response = client.beta.skills.versions.download(
    version="version",
    skill_id="skill_id",
)
print(response)
content = response.read()
print(content)
```

## Get Skill Version

`beta.skills.versions.retrieve(strversion, VersionRetrieveParams**kwargs)  -> VersionRetrieveResponse`

**get** `/v1/skills/{skill_id}/versions/{version}`

Get Skill Version

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `version: str`

  Version identifier for the skill.

  Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class VersionRetrieveResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
version = client.beta.skills.versions.retrieve(
    version="version",
    skill_id="skill_id",
)
print(version.id)
```

#### Response

```json
{
  "id": "skillver_01JAbcdefghijklmnopqrstuvw",
  "created_at": "2024-10-30T23:58:27.427722Z",
  "description": "A custom skill for doing something useful",
  "directory": "my-skill",
  "name": "my-skill",
  "skill_id": "skill_01JAbcdefghijklmnopqrstuvw",
  "type": "type",
  "version": "1759178010641129"
}
```

## Delete Skill Version

`beta.skills.versions.delete(strversion, VersionDeleteParams**kwargs)  -> VersionDeleteResponse`

**delete** `/v1/skills/{skill_id}/versions/{version}`

Delete Skill Version

### Parameters

- `skill_id: str`

  Unique identifier for the skill.

  The format and length of IDs may change over time.

- `version: str`

  Version identifier for the skill.

  Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class VersionDeleteResponse: …`

  - `id: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

  - `type: str`

    Deleted object type.

    For Skill Versions, this is always `"skill_version_deleted"`.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
version = client.beta.skills.versions.delete(
    version="version",
    skill_id="skill_id",
)
print(version.id)
```

#### Response

```json
{
  "id": "1759178010641129",
  "type": "type"
}
```

## Domain Types

### Version Create Response

- `class VersionCreateResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Version List Response

- `class VersionListResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Version Retrieve Response

- `class VersionRetrieveResponse: …`

  - `id: str`

    Unique identifier for the skill version.

    The format and length of IDs may change over time.

  - `created_at: str`

    ISO 8601 timestamp of when the skill version was created.

  - `description: str`

    Description of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `directory: str`

    Directory name of the skill version.

    This is the top-level directory name that was extracted from the uploaded files.

  - `name: str`

    Human-readable name of the skill version.

    This is extracted from the SKILL.md file in the skill upload.

  - `skill_id: str`

    Identifier for the skill that this version belongs to.

  - `type: str`

    Object type.

    For Skill Versions, this is always `"skill_version"`.

  - `version: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

### Version Delete Response

- `class VersionDeleteResponse: …`

  - `id: str`

    Version identifier for the skill.

    Each version is identified by a Unix epoch timestamp (e.g., "1759178010641129").

  - `type: str`

    Deleted object type.

    For Skill Versions, this is always `"skill_version_deleted"`.

# User Profiles

## Create User Profile

`beta.user_profiles.create(UserProfileCreateParams**kwargs)  -> BetaUserProfile`

**post** `/v1/user_profiles`

Create User Profile

### Parameters

- `external_id: Optional[str]`

  Platform's own identifier for this user. Not enforced unique. Maximum 255 characters.

- `metadata: Optional[Dict[str, str]]`

  Free-form key-value data to attach to this user profile. Maximum 16 keys, with keys up to 64 characters and values up to 512 characters. Values must be non-empty strings.

- `name: Optional[str]`

  Display name of the entity this profile represents. Required when relationship is `resold` (the resold-to company's name); optional otherwise. Maximum 255 characters.

- `relationship: Optional[Literal["external", "resold", "internal"]]`

  How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

  - `"external"`

  - `"resold"`

  - `"internal"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaUserProfile: …`

  - `id: str`

    Unique identifier for this user profile, prefixed `uprof_`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  - `relationship: Literal["external", "resold", "internal"]`

    How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

    - `"external"`

    - `"resold"`

    - `"internal"`

  - `trust_grants: Dict[str, BetaUserProfileTrustGrant]`

    Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight.

    - `status: Literal["active", "pending", "rejected"]`

      Status of the trust grant.

      - `"active"`

      - `"pending"`

      - `"rejected"`

  - `type: Literal["user_profile"]`

    Object type. Always `user_profile`.

    - `"user_profile"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `external_id: Optional[str]`

    Platform's own identifier for this user. Not enforced unique.

  - `name: Optional[str]`

    Display name of the entity this profile represents. For `resold` this is the resold-to company's name.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_user_profile = client.beta.user_profiles.create()
print(beta_user_profile.id)
```

#### Response

```json
{
  "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {},
  "relationship": "external",
  "trust_grants": {
    "cyber": {
      "status": "active"
    }
  },
  "type": "user_profile",
  "updated_at": "2026-03-15T10:00:00Z",
  "external_id": "user_12345",
  "name": "Example User"
}
```

## List User Profiles

`beta.user_profiles.list(UserProfileListParams**kwargs)  -> SyncPageCursor[BetaUserProfile]`

**get** `/v1/user_profiles`

List User Profiles

### Parameters

- `limit: Optional[int]`

  Query parameter for limit

- `order: Optional[Literal["asc", "desc"]]`

  Query parameter for order

  - `"asc"`

  - `"desc"`

- `page: Optional[str]`

  Query parameter for page

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaUserProfile: …`

  - `id: str`

    Unique identifier for this user profile, prefixed `uprof_`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  - `relationship: Literal["external", "resold", "internal"]`

    How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

    - `"external"`

    - `"resold"`

    - `"internal"`

  - `trust_grants: Dict[str, BetaUserProfileTrustGrant]`

    Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight.

    - `status: Literal["active", "pending", "rejected"]`

      Status of the trust grant.

      - `"active"`

      - `"pending"`

      - `"rejected"`

  - `type: Literal["user_profile"]`

    Object type. Always `user_profile`.

    - `"user_profile"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `external_id: Optional[str]`

    Platform's own identifier for this user. Not enforced unique.

  - `name: Optional[str]`

    Display name of the entity this profile represents. For `resold` this is the resold-to company's name.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
page = client.beta.user_profiles.list()
page = page.data[0]
print(page.id)
```

#### Response

```json
{
  "data": [
    {
      "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
      "created_at": "2026-03-15T10:00:00Z",
      "metadata": {},
      "relationship": "external",
      "trust_grants": {
        "cyber": {
          "status": "active"
        }
      },
      "type": "user_profile",
      "updated_at": "2026-03-15T10:00:00Z",
      "external_id": "user_12345",
      "name": "Example User"
    }
  ],
  "next_page": "page_MjAyNS0wNS0xNFQwMDowMDowMFo="
}
```

## Get User Profile

`beta.user_profiles.retrieve(struser_profile_id, UserProfileRetrieveParams**kwargs)  -> BetaUserProfile`

**get** `/v1/user_profiles/{user_profile_id}`

Get User Profile

### Parameters

- `user_profile_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaUserProfile: …`

  - `id: str`

    Unique identifier for this user profile, prefixed `uprof_`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  - `relationship: Literal["external", "resold", "internal"]`

    How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

    - `"external"`

    - `"resold"`

    - `"internal"`

  - `trust_grants: Dict[str, BetaUserProfileTrustGrant]`

    Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight.

    - `status: Literal["active", "pending", "rejected"]`

      Status of the trust grant.

      - `"active"`

      - `"pending"`

      - `"rejected"`

  - `type: Literal["user_profile"]`

    Object type. Always `user_profile`.

    - `"user_profile"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `external_id: Optional[str]`

    Platform's own identifier for this user. Not enforced unique.

  - `name: Optional[str]`

    Display name of the entity this profile represents. For `resold` this is the resold-to company's name.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_user_profile = client.beta.user_profiles.retrieve(
    user_profile_id="uprof_011CZkZCu8hGbp5mYRQgUmz9",
)
print(beta_user_profile.id)
```

#### Response

```json
{
  "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {},
  "relationship": "external",
  "trust_grants": {
    "cyber": {
      "status": "active"
    }
  },
  "type": "user_profile",
  "updated_at": "2026-03-15T10:00:00Z",
  "external_id": "user_12345",
  "name": "Example User"
}
```

## Update User Profile

`beta.user_profiles.update(struser_profile_id, UserProfileUpdateParams**kwargs)  -> BetaUserProfile`

**post** `/v1/user_profiles/{user_profile_id}`

Update User Profile

### Parameters

- `user_profile_id: str`

- `external_id: Optional[str]`

  If present, replaces the stored external_id. Omit to leave unchanged. Maximum 255 characters.

- `metadata: Optional[Dict[str, str]]`

  Key-value pairs to merge into the stored metadata. Keys provided overwrite existing values. To remove a key, set its value to an empty string. Keys not provided are left unchanged. Maximum 16 keys, with keys up to 64 characters and values up to 512 characters.

- `name: Optional[str]`

  If present, replaces the stored name. Omit to leave unchanged. Maximum 255 characters.

- `relationship: Optional[Literal["external", "resold", "internal"]]`

  How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

  - `"external"`

  - `"resold"`

  - `"internal"`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaUserProfile: …`

  - `id: str`

    Unique identifier for this user profile, prefixed `uprof_`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  - `relationship: Literal["external", "resold", "internal"]`

    How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

    - `"external"`

    - `"resold"`

    - `"internal"`

  - `trust_grants: Dict[str, BetaUserProfileTrustGrant]`

    Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight.

    - `status: Literal["active", "pending", "rejected"]`

      Status of the trust grant.

      - `"active"`

      - `"pending"`

      - `"rejected"`

  - `type: Literal["user_profile"]`

    Object type. Always `user_profile`.

    - `"user_profile"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `external_id: Optional[str]`

    Platform's own identifier for this user. Not enforced unique.

  - `name: Optional[str]`

    Display name of the entity this profile represents. For `resold` this is the resold-to company's name.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_user_profile = client.beta.user_profiles.update(
    user_profile_id="uprof_011CZkZCu8hGbp5mYRQgUmz9",
)
print(beta_user_profile.id)
```

#### Response

```json
{
  "id": "uprof_011CZkZCu8hGbp5mYRQgUmz9",
  "created_at": "2026-03-15T10:00:00Z",
  "metadata": {},
  "relationship": "external",
  "trust_grants": {
    "cyber": {
      "status": "active"
    }
  },
  "type": "user_profile",
  "updated_at": "2026-03-15T10:00:00Z",
  "external_id": "user_12345",
  "name": "Example User"
}
```

## Create Enrollment URL

`beta.user_profiles.create_enrollment_url(struser_profile_id, UserProfileCreateEnrollmentURLParams**kwargs)  -> BetaUserProfileEnrollmentURL`

**post** `/v1/user_profiles/{user_profile_id}/enrollment_url`

Create Enrollment URL

### Parameters

- `user_profile_id: str`

- `betas: Optional[List[AnthropicBetaParam]]`

  Optional header to specify the beta version(s) you want to use.

  - `str`

  - `Literal["message-batches-2024-09-24", "prompt-caching-2024-07-31", "computer-use-2024-10-22", 23 more]`

    - `"message-batches-2024-09-24"`

    - `"prompt-caching-2024-07-31"`

    - `"computer-use-2024-10-22"`

    - `"computer-use-2025-01-24"`

    - `"pdfs-2024-09-25"`

    - `"token-counting-2024-11-01"`

    - `"token-efficient-tools-2025-02-19"`

    - `"output-128k-2025-02-19"`

    - `"files-api-2025-04-14"`

    - `"mcp-client-2025-04-04"`

    - `"mcp-client-2025-11-20"`

    - `"dev-full-thinking-2025-05-14"`

    - `"interleaved-thinking-2025-05-14"`

    - `"code-execution-2025-05-22"`

    - `"extended-cache-ttl-2025-04-11"`

    - `"context-1m-2025-08-07"`

    - `"context-management-2025-06-27"`

    - `"model-context-window-exceeded-2025-08-26"`

    - `"skills-2025-10-02"`

    - `"fast-mode-2026-02-01"`

    - `"output-300k-2026-03-24"`

    - `"user-profiles-2026-03-24"`

    - `"advisor-tool-2026-03-01"`

    - `"managed-agents-2026-04-01"`

    - `"cache-diagnosis-2026-04-07"`

    - `"thinking-token-count-2026-05-13"`

### Returns

- `class BetaUserProfileEnrollmentURL: …`

  - `expires_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["enrollment_url"]`

    Object type. Always `enrollment_url`.

    - `"enrollment_url"`

  - `url: str`

    Enrollment URL to send to the end user. Valid until `expires_at`.

### Example

```python
import os
from anthropic import Anthropic

client = Anthropic(
    api_key=os.environ.get("ANTHROPIC_API_KEY"),  # This is the default and can be omitted
)
beta_user_profile_enrollment_url = client.beta.user_profiles.create_enrollment_url(
    user_profile_id="uprof_011CZkZCu8hGbp5mYRQgUmz9",
)
print(beta_user_profile_enrollment_url.expires_at)
```

#### Response

```json
{
  "expires_at": "2026-03-15T10:15:00Z",
  "type": "enrollment_url",
  "url": "https://platform.claude.com/user-profiles/enrollment/M3J0bGJxZ2ppMnptbnB1"
}
```

## Domain Types

### Beta User Profile

- `class BetaUserProfile: …`

  - `id: str`

    Unique identifier for this user profile, prefixed `uprof_`.

  - `created_at: datetime`

    A timestamp in RFC 3339 format

  - `metadata: Dict[str, str]`

    Arbitrary key-value metadata. Maximum 16 pairs, keys up to 64 chars, values up to 512 chars.

  - `relationship: Literal["external", "resold", "internal"]`

    How the entity behind a user profile relates to the platform that owns the API key. `external`: an individual end-user of the platform. `resold`: a company the platform resells Claude access to. `internal`: the platform's own usage.

    - `"external"`

    - `"resold"`

    - `"internal"`

  - `trust_grants: Dict[str, BetaUserProfileTrustGrant]`

    Trust grants for this profile, keyed by grant name. Key omitted when no grant is active or in flight.

    - `status: Literal["active", "pending", "rejected"]`

      Status of the trust grant.

      - `"active"`

      - `"pending"`

      - `"rejected"`

  - `type: Literal["user_profile"]`

    Object type. Always `user_profile`.

    - `"user_profile"`

  - `updated_at: datetime`

    A timestamp in RFC 3339 format

  - `external_id: Optional[str]`

    Platform's own identifier for this user. Not enforced unique.

  - `name: Optional[str]`

    Display name of the entity this profile represents. For `resold` this is the resold-to company's name.

### Beta User Profile Enrollment URL

- `class BetaUserProfileEnrollmentURL: …`

  - `expires_at: datetime`

    A timestamp in RFC 3339 format

  - `type: Literal["enrollment_url"]`

    Object type. Always `enrollment_url`.

    - `"enrollment_url"`

  - `url: str`

    Enrollment URL to send to the end user. Valid until `expires_at`.

### Beta User Profile Trust Grant

- `class BetaUserProfileTrustGrant: …`

  - `status: Literal["active", "pending", "rejected"]`

    Status of the trust grant.

    - `"active"`

    - `"pending"`

    - `"rejected"`

# Webhooks

## Domain Types

### Beta Webhook Event

- `class BetaWebhookEvent: …`

  - `id: str`

    Unique event identifier for idempotency.

  - `created_at: datetime`

    RFC 3339 timestamp when the event occurred.

  - `data: BetaWebhookEventData`

    - `class BetaWebhookSessionCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.created"]`

        - `"session.created"`

      - `workspace_id: str`

    - `class BetaWebhookSessionPendingEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.pending"]`

        - `"session.pending"`

      - `workspace_id: str`

    - `class BetaWebhookSessionRunningEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.running"]`

        - `"session.running"`

      - `workspace_id: str`

    - `class BetaWebhookSessionIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.idled"]`

        - `"session.idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionRequiresActionEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.requires_action"]`

        - `"session.requires_action"`

      - `workspace_id: str`

    - `class BetaWebhookSessionArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.archived"]`

        - `"session.archived"`

      - `workspace_id: str`

    - `class BetaWebhookSessionDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.deleted"]`

        - `"session.deleted"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusRescheduledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_rescheduled"]`

        - `"session.status_rescheduled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusRunStartedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_run_started"]`

        - `"session.status_run_started"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_idled"]`

        - `"session.status_idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusTerminatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_terminated"]`

        - `"session.status_terminated"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_created"]`

        - `"session.thread_created"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_idled"]`

        - `"session.thread_idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadTerminatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_terminated"]`

        - `"session.thread_terminated"`

      - `workspace_id: str`

    - `class BetaWebhookSessionOutcomeEvaluationEndedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.outcome_evaluation_ended"]`

        - `"session.outcome_evaluation_ended"`

      - `workspace_id: str`

    - `class BetaWebhookVaultCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.created"]`

        - `"vault.created"`

      - `workspace_id: str`

    - `class BetaWebhookVaultArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.archived"]`

        - `"vault.archived"`

      - `workspace_id: str`

    - `class BetaWebhookVaultDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.deleted"]`

        - `"vault.deleted"`

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.created"]`

        - `"vault_credential.created"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.archived"]`

        - `"vault_credential.archived"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.deleted"]`

        - `"vault_credential.deleted"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialRefreshFailedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.refresh_failed"]`

        - `"vault_credential.refresh_failed"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

  - `type: Literal["event"]`

    Object type. Always `event` for webhook payloads.

    - `"event"`

### Beta Webhook Event Data

- `BetaWebhookEventData`

  - `class BetaWebhookSessionCreatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.created"]`

      - `"session.created"`

    - `workspace_id: str`

  - `class BetaWebhookSessionPendingEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.pending"]`

      - `"session.pending"`

    - `workspace_id: str`

  - `class BetaWebhookSessionRunningEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.running"]`

      - `"session.running"`

    - `workspace_id: str`

  - `class BetaWebhookSessionIdledEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.idled"]`

      - `"session.idled"`

    - `workspace_id: str`

  - `class BetaWebhookSessionRequiresActionEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.requires_action"]`

      - `"session.requires_action"`

    - `workspace_id: str`

  - `class BetaWebhookSessionArchivedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.archived"]`

      - `"session.archived"`

    - `workspace_id: str`

  - `class BetaWebhookSessionDeletedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.deleted"]`

      - `"session.deleted"`

    - `workspace_id: str`

  - `class BetaWebhookSessionStatusRescheduledEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.status_rescheduled"]`

      - `"session.status_rescheduled"`

    - `workspace_id: str`

  - `class BetaWebhookSessionStatusRunStartedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.status_run_started"]`

      - `"session.status_run_started"`

    - `workspace_id: str`

  - `class BetaWebhookSessionStatusIdledEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.status_idled"]`

      - `"session.status_idled"`

    - `workspace_id: str`

  - `class BetaWebhookSessionStatusTerminatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.status_terminated"]`

      - `"session.status_terminated"`

    - `workspace_id: str`

  - `class BetaWebhookSessionThreadCreatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.thread_created"]`

      - `"session.thread_created"`

    - `workspace_id: str`

  - `class BetaWebhookSessionThreadIdledEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.thread_idled"]`

      - `"session.thread_idled"`

    - `workspace_id: str`

  - `class BetaWebhookSessionThreadTerminatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.thread_terminated"]`

      - `"session.thread_terminated"`

    - `workspace_id: str`

  - `class BetaWebhookSessionOutcomeEvaluationEndedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["session.outcome_evaluation_ended"]`

      - `"session.outcome_evaluation_ended"`

    - `workspace_id: str`

  - `class BetaWebhookVaultCreatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault.created"]`

      - `"vault.created"`

    - `workspace_id: str`

  - `class BetaWebhookVaultArchivedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault.archived"]`

      - `"vault.archived"`

    - `workspace_id: str`

  - `class BetaWebhookVaultDeletedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault.deleted"]`

      - `"vault.deleted"`

    - `workspace_id: str`

  - `class BetaWebhookVaultCredentialCreatedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault_credential.created"]`

      - `"vault_credential.created"`

    - `vault_id: str`

      ID of the vault that owns this credential.

    - `workspace_id: str`

  - `class BetaWebhookVaultCredentialArchivedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault_credential.archived"]`

      - `"vault_credential.archived"`

    - `vault_id: str`

      ID of the vault that owns this credential.

    - `workspace_id: str`

  - `class BetaWebhookVaultCredentialDeletedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault_credential.deleted"]`

      - `"vault_credential.deleted"`

    - `vault_id: str`

      ID of the vault that owns this credential.

    - `workspace_id: str`

  - `class BetaWebhookVaultCredentialRefreshFailedEventData: …`

    - `id: str`

      ID of the resource that triggered the event.

    - `organization_id: str`

    - `type: Literal["vault_credential.refresh_failed"]`

      - `"vault_credential.refresh_failed"`

    - `vault_id: str`

      ID of the vault that owns this credential.

    - `workspace_id: str`

### Beta Webhook Session Archived Event Data

- `class BetaWebhookSessionArchivedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.archived"]`

    - `"session.archived"`

  - `workspace_id: str`

### Beta Webhook Session Created Event Data

- `class BetaWebhookSessionCreatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.created"]`

    - `"session.created"`

  - `workspace_id: str`

### Beta Webhook Session Deleted Event Data

- `class BetaWebhookSessionDeletedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.deleted"]`

    - `"session.deleted"`

  - `workspace_id: str`

### Beta Webhook Session Idled Event Data

- `class BetaWebhookSessionIdledEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.idled"]`

    - `"session.idled"`

  - `workspace_id: str`

### Beta Webhook Session Outcome Evaluation Ended Event Data

- `class BetaWebhookSessionOutcomeEvaluationEndedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.outcome_evaluation_ended"]`

    - `"session.outcome_evaluation_ended"`

  - `workspace_id: str`

### Beta Webhook Session Pending Event Data

- `class BetaWebhookSessionPendingEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.pending"]`

    - `"session.pending"`

  - `workspace_id: str`

### Beta Webhook Session Requires Action Event Data

- `class BetaWebhookSessionRequiresActionEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.requires_action"]`

    - `"session.requires_action"`

  - `workspace_id: str`

### Beta Webhook Session Running Event Data

- `class BetaWebhookSessionRunningEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.running"]`

    - `"session.running"`

  - `workspace_id: str`

### Beta Webhook Session Status Idled Event Data

- `class BetaWebhookSessionStatusIdledEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.status_idled"]`

    - `"session.status_idled"`

  - `workspace_id: str`

### Beta Webhook Session Status Rescheduled Event Data

- `class BetaWebhookSessionStatusRescheduledEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.status_rescheduled"]`

    - `"session.status_rescheduled"`

  - `workspace_id: str`

### Beta Webhook Session Status Run Started Event Data

- `class BetaWebhookSessionStatusRunStartedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.status_run_started"]`

    - `"session.status_run_started"`

  - `workspace_id: str`

### Beta Webhook Session Status Terminated Event Data

- `class BetaWebhookSessionStatusTerminatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.status_terminated"]`

    - `"session.status_terminated"`

  - `workspace_id: str`

### Beta Webhook Session Thread Created Event Data

- `class BetaWebhookSessionThreadCreatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.thread_created"]`

    - `"session.thread_created"`

  - `workspace_id: str`

### Beta Webhook Session Thread Idled Event Data

- `class BetaWebhookSessionThreadIdledEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.thread_idled"]`

    - `"session.thread_idled"`

  - `workspace_id: str`

### Beta Webhook Session Thread Terminated Event Data

- `class BetaWebhookSessionThreadTerminatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["session.thread_terminated"]`

    - `"session.thread_terminated"`

  - `workspace_id: str`

### Beta Webhook Vault Archived Event Data

- `class BetaWebhookVaultArchivedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault.archived"]`

    - `"vault.archived"`

  - `workspace_id: str`

### Beta Webhook Vault Created Event Data

- `class BetaWebhookVaultCreatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault.created"]`

    - `"vault.created"`

  - `workspace_id: str`

### Beta Webhook Vault Credential Archived Event Data

- `class BetaWebhookVaultCredentialArchivedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault_credential.archived"]`

    - `"vault_credential.archived"`

  - `vault_id: str`

    ID of the vault that owns this credential.

  - `workspace_id: str`

### Beta Webhook Vault Credential Created Event Data

- `class BetaWebhookVaultCredentialCreatedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault_credential.created"]`

    - `"vault_credential.created"`

  - `vault_id: str`

    ID of the vault that owns this credential.

  - `workspace_id: str`

### Beta Webhook Vault Credential Deleted Event Data

- `class BetaWebhookVaultCredentialDeletedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault_credential.deleted"]`

    - `"vault_credential.deleted"`

  - `vault_id: str`

    ID of the vault that owns this credential.

  - `workspace_id: str`

### Beta Webhook Vault Credential Refresh Failed Event Data

- `class BetaWebhookVaultCredentialRefreshFailedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault_credential.refresh_failed"]`

    - `"vault_credential.refresh_failed"`

  - `vault_id: str`

    ID of the vault that owns this credential.

  - `workspace_id: str`

### Beta Webhook Vault Deleted Event Data

- `class BetaWebhookVaultDeletedEventData: …`

  - `id: str`

    ID of the resource that triggered the event.

  - `organization_id: str`

  - `type: Literal["vault.deleted"]`

    - `"vault.deleted"`

  - `workspace_id: str`

### Unwrap Webhook Event

- `class UnwrapWebhookEvent: …`

  - `id: str`

    Unique event identifier for idempotency.

  - `created_at: datetime`

    RFC 3339 timestamp when the event occurred.

  - `data: BetaWebhookEventData`

    - `class BetaWebhookSessionCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.created"]`

        - `"session.created"`

      - `workspace_id: str`

    - `class BetaWebhookSessionPendingEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.pending"]`

        - `"session.pending"`

      - `workspace_id: str`

    - `class BetaWebhookSessionRunningEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.running"]`

        - `"session.running"`

      - `workspace_id: str`

    - `class BetaWebhookSessionIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.idled"]`

        - `"session.idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionRequiresActionEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.requires_action"]`

        - `"session.requires_action"`

      - `workspace_id: str`

    - `class BetaWebhookSessionArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.archived"]`

        - `"session.archived"`

      - `workspace_id: str`

    - `class BetaWebhookSessionDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.deleted"]`

        - `"session.deleted"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusRescheduledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_rescheduled"]`

        - `"session.status_rescheduled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusRunStartedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_run_started"]`

        - `"session.status_run_started"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_idled"]`

        - `"session.status_idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionStatusTerminatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.status_terminated"]`

        - `"session.status_terminated"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_created"]`

        - `"session.thread_created"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadIdledEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_idled"]`

        - `"session.thread_idled"`

      - `workspace_id: str`

    - `class BetaWebhookSessionThreadTerminatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.thread_terminated"]`

        - `"session.thread_terminated"`

      - `workspace_id: str`

    - `class BetaWebhookSessionOutcomeEvaluationEndedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["session.outcome_evaluation_ended"]`

        - `"session.outcome_evaluation_ended"`

      - `workspace_id: str`

    - `class BetaWebhookVaultCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.created"]`

        - `"vault.created"`

      - `workspace_id: str`

    - `class BetaWebhookVaultArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.archived"]`

        - `"vault.archived"`

      - `workspace_id: str`

    - `class BetaWebhookVaultDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault.deleted"]`

        - `"vault.deleted"`

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialCreatedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.created"]`

        - `"vault_credential.created"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialArchivedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.archived"]`

        - `"vault_credential.archived"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialDeletedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.deleted"]`

        - `"vault_credential.deleted"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

    - `class BetaWebhookVaultCredentialRefreshFailedEventData: …`

      - `id: str`

        ID of the resource that triggered the event.

      - `organization_id: str`

      - `type: Literal["vault_credential.refresh_failed"]`

        - `"vault_credential.refresh_failed"`

      - `vault_id: str`

        ID of the vault that owns this credential.

      - `workspace_id: str`

  - `type: Literal["event"]`

    Object type. Always `event` for webhook payloads.

    - `"event"`
