anthropic 0.72.0__py3-none-any.whl → 0.73.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.
Files changed (43) hide show
  1. anthropic/__init__.py +2 -0
  2. anthropic/_compat.py +6 -0
  3. anthropic/_models.py +50 -16
  4. anthropic/_streaming.py +4 -6
  5. anthropic/_utils/_sync.py +3 -31
  6. anthropic/_utils/_transform.py +1 -1
  7. anthropic/_utils/_utils.py +1 -1
  8. anthropic/_version.py +1 -1
  9. anthropic/lib/_parse/_response.py +44 -0
  10. anthropic/lib/_parse/_transform.py +167 -0
  11. anthropic/lib/streaming/__init__.py +14 -4
  12. anthropic/lib/streaming/_beta_messages.py +82 -43
  13. anthropic/lib/streaming/_beta_types.py +21 -13
  14. anthropic/lib/tools/_beta_runner.py +102 -101
  15. anthropic/resources/beta/messages/batches.py +12 -12
  16. anthropic/resources/beta/messages/messages.py +365 -29
  17. anthropic/resources/messages/batches.py +12 -12
  18. anthropic/resources/messages/messages.py +14 -8
  19. anthropic/types/beta/__init__.py +1 -0
  20. anthropic/types/beta/beta_code_execution_tool_20250522_param.py +2 -0
  21. anthropic/types/beta/beta_code_execution_tool_20250825_param.py +2 -0
  22. anthropic/types/beta/beta_json_output_format_param.py +15 -0
  23. anthropic/types/beta/beta_memory_tool_20250818_param.py +2 -0
  24. anthropic/types/beta/beta_tool_bash_20241022_param.py +2 -0
  25. anthropic/types/beta/beta_tool_bash_20250124_param.py +2 -0
  26. anthropic/types/beta/beta_tool_computer_use_20241022_param.py +2 -0
  27. anthropic/types/beta/beta_tool_computer_use_20250124_param.py +2 -0
  28. anthropic/types/beta/beta_tool_param.py +2 -0
  29. anthropic/types/beta/beta_tool_text_editor_20241022_param.py +2 -0
  30. anthropic/types/beta/beta_tool_text_editor_20250124_param.py +2 -0
  31. anthropic/types/beta/beta_tool_text_editor_20250429_param.py +2 -0
  32. anthropic/types/beta/beta_tool_text_editor_20250728_param.py +2 -0
  33. anthropic/types/beta/beta_web_fetch_tool_20250910_param.py +2 -0
  34. anthropic/types/beta/beta_web_search_tool_20250305_param.py +2 -0
  35. anthropic/types/beta/message_count_tokens_params.py +4 -0
  36. anthropic/types/beta/message_create_params.py +24 -2
  37. anthropic/types/beta/messages/batch_create_params.py +8 -2
  38. anthropic/types/beta/parsed_beta_message.py +68 -0
  39. anthropic/types/messages/batch_create_params.py +0 -1
  40. {anthropic-0.72.0.dist-info → anthropic-0.73.0.dist-info}/METADATA +4 -5
  41. {anthropic-0.72.0.dist-info → anthropic-0.73.0.dist-info}/RECORD +43 -39
  42. {anthropic-0.72.0.dist-info → anthropic-0.73.0.dist-info}/WHEEL +0 -0
  43. {anthropic-0.72.0.dist-info → anthropic-0.73.0.dist-info}/licenses/LICENSE +0 -0
@@ -63,7 +63,7 @@ class Batches(SyncAPIResource):
63
63
  can take up to 24 hours to complete.
64
64
 
65
65
  Learn more about the Message Batches API in our
66
- [user guide](/en/docs/build-with-claude/batch-processing)
66
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
67
67
 
68
68
  Args:
69
69
  requests: List of requests for prompt completion. Each is an individual request to create
@@ -104,7 +104,7 @@ class Batches(SyncAPIResource):
104
104
  `results_url` field in the response.
105
105
 
106
106
  Learn more about the Message Batches API in our
107
- [user guide](/en/docs/build-with-claude/batch-processing)
107
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
108
108
 
109
109
  Args:
110
110
  message_batch_id: ID of the Message Batch.
@@ -146,7 +146,7 @@ class Batches(SyncAPIResource):
146
146
  returned first.
147
147
 
148
148
  Learn more about the Message Batches API in our
