The official Python library for the anthropic API
—
Quality
Pending
Does it follow best practices?
Impact
Pending
No eval scenarios have been run
Access experimental capabilities through the client.beta namespace including extended thinking, citations, web search, code execution, computer use, and more.
Beta features provide experimental functionality that may change in future releases. They enable advanced capabilities beyond standard message creation.
Add advanced capabilities to message creation:
→ Message Features Documentation
Manage resources and process messages at scale:
from anthropic import Anthropic
client = Anthropic()
message = client.beta.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=4096,
thinking={"type": "enabled", "budget_tokens": 2000},
messages=[
{"role": "user", "content": "Solve this complex problem: ..."}
]
)
# Access thinking and response
for block in message.content:
if block.type == "thinking":
print(f"Reasoning: {block.thinking}")
elif block.type == "text":
print(f"Answer: {block.text}")message = client.beta.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=4096,
thinking={"type": "enabled"},
web_search={"type": "enabled"},
citations={"type": "enabled"},
messages=[
{
"role": "user",
"content": [
{
"type": "document",
"source": {
"type": "base64",
"media_type": "application/pdf",
"data": pdf_data
}
},
{"type": "text", "text": "Analyze this paper and find related research"}
]
}
]
)The beta messages API extends the standard messages API with additional parameters.
def create(
self,
*,
model: str,
messages: list[BetaMessageParam],
max_tokens: int,
# Standard parameters
system: str | list[BetaTextBlockParam] = NOT_GIVEN,
metadata: MetadataParam = NOT_GIVEN,
stop_sequences: list[str] = NOT_GIVEN,
stream: bool = False,
temperature: float = NOT_GIVEN,
top_p: float = NOT_GIVEN,
top_k: int = NOT_GIVEN,
tools: list[BetaToolParam] = NOT_GIVEN,
tool_choice: BetaToolChoice = NOT_GIVEN,
# Beta feature parameters
thinking: ThinkingConfigParam = NOT_GIVEN,
citations: CitationsConfigParam = NOT_GIVEN,
web_search: WebSearchConfigParam = NOT_GIVEN,
code_execution: CodeExecutionConfigParam = NOT_GIVEN,
bash: BashConfigParam = NOT_GIVEN,
text_editor: TextEditorConfigParam = NOT_GIVEN,
computer_use: ComputerUseConfigParam = NOT_GIVEN,
mcp: MCPConfigParam = NOT_GIVEN,
memory: MemoryConfigParam = NOT_GIVEN,
context: ContextConfigParam = NOT_GIVEN,
**kwargs
) -> BetaMessage:
"""
Create message with beta features.
All standard message parameters are supported, plus beta feature configurations.
Multiple beta features can be enabled simultaneously.
Returns:
BetaMessage with beta content blocks
"""
...
async def create(self, **kwargs) -> BetaMessage:
"""Async version of create."""
...def stream(
self,
**kwargs
) -> BetaMessageStreamManager:
"""Stream message with beta features."""
...
def stream(self, **kwargs) -> BetaAsyncMessageStreamManager:
"""Async version of stream."""
...def count_tokens(
self,
*,
model: str,
messages: list[BetaMessageParam],
system: str | list[BetaTextBlockParam] = NOT_GIVEN,
tools: list[BetaToolParam] = NOT_GIVEN,
tool_choice: BetaToolChoice = NOT_GIVEN,
**kwargs
) -> BetaMessageTokensCount:
"""Count tokens for beta message."""
...def tool_runner(
self,
*,
model: str,
messages: list[BetaMessageParam],
max_tokens: int,
tools: list[BetaToolParam | BetaFunctionTool],
**kwargs
) -> Iterator[BetaMessage]:
"""Automatically execute tools in beta messages."""
...Retrieve model information with beta feature support.
def retrieve(
self,
model_id: str,
**kwargs
) -> BetaModelInfo:
"""Get information about a specific model."""
...
def list(
self,
*,
before_id: str = NOT_GIVEN,
after_id: str = NOT_GIVEN,
limit: int = NOT_GIVEN,
**kwargs
) -> SyncPage[BetaModelInfo]:
"""List available models with pagination."""
...Beta features are organized into three categories:
Parameters that enhance client.beta.messages.create():
Process multiple beta messages with all features:
Manage files and skills:
→ Skills Documentation | → Files Documentation
| Feature | Standard API | Beta API |
|---|---|---|
| Basic messaging | ✓ | ✓ |
| Streaming | ✓ | ✓ |
| Tool use | ✓ | ✓ |
| Extended thinking | ✗ | ✓ |
| Citations | ✗ | ✓ |
| Web search | ✗ | ✓ |
| Code execution | ✗ | ✓ |
| Computer use | ✗ | ✓ |
| Batches | ✓ | ✓ (with beta features) |
| Skills management | ✗ | ✓ |
| File management | ✗ | ✓ |
Most code using the standard API can be upgraded to beta with minimal changes:
# Standard API
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)
# Beta API (backward compatible)
message = client.beta.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello"}]
)
# Beta API (with features)
message = client.beta.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
thinking={"type": "enabled"}, # Add beta features
messages=[{"role": "user", "content": "Hello"}]
)message-features.md - Comprehensive guide to all message enhancement parameters:
batches.md - Beta message batches:
skills.md - Skills management:
files.md - File management: