anthropic 0.55.0__py3-none-any.whl → 0.57.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 (34) hide show
  1. anthropic/_exceptions.py +4 -1
  2. anthropic/_version.py +1 -1
  3. anthropic/lib/bedrock/_client.py +28 -6
  4. anthropic/lib/streaming/_beta_messages.py +7 -2
  5. anthropic/lib/streaming/_messages.py +6 -2
  6. anthropic/lib/vertex/_client.py +8 -2
  7. anthropic/resources/beta/messages/messages.py +56 -8
  8. anthropic/resources/messages/messages.py +57 -8
  9. anthropic/types/beta/__init__.py +5 -0
  10. anthropic/types/beta/beta_citations_delta.py +2 -0
  11. anthropic/types/beta/beta_content_block.py +2 -2
  12. anthropic/types/beta/beta_content_block_param.py +9 -7
  13. anthropic/types/beta/beta_message.py +4 -0
  14. anthropic/types/beta/beta_raw_content_block_start_event.py +2 -2
  15. anthropic/types/beta/beta_search_result_block_param.py +27 -0
  16. anthropic/types/beta/beta_search_result_location_citation.py +24 -0
  17. anthropic/types/beta/beta_search_result_location_citation_param.py +24 -0
  18. anthropic/types/beta/beta_text_citation.py +2 -0
  19. anthropic/types/beta/beta_text_citation_param.py +2 -0
  20. anthropic/types/beta/beta_tool_result_block_param.py +2 -1
  21. anthropic/types/beta/beta_tool_union_param.py +4 -4
  22. anthropic/types/beta/message_count_tokens_params.py +11 -5
  23. anthropic/types/beta/message_create_params.py +7 -1
  24. anthropic/types/content_block.py +1 -1
  25. anthropic/types/content_block_param.py +4 -4
  26. anthropic/types/message.py +4 -0
  27. anthropic/types/message_count_tokens_params.py +7 -1
  28. anthropic/types/message_create_params.py +7 -1
  29. anthropic/types/message_param.py +4 -4
  30. anthropic/types/raw_content_block_start_event.py +1 -1
  31. {anthropic-0.55.0.dist-info → anthropic-0.57.0.dist-info}/METADATA +30 -32
  32. {anthropic-0.55.0.dist-info → anthropic-0.57.0.dist-info}/RECORD +34 -31
  33. {anthropic-0.55.0.dist-info → anthropic-0.57.0.dist-info}/WHEEL +0 -0
  34. {anthropic-0.55.0.dist-info → anthropic-0.57.0.dist-info}/licenses/LICENSE +0 -0
anthropic/_exceptions.py CHANGED
@@ -75,7 +75,10 @@ class APIConnectionError(APIError):
75
75
 
76
76
  class APITimeoutError(APIConnectionError):
77
77
  def __init__(self, request: httpx.Request) -> None:
78
- super().__init__(message="Request timed out.", request=request)
78
+ super().__init__(
79
+ message="Request timed out or interrupted. This could be due to a network timeout, dropped connection, or request cancellation. See https://docs.anthropic.com/en/api/errors#long-requests for more details.",
80
+ request=request,
81
+ )
79
82
 
80
83
 
81
84
  class BadRequestError(APIStatusError):
anthropic/_version.py CHANGED
@@ -1,4 +1,4 @@
1
1
  # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  __title__ = "anthropic"
4
- __version__ = "0.55.0" # x-release-please-version
4
+ __version__ = "0.57.0" # x-release-please-version
@@ -1,6 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
3
  import os
4
+ import logging
4
5
  import urllib.parse
5
6
  from typing import Any, Union, Mapping, TypeVar
6
7
  from typing_extensions import Self, override
@@ -26,6 +27,8 @@ from ._stream_decoder import AWSEventStreamDecoder
26
27
  from ...resources.messages import Messages, AsyncMessages
27
28
  from ...resources.completions import Completions, AsyncCompletions
28
29
 
30
+ log: logging.Logger = logging.getLogger(__name__)
31
+
29
32
  DEFAULT_VERSION = "bedrock-2023-05-31"
30
33
 
31
34
  _HttpxClientT = TypeVar("_HttpxClientT", bound=Union[httpx.Client, httpx.AsyncClient])