149
- [user guide](/en/docs/build-with-claude/batch-processing)
149
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
150
150
 
151
151
  Args:
152
152
  after_id: ID of the object to use as a cursor for pagination. When provided, returns the
@@ -205,7 +205,7 @@ class Batches(SyncAPIResource):
205
205
  like to delete an in-progress batch, you must first cancel it.
206
206
 
207
207
  Learn more about the Message Batches API in our
208
- [user guide](/en/docs/build-with-claude/batch-processing)
208
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
209
209
 
210
210
  Args:
211
211
  message_batch_id: ID of the Message Batch.
@@ -252,7 +252,7 @@ class Batches(SyncAPIResource):
252
252
  non-interruptible.
253
253
 
254
254
  Learn more about the Message Batches API in our
255
- [user guide](/en/docs/build-with-claude/batch-processing)
255
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
256
256
 
257
257
  Args:
258
258
  message_batch_id: ID of the Message Batch.
@@ -294,7 +294,7 @@ class Batches(SyncAPIResource):
294
294
  requests. Use the `custom_id` field to match results to requests.
295
295
 
296
296
  Learn more about the Message Batches API in our
297
- [user guide](/en/docs/build-with-claude/batch-processing)
297
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
298
298
 
299
299
  Args:
300
300
  message_batch_id: ID of the Message Batch.
@@ -366,7 +366,7 @@ class AsyncBatches(AsyncAPIResource):
366
366
  can take up to 24 hours to complete.
367
367
 
368
368
  Learn more about the Message Batches API in our
369
- [user guide](/en/docs/build-with-claude/batch-processing)
369
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
370
370
 
371
371
  Args:
372
372
  requests: List of requests for prompt completion. Each is an individual request to create
@@ -407,7 +407,7 @@ class AsyncBatches(AsyncAPIResource):
407
407
  `results_url` field in the response.
408
408
 
409
409
  Learn more about the Message Batches API in our
410
- [user guide](/en/docs/build-with-claude/batch-processing)
410
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
411
411
 
412
412
  Args:
413
413
  message_batch_id: ID of the Message Batch.
@@ -449,7 +449,7 @@ class AsyncBatches(AsyncAPIResource):
449
449
  returned first.
450
450
 
451
451
  Learn more about the Message Batches API in our
452
- [user guide](/en/docs/build-with-claude/batch-processing)
452
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
453
453
 
454
454
  Args:
455
455
  after_id: ID of the object to use as a cursor for pagination. When provided, returns the
@@ -508,7 +508,7 @@ class AsyncBatches(AsyncAPIResource):
508
508
  like to delete an in-progress batch, you must first cancel it.
509
509
 
510
510
  Learn more about the Message Batches API in our
511
- [user guide](/en/docs/build-with-claude/batch-processing)
511
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
512
512
 
513
513
  Args:
514
514
  message_batch_id: ID of the Message Batch.
@@ -555,7 +555,7 @@ class AsyncBatches(AsyncAPIResource):
555
555
  non-interruptible.
556
556
 
557
557
  Learn more about the Message Batches API in our
558
- [user guide](/en/docs/build-with-claude/batch-processing)
558
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
559
559
 
560
560
  Args:
561
561
  message_batch_id: ID of the Message Batch.
@@ -597,7 +597,7 @@ class AsyncBatches(AsyncAPIResource):
597
597
  requests. Use the `custom_id` field to match results to requests.
598
598
 
599
599
  Learn more about the Message Batches API in our
600
- [user guide](/en/docs/build-with-claude/batch-processing)
600
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/batch-processing)
601
601
 
602
602
  Args:
603
603
  message_batch_id: ID of the Message Batch.
@@ -118,7 +118,8 @@ class Messages(SyncAPIResource):
118
118
  The Messages API can be used for either single queries or stateless multi-turn
119
119
  conversations.
120
120
 
121
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
121
+ Learn more about the Messages API in our
122
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
122
123
 
123
124
  Args:
124
125
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -385,7 +386,8 @@ class Messages(SyncAPIResource):
385
386
  The Messages API can be used for either single queries or stateless multi-turn
386
387
  conversations.
387
388
 
388
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
389
+ Learn more about the Messages API in our
390
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
389
391
 
390
392
  Args:
391
393
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -652,7 +654,8 @@ class Messages(SyncAPIResource):
652
654
  The Messages API can be used for either single queries or stateless multi-turn
653
655
  conversations.
