anthropic 0.56.0__py3-none-any.whl → 0.57.1__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 (32) hide show
  1. anthropic/_exceptions.py +4 -1
  2. anthropic/_version.py +1 -1
  3. anthropic/lib/streaming/_beta_messages.py +7 -2
  4. anthropic/lib/streaming/_messages.py +6 -2
  5. anthropic/resources/beta/messages/messages.py +56 -8
  6. anthropic/resources/messages/messages.py +56 -8
  7. anthropic/types/beta/__init__.py +5 -0
  8. anthropic/types/beta/beta_citation_search_result_location.py +24 -0
  9. anthropic/types/beta/beta_citation_search_result_location_param.py +24 -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_text_citation.py +2 -0
  17. anthropic/types/beta/beta_text_citation_param.py +2 -0
  18. anthropic/types/beta/beta_tool_result_block_param.py +2 -1
  19. anthropic/types/beta/beta_tool_union_param.py +4 -4
  20. anthropic/types/beta/message_count_tokens_params.py +11 -5
  21. anthropic/types/beta/message_create_params.py +7 -1
  22. anthropic/types/content_block.py +1 -1
  23. anthropic/types/content_block_param.py +4 -4
  24. anthropic/types/message.py +4 -0
  25. anthropic/types/message_count_tokens_params.py +7 -1
  26. anthropic/types/message_create_params.py +7 -1
  27. anthropic/types/message_param.py +4 -4
  28. anthropic/types/raw_content_block_start_event.py +1 -1
  29. {anthropic-0.56.0.dist-info → anthropic-0.57.1.dist-info}/METADATA +30 -32
  30. {anthropic-0.56.0.dist-info → anthropic-0.57.1.dist-info}/RECORD +32 -29
  31. {anthropic-0.56.0.dist-info → anthropic-0.57.1.dist-info}/WHEEL +0 -0
  32. {anthropic-0.56.0.dist-info → anthropic-0.57.1.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.56.0" # x-release-please-version
4
+ __version__ = "0.57.1" # x-release-please-version
@@ -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
 
@@ -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.
@@ -214,7 +214,7 @@ class Messages(SyncAPIResource):
214
214
  the top-level `system` parameter — there is no `"system"` role for input
215
215
  messages in the Messages API.
216
216
 
217
- There is a limit of 100000 messages in a single request.
217
+ There is a limit of 100,000 messages in a single request.
218
218
 
219
219
  model: The model that will complete your prompt.\n\nSee
220
220
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -278,6 +278,12 @@ class Messages(SyncAPIResource):
278
278
  those tools using the tool input generated by the model and then optionally
279
279
  return results back to the model using `tool_result` content blocks.
280
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
+
281
287
  Each tool definition includes:
282
288
 
283
289
  - `name`: Name of the tool.
@@ -499,7 +505,7 @@ class Messages(SyncAPIResource):
499
505
  the top-level `system` parameter — there is no `"system"` role for input
500
506
  messages in the Messages API.
501
507
 
502
- There is a limit of 100000 messages in a single request.
508
+ There is a limit of 100,000 messages in a single request.
503
509
 
504
510
  model: The model that will complete your prompt.\n\nSee
505
511
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -563,6 +569,12 @@ class Messages(SyncAPIResource):
563
569
  those tools using the tool input generated by the model and then optionally
564
570
  return results back to the model using `tool_result` content blocks.
565
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
+
566
578
  Each tool definition includes:
567
579
 
568
580
  - `name`: Name of the tool.
@@ -784,7 +796,7 @@ class Messages(SyncAPIResource):
784
796
  the top-level `system` parameter — there is no `"system"` role for input
785
797
  messages in the Messages API.
786
798
 
787
- There is a limit of 100000 messages in a single request.
799
+ There is a limit of 100,000 messages in a single request.
788
800
 
789
801
  model: The model that will complete your prompt.\n\nSee
790
802
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -848,6 +860,12 @@ class Messages(SyncAPIResource):
848
860
  those tools using the tool input generated by the model and then optionally
849
861
  return results back to the model using `tool_result` content blocks.
850
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
+
851
869
  Each tool definition includes:
852
870
 
853
871
  - `name`: Name of the tool.
@@ -1188,7 +1206,7 @@ class Messages(SyncAPIResource):
1188
1206
  the top-level `system` parameter — there is no `"system"` role for input
1189
1207
  messages in the Messages API.
1190
1208
 
1191
- There is a limit of 100000 messages in a single request.
1209
+ There is a limit of 100,000 messages in a single request.
1192
1210
 
1193
1211
  model: The model that will complete your prompt.\n\nSee
1194
1212
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1220,6 +1238,12 @@ class Messages(SyncAPIResource):
1220
1238
  those tools using the tool input generated by the model and then optionally
1221
1239
  return results back to the model using `tool_result` content blocks.
1222
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
+
1223
1247
  Each tool definition includes:
1224
1248
 
1225
1249
  - `name`: Name of the tool.
@@ -1465,7 +1489,7 @@ class AsyncMessages(AsyncAPIResource):
1465
1489
  the top-level `system` parameter — there is no `"system"` role for input
1466
1490
  messages in the Messages API.
1467
1491
 
1468
- There is a limit of 100000 messages in a single request.
1492
+ There is a limit of 100,000 messages in a single request.
1469
1493
 
1470
1494
  model: The model that will complete your prompt.\n\nSee
1471
1495
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1529,6 +1553,12 @@ class AsyncMessages(AsyncAPIResource):
1529
1553
  those tools using the tool input generated by the model and then optionally
1530
1554
  return results back to the model using `tool_result` content blocks.
1531
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
+
1532
1562
  Each tool definition includes:
1533
1563
 
1534
1564
  - `name`: Name of the tool.
@@ -1750,7 +1780,7 @@ class AsyncMessages(AsyncAPIResource):
1750
1780
  the top-level `system` parameter — there is no `"system"` role for input
1751
1781
  messages in the Messages API.
1752
1782
 
1753
- There is a limit of 100000 messages in a single request.
1783
+ There is a limit of 100,000 messages in a single request.
1754
1784
 
1755
1785
  model: The model that will complete your prompt.\n\nSee
1756
1786
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -1814,6 +1844,12 @@ class AsyncMessages(AsyncAPIResource):
1814
1844
  those tools using the tool input generated by the model and then optionally
1815
1845
  return results back to the model using `tool_result` content blocks.
1816
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
+
1817
1853
  Each tool definition includes:
1818
1854
 
1819
1855
  - `name`: Name of the tool.
@@ -2035,7 +2071,7 @@ class AsyncMessages(AsyncAPIResource):
2035
2071
  the top-level `system` parameter — there is no `"system"` role for input
2036
2072
  messages in the Messages API.
2037
2073
 
2038
- There is a limit of 100000 messages in a single request.
2074
+ There is a limit of 100,000 messages in a single request.
2039
2075
 
2040
2076
  model: The model that will complete your prompt.\n\nSee
2041
2077
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2099,6 +2135,12 @@ class AsyncMessages(AsyncAPIResource):
2099
2135
  those tools using the tool input generated by the model and then optionally
2100
2136
  return results back to the model using `tool_result` content blocks.
2101
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
+
2102
2144
  Each tool definition includes:
2103
2145
 
2104
2146
  - `name`: Name of the tool.
@@ -2438,7 +2480,7 @@ class AsyncMessages(AsyncAPIResource):
2438
2480
  the top-level `system` parameter — there is no `"system"` role for input
2439
2481
  messages in the Messages API.
2440
2482
 
2441
- There is a limit of 100000 messages in a single request.
2483
+ There is a limit of 100,000 messages in a single request.
2442
2484
 
2443
2485
  model: The model that will complete your prompt.\n\nSee
2444
2486
  [models](https://docs.anthropic.com/en/docs/models-overview) for additional
@@ -2470,6 +2512,12 @@ class AsyncMessages(AsyncAPIResource):
2470
2512
  those tools using the tool input generated by the model and then optionally
2471
2513
  return results back to the model using `tool_result` content blocks.
2472
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
+
2473
2521
  Each tool definition includes:
2474
2522
 
2475
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_citation_search_result_location import BetaCitationSearchResultLocation as BetaCitationSearchResultLocation
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
@@ -128,6 +130,9 @@ from .beta_web_search_tool_result_block_content import (
128
130
  from .beta_citation_content_block_location_param import (
129
131
  BetaCitationContentBlockLocationParam as BetaCitationContentBlockLocationParam,
130
132
  )
133
+ from .beta_citation_search_result_location_param import (
134
+ BetaCitationSearchResultLocationParam as BetaCitationSearchResultLocationParam,
135
+ )
131
136
  from .beta_code_execution_tool_result_error_code import (
132
137
  BetaCodeExecutionToolResultErrorCode as BetaCodeExecutionToolResultErrorCode,
133
138
  )
@@ -0,0 +1,24 @@
1
+ # File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ from typing import Optional
4
+ from typing_extensions import Literal
5
+
6
+ from ..._models import BaseModel
7
+
8
+ __all__ = ["BetaCitationSearchResultLocation"]
9
+
10
+
11
+ class BetaCitationSearchResultLocation(BaseModel):
12
+ cited_text: str
13
+
14
+ end_block_index: int
15
+
16
+ search_result_index: int
17
+
18
+ source: str
19
+
20
+ start_block_index: int
21
+
22
+ title: Optional[str] = None
23
+
24
+ type: Literal["search_result_location"]
@@ -0,0 +1,24 @@
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
+ __all__ = ["BetaCitationSearchResultLocationParam"]
9
+
10
+
11
+ class BetaCitationSearchResultLocationParam(TypedDict, total=False):
12
+ cited_text: Required[str]
13
+
14
+ end_block_index: Required[int]
15
+
16
+ search_result_index: Required[int]
17
+
18
+ source: Required[str]
19
+
20
+ start_block_index: Required[int]
21
+
22
+ title: Required[Optional[str]]
23
+
24
+ type: Required[Literal["search_result_location"]]
@@ -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_citation_search_result_location import BetaCitationSearchResultLocation
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
+ BetaCitationSearchResultLocation,
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
  ]
@@ -0,0 +1,27 @@
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 Iterable, Optional
6
+ from typing_extensions import Literal, Required, TypedDict
7
+
8
+ from .beta_text_block_param import BetaTextBlockParam
9
+ from .beta_citations_config_param import BetaCitationsConfigParam
10
+ from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam
11
+
12
+ __all__ = ["BetaSearchResultBlockParam"]
13
+
14
+
15
+ class BetaSearchResultBlockParam(TypedDict, total=False):
16
+ content: Required[Iterable[BetaTextBlockParam]]
17
+
18
+ source: Required[str]
19
+
20
+ title: Required[str]
21
+
22
+ type: Required[Literal["search_result"]]
23
+
24
+ cache_control: Optional[BetaCacheControlEphemeralParam]
25
+ """Create a cache control breakpoint at this content block."""
26
+
27
+ citations: BetaCitationsConfigParam
@@ -7,6 +7,7 @@ from ..._utils import PropertyInfo
7
7
  from .beta_citation_char_location import BetaCitationCharLocation
8
8
  from .beta_citation_page_location import BetaCitationPageLocation
9
9
  from .beta_citation_content_block_location import BetaCitationContentBlockLocation
10
+ from .beta_citation_search_result_location import BetaCitationSearchResultLocation
10
11
  from .beta_citations_web_search_result_location import BetaCitationsWebSearchResultLocation
11
12
 
12
13
  __all__ = ["BetaTextCitation"]
@@ -17,6 +18,7 @@ BetaTextCitation: TypeAlias = Annotated[
17
18
  BetaCitationPageLocation,
18
19
  BetaCitationContentBlockLocation,
19
20
  BetaCitationsWebSearchResultLocation,
21
+ BetaCitationSearchResultLocation,
20
22
  ],
21
23
  PropertyInfo(discriminator="type"),
22
24
  ]
@@ -8,6 +8,7 @@ from typing_extensions import TypeAlias
8
8
  from .beta_citation_char_location_param import BetaCitationCharLocationParam
9
9
  from .beta_citation_page_location_param import BetaCitationPageLocationParam
10
10
  from .beta_citation_content_block_location_param import BetaCitationContentBlockLocationParam
11
+ from .beta_citation_search_result_location_param import BetaCitationSearchResultLocationParam
11
12
  from .beta_citation_web_search_result_location_param import BetaCitationWebSearchResultLocationParam
12
13
 
13
14
  __all__ = ["BetaTextCitationParam"]
@@ -17,4 +18,5 @@ BetaTextCitationParam: TypeAlias = Union[
17
18
  BetaCitationPageLocationParam,
18
19
  BetaCitationContentBlockLocationParam,
19
20
  BetaCitationWebSearchResultLocationParam,
21
+ BetaCitationSearchResultLocationParam,
20
22
  ]