@@ -64,6 +67,29 @@ def _prepare_options(input_options: FinalRequestOptions) -> FinalRequestOptions:
64
67
  return options
65
68
 
66
69
 
70
+ def _infer_region() -> str:
71
+ """
72
+ Infer the AWS region from the environment variables or
73
+ from the boto3 session if available.
74
+ """
75
+ aws_region = os.environ.get("AWS_REGION")
76
+ if aws_region is None:
77
+ try:
78
+ import boto3
79
+
80
+ session = boto3.Session()
81
+ if session.region_name:
82
+ aws_region = session.region_name
83
+ except ImportError:
84
+ pass
85
+
86
+ if aws_region is None:
87
+ log.warning("No AWS region specified, defaulting to us-east-1")
88
+ aws_region = "us-east-1" # fall back to legacy behavior
89
+
90
+ return aws_region
91
+
92
+
67
93
  class BaseBedrockClient(BaseClient[_HttpxClientT, _DefaultStreamT]):
68
94
  @override
69
95
  def _make_status_error(
@@ -135,9 +161,7 @@ class AnthropicBedrock(BaseBedrockClient[httpx.Client, Stream[Any]], SyncAPIClie
135
161
 
136
162
  self.aws_access_key = aws_access_key
137
163
 
138
- if aws_region is None:
139
- aws_region = os.environ.get("AWS_REGION") or "us-east-1"
140
- self.aws_region = aws_region
164
+ self.aws_region = _infer_region() if aws_region is None else aws_region
141
165
  self.aws_profile = aws_profile
142
166
 
143
167
  self.aws_session_token = aws_session_token
@@ -279,9 +303,7 @@ class AsyncAnthropicBedrock(BaseBedrockClient[httpx.AsyncClient, AsyncStream[Any
279
303
 
280
304
  self.aws_access_key = aws_access_key
281
305
 
282
- if aws_region is None:
283
- aws_region = os.environ.get("AWS_REGION") or "us-east-1"
284
- self.aws_region = aws_region
306
+ self.aws_region = _infer_region() if aws_region is None else aws_region
285
307
  self.aws_profile = aws_profile
286
308
 
287
309
  self.aws_session_token = aws_session_token
@@ -101,7 +101,9 @@ class BetaMessageStream:
101
101
  text_blocks.append(block.text)
102
102
 
103
103
  if not text_blocks:
104
- raise RuntimeError("Expected to have received at least 1 text block")
104
+ raise RuntimeError(
105
+ f".get_final_text() can only be called when the API returns a `text` content block.\nThe API returned {','.join([b.type for b in message.content])} content block type(s) that you can access by calling get_final_message().content"
106
+ )
105
107
 
106
108
  return "".join(text_blocks)
107
109
 
@@ -239,7 +241,10 @@ class BetaAsyncMessageStream:
239
241
  text_blocks.append(block.text)
240
242
 
241
243
  if not text_blocks:
242
- raise RuntimeError("Expected to have received at least 1 text block")
244
+ raise RuntimeError(
245
+ f".get_final_text() can only be called when the API returns a `text` content block.\nThe API returned {','.join([b.type for b in message.content])} content block type(s) that you can access by calling get_final_message().content"
246
+ )
247
+
243
248
 
244
249
  return "".join(text_blocks)
245
250
 
@@ -100,7 +100,9 @@ class MessageStream:
100
100
  text_blocks.append(block.text)
101
101
 
102
102
  if not text_blocks:
103
- raise RuntimeError("Expected to have received at least 1 text block")
103
+ raise RuntimeError(
104
+ f".get_final_text() can only be called when the API returns a `text` content block.\nThe API returned {','.join([b.type for b in message.content])} content block type(s) that you can access by calling get_final_message().content"
105
+ )
104
106
 
105
107
  return "".join(text_blocks)
106
108
 
@@ -237,7 +239,9 @@ class AsyncMessageStream:
237
239
  text_blocks.append(block.text)
238
240
 
239
241
  if not text_blocks:
240
- raise RuntimeError("Expected to have received at least 1 text block")
242
+ raise RuntimeError(
243
+ f".get_final_text() can only be called when the API returns a `text` content block.\nThe API returned {','.join([b.type for b in message.content])} content block type(s) that you can access by calling get_final_message().content"
244
+ )
241
245
 
242
246
  return "".join(text_blocks)
243
247
 
@@ -117,7 +117,10 @@ class AnthropicVertex(BaseVertexClient[httpx.Client, Stream[Any]], SyncAPIClient
117
117
  if base_url is None:
118
118
  base_url = os.environ.get("ANTHROPIC_VERTEX_BASE_URL")
119
119
  if base_url is None:
120
- base_url = f"https://{region}-aiplatform.googleapis.com/v1"
120
+ if region == "global":
121
+ base_url = "https://aiplatform.googleapis.com/v1"
122
+ else:
123
+ base_url = f"https://{region}-aiplatform.googleapis.com/v1"
121
124
 
122
125
  super().__init__(
123
126
  version=__version__,
@@ -259,7 +262,10 @@ class AsyncAnthropicVertex(BaseVertexClient[httpx.AsyncClient, AsyncStream[Any]]
259
262
  if base_url is None:
260
263
  base_url = os.environ.get("ANTHROPIC_VERTEX_BASE_URL")
261
264
  if base_url is None:
262
- base_url = f"https://{region}-aiplatform.googleapis.com/v1"
265
+ if region == "global":
266
+ base_url = "https://aiplatform.googleapis.com/v1"
267
+ else:
268
+ base_url = f"https://{region}-aiplatform.googleapis.com/v1"
263
269
 
264
270
  super().__init__(
265
271
  version=__version__,
@@ -207,7 +207,7 @@ class Messages(SyncAPIResource):
207
207
  the top-level `system` parameter — there is no `"system"` role for input
208
208
  messages in the Messages API.
209
209
 
210
- There is a limit of 100000 messages in a single request.
210
+ There is a limit of 100,000 messages in a single request.
211
211
 
212
212
  model: The model that will complete your prompt.\n\nSee
213
213
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -275,6 +275,12 @@ class Messages(SyncAPIResource):
275
275
  those tools using the tool input generated by the model and then optionally
276
276
  return results back to the model using `tool_result` content blocks.
277
277
 
278
+ There are two types of tools: **client tools** and **server tools**. The
279
+ behavior described below applies to client tools. For
280
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
281
+ see their individual documentation as each has its own behavior (e.g., the
282
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
283
+
278
284
  Each tool definition includes:
279
285
 
280
286
  - `name`: Name of the tool.
@@ -501,7 +507,7 @@ class Messages(SyncAPIResource):
501
507
  the top-level `system` parameter — there is no `"system"` role for input
502
508
  messages in the Messages API.
503
509
 
504
- There is a limit of 100000 messages in a single request.
510
+ There is a limit of 100,000 messages in a single request.
505
511
 
506
512
  model: The model that will complete your prompt.\n\nSee
507
513
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -569,6 +575,12 @@ class Messages(SyncAPIResource):
569
575
  those tools using the tool input generated by the model and then optionally
570
576
  return results back to the model using `tool_result` content blocks.
571
577
 
578
+ There are two types of tools: **client tools** and **server tools**. The
579
+ behavior described below applies to client tools. For
580
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
581
+ see their individual documentation as each has its own behavior (e.g., the
582
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
583
+
572
584
  Each tool definition includes:
573
585
 
574
586
  - `name`: Name of the tool.
@@ -795,7 +807,7 @@ class Messages(SyncAPIResource):
795
807
  the top-level `system` parameter — there is no `"system"` role for input
796
808
  messages in the Messages API.
797
809
 
798
- There is a limit of 100000 messages in a single request.
810
+ There is a limit of 100,000 messages in a single request.
799
811
 
800
812
  model: The model that will complete your prompt.\n\nSee
801
813
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -863,6 +875,12 @@ class Messages(SyncAPIResource):
863
875
  those tools using the tool input generated by the model and then optionally
864
876
  return results back to the model using `tool_result` content blocks.
865
877
 
878
+ There are two types of tools: **client tools** and **server tools**. The
879
+ behavior described below applies to client tools. For
880
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
881
+ see their individual documentation as each has its own behavior (e.g., the
882
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
883
+
866
884
  Each tool definition includes:
867
885
 
868
886
  - `name`: Name of the tool.
@@ -1220,7 +1238,7 @@ class Messages(SyncAPIResource):
1220
1238
  the top-level `system` parameter — there is no `"system"` role for input
1221
1239
  messages in the Messages API.
1222
1240
 
1223
- There is a limit of 100000 messages in a single request.
1241
+ There is a limit of 100,000 messages in a single request.
1224
1242
 
1225
1243
  model: The model that will complete your prompt.\n\nSee
1226
1244
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1254,6 +1272,12 @@ class Messages(SyncAPIResource):
1254
1272
  those tools using the tool input generated by the model and then optionally
1255
1273
  return results back to the model using `tool_result` content blocks.
1256
1274
 
1275
+ There are two types of tools: **client tools** and **server tools**. The
1276
+ behavior described below applies to client tools. For
1277
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1278
+ see their individual documentation as each has its own behavior (e.g., the
1279
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1280
+
1257
1281
  Each tool definition includes:
1258
1282
 
1259
1283
  - `name`: Name of the tool.
@@ -1516,7 +1540,7 @@ class AsyncMessages(AsyncAPIResource):
1516
1540
  the top-level `system` parameter — there is no `"system"` role for input
1517
1541
  messages in the Messages API.
1518
1542
 
1519
- There is a limit of 100000 messages in a single request.
1543
+ There is a limit of 100,000 messages in a single request.
1520
1544
 
1521
1545
  model: The model that will complete your prompt.\n\nSee
1522
1546
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1584,6 +1608,12 @@ class AsyncMessages(AsyncAPIResource):
1584
1608
  those tools using the tool input generated by the model and then optionally
1585
1609
  return results back to the model using `tool_result` content blocks.
1586
1610
 
1611
+ There are two types of tools: **client tools** and **server tools**. The
1612
+ behavior described below applies to client tools. For
1613
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1614
+ see their individual documentation as each has its own behavior (e.g., the
1615
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1616
+
1587
1617
  Each tool definition includes:
1588
1618
 
1589
1619
  - `name`: Name of the tool.
@@ -1810,7 +1840,7 @@ class AsyncMessages(AsyncAPIResource):
1810
1840
  the top-level `system` parameter — there is no `"system"` role for input
1811
1841
  messages in the Messages API.
1812
1842
 
1813
- There is a limit of 100000 messages in a single request.
1843
+ There is a limit of 100,000 messages in a single request.
1814
1844
 
1815
1845
  model: The model that will complete your prompt.\n\nSee
1816
1846
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1878,6 +1908,12 @@ class AsyncMessages(AsyncAPIResource):
1878
1908
  those tools using the tool input generated by the model and then optionally
1879
1909
  return results back to the model using `tool_result` content blocks.
1880
1910
 
1911
+ There are two types of tools: **client tools** and **server tools**. The
1912
+ behavior described below applies to client tools. For
1913
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1914
+ see their individual documentation as each has its own behavior (e.g., the
1915
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1916
+
1881
1917
  Each tool definition includes:
1882
1918
 
1883
1919
  - `name`: Name of the tool.
@@ -2104,7 +2140,7 @@ class AsyncMessages(AsyncAPIResource):
2104
2140
  the top-level `system` parameter — there is no `"system"` role for input
2105
2141
  messages in the Messages API.
2106
2142
 
2107
- There is a limit of 100000 messages in a single request.
2143
+ There is a limit of 100,000 messages in a single request.
2108
2144
 
2109
2145
  model: The model that will complete your prompt.\n\nSee
2110
2146
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2172,6 +2208,12 @@ class AsyncMessages(AsyncAPIResource):
2172
2208
  those tools using the tool input generated by the model and then optionally
2173
2209
  return results back to the model using `tool_result` content blocks.
2174
2210
 
2211
+ There are two types of tools: **client tools** and **server tools**. The
2212
+ behavior described below applies to client tools. For
2213
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
2214
+ see their individual documentation as each has its own behavior (e.g., the
2215
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
2216
+
2175
2217
  Each tool definition includes:
2176
2218
 
2177
2219
  - `name`: Name of the tool.
@@ -2527,7 +2569,7 @@ class AsyncMessages(AsyncAPIResource):
2527
2569
  the top-level `system` parameter — there is no `"system"` role for input
2528
2570
  messages in the Messages API.
2529
2571
 
2530
- There is a limit of 100000 messages in a single request.
2572
+ There is a limit of 100,000 messages in a single request.
2531
2573
 
2532
2574
  model: The model that will complete your prompt.\n\nSee
2533
2575
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2561,6 +2603,12 @@ class AsyncMessages(AsyncAPIResource):
2561
2603
  those tools using the tool input generated by the model and then optionally
2562
2604
  return results back to the model using `tool_result` content blocks.
2563
2605
 
2606
+ There are two types of tools: **client tools** and **server tools**. The
2607
+ behavior described below applies to client tools. For
2608
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
2609
+ see their individual documentation as each has its own behavior (e.g., the
2610
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
2611
+
2564
2612
  Each tool definition includes:
2565
2613
 
2566
2614
  - `name`: Name of the tool.
@@ -54,6 +54,7 @@ DEPRECATED_MODELS = {
54
54
  "claude-instant-1.1-100k": "November 6th, 2024",
55
55
  "claude-instant-1.2": "November 6th, 2024",
56
56
  "claude-3-sonnet-20240229": "July 21st, 2025",
57
+ "claude-3-opus-20240229": "January 5th, 2026",
57
58
  "claude-2.1": "July 21st, 2025",
58
59
  "claude-2.0": "July 21st, 2025",
59
60
  }
@@ -213,7 +214,7 @@ class Messages(SyncAPIResource):
213
214
  the top-level `system` parameter — there is no `"system"` role for input
214
215
  messages in the Messages API.
215
216
 
216
- There is a limit of 100000 messages in a single request.
217
+ There is a limit of 100,000 messages in a single request.
217
218
 
218
219
  model: The model that will complete your prompt.\n\nSee
219
220
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -277,6 +278,12 @@ class Messages(SyncAPIResource):
277
278
  those tools using the tool input generated by the model and then optionally
278
279
  return results back to the model using `tool_result` content blocks.
279
280
 
281
+ There are two types of tools: **client tools** and **server tools**. The
282
+ behavior described below applies to client tools. For
283
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
284
+ see their individual documentation as each has its own behavior (e.g., the
285
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
286
+
280
287
  Each tool definition includes:
281
288
 
282
289
  - `name`: Name of the tool.
@@ -498,7 +505,7 @@ class Messages(SyncAPIResource):
498
505
  the top-level `system` parameter — there is no `"system"` role for input
499
506
  messages in the Messages API.
500
507
 
501
- There is a limit of 100000 messages in a single request.
508
+ There is a limit of 100,000 messages in a single request.
502
509
 
503
510
  model: The model that will complete your prompt.\n\nSee
504
511
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -562,6 +569,12 @@ class Messages(SyncAPIResource):
562
569
  those tools using the tool input generated by the model and then optionally
563
570
  return results back to the model using `tool_result` content blocks.
564
571
 
572
+ There are two types of tools: **client tools** and **server tools**. The
573
+ behavior described below applies to client tools. For
574
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
575
+ see their individual documentation as each has its own behavior (e.g., the
576
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
577
+
565
578
  Each tool definition includes:
566
579
 
567
580
  - `name`: Name of the tool.
@@ -783,7 +796,7 @@ class Messages(SyncAPIResource):
783
796
  the top-level `system` parameter — there is no `"system"` role for input
784
797
  messages in the Messages API.
785
798
 
786
- There is a limit of 100000 messages in a single request.
799
+ There is a limit of 100,000 messages in a single request.
787
800
 
788
801
  model: The model that will complete your prompt.\n\nSee
789
802
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -847,6 +860,12 @@ class Messages(SyncAPIResource):
847
860
  those tools using the tool input generated by the model and then optionally
848
861
  return results back to the model using `tool_result` content blocks.
849
862
 
863
+ There are two types of tools: **client tools** and **server tools**. The
864
+ behavior described below applies to client tools. For
865
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
866
+ see their individual documentation as each has its own behavior (e.g., the
867
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
868
+
850
869
  Each tool definition includes:
851
870
 
852
871
  - `name`: Name of the tool.
@@ -1187,7 +1206,7 @@ class Messages(SyncAPIResource):
1187
1206
  the top-level `system` parameter — there is no `"system"` role for input
1188
1207
  messages in the Messages API.
1189
1208
 
1190
- There is a limit of 100000 messages in a single request.
1209
+ There is a limit of 100,000 messages in a single request.
1191
1210
 
1192
1211
  model: The model that will complete your prompt.\n\nSee
1193
1212
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1219,6 +1238,12 @@ class Messages(SyncAPIResource):
1219
1238
  those tools using the tool input generated by the model and then optionally
1220
1239
  return results back to the model using `tool_result` content blocks.
1221
1240
 
1241
+ There are two types of tools: **client tools** and **server tools**. The
1242
+ behavior described below applies to client tools. For
1243
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1244
+ see their individual documentation as each has its own behavior (e.g., the
1245
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1246
+
1222
1247
  Each tool definition includes:
1223
1248
 
1224
1249
  - `name`: Name of the tool.
@@ -1464,7 +1489,7 @@ class AsyncMessages(AsyncAPIResource):
1464
1489
  the top-level `system` parameter — there is no `"system"` role for input
1465
1490
  messages in the Messages API.
1466
1491
 
1467
- There is a limit of 100000 messages in a single request.
1492
+ There is a limit of 100,000 messages in a single request.
1468
1493
 
1469
1494
  model: The model that will complete your prompt.\n\nSee
1470
1495
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1528,6 +1553,12 @@ class AsyncMessages(AsyncAPIResource):
1528
1553
  those tools using the tool input generated by the model and then optionally
1529
1554
  return results back to the model using `tool_result` content blocks.
1530
1555
 
1556
+ There are two types of tools: **client tools** and **server tools**. The
1557
+ behavior described below applies to client tools. For
1558
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1559
+ see their individual documentation as each has its own behavior (e.g., the
1560
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1561
+
1531
1562
  Each tool definition includes:
1532
1563
 
1533
1564
  - `name`: Name of the tool.
@@ -1749,7 +1780,7 @@ class AsyncMessages(AsyncAPIResource):
1749
1780
  the top-level `system` parameter — there is no `"system"` role for input
1750
1781
  messages in the Messages API.
1751
1782
 
1752
- There is a limit of 100000 messages in a single request.
1783
+ There is a limit of 100,000 messages in a single request.
1753
1784
 
1754
1785
  model: The model that will complete your prompt.\n\nSee
1755
1786
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1813,6 +1844,12 @@ class AsyncMessages(AsyncAPIResource):
1813
1844
  those tools using the tool input generated by the model and then optionally
1814
1845
  return results back to the model using `tool_result` content blocks.
1815
1846
 
1847
+ There are two types of tools: **client tools** and **server tools**. The
1848
+ behavior described below applies to client tools. For
1849
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
1850
+ see their individual documentation as each has its own behavior (e.g., the
1851
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
1852
+
1816
1853
  Each tool definition includes:
1817
1854
 
1818
1855
  - `name`: Name of the tool.
@@ -2034,7 +2071,7 @@ class AsyncMessages(AsyncAPIResource):
2034
2071
  the top-level `system` parameter — there is no `"system"` role for input
2035
2072
  messages in the Messages API.
2036
2073
 
2037
- There is a limit of 100000 messages in a single request.
2074
+ There is a limit of 100,000 messages in a single request.
2038
2075
 
2039
2076
  model: The model that will complete your prompt.\n\nSee
2040
2077
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2098,6 +2135,12 @@ class AsyncMessages(AsyncAPIResource):
2098
2135
  those tools using the tool input generated by the model and then optionally
2099
2136
  return results back to the model using `tool_result` content blocks.
2100
2137
 
2138
+ There are two types of tools: **client tools** and **server tools**. The
2139
+ behavior described below applies to client tools. For
2140
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
2141
+ see their individual documentation as each has its own behavior (e.g., the
2142
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
2143
+
2101
2144
  Each tool definition includes:
2102
2145
 
2103
2146
  - `name`: Name of the tool.
@@ -2437,7 +2480,7 @@ class AsyncMessages(AsyncAPIResource):
2437
2480
  the top-level `system` parameter — there is no `"system"` role for input
2438
2481
  messages in the Messages API.
2439
2482
 
2440
- There is a limit of 100000 messages in a single request.
2483
+ There is a limit of 100,000 messages in a single request.
2441
2484
 
2442
2485
  model: The model that will complete your prompt.\n\nSee
2443
2486
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2469,6 +2512,12 @@ class AsyncMessages(AsyncAPIResource):
2469
2512
  those tools using the tool input generated by the model and then optionally
2470
2513
  return results back to the model using `tool_result` content blocks.
2471
2514
 
2515
+ There are two types of tools: **client tools** and **server tools**. The
2516
+ behavior described below applies to client tools. For
2517
+ [server tools](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/overview#server-tools),
2518
+ see their individual documentation as each has its own behavior (e.g., the
2519
+ [web search tool](https://docs.anthropic.com/en/docs/agents-and-tools/tool-use/web-search-tool)).
2520
+
2472
2521
  Each tool definition includes:
2473
2522
 
2474
2523
  - `name`: Name of the tool.
@@ -69,6 +69,7 @@ from .beta_raw_message_stream_event import BetaRawMessageStreamEvent as BetaRawM
69
69
  from .beta_tool_bash_20241022_param import BetaToolBash20241022Param as BetaToolBash20241022Param
70
70
  from .beta_tool_bash_20250124_param import BetaToolBash20250124Param as BetaToolBash20250124Param
71
71
  from .beta_base64_image_source_param import BetaBase64ImageSourceParam as BetaBase64ImageSourceParam
72
+ from .beta_search_result_block_param import BetaSearchResultBlockParam as BetaSearchResultBlockParam
72
73
  from .beta_content_block_source_param import BetaContentBlockSourceParam as BetaContentBlockSourceParam
73
74
  from .beta_file_document_source_param import BetaFileDocumentSourceParam as BetaFileDocumentSourceParam
74
75
  from .beta_code_execution_output_block import BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock
@@ -90,6 +91,7 @@ from .beta_web_search_result_block_param import BetaWebSearchResultBlockParam as
90
91
  from .beta_thinking_config_disabled_param import BetaThinkingConfigDisabledParam as BetaThinkingConfigDisabledParam
91
92
  from .beta_web_search_tool_20250305_param import BetaWebSearchTool20250305Param as BetaWebSearchTool20250305Param
92
93
  from .beta_citation_content_block_location import BetaCitationContentBlockLocation as BetaCitationContentBlockLocation
94
+ from .beta_search_result_location_citation import BetaSearchResultLocationCitation as BetaSearchResultLocationCitation
93
95
  from .beta_tool_text_editor_20241022_param import BetaToolTextEditor20241022Param as BetaToolTextEditor20241022Param
94
96
  from .beta_tool_text_editor_20250124_param import BetaToolTextEditor20250124Param as BetaToolTextEditor20250124Param
95
97
  from .beta_tool_text_editor_20250429_param import BetaToolTextEditor20250429Param as BetaToolTextEditor20250429Param
@@ -131,6 +133,9 @@ from .beta_citation_content_block_location_param import (
131
133
  from .beta_code_execution_tool_result_error_code import (
132
134
  BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
133
135
  )
136
+ from .beta_search_result_location_citation_param import (
137
+ BetaSearchResultLocationCitationParam as BetaSearchResultLocationCitationParam,
138
+ )
134
139
  from .beta_code_execution_tool_result_block_param import (
135
140
  BetaCodeExecutionToolResultBlockParam as BetaCodeExecutionToolResultBlockParam,
136
141
  )
@@ -8,6 +8,7 @@ from ..._models import BaseModel
8
8
  from .beta_citation_char_location import BetaCitationCharLocation
9
9
  from .beta_citation_page_location import BetaCitationPageLocation
10
10
  from .beta_citation_content_block_location import BetaCitationContentBlockLocation
11
+ from .beta_search_result_location_citation import BetaSearchResultLocationCitation
11
12
  from .beta_citations_web_search_result_location import BetaCitationsWebSearchResultLocation
12
13
 
13
14
  __all__ = ["BetaCitationsDelta", "Citation"]
@@ -18,6 +19,7 @@ Citation: TypeAlias = Annotated[
18
19
  BetaCitationPageLocation,
19
20
  BetaCitationContentBlockLocation,
20
21
  BetaCitationsWebSearchResultLocation,
22
+ BetaSearchResultLocationCitation,
21
23
  ],
22
24
  PropertyInfo(discriminator="type"),
23
25
  ]
@@ -20,6 +20,8 @@ __all__ = ["BetaContentBlock"]
20
20
  BetaContentBlock: TypeAlias = Annotated[
21
21
  Union[
22
22
  BetaTextBlock,
23
+ BetaThinkingBlock,
24
+ BetaRedactedThinkingBlock,
23
25
  BetaToolUseBlock,
24
26
  BetaServerToolUseBlock,
25
27
  BetaWebSearchToolResultBlock,
@@ -27,8 +29,6 @@ BetaContentBlock: TypeAlias = Annotated[
27
29
  BetaMCPToolUseBlock,
28
30
  BetaMCPToolResultBlock,
29
31
  BetaContainerUploadBlock,
30
- BetaThinkingBlock,
31
- BetaRedactedThinkingBlock,
32
32
  ],
33
33
  PropertyInfo(discriminator="type"),
34
34
  ]
@@ -11,6 +11,7 @@ from .beta_thinking_block_param import BetaThinkingBlockParam
11
11
  from .beta_tool_use_block_param import BetaToolUseBlockParam
12
12
  from .beta_tool_result_block_param import BetaToolResultBlockParam
13
13
  from .beta_mcp_tool_use_block_param import BetaMCPToolUseBlockParam
14
+ from .beta_search_result_block_param import BetaSearchResultBlockParam
14
15
  from .beta_server_tool_use_block_param import BetaServerToolUseBlockParam
15
16
  from .beta_container_upload_block_param import BetaContainerUploadBlockParam
16
17
  from .beta_request_document_block_param import BetaRequestDocumentBlockParam
@@ -22,17 +23,18 @@ from .beta_code_execution_tool_result_block_param import BetaCodeExecutionToolRe
22
23
  __all__ = ["BetaContentBlockParam"]
23
24
 
24
25
  BetaContentBlockParam: TypeAlias = Union[
25
- BetaServerToolUseBlockParam,
26
- BetaWebSearchToolResultBlockParam,
27
- BetaCodeExecutionToolResultBlockParam,
28
- BetaMCPToolUseBlockParam,
29
- BetaRequestMCPToolResultBlockParam,
30
26
  BetaTextBlockParam,
31
27
  BetaImageBlockParam,
32
- BetaToolUseBlockParam,
33
- BetaToolResultBlockParam,
34
28
  BetaRequestDocumentBlockParam,
29
+ BetaSearchResultBlockParam,
35
30
  BetaThinkingBlockParam,
36
31
  BetaRedactedThinkingBlockParam,
32
+ BetaToolUseBlockParam,
33
+ BetaToolResultBlockParam,
34
+ BetaServerToolUseBlockParam,
35
+ BetaWebSearchToolResultBlockParam,
36
+ BetaCodeExecutionToolResultBlockParam,
37
+ BetaMCPToolUseBlockParam,
38
+ BetaRequestMCPToolResultBlockParam,
37
39
  BetaContainerUploadBlockParam,
38
40
  ]
@@ -83,6 +83,10 @@ class BetaMessage(BaseModel):
83
83
  - `"max_tokens"`: we exceeded the requested `max_tokens` or the model's maximum
84
84
  - `"stop_sequence"`: one of your provided custom `stop_sequences` was generated
85
85
  - `"tool_use"`: the model invoked one or more tools
86
+ - `"pause_turn"`: we paused a long-running turn. You may provide the response
87
+ back as-is in a subsequent request to let the model continue.
88
+ - `"refusal"`: when streaming classifiers intervene to handle potential policy
89
+ violations
86
90
 
87
91
  In non-streaming mode this value is always non-null. In streaming mode, it is
88
92
  null in the `message_start` event and non-null otherwise.
@@ -21,6 +21,8 @@ __all__ = ["BetaRawContentBlockStartEvent", "ContentBlock"]
21
21
  ContentBlock: TypeAlias = Annotated[
22
22
  Union[
23
23
  BetaTextBlock,
24
+ BetaThinkingBlock,
25
+ BetaRedactedThinkingBlock,
24
26
  BetaToolUseBlock,
25
27
  BetaServerToolUseBlock,
26
28
  BetaWebSearchToolResultBlock,
@@ -28,8 +30,6 @@ ContentBlock: TypeAlias = Annotated[
28
30
  BetaMCPToolUseBlock,
29
31
  BetaMCPToolResultBlock,
30
32
  BetaContainerUploadBlock,
31
- BetaThinkingBlock,
32
- BetaRedactedThinkingBlock,
33
33
  ],
34
34
  PropertyInfo(discriminator="type"),
35
35
  ]