654
656
 
655
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
657
+ Learn more about the Messages API in our
658
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
656
659
 
657
660
  Args:
658
661
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -1046,7 +1049,7 @@ class Messages(SyncAPIResource):
1046
1049
  including tools, images, and documents, without creating it.
1047
1050
 
1048
1051
  Learn more about token counting in our
1049
- [user guide](/en/docs/build-with-claude/token-counting)
1052
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)
1050
1053
 
1051
1054
  Args:
1052
1055
  messages: Input messages.
@@ -1298,7 +1301,8 @@ class AsyncMessages(AsyncAPIResource):
1298
1301
  The Messages API can be used for either single queries or stateless multi-turn
1299
1302
  conversations.
1300
1303
 
1301
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
1304
+ Learn more about the Messages API in our
1305
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
1302
1306
 
1303
1307
  Args:
1304
1308
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -1565,7 +1569,8 @@ class AsyncMessages(AsyncAPIResource):
1565
1569
  The Messages API can be used for either single queries or stateless multi-turn
1566
1570
  conversations.
1567
1571
 
1568
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
1572
+ Learn more about the Messages API in our
1573
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
1569
1574
 
1570
1575
  Args:
1571
1576
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -1832,7 +1837,8 @@ class AsyncMessages(AsyncAPIResource):
1832
1837
  The Messages API can be used for either single queries or stateless multi-turn
1833
1838
  conversations.
1834
1839
 
1835
- Learn more about the Messages API in our [user guide](/en/docs/initial-setup)
1840
+ Learn more about the Messages API in our
1841
+ [user guide](https://docs.claude.com/en/docs/initial-setup)
1836
1842
 
1837
1843
  Args:
1838
1844
  max_tokens: The maximum number of tokens to generate before stopping.
@@ -2225,7 +2231,7 @@ class AsyncMessages(AsyncAPIResource):
2225
2231
  including tools, images, and documents, without creating it.
2226
2232
 
2227
2233
  Learn more about token counting in our
2228
- [user guide](/en/docs/build-with-claude/token-counting)
2234
+ [user guide](https://docs.claude.com/en/docs/build-with-claude/token-counting)
2229
2235
 
2230
2236
  Args:
2231
2237
  messages: Input messages.
@@ -83,6 +83,7 @@ from .beta_tool_result_block_param import BetaToolResultBlockParam as BetaToolRe
83
83
  from .beta_tool_uses_trigger_param import BetaToolUsesTriggerParam as BetaToolUsesTriggerParam
84
84
  from .beta_web_search_result_block import BetaWebSearchResultBlock as BetaWebSearchResultBlock
85
85
  from .beta_all_thinking_turns_param import BetaAllThinkingTurnsParam as BetaAllThinkingTurnsParam
86
+ from .beta_json_output_format_param import BetaJSONOutputFormatParam as BetaJSONOutputFormatParam
86
87
  from .beta_mcp_tool_use_block_param import BetaMCPToolUseBlockParam as BetaMCPToolUseBlockParam
87
88
  from .beta_raw_message_stream_event import BetaRawMessageStreamEvent as BetaRawMessageStreamEvent
88
89
  from .beta_tool_bash_20241022_param import BetaToolBash20241022Param as BetaToolBash20241022Param
@@ -21,3 +21,5 @@ class BetaCodeExecutionTool20250522Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -21,3 +21,5 @@ class BetaCodeExecutionTool20250825Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -0,0 +1,15 @@
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 Dict
6
+ from typing_extensions import Literal, Required, TypedDict
7
+
8
+ __all__ = ["BetaJSONOutputFormatParam"]
9
+
10
+
11
+ class BetaJSONOutputFormatParam(TypedDict, total=False):
12
+ schema: Required[Dict[str, object]]
13
+ """The JSON schema of the format"""
14
+
15
+ type: Required[Literal["json_schema"]]
@@ -21,3 +21,5 @@ class BetaMemoryTool20250818Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -21,3 +21,5 @@ class BetaToolBash20241022Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -21,3 +21,5 @@ class BetaToolBash20250124Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -30,3 +30,5 @@ class BetaToolComputerUse20241022Param(TypedDict, total=False):
30
30
 
31
31
  display_number: Optional[int]
32
32
  """The X11 display number (e.g. 0, 1) for the display."""
33
+
34
+ strict: bool
@@ -30,3 +30,5 @@ class BetaToolComputerUse20250124Param(TypedDict, total=False):
30
30
 
31
31
  display_number: Optional[int]
32
32
  """The X11 display number (e.g. 0, 1) for the display."""
33
+
34
+ strict: bool
@@ -48,4 +48,6 @@ class BetaToolParam(TypedDict, total=False):
48
48
  aspects of the tool input JSON schema.
49
49
  """
50
50
 
51
+ strict: bool
52
+
51
53
  type: Optional[Literal["custom"]]
@@ -21,3 +21,5 @@ class BetaToolTextEditor20241022Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -21,3 +21,5 @@ class BetaToolTextEditor20250124Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -21,3 +21,5 @@ class BetaToolTextEditor20250429Param(TypedDict, total=False):
21
21
 
22
22
  cache_control: Optional[BetaCacheControlEphemeralParam]
23
23
  """Create a cache control breakpoint at this content block."""
24
+
25
+ strict: bool
@@ -27,3 +27,5 @@ class BetaToolTextEditor20250728Param(TypedDict, total=False):
27
27
 
28
28
  If not specified, defaults to displaying the full file.
29
29
  """
30
+
31
+ strict: bool
@@ -44,3 +44,5 @@ class BetaWebFetchTool20250910Param(TypedDict, total=False):
44
44
 
45
45
  max_uses: Optional[int]
46
46
  """Maximum number of times the tool can be used in the API request."""
47
+
48
+ strict: bool
@@ -58,6 +58,8 @@ class BetaWebSearchTool20250305Param(TypedDict, total=False):
58
58
  max_uses: Optional[int]
59
59
  """Maximum number of times the tool can be used in the API request."""
60
60
 
61
+ strict: bool
62
+
61
63
  user_location: Optional[UserLocation]
62
64
  """Parameters for the user's location.
63
65
 
@@ -13,6 +13,7 @@ from ..anthropic_beta_param import AnthropicBetaParam
13
13
  from .beta_text_block_param import BetaTextBlockParam
14
14
  from .beta_tool_choice_param import BetaToolChoiceParam
15
15
  from .beta_thinking_config_param import BetaThinkingConfigParam
16
+ from .beta_json_output_format_param import BetaJSONOutputFormatParam
16
17
  from .beta_tool_bash_20241022_param import BetaToolBash20241022Param
17
18
  from .beta_tool_bash_20250124_param import BetaToolBash20250124Param
18
19
  from .beta_memory_tool_20250818_param import BetaMemoryTool20250818Param
@@ -118,6 +119,9 @@ class MessageCountTokensParams(TypedDict, total=False):
118
119
  mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam]
119
120
  """MCP servers to be utilized in this request"""
120
121
 
122
+ output_format: Optional[BetaJSONOutputFormatParam]
123
+ """A schema to specify Claude's output format in responses."""
124
+
121
125
  system: Union[str, Iterable[BetaTextBlockParam]]
122
126
  """System prompt.
123
127
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  from __future__ import annotations
4
4
 
5
- from typing import List, Union, Iterable, Optional
5
+ from typing import List, Union, Generic, Iterable, Optional
6
6
  from typing_extensions import Literal, Required, Annotated, TypeAlias, TypedDict
7
7
 
8
8
  from ..._types import SequenceNotStr
@@ -10,16 +10,24 @@ from ..._utils import PropertyInfo
10
10
  from ..model_param import ModelParam
11
11
  from .beta_message_param import BetaMessageParam
12
12
  from .beta_metadata_param import BetaMetadataParam
13
+ from .parsed_beta_message import ResponseFormatT
13
14
  from ..anthropic_beta_param import AnthropicBetaParam
14
15
  from .beta_container_params import BetaContainerParams
15
16
  from .beta_text_block_param import BetaTextBlockParam
16
17
  from .beta_tool_union_param import BetaToolUnionParam
17
18
  from .beta_tool_choice_param import BetaToolChoiceParam
18
19
  from .beta_thinking_config_param import BetaThinkingConfigParam
20
+ from .beta_json_output_format_param import BetaJSONOutputFormatParam
19
21
  from .beta_context_management_config_param import BetaContextManagementConfigParam
20
22
  from .beta_request_mcp_server_url_definition_param import BetaRequestMCPServerURLDefinitionParam
21
23
 
22
- __all__ = ["MessageCreateParamsBase", "Container", "MessageCreateParamsNonStreaming", "MessageCreateParamsStreaming"]
24
+ __all__ = [
25
+ "MessageCreateParamsBase",
26
+ "Container",
27
+ "MessageCreateParamsNonStreaming",
28
+ "MessageCreateParamsStreaming",
29
+ "OutputFormat",
30
+ ]
23
31
 
24
32
 
25
33
  class MessageCreateParamsBase(TypedDict, total=False):
@@ -124,6 +132,9 @@ class MessageCreateParamsBase(TypedDict, total=False):
124
132
  metadata: BetaMetadataParam
125
133
  """An object describing metadata about the request."""
126
134
 
135
+ output_format: Optional[BetaJSONOutputFormatParam]
136
+ """A schema to specify Claude's output format in responses."""
137
+
127
138
  service_tier: Literal["auto", "standard_only"]
128
139
  """
129
140
  Determines whether to use priority capacity (if available) or standard capacity
@@ -290,6 +301,17 @@ class MessageCreateParamsBase(TypedDict, total=False):
290
301
  Container: TypeAlias = Union[BetaContainerParams, str]
291
302
 
292
303
 
304
+ class ParseMessageCreateParamsBase(MessageCreateParamsBase, Generic[ResponseFormatT]):
305
+ output_format: type[ResponseFormatT] # type: ignore[misc]
306
+
307
+
308
+ class OutputFormat(TypedDict, total=False):
309
+ schema: Required[object]
310
+ """The JSON schema of the format"""
311
+
312
+ type: Required[Literal["json_schema"]]
313
+
314
+
293
315
  class MessageCreateParamsNonStreaming(MessageCreateParamsBase, total=False):
294
316
  stream: Literal[False]
295
317
  """Whether to incrementally stream the response using server-sent events.
@@ -3,13 +3,13 @@
3
3
  from __future__ import annotations
4
4
 
5
5
  from typing import List, Iterable
6
- from typing_extensions import Required, Annotated, TypedDict
6
+ from typing_extensions import Literal, Required, Annotated, TypedDict
7
7
 
8
8
  from ...._utils import PropertyInfo
9
9
  from ...anthropic_beta_param import AnthropicBetaParam
10
10
  from ..message_create_params import MessageCreateParamsNonStreaming
11
11
 
12
- __all__ = ["BatchCreateParams", "Request"]
12
+ __all__ = ["BatchCreateParams", "Request", "RequestParamsOutputFormat"]
13
13
 
14
14
 
15
15
  class BatchCreateParams(TypedDict, total=False):
@@ -23,6 +23,12 @@ class BatchCreateParams(TypedDict, total=False):
23
23
  """Optional header to specify the beta version(s) you want to use."""
24
24
 
25
25
 
26
+ class RequestParamsOutputFormat(TypedDict, total=False):
27
+ schema: Required[object]
28
+ """The JSON schema of the format"""
29
+
30
+ type: Required[Literal["json_schema"]]
31
+
26
32
 
27
33
  class Request(TypedDict, total=False):
28
34
  custom_id: Required[str]
@@ -0,0 +1,68 @@
1
+ from __future__ import annotations
2
+
3
+ from typing import TYPE_CHECKING, List, Union, Generic, Optional
4
+ from typing_extensions import TypeVar, Annotated, TypeAlias
5
+
6
+ from ..._utils import PropertyInfo
7
+ from .beta_message import BetaMessage
8
+ from .beta_text_block import BetaTextBlock
9
+ from .beta_thinking_block import BetaThinkingBlock
10
+ from .beta_tool_use_block import BetaToolUseBlock
11
+ from .beta_mcp_tool_use_block import BetaMCPToolUseBlock
12
+ from .beta_mcp_tool_result_block import BetaMCPToolResultBlock
13
+ from .beta_server_tool_use_block import BetaServerToolUseBlock
14
+ from .beta_container_upload_block import BetaContainerUploadBlock
15
+ from .beta_redacted_thinking_block import BetaRedactedThinkingBlock
16
+ from .beta_web_search_tool_result_block import BetaWebSearchToolResultBlock
17
+ from .beta_code_execution_tool_result_block import BetaCodeExecutionToolResultBlock
18
+ from .beta_bash_code_execution_tool_result_block import BetaBashCodeExecutionToolResultBlock
19
+ from .beta_text_editor_code_execution_tool_result_block import BetaTextEditorCodeExecutionToolResultBlock
20
+
21
+ ResponseFormatT = TypeVar("ResponseFormatT", default=None)
22
+
23
+
24
+ __all__ = [
25
+ "ParsedBetaTextBlock",
26
+ "ParsedBetaContentBlock",
27
+ "ParsedBetaMessage",
28
+ ]
29
+
30
+
31
+ class ParsedBetaTextBlock(BetaTextBlock, Generic[ResponseFormatT]):
32
+ parsed_output: Optional[ResponseFormatT] = None
33
+
34
+ __api_exclude__ = {"parsed_output"}
35
+
36
+
37
+ # Note that generic unions are not valid for pydantic at runtime
38
+ ParsedBetaContentBlock: TypeAlias = Annotated[
39
+ Union[
40
+ ParsedBetaTextBlock[ResponseFormatT],
41
+ BetaThinkingBlock,
42
+ BetaRedactedThinkingBlock,
43
+ BetaToolUseBlock,
44
+ BetaServerToolUseBlock,
45
+ BetaWebSearchToolResultBlock,
46
+ BetaCodeExecutionToolResultBlock,
47
+ BetaBashCodeExecutionToolResultBlock,
48
+ BetaTextEditorCodeExecutionToolResultBlock,
49
+ BetaMCPToolUseBlock,
50
+ BetaMCPToolResultBlock,
51
+ BetaContainerUploadBlock,
52
+ ],
53
+ PropertyInfo(discriminator="type"),
54
+ ]
55
+
56
+
57
+ class ParsedBetaMessage(BetaMessage, Generic[ResponseFormatT]):
58
+ if TYPE_CHECKING:
59
+ content: List[ParsedBetaContentBlock[ResponseFormatT]] # type: ignore[assignment]
60
+ else:
61
+ content: List[ParsedBetaContentBlock]
62
+
63
+ @property
64
+ def parsed_output(self) -> Optional[ResponseFormatT]:
65
+ for content in self.content:
66
+ if content.type == "text" and content.parsed_output:
67
+ return content.parsed_output
68
+ return None
@@ -18,7 +18,6 @@ class BatchCreateParams(TypedDict, total=False):
18
18
  """
19
19
 
20
20
 
21
-
22
21
  class Request(TypedDict, total=False):
23
22
  custom_id: Required[str]
24
23
  """Developer-provided ID created for each request in a Message Batch.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: anthropic
3
- Version: 0.72.0
3
+ Version: 0.73.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
@@ -13,7 +13,6 @@ Classifier: Operating System :: Microsoft :: Windows
13
13
  Classifier: Operating System :: OS Independent
14
14
  Classifier: Operating System :: POSIX
15
15
  Classifier: Operating System :: POSIX :: Linux
16
- Classifier: Programming Language :: Python :: 3.8
17
16
  Classifier: Programming Language :: Python :: 3.9
18
17
  Classifier: Programming Language :: Python :: 3.10
19
18
  Classifier: Programming Language :: Python :: 3.11
@@ -21,7 +20,7 @@ Classifier: Programming Language :: Python :: 3.12
21
20
  Classifier: Programming Language :: Python :: 3.13
22
21
  Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
22
  Classifier: Typing :: Typed
24
- Requires-Python: >=3.8
23
+ Requires-Python: >=3.9
25
24
  Requires-Dist: anyio<5,>=3.5.0
26
25
  Requires-Dist: distro<2,>=1.7.0
27
26
  Requires-Dist: docstring-parser<1,>=0.15
@@ -45,7 +44,7 @@ Description-Content-Type: text/markdown
45
44
  <!-- prettier-ignore -->
46
45
  [![PyPI version](https://img.shields.io/pypi/v/anthropic.svg?label=pypi%20(stable))](https://pypi.org/project/anthropic/)
47
46
 
48
- The Anthropic Python library provides convenient access to the Anthropic REST API from any Python 3.8+
47
+ The Anthropic Python library provides convenient access to the Anthropic REST API from any Python 3.9+
49
48
  application. It includes type definitions for all request params and response fields,
50
49
  and offers both synchronous and asynchronous clients powered by [httpx](https://github.com/encode/httpx).
51
50
 
@@ -909,7 +908,7 @@ print(anthropic.__version__)
909
908
 
910
909
  ## Requirements
911
910
 
912
- Python 3.8 or higher.
911
+ Python 3.9 or higher.
913
912
 
914
913
  ## Contributing
915
914