anthropic 0.68.2__py3-none-any.whl → 0.70.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anthropic/_version.py +1 -1
- anthropic/lib/streaming/_beta_messages.py +1 -0
- anthropic/lib/tools/__init__.py +7 -0
- anthropic/lib/tools/_beta_builtin_memory_tool.py +245 -0
- anthropic/lib/tools/_beta_functions.py +30 -0
- anthropic/lib/tools/_beta_runner.py +18 -6
- anthropic/resources/beta/messages/messages.py +55 -11
- anthropic/types/anthropic_beta_param.py +2 -0
- anthropic/types/beta/__init__.py +35 -0
- anthropic/types/beta/beta_clear_tool_uses_20250919_edit_param.py +38 -0
- anthropic/types/beta/beta_clear_tool_uses_20250919_edit_response.py +18 -0
- anthropic/types/beta/beta_context_management_config_param.py +15 -0
- anthropic/types/beta/beta_context_management_response.py +13 -0
- anthropic/types/beta/beta_count_tokens_context_management_response.py +10 -0
- anthropic/types/beta/beta_input_tokens_clear_at_least_param.py +13 -0
- anthropic/types/beta/beta_input_tokens_trigger_param.py +13 -0
- anthropic/types/beta/beta_memory_tool_20250818_command.py +26 -0
- anthropic/types/beta/beta_memory_tool_20250818_create_command.py +18 -0
- anthropic/types/beta/beta_memory_tool_20250818_delete_command.py +15 -0
- anthropic/types/beta/beta_memory_tool_20250818_insert_command.py +21 -0
- anthropic/types/beta/beta_memory_tool_20250818_param.py +23 -0
- anthropic/types/beta/beta_memory_tool_20250818_rename_command.py +18 -0
- anthropic/types/beta/beta_memory_tool_20250818_str_replace_command.py +21 -0
- anthropic/types/beta/beta_memory_tool_20250818_view_command.py +19 -0
- anthropic/types/beta/beta_message.py +4 -0
- anthropic/types/beta/beta_message_tokens_count.py +6 -0
- anthropic/types/beta/beta_raw_message_delta_event.py +4 -0
- anthropic/types/beta/beta_stop_reason.py +3 -1
- anthropic/types/beta/beta_tool_union_param.py +2 -0
- anthropic/types/beta/beta_tool_uses_keep_param.py +13 -0
- anthropic/types/beta/beta_tool_uses_trigger_param.py +13 -0
- anthropic/types/beta/message_count_tokens_params.py +7 -1
- anthropic/types/beta/message_create_params.py +4 -0
- anthropic/types/model.py +4 -0
- anthropic/types/model_param.py +4 -0
- anthropic/types/stop_reason.py +3 -1
- {anthropic-0.68.2.dist-info → anthropic-0.70.0.dist-info}/METADATA +19 -19
- {anthropic-0.68.2.dist-info → anthropic-0.70.0.dist-info}/RECORD +40 -22
- {anthropic-0.68.2.dist-info → anthropic-0.70.0.dist-info}/WHEEL +0 -0
- {anthropic-0.68.2.dist-info → anthropic-0.70.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Literal
|
|
4
|
+
|
|
5
|
+
from ..._models import BaseModel
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaMemoryTool20250818InsertCommand"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaMemoryTool20250818InsertCommand(BaseModel):
|
|
11
|
+
command: Literal["insert"]
|
|
12
|
+
"""Command type identifier"""
|
|
13
|
+
|
|
14
|
+
insert_line: int
|
|
15
|
+
"""Line number where text should be inserted"""
|
|
16
|
+
|
|
17
|
+
insert_text: str
|
|
18
|
+
"""Text to insert at the specified line"""
|
|
19
|
+
|
|
20
|
+
path: str
|
|
21
|
+
"""Path to the file where text should be inserted"""
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam
|
|
9
|
+
|
|
10
|
+
__all__ = ["BetaMemoryTool20250818Param"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BetaMemoryTool20250818Param(TypedDict, total=False):
|
|
14
|
+
name: Required[Literal["memory"]]
|
|
15
|
+
"""Name of the tool.
|
|
16
|
+
|
|
17
|
+
This is how the tool will be called by the model and in `tool_use` blocks.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
type: Required[Literal["memory_20250818"]]
|
|
21
|
+
|
|
22
|
+
cache_control: Optional[BetaCacheControlEphemeralParam]
|
|
23
|
+
"""Create a cache control breakpoint at this content block."""
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Literal
|
|
4
|
+
|
|
5
|
+
from ..._models import BaseModel
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaMemoryTool20250818RenameCommand"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaMemoryTool20250818RenameCommand(BaseModel):
|
|
11
|
+
command: Literal["rename"]
|
|
12
|
+
"""Command type identifier"""
|
|
13
|
+
|
|
14
|
+
new_path: str
|
|
15
|
+
"""New path for the file or directory"""
|
|
16
|
+
|
|
17
|
+
old_path: str
|
|
18
|
+
"""Current path of the file or directory"""
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing_extensions import Literal
|
|
4
|
+
|
|
5
|
+
from ..._models import BaseModel
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaMemoryTool20250818StrReplaceCommand"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaMemoryTool20250818StrReplaceCommand(BaseModel):
|
|
11
|
+
command: Literal["str_replace"]
|
|
12
|
+
"""Command type identifier"""
|
|
13
|
+
|
|
14
|
+
new_str: str
|
|
15
|
+
"""Text to replace with"""
|
|
16
|
+
|
|
17
|
+
old_str: str
|
|
18
|
+
"""Text to search for and replace"""
|
|
19
|
+
|
|
20
|
+
path: str
|
|
21
|
+
"""Path to the file where text should be replaced"""
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Optional
|
|
4
|
+
from typing_extensions import Literal
|
|
5
|
+
|
|
6
|
+
from ..._models import BaseModel
|
|
7
|
+
|
|
8
|
+
__all__ = ["BetaMemoryTool20250818ViewCommand"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BetaMemoryTool20250818ViewCommand(BaseModel):
|
|
12
|
+
command: Literal["view"]
|
|
13
|
+
"""Command type identifier"""
|
|
14
|
+
|
|
15
|
+
path: str
|
|
16
|
+
"""Path to directory or file to view"""
|
|
17
|
+
|
|
18
|
+
view_range: Optional[List[int]] = None
|
|
19
|
+
"""Optional line range for viewing specific lines"""
|
|
@@ -9,6 +9,7 @@ from .beta_usage import BetaUsage
|
|
|
9
9
|
from .beta_container import BetaContainer
|
|
10
10
|
from .beta_stop_reason import BetaStopReason
|
|
11
11
|
from .beta_content_block import BetaContentBlock, BetaContentBlock as BetaContentBlock
|
|
12
|
+
from .beta_context_management_response import BetaContextManagementResponse
|
|
12
13
|
|
|
13
14
|
__all__ = ["BetaMessage"]
|
|
14
15
|
|
|
@@ -61,6 +62,9 @@ class BetaMessage(BaseModel):
|
|
|
61
62
|
```
|
|
62
63
|
"""
|
|
63
64
|
|
|
65
|
+
context_management: Optional[BetaContextManagementResponse] = None
|
|
66
|
+
"""Information about context management operations applied during the request."""
|
|
67
|
+
|
|
64
68
|
model: Model
|
|
65
69
|
"""
|
|
66
70
|
The model that will complete your prompt.\n\nSee
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
+
from typing import Optional
|
|
4
|
+
|
|
3
5
|
from ..._models import BaseModel
|
|
6
|
+
from .beta_count_tokens_context_management_response import BetaCountTokensContextManagementResponse
|
|
4
7
|
|
|
5
8
|
__all__ = ["BetaMessageTokensCount"]
|
|
6
9
|
|
|
7
10
|
|
|
8
11
|
class BetaMessageTokensCount(BaseModel):
|
|
12
|
+
context_management: Optional[BetaCountTokensContextManagementResponse] = None
|
|
13
|
+
"""Information about context management applied to the message."""
|
|
14
|
+
|
|
9
15
|
input_tokens: int
|
|
10
16
|
"""
|
|
11
17
|
The total number of tokens across the provided list of messages, system prompt,
|
|
@@ -7,6 +7,7 @@ from ..._models import BaseModel
|
|
|
7
7
|
from .beta_container import BetaContainer
|
|
8
8
|
from .beta_stop_reason import BetaStopReason
|
|
9
9
|
from .beta_message_delta_usage import BetaMessageDeltaUsage
|
|
10
|
+
from .beta_context_management_response import BetaContextManagementResponse
|
|
10
11
|
|
|
11
12
|
__all__ = ["BetaRawMessageDeltaEvent", "Delta"]
|
|
12
13
|
|
|
@@ -24,6 +25,9 @@ class Delta(BaseModel):
|
|
|
24
25
|
|
|
25
26
|
|
|
26
27
|
class BetaRawMessageDeltaEvent(BaseModel):
|
|
28
|
+
context_management: Optional[BetaContextManagementResponse] = None
|
|
29
|
+
"""Information about context management operations applied during the request."""
|
|
30
|
+
|
|
27
31
|
delta: Delta
|
|
28
32
|
|
|
29
33
|
type: Literal["message_delta"]
|
|
@@ -4,4 +4,6 @@ from typing_extensions import Literal, TypeAlias
|
|
|
4
4
|
|
|
5
5
|
__all__ = ["BetaStopReason"]
|
|
6
6
|
|
|
7
|
-
BetaStopReason: TypeAlias = Literal[
|
|
7
|
+
BetaStopReason: TypeAlias = Literal[
|
|
8
|
+
"end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal", "model_context_window_exceeded"
|
|
9
|
+
]
|
|
@@ -8,6 +8,7 @@ from typing_extensions import TypeAlias
|
|
|
8
8
|
from .beta_tool_param import BetaToolParam
|
|
9
9
|
from .beta_tool_bash_20241022_param import BetaToolBash20241022Param
|
|
10
10
|
from .beta_tool_bash_20250124_param import BetaToolBash20250124Param
|
|
11
|
+
from .beta_memory_tool_20250818_param import BetaMemoryTool20250818Param
|
|
11
12
|
from .beta_web_fetch_tool_20250910_param import BetaWebFetchTool20250910Param
|
|
12
13
|
from .beta_web_search_tool_20250305_param import BetaWebSearchTool20250305Param
|
|
13
14
|
from .beta_tool_text_editor_20241022_param import BetaToolTextEditor20241022Param
|
|
@@ -28,6 +29,7 @@ BetaToolUnionParam: TypeAlias = Union[
|
|
|
28
29
|
BetaCodeExecutionTool20250522Param,
|
|
29
30
|
BetaCodeExecutionTool20250825Param,
|
|
30
31
|
BetaToolComputerUse20241022Param,
|
|
32
|
+
BetaMemoryTool20250818Param,
|
|
31
33
|
BetaToolComputerUse20250124Param,
|
|
32
34
|
BetaToolTextEditor20241022Param,
|
|
33
35
|
BetaToolTextEditor20250124Param,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaToolUsesKeepParam"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaToolUsesKeepParam(TypedDict, total=False):
|
|
11
|
+
type: Required[Literal["tool_uses"]]
|
|
12
|
+
|
|
13
|
+
value: Required[int]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaToolUsesTriggerParam"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaToolUsesTriggerParam(TypedDict, total=False):
|
|
11
|
+
type: Required[Literal["tool_uses"]]
|
|
12
|
+
|
|
13
|
+
value: Required[int]
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from __future__ import annotations
|
|
4
4
|
|
|
5
|
-
from typing import List, Union, Iterable
|
|
5
|
+
from typing import List, Union, Iterable, Optional
|
|
6
6
|
from typing_extensions import Required, Annotated, TypeAlias, TypedDict
|
|
7
7
|
|
|
8
8
|
from ..._utils import PropertyInfo
|
|
@@ -15,8 +15,10 @@ from .beta_tool_choice_param import BetaToolChoiceParam
|
|
|
15
15
|
from .beta_thinking_config_param import BetaThinkingConfigParam
|
|
16
16
|
from .beta_tool_bash_20241022_param import BetaToolBash20241022Param
|
|
17
17
|
from .beta_tool_bash_20250124_param import BetaToolBash20250124Param
|
|
18
|
+
from .beta_memory_tool_20250818_param import BetaMemoryTool20250818Param
|
|
18
19
|
from .beta_web_fetch_tool_20250910_param import BetaWebFetchTool20250910Param
|
|
19
20
|
from .beta_web_search_tool_20250305_param import BetaWebSearchTool20250305Param
|
|
21
|
+
from .beta_context_management_config_param import BetaContextManagementConfigParam
|
|
20
22
|
from .beta_tool_text_editor_20241022_param import BetaToolTextEditor20241022Param
|
|
21
23
|
from .beta_tool_text_editor_20250124_param import BetaToolTextEditor20250124Param
|
|
22
24
|
from .beta_tool_text_editor_20250429_param import BetaToolTextEditor20250429Param
|
|
@@ -106,6 +108,9 @@ class MessageCountTokensParams(TypedDict, total=False):
|
|
|
106
108
|
details and options.
|
|
107
109
|
"""
|
|
108
110
|
|
|
111
|
+
context_management: Optional[BetaContextManagementConfigParam]
|
|
112
|
+
"""Configuration for context management operations."""
|
|
113
|
+
|
|
109
114
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam]
|
|
110
115
|
"""MCP servers to be utilized in this request"""
|
|
111
116
|
|
|
@@ -225,6 +230,7 @@ Tool: TypeAlias = Union[
|
|
|
225
230
|
BetaCodeExecutionTool20250522Param,
|
|
226
231
|
BetaCodeExecutionTool20250825Param,
|
|
227
232
|
BetaToolComputerUse20241022Param,
|
|
233
|
+
BetaMemoryTool20250818Param,
|
|
228
234
|
BetaToolComputerUse20250124Param,
|
|
229
235
|
BetaToolTextEditor20241022Param,
|
|
230
236
|
BetaToolTextEditor20250124Param,
|
|
@@ -15,6 +15,7 @@ from .beta_text_block_param import BetaTextBlockParam
|
|
|
15
15
|
from .beta_tool_union_param import BetaToolUnionParam
|
|
16
16
|
from .beta_tool_choice_param import BetaToolChoiceParam
|
|
17
17
|
from .beta_thinking_config_param import BetaThinkingConfigParam
|
|
18
|
+
from .beta_context_management_config_param import BetaContextManagementConfigParam
|
|
18
19
|
from .beta_request_mcp_server_url_definition_param import BetaRequestMCPServerURLDefinitionParam
|
|
19
20
|
|
|
20
21
|
__all__ = ["MessageCreateParamsBase", "MessageCreateParamsNonStreaming", "MessageCreateParamsStreaming"]
|
|
@@ -109,6 +110,9 @@ class MessageCreateParamsBase(TypedDict, total=False):
|
|
|
109
110
|
container: Optional[str]
|
|
110
111
|
"""Container identifier for reuse across requests."""
|
|
111
112
|
|
|
113
|
+
context_management: Optional[BetaContextManagementConfigParam]
|
|
114
|
+
"""Configuration for context management operations."""
|
|
115
|
+
|
|
112
116
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam]
|
|
113
117
|
"""MCP servers to be utilized in this request"""
|
|
114
118
|
|
anthropic/types/model.py
CHANGED
|
@@ -11,9 +11,13 @@ Model: TypeAlias = Union[
|
|
|
11
11
|
"claude-3-7-sonnet-20250219",
|
|
12
12
|
"claude-3-5-haiku-latest",
|
|
13
13
|
"claude-3-5-haiku-20241022",
|
|
14
|
+
"claude-haiku-4-5",
|
|
15
|
+
"claude-haiku-4-5-20251001",
|
|
14
16
|
"claude-sonnet-4-20250514",
|
|
15
17
|
"claude-sonnet-4-0",
|
|
16
18
|
"claude-4-sonnet-20250514",
|
|
19
|
+
"claude-sonnet-4-5",
|
|
20
|
+
"claude-sonnet-4-5-20250929",
|
|
17
21
|
"claude-3-5-sonnet-latest",
|
|
18
22
|
"claude-3-5-sonnet-20241022",
|
|
19
23
|
"claude-3-5-sonnet-20240620",
|
anthropic/types/model_param.py
CHANGED
|
@@ -13,9 +13,13 @@ ModelParam: TypeAlias = Union[
|
|
|
13
13
|
"claude-3-7-sonnet-20250219",
|
|
14
14
|
"claude-3-5-haiku-latest",
|
|
15
15
|
"claude-3-5-haiku-20241022",
|
|
16
|
+
"claude-haiku-4-5",
|
|
17
|
+
"claude-haiku-4-5-20251001",
|
|
16
18
|
"claude-sonnet-4-20250514",
|
|
17
19
|
"claude-sonnet-4-0",
|
|
18
20
|
"claude-4-sonnet-20250514",
|
|
21
|
+
"claude-sonnet-4-5",
|
|
22
|
+
"claude-sonnet-4-5-20250929",
|
|
19
23
|
"claude-3-5-sonnet-latest",
|
|
20
24
|
"claude-3-5-sonnet-20241022",
|
|
21
25
|
"claude-3-5-sonnet-20240620",
|
anthropic/types/stop_reason.py
CHANGED
|
@@ -4,4 +4,6 @@ from typing_extensions import Literal, TypeAlias
|
|
|
4
4
|
|
|
5
5
|
__all__ = ["StopReason"]
|
|
6
6
|
|
|
7
|
-
StopReason: TypeAlias = Literal[
|
|
7
|
+
StopReason: TypeAlias = Literal[
|
|
8
|
+
"end_turn", "max_tokens", "stop_sequence", "tool_use", "pause_turn", "refusal", "model_context_window_exceeded"
|
|
9
|
+
]
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: anthropic
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.70.0
|
|
4
4
|
Summary: The official Python library for the anthropic API
|
|
5
5
|
Project-URL: Homepage, https://github.com/anthropics/anthropic-sdk-python
|
|
6
6
|
Project-URL: Repository, https://github.com/anthropics/anthropic-sdk-python
|
|
@@ -80,7 +80,7 @@ message = client.messages.create(
|
|
|
80
80
|
"content": "Hello, Claude",
|
|
81
81
|
}
|
|
82
82
|
],
|
|
83
|
-
model="claude-sonnet-4-
|
|
83
|
+
model="claude-sonnet-4-5-20250929",
|
|
84
84
|
)
|
|
85
85
|
print(message.content)
|
|
86
86
|
```
|
|
@@ -113,7 +113,7 @@ async def main() -> None:
|
|
|
113
113
|
"content": "Hello, Claude",
|
|
114
114
|
}
|
|
115
115
|
],
|
|
116
|
-
model="claude-sonnet-4-
|
|
116
|
+
model="claude-sonnet-4-5-20250929",
|
|
117
117
|
)
|
|
118
118
|
print(message.content)
|
|
119
119
|
|
|
@@ -155,7 +155,7 @@ async def main() -> None:
|
|
|
155
155
|
"content": "Hello, Claude",
|
|
156
156
|
}
|
|
157
157
|
],
|
|
158
|
-
model="claude-sonnet-4-
|
|
158
|
+
model="claude-sonnet-4-5-20250929",
|
|
159
159
|
)
|
|
160
160
|
print(message.content)
|
|
161
161
|
|
|
@@ -180,7 +180,7 @@ stream = client.messages.create(
|
|
|
180
180
|
"content": "Hello, Claude",
|
|
181
181
|
}
|
|
182
182
|
],
|
|
183
|
-
model="claude-sonnet-4-
|
|
183
|
+
model="claude-sonnet-4-5-20250929",
|
|
184
184
|
stream=True,
|
|
185
185
|
)
|
|
186
186
|
for event in stream:
|
|
@@ -202,7 +202,7 @@ stream = await client.messages.create(
|
|
|
202
202
|
"content": "Hello, Claude",
|
|
203
203
|
}
|
|
204
204
|
],
|
|
205
|
-
model="claude-sonnet-4-
|
|
205
|
+
model="claude-sonnet-4-5-20250929",
|
|
206
206
|
stream=True,
|
|
207
207
|
)
|
|
208
208
|
async for event in stream:
|
|
@@ -244,7 +244,7 @@ def get_weather(location: str) -> str:
|
|
|
244
244
|
|
|
245
245
|
runner = client.beta.messages.tool_runner(
|
|
246
246
|
max_tokens=1024,
|
|
247
|
-
model="claude-sonnet-4-
|
|
247
|
+
model="claude-sonnet-4-5-20250929",
|
|
248
248
|
tools=[get_weather],
|
|
249
249
|
messages=[
|
|
250
250
|
{"role": "user", "content": "What is the weather in SF?"},
|
|
@@ -277,7 +277,7 @@ async def main() -> None:
|
|
|
277
277
|
"content": "Say hello there!",
|
|
278
278
|
}
|
|
279
279
|
],
|
|
280
|
-
model="claude-sonnet-4-
|
|
280
|
+
model="claude-sonnet-4-5-20250929",
|
|
281
281
|
) as stream:
|
|
282
282
|
async for text in stream.text_stream:
|
|
283
283
|
print(text, end="", flush=True)
|
|
@@ -299,7 +299,7 @@ To get the token count for a message without creating it you can use the `client
|
|
|
299
299
|
|
|
300
300
|
```py
|
|
301
301
|
count = client.messages.count_tokens(
|
|
302
|
-
model="claude-sonnet-4-
|
|
302
|
+
model="claude-sonnet-4-5-20250929",
|
|
303
303
|
messages=[
|
|
304
304
|
{"role": "user", "content": "Hello, world"}
|
|
305
305
|
]
|
|
@@ -329,7 +329,7 @@ await client.messages.batches.create(
|
|
|
329
329
|
{
|
|
330
330
|
"custom_id": "my-first-request",
|
|
331
331
|
"params": {
|
|
332
|
-
"model": "claude-sonnet-4-
|
|
332
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
333
333
|
"max_tokens": 1024,
|
|
334
334
|
"messages": [{"role": "user", "content": "Hello, world"}],
|
|
335
335
|
},
|
|
@@ -337,7 +337,7 @@ await client.messages.batches.create(
|
|
|
337
337
|
{
|
|
338
338
|
"custom_id": "my-second-request",
|
|
339
339
|
"params": {
|
|
340
|
-
"model": "claude-sonnet-4-
|
|
340
|
+
"model": "claude-sonnet-4-5-20250929",
|
|
341
341
|
"max_tokens": 1024,
|
|
342
342
|
"messages": [{"role": "user", "content": "Hi again, friend"}],
|
|
343
343
|
},
|
|
@@ -380,7 +380,7 @@ message = client.messages.create(
|
|
|
380
380
|
"content": "Hello!",
|
|
381
381
|
}
|
|
382
382
|
],
|
|
383
|
-
model="anthropic.claude-sonnet-4-
|
|
383
|
+
model="anthropic.claude-sonnet-4-5-20250929-v1:0",
|
|
384
384
|
)
|
|
385
385
|
print(message)
|
|
386
386
|
```
|
|
@@ -522,7 +522,7 @@ message = client.messages.create(
|
|
|
522
522
|
"role": "user",
|
|
523
523
|
}
|
|
524
524
|
],
|
|
525
|
-
model="claude-sonnet-4-
|
|
525
|
+
model="claude-sonnet-4-5-20250929",
|
|
526
526
|
metadata={},
|
|
527
527
|
)
|
|
528
528
|
print(message.metadata)
|
|
@@ -569,7 +569,7 @@ try:
|
|
|
569
569
|
"content": "Hello, Claude",
|
|
570
570
|
}
|
|
571
571
|
],
|
|
572
|
-
model="claude-sonnet-4-
|
|
572
|
+
model="claude-sonnet-4-5-20250929",
|
|
573
573
|
)
|
|
574
574
|
except anthropic.APIConnectionError as e:
|
|
575
575
|
print("The server could not be reached")
|
|
@@ -610,7 +610,7 @@ message = client.messages.create(
|
|
|
610
610
|
"content": "Hello, Claude",
|
|
611
611
|
}
|
|
612
612
|
],
|
|
613
|
-
model="claude-sonnet-4-
|
|
613
|
+
model="claude-sonnet-4-5-20250929",
|
|
614
614
|
)
|
|
615
615
|
print(message._request_id) # req_018EeWyXxfu5pfWkrYcMdjWG
|
|
616
616
|
```
|
|
@@ -645,7 +645,7 @@ client.with_options(max_retries=5).messages.create(
|
|
|
645
645
|
"content": "Hello, Claude",
|
|
646
646
|
}
|
|
647
647
|
],
|
|
648
|
-
model="claude-sonnet-4-
|
|
648
|
+
model="claude-sonnet-4-5-20250929",
|
|
649
649
|
)
|
|
650
650
|
```
|
|
651
651
|
|
|
@@ -677,7 +677,7 @@ client.with_options(timeout=5.0).messages.create(
|
|
|
677
677
|
"content": "Hello, Claude",
|
|
678
678
|
}
|
|
679
679
|
],
|
|
680
|
-
model="claude-sonnet-4-
|
|
680
|
+
model="claude-sonnet-4-5-20250929",
|
|
681
681
|
)
|
|
682
682
|
```
|
|
683
683
|
|
|
@@ -760,7 +760,7 @@ response = client.messages.with_raw_response.create(
|
|
|
760
760
|
"role": "user",
|
|
761
761
|
"content": "Hello, Claude",
|
|
762
762
|
}],
|
|
763
|
-
model="claude-sonnet-4-
|
|
763
|
+
model="claude-sonnet-4-5-20250929",
|
|
764
764
|
)
|
|
765
765
|
print(response.headers.get('X-My-Header'))
|
|
766
766
|
|
|
@@ -794,7 +794,7 @@ with client.messages.with_streaming_response.create(
|
|
|
794
794
|
"content": "Hello, Claude",
|
|
795
795
|
}
|
|
796
796
|
],
|
|
797
|
-
model="claude-sonnet-4-
|
|
797
|
+
model="claude-sonnet-4-5-20250929",
|
|
798
798
|
) as response:
|
|
799
799
|
print(response.headers.get("X-My-Header"))
|
|
800
800
|
|