Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Implementation:Anthropics Anthropic sdk python Beta Types Namespace

From Leeroopedia
Knowledge Sources
Domains API_Types, SDK_Infrastructure
Last Updated 2026-02-15 12:00 GMT

Overview

Package init module that re-exports over 200 beta type definitions, making the entire beta types namespace available through a single import path at anthropic.types.beta.

Description

The __init__.py file in the types/beta subpackage serves as the central aggregation point for all beta API type definitions in the Anthropic Python SDK. It uses the import-as-import re-export pattern (from .module import Name as Name) to ensure that each type is properly exported and discoverable by type checkers and IDEs.

This module aggregates types from a wide range of beta feature areas including: message types (BetaMessage, BetaMessageParam, BetaContentBlock), tool-related types (computer use, text editor, bash, web search, web fetch, code execution, MCP toolsets, tool search, memory tools), thinking/extended reasoning types (BetaThinkingBlock, BetaThinkingConfigParam), citation types, document and image source types, container types, compaction types, context management types, streaming event types, and parameter definition TypedDicts for API requests.

The file is auto-generated from the OpenAPI spec by the Stainless code generation tool, as indicated by the header comment. It is updated whenever the API specification changes, ensuring the SDK type definitions remain in sync with the API.

Usage

Import beta types from this namespace when working with the beta Messages API or any beta feature. This is the primary import path for SDK consumers who need beta-specific type annotations, whether for constructing request parameters or type-checking response objects.

Code Reference

Source Location

Import

from anthropic.types.beta import (
    BetaMessage,
    BetaMessageParam,
    BetaContentBlock,
    BetaContentBlockParam,
    BetaTextBlock,
    BetaToolUseBlock,
    BetaThinkingBlock,
    BetaThinkingConfigParam,
    BetaToolParam,
    BetaToolChoiceParam,
    MessageCreateParams,
    BetaUsage,
    BetaStopReason,
    BetaModelInfo,
    # ... 200+ types available
)

I/O Contract

This module has no runtime logic. It is purely a re-export namespace module.

Re-exported Type Categories

Category Example Types Count (approx.)
Core Message Types BetaMessage, BetaMessageParam, BetaUsage, BetaStopReason ~10
Content Blocks BetaTextBlock, BetaToolUseBlock, BetaContentBlock, BetaContentBlockParam ~15
Thinking/Reasoning BetaThinkingBlock, BetaThinkingConfigParam, BetaRedactedThinkingBlock, BetaThinkingDelta ~12
Tool Definitions BetaToolParam, BetaToolUnionParam, BetaToolChoiceParam, BetaToolBash20241022Param ~20
Computer Use Tools BetaToolComputerUse20241022Param, BetaToolComputerUse20250124Param, BetaToolComputerUse20251124Param ~3
Text Editor Tools BetaToolTextEditor20241022Param, BetaToolTextEditor20250124Param, BetaToolTextEditor20250429Param, BetaToolTextEditor20250728Param ~4
Code Execution BetaCodeExecutionTool20250522Param, BetaCodeExecutionOutputBlock, BetaCodeExecutionResultBlock ~15
Web Search BetaWebSearchTool20250305Param, BetaWebSearchResultBlock, BetaWebSearchToolResultBlock ~12
Web Fetch BetaWebFetchTool20250910Param, BetaWebFetchBlock, BetaWebFetchToolResultBlock ~8
MCP Toolsets BetaMCPToolsetParam, BetaMCPToolUseBlock, BetaMCPToolResultBlock ~8
Tool Search BetaToolSearchToolBm25_20251119Param, BetaToolSearchToolRegex20251119Param ~8
Memory Tools BetaMemoryTool20250818Param, BetaMemoryTool20250818Command and subcommands ~8
Citations BetaTextCitation, BetaCitationCharLocation, BetaCitationPageLocation, BetaCitationsConfigParam ~15
Documents/Images BetaDocumentBlock, BetaImageBlockParam, BetaBase64PDFSource, BetaPlainTextSource ~12
Containers BetaContainer, BetaContainerParams, BetaContainerUploadBlock ~4
Context Management BetaContextManagementConfigParam, BetaContextManagementResponse, BetaCompactionBlock ~8
Streaming Events BetaRawMessageStreamEvent, BetaRawContentBlockDeltaEvent, BetaRawMessageStartEvent ~10
Request Parameters MessageCreateParams, MessageCountTokensParams, FileUploadParams, FileListParams ~10
Deltas BetaTextDelta, BetaThinkingDelta, BetaInputJSONDelta, BetaSignatureDelta, BetaCitationsDelta ~6
Files/Skills FileMetadata, DeletedFile, BetaSkill, SkillListResponse, SkillCreateResponse ~10

Usage Examples

from anthropic.types.beta import (
    BetaMessage,
    BetaMessageParam,
    BetaToolParam,
    BetaThinkingConfigParam,
    MessageCreateParams,
)

# Type-annotating a function that works with beta messages
def process_response(message: BetaMessage) -> str:
    for block in message.content:
        if block.type == "text":
            return block.text
    return ""

# Constructing typed message parameters
messages: list[BetaMessageParam] = [
    {"role": "user", "content": "Hello, Claude!"}
]

# Type-checking tool definitions
tools: list[BetaToolParam] = [
    {
        "name": "get_weather",
        "description": "Get weather for a location",
        "input_schema": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"],
        },
    }
]

# Using thinking config types
thinking: BetaThinkingConfigParam = {
    "type": "enabled",
    "budget_tokens": 5000,
}

Related Pages

Implements Principle

Used By

See Also

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment