anthropic 0.77.1__py3-none-any.whl → 0.78.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- anthropic/_version.py +1 -1
- anthropic/lib/streaming/_beta_messages.py +15 -0
- anthropic/lib/streaming/_beta_types.py +8 -0
- anthropic/resources/beta/messages/messages.py +110 -1
- anthropic/resources/messages/messages.py +76 -0
- anthropic/types/__init__.py +1 -0
- anthropic/types/beta/__init__.py +8 -0
- anthropic/types/beta/beta_compact_20260112_edit_param.py +27 -0
- anthropic/types/beta/beta_compaction_block.py +22 -0
- anthropic/types/beta/beta_compaction_block_param.py +29 -0
- anthropic/types/beta/beta_compaction_content_block_delta.py +14 -0
- anthropic/types/beta/beta_compaction_iteration_usage.py +31 -0
- anthropic/types/beta/beta_content_block.py +2 -0
- anthropic/types/beta/beta_content_block_param.py +2 -0
- anthropic/types/beta/beta_context_management_config_param.py +4 -1
- anthropic/types/beta/beta_iterations_usage.py +13 -0
- anthropic/types/beta/beta_message_delta_usage.py +12 -0
- anthropic/types/beta/beta_message_iteration_usage.py +31 -0
- anthropic/types/beta/beta_output_config_param.py +2 -7
- anthropic/types/beta/beta_raw_content_block_delta.py +9 -1
- anthropic/types/beta/beta_raw_content_block_start_event.py +2 -0
- anthropic/types/beta/beta_stop_reason.py +8 -1
- anthropic/types/beta/beta_thinking_config_adaptive_param.py +11 -0
- anthropic/types/beta/beta_thinking_config_param.py +4 -1
- anthropic/types/beta/beta_tool_param.py +10 -0
- anthropic/types/beta/beta_usage.py +15 -0
- anthropic/types/beta/message_create_params.py +6 -0
- anthropic/types/beta/messages/batch_create_params.py +1 -0
- anthropic/types/beta/parsed_beta_message.py +2 -0
- anthropic/types/message_create_params.py +7 -1
- anthropic/types/messages/batch_create_params.py +1 -0
- anthropic/types/model.py +1 -0
- anthropic/types/model_param.py +1 -0
- anthropic/types/output_config_param.py +4 -1
- anthropic/types/thinking_config_adaptive_param.py +11 -0
- anthropic/types/thinking_config_param.py +4 -1
- anthropic/types/tool_param.py +10 -0
- anthropic/types/usage.py +3 -0
- {anthropic-0.77.1.dist-info → anthropic-0.78.0.dist-info}/METADATA +2 -2
- {anthropic-0.77.1.dist-info → anthropic-0.78.0.dist-info}/RECORD +42 -33
- {anthropic-0.77.1.dist-info → anthropic-0.78.0.dist-info}/WHEEL +0 -0
- {anthropic-0.77.1.dist-info → anthropic-0.78.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -71,6 +71,8 @@ DEPRECATED_MODELS = {
|
|
|
71
71
|
"claude-3-5-haiku-20241022": "February 19th, 2026",
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
MODELS_TO_WARN_WITH_THINKING_ENABLED = ["claude-opus-4-6"]
|
|
75
|
+
|
|
74
76
|
|
|
75
77
|
class Messages(SyncAPIResource):
|
|
76
78
|
@cached_property
|
|
@@ -103,6 +105,7 @@ class Messages(SyncAPIResource):
|
|
|
103
105
|
max_tokens: int,
|
|
104
106
|
messages: Iterable[MessageParam],
|
|
105
107
|
model: ModelParam,
|
|
108
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
106
109
|
metadata: MetadataParam | Omit = omit,
|
|
107
110
|
output_config: OutputConfigParam | Omit = omit,
|
|
108
111
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -211,6 +214,9 @@ class Messages(SyncAPIResource):
|
|
|
211
214
|
[models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
212
215
|
details and options.
|
|
213
216
|
|
|
217
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
218
|
+
workspace's `default_inference_geo` is used.
|
|
219
|
+
|
|
214
220
|
metadata: An object describing metadata about the request.
|
|
215
221
|
|
|
216
222
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -375,6 +381,7 @@ class Messages(SyncAPIResource):
|
|
|
375
381
|
messages: Iterable[MessageParam],
|
|
376
382
|
model: ModelParam,
|
|
377
383
|
stream: Literal[True],
|
|
384
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
378
385
|
metadata: MetadataParam | Omit = omit,
|
|
379
386
|
output_config: OutputConfigParam | Omit = omit,
|
|
380
387
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -486,6 +493,9 @@ class Messages(SyncAPIResource):
|
|
|
486
493
|
|
|
487
494
|
See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
|
|
488
495
|
|
|
496
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
497
|
+
workspace's `default_inference_geo` is used.
|
|
498
|
+
|
|
489
499
|
metadata: An object describing metadata about the request.
|
|
490
500
|
|
|
491
501
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -646,6 +656,7 @@ class Messages(SyncAPIResource):
|
|
|
646
656
|
messages: Iterable[MessageParam],
|
|
647
657
|
model: ModelParam,
|
|
648
658
|
stream: bool,
|
|
659
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
649
660
|
metadata: MetadataParam | Omit = omit,
|
|
650
661
|
output_config: OutputConfigParam | Omit = omit,
|
|
651
662
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -757,6 +768,9 @@ class Messages(SyncAPIResource):
|
|
|
757
768
|
|
|
758
769
|
See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
|
|
759
770
|
|
|
771
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
772
|
+
workspace's `default_inference_geo` is used.
|
|
773
|
+
|
|
760
774
|
metadata: An object describing metadata about the request.
|
|
761
775
|
|
|
762
776
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -916,6 +930,7 @@ class Messages(SyncAPIResource):
|
|
|
916
930
|
max_tokens: int,
|
|
917
931
|
messages: Iterable[MessageParam],
|
|
918
932
|
model: ModelParam,
|
|
933
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
919
934
|
metadata: MetadataParam | Omit = omit,
|
|
920
935
|
output_config: OutputConfigParam | Omit = omit,
|
|
921
936
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -947,6 +962,13 @@ class Messages(SyncAPIResource):
|
|
|
947
962
|
stacklevel=3,
|
|
948
963
|
)
|
|
949
964
|
|
|
965
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
966
|
+
warnings.warn(
|
|
967
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
968
|
+
UserWarning,
|
|
969
|
+
stacklevel=3,
|
|
970
|
+
)
|
|
971
|
+
|
|
950
972
|
return self._post(
|
|
951
973
|
"/v1/messages",
|
|
952
974
|
body=maybe_transform(
|
|
@@ -954,6 +976,7 @@ class Messages(SyncAPIResource):
|
|
|
954
976
|
"max_tokens": max_tokens,
|
|
955
977
|
"messages": messages,
|
|
956
978
|
"model": model,
|
|
979
|
+
"inference_geo": inference_geo,
|
|
957
980
|
"metadata": metadata,
|
|
958
981
|
"output_config": output_config,
|
|
959
982
|
"service_tier": service_tier,
|
|
@@ -985,6 +1008,7 @@ class Messages(SyncAPIResource):
|
|
|
985
1008
|
max_tokens: int,
|
|
986
1009
|
messages: Iterable[MessageParam],
|
|
987
1010
|
model: ModelParam,
|
|
1011
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
988
1012
|
metadata: MetadataParam | Omit = omit,
|
|
989
1013
|
output_config: OutputConfigParam | Omit = omit,
|
|
990
1014
|
output_format: None | JSONOutputFormatParam | type[ResponseFormatT] | Omit = omit,
|
|
@@ -1013,6 +1037,13 @@ class Messages(SyncAPIResource):
|
|
|
1013
1037
|
stacklevel=3,
|
|
1014
1038
|
)
|
|
1015
1039
|
|
|
1040
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1041
|
+
warnings.warn(
|
|
1042
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
1043
|
+
UserWarning,
|
|
1044
|
+
stacklevel=3,
|
|
1045
|
+
)
|
|
1046
|
+
|
|
1016
1047
|
extra_headers = {
|
|
1017
1048
|
"X-Stainless-Helper-Method": "stream",
|
|
1018
1049
|
"X-Stainless-Stream-Helper": "messages",
|
|
@@ -1055,6 +1086,7 @@ class Messages(SyncAPIResource):
|
|
|
1055
1086
|
"max_tokens": max_tokens,
|
|
1056
1087
|
"messages": messages,
|
|
1057
1088
|
"model": model,
|
|
1089
|
+
"inference_geo": inference_geo,
|
|
1058
1090
|
"metadata": metadata,
|
|
1059
1091
|
"output_config": merged_output_config,
|
|
1060
1092
|
"container": container,
|
|
@@ -1121,6 +1153,13 @@ class Messages(SyncAPIResource):
|
|
|
1121
1153
|
stacklevel=3,
|
|
1122
1154
|
)
|
|
1123
1155
|
|
|
1156
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1157
|
+
warnings.warn(
|
|
1158
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
1159
|
+
UserWarning,
|
|
1160
|
+
stacklevel=3,
|
|
1161
|
+
)
|
|
1162
|
+
|
|
1124
1163
|
extra_headers = {
|
|
1125
1164
|
"X-Stainless-Helper": "messages.parse",
|
|
1126
1165
|
**(extra_headers or {}),
|
|
@@ -1484,6 +1523,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1484
1523
|
max_tokens: int,
|
|
1485
1524
|
messages: Iterable[MessageParam],
|
|
1486
1525
|
model: ModelParam,
|
|
1526
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1487
1527
|
metadata: MetadataParam | Omit = omit,
|
|
1488
1528
|
output_config: OutputConfigParam | Omit = omit,
|
|
1489
1529
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -1592,6 +1632,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1592
1632
|
[models](https://docs.anthropic.com/en/docs/models-overview) for additional
|
|
1593
1633
|
details and options.
|
|
1594
1634
|
|
|
1635
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
1636
|
+
workspace's `default_inference_geo` is used.
|
|
1637
|
+
|
|
1595
1638
|
metadata: An object describing metadata about the request.
|
|
1596
1639
|
|
|
1597
1640
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -1756,6 +1799,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1756
1799
|
messages: Iterable[MessageParam],
|
|
1757
1800
|
model: ModelParam,
|
|
1758
1801
|
stream: Literal[True],
|
|
1802
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1759
1803
|
metadata: MetadataParam | Omit = omit,
|
|
1760
1804
|
output_config: OutputConfigParam | Omit = omit,
|
|
1761
1805
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -1867,6 +1911,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1867
1911
|
|
|
1868
1912
|
See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
|
|
1869
1913
|
|
|
1914
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
1915
|
+
workspace's `default_inference_geo` is used.
|
|
1916
|
+
|
|
1870
1917
|
metadata: An object describing metadata about the request.
|
|
1871
1918
|
|
|
1872
1919
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -2027,6 +2074,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2027
2074
|
messages: Iterable[MessageParam],
|
|
2028
2075
|
model: ModelParam,
|
|
2029
2076
|
stream: bool,
|
|
2077
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2030
2078
|
metadata: MetadataParam | Omit = omit,
|
|
2031
2079
|
output_config: OutputConfigParam | Omit = omit,
|
|
2032
2080
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -2138,6 +2186,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2138
2186
|
|
|
2139
2187
|
See [streaming](https://docs.claude.com/en/api/messages-streaming) for details.
|
|
2140
2188
|
|
|
2189
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
2190
|
+
workspace's `default_inference_geo` is used.
|
|
2191
|
+
|
|
2141
2192
|
metadata: An object describing metadata about the request.
|
|
2142
2193
|
|
|
2143
2194
|
output_config: Configuration options for the model's output, such as the output format.
|
|
@@ -2297,6 +2348,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2297
2348
|
max_tokens: int,
|
|
2298
2349
|
messages: Iterable[MessageParam],
|
|
2299
2350
|
model: ModelParam,
|
|
2351
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2300
2352
|
metadata: MetadataParam | Omit = omit,
|
|
2301
2353
|
output_config: OutputConfigParam | Omit = omit,
|
|
2302
2354
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
@@ -2328,6 +2380,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2328
2380
|
stacklevel=3,
|
|
2329
2381
|
)
|
|
2330
2382
|
|
|
2383
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
2384
|
+
warnings.warn(
|
|
2385
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
2386
|
+
UserWarning,
|
|
2387
|
+
stacklevel=3,
|
|
2388
|
+
)
|
|
2389
|
+
|
|
2331
2390
|
return await self._post(
|
|
2332
2391
|
"/v1/messages",
|
|
2333
2392
|
body=await async_maybe_transform(
|
|
@@ -2335,6 +2394,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2335
2394
|
"max_tokens": max_tokens,
|
|
2336
2395
|
"messages": messages,
|
|
2337
2396
|
"model": model,
|
|
2397
|
+
"inference_geo": inference_geo,
|
|
2338
2398
|
"metadata": metadata,
|
|
2339
2399
|
"output_config": output_config,
|
|
2340
2400
|
"service_tier": service_tier,
|
|
@@ -2366,6 +2426,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2366
2426
|
max_tokens: int,
|
|
2367
2427
|
messages: Iterable[MessageParam],
|
|
2368
2428
|
model: ModelParam,
|
|
2429
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2369
2430
|
metadata: MetadataParam | Omit = omit,
|
|
2370
2431
|
output_config: OutputConfigParam | Omit = omit,
|
|
2371
2432
|
output_format: None | JSONOutputFormatParam | type[ResponseFormatT] | Omit = omit,
|
|
@@ -2394,6 +2455,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2394
2455
|
stacklevel=3,
|
|
2395
2456
|
)
|
|
2396
2457
|
|
|
2458
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
2459
|
+
warnings.warn(
|
|
2460
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
2461
|
+
UserWarning,
|
|
2462
|
+
stacklevel=3,
|
|
2463
|
+
)
|
|
2464
|
+
|
|
2397
2465
|
extra_headers = {
|
|
2398
2466
|
"X-Stainless-Helper-Method": "stream",
|
|
2399
2467
|
"X-Stainless-Stream-Helper": "messages",
|
|
@@ -2435,6 +2503,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2435
2503
|
"max_tokens": max_tokens,
|
|
2436
2504
|
"messages": messages,
|
|
2437
2505
|
"model": model,
|
|
2506
|
+
"inference_geo": inference_geo,
|
|
2438
2507
|
"metadata": metadata,
|
|
2439
2508
|
"output_config": merged_output_config,
|
|
2440
2509
|
"container": container,
|
|
@@ -2501,6 +2570,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2501
2570
|
stacklevel=3,
|
|
2502
2571
|
)
|
|
2503
2572
|
|
|
2573
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
2574
|
+
warnings.warn(
|
|
2575
|
+
f"Using Claude with {model} and 'thinking.type=enabled' is deprecated. Use 'thinking.type=adaptive' instead which results in better model performance in our testing: https://platform.claude.com/docs/en/build-with-claude/adaptive-thinking",
|
|
2576
|
+
UserWarning,
|
|
2577
|
+
stacklevel=3,
|
|
2578
|
+
)
|
|
2579
|
+
|
|
2504
2580
|
extra_headers = {
|
|
2505
2581
|
"X-Stainless-Helper": "messages.parse",
|
|
2506
2582
|
**(extra_headers or {}),
|
anthropic/types/__init__.py
CHANGED
|
@@ -115,6 +115,7 @@ from .raw_content_block_start_event import RawContentBlockStartEvent as RawConte
|
|
|
115
115
|
from .redacted_thinking_block_param import RedactedThinkingBlockParam as RedactedThinkingBlockParam
|
|
116
116
|
from .thinking_config_enabled_param import ThinkingConfigEnabledParam as ThinkingConfigEnabledParam
|
|
117
117
|
from .web_search_result_block_param import WebSearchResultBlockParam as WebSearchResultBlockParam
|
|
118
|
+
from .thinking_config_adaptive_param import ThinkingConfigAdaptiveParam as ThinkingConfigAdaptiveParam
|
|
118
119
|
from .thinking_config_disabled_param import ThinkingConfigDisabledParam as ThinkingConfigDisabledParam
|
|
119
120
|
from .web_search_tool_20250305_param import WebSearchTool20250305Param as WebSearchTool20250305Param
|
|
120
121
|
from .citation_content_block_location import CitationContentBlockLocation as CitationContentBlockLocation
|
anthropic/types/beta/__init__.py
CHANGED
|
@@ -34,8 +34,10 @@ from .beta_citation_config import BetaCitationConfig as BetaCitationConfig
|
|
|
34
34
|
from .beta_citations_delta import BetaCitationsDelta as BetaCitationsDelta
|
|
35
35
|
from .beta_signature_delta import BetaSignatureDelta as BetaSignatureDelta
|
|
36
36
|
from .beta_web_fetch_block import BetaWebFetchBlock as BetaWebFetchBlock
|
|
37
|
+
from .beta_compaction_block import BetaCompactionBlock as BetaCompactionBlock
|
|
37
38
|
from .beta_container_params import BetaContainerParams as BetaContainerParams
|
|
38
39
|
from .beta_input_json_delta import BetaInputJSONDelta as BetaInputJSONDelta
|
|
40
|
+
from .beta_iterations_usage import BetaIterationsUsage as BetaIterationsUsage
|
|
39
41
|
from .beta_text_block_param import BetaTextBlockParam as BetaTextBlockParam
|
|
40
42
|
from .beta_tool_union_param import BetaToolUnionParam as BetaToolUnionParam
|
|
41
43
|
from .message_create_params import MessageCreateParams as MessageCreateParams
|
|
@@ -72,6 +74,7 @@ from .beta_base64_pdf_block_param import BetaBase64PDFBlockParam as BetaBase64PD
|
|
|
72
74
|
from .beta_citation_char_location import BetaCitationCharLocation as BetaCitationCharLocation
|
|
73
75
|
from .beta_citation_page_location import BetaCitationPageLocation as BetaCitationPageLocation
|
|
74
76
|
from .beta_citations_config_param import BetaCitationsConfigParam as BetaCitationsConfigParam
|
|
77
|
+
from .beta_compaction_block_param import BetaCompactionBlockParam as BetaCompactionBlockParam
|
|
75
78
|
from .beta_container_upload_block import BetaContainerUploadBlock as BetaContainerUploadBlock
|
|
76
79
|
from .beta_raw_message_stop_event import BetaRawMessageStopEvent as BetaRawMessageStopEvent
|
|
77
80
|
from .beta_tool_choice_auto_param import BetaToolChoiceAutoParam as BetaToolChoiceAutoParam
|
|
@@ -81,6 +84,7 @@ from .beta_url_image_source_param import BetaURLImageSourceParam as BetaURLImage
|
|
|
81
84
|
from .message_count_tokens_params import MessageCountTokensParams as MessageCountTokensParams
|
|
82
85
|
from .beta_base64_pdf_source_param import BetaBase64PDFSourceParam as BetaBase64PDFSourceParam
|
|
83
86
|
from .beta_file_image_source_param import BetaFileImageSourceParam as BetaFileImageSourceParam
|
|
87
|
+
from .beta_message_iteration_usage import BetaMessageIterationUsage as BetaMessageIterationUsage
|
|
84
88
|
from .beta_plain_text_source_param import BetaPlainTextSourceParam as BetaPlainTextSourceParam
|
|
85
89
|
from .beta_raw_content_block_delta import BetaRawContentBlockDelta as BetaRawContentBlockDelta
|
|
86
90
|
from .beta_raw_message_delta_event import BetaRawMessageDeltaEvent as BetaRawMessageDeltaEvent
|
|
@@ -98,6 +102,7 @@ from .beta_tool_bash_20241022_param import BetaToolBash20241022Param as BetaTool
|
|
|
98
102
|
from .beta_tool_bash_20250124_param import BetaToolBash20250124Param as BetaToolBash20250124Param
|
|
99
103
|
from .beta_base64_image_source_param import BetaBase64ImageSourceParam as BetaBase64ImageSourceParam
|
|
100
104
|
from .beta_search_result_block_param import BetaSearchResultBlockParam as BetaSearchResultBlockParam
|
|
105
|
+
from .beta_compaction_iteration_usage import BetaCompactionIterationUsage as BetaCompactionIterationUsage
|
|
101
106
|
from .beta_content_block_source_param import BetaContentBlockSourceParam as BetaContentBlockSourceParam
|
|
102
107
|
from .beta_file_document_source_param import BetaFileDocumentSourceParam as BetaFileDocumentSourceParam
|
|
103
108
|
from .beta_input_tokens_trigger_param import BetaInputTokensTriggerParam as BetaInputTokensTriggerParam
|
|
@@ -105,6 +110,7 @@ from .beta_memory_tool_20250818_param import BetaMemoryTool20250818Param as Beta
|
|
|
105
110
|
from .beta_tool_reference_block_param import BetaToolReferenceBlockParam as BetaToolReferenceBlockParam
|
|
106
111
|
from .beta_code_execution_output_block import BetaCodeExecutionOutputBlock as BetaCodeExecutionOutputBlock
|
|
107
112
|
from .beta_code_execution_result_block import BetaCodeExecutionResultBlock as BetaCodeExecutionResultBlock
|
|
113
|
+
from .beta_compact_20260112_edit_param import BetaCompact20260112EditParam as BetaCompact20260112EditParam
|
|
108
114
|
from .beta_context_management_response import BetaContextManagementResponse as BetaContextManagementResponse
|
|
109
115
|
from .beta_server_tool_use_block_param import BetaServerToolUseBlockParam as BetaServerToolUseBlockParam
|
|
110
116
|
from .beta_web_fetch_tool_result_block import BetaWebFetchToolResultBlock as BetaWebFetchToolResultBlock
|
|
@@ -126,6 +132,8 @@ from .beta_tool_search_tool_result_block import BetaToolSearchToolResultBlock as
|
|
|
126
132
|
from .beta_tool_search_tool_result_error import BetaToolSearchToolResultError as BetaToolSearchToolResultError
|
|
127
133
|
from .beta_web_fetch_tool_20250910_param import BetaWebFetchTool20250910Param as BetaWebFetchTool20250910Param
|
|
128
134
|
from .beta_web_search_result_block_param import BetaWebSearchResultBlockParam as BetaWebSearchResultBlockParam
|
|
135
|
+
from .beta_compaction_content_block_delta import BetaCompactionContentBlockDelta as BetaCompactionContentBlockDelta
|
|
136
|
+
from .beta_thinking_config_adaptive_param import BetaThinkingConfigAdaptiveParam as BetaThinkingConfigAdaptiveParam
|
|
129
137
|
from .beta_thinking_config_disabled_param import BetaThinkingConfigDisabledParam as BetaThinkingConfigDisabledParam
|
|
130
138
|
from .beta_web_search_tool_20250305_param import BetaWebSearchTool20250305Param as BetaWebSearchTool20250305Param
|
|
131
139
|
from .beta_citation_content_block_location import BetaCitationContentBlockLocation as BetaCitationContentBlockLocation
|
|
@@ -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 Optional
|
|
6
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .beta_input_tokens_trigger_param import BetaInputTokensTriggerParam
|
|
9
|
+
|
|
10
|
+
__all__ = ["BetaCompact20260112EditParam"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BetaCompact20260112EditParam(TypedDict, total=False):
|
|
14
|
+
"""
|
|
15
|
+
Automatically compact older context when reaching the configured trigger threshold.
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
type: Required[Literal["compact_20260112"]]
|
|
19
|
+
|
|
20
|
+
instructions: Optional[str]
|
|
21
|
+
"""Additional instructions for summarization."""
|
|
22
|
+
|
|
23
|
+
pause_after_compaction: bool
|
|
24
|
+
"""Whether to pause after compaction and return the compaction block to the user."""
|
|
25
|
+
|
|
26
|
+
trigger: Optional[BetaInputTokensTriggerParam]
|
|
27
|
+
"""When to trigger compaction. Defaults to 150000 input tokens."""
|
|
@@ -0,0 +1,22 @@
|
|
|
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__ = ["BetaCompactionBlock"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BetaCompactionBlock(BaseModel):
|
|
12
|
+
"""A compaction block returned when autocompact is triggered.
|
|
13
|
+
|
|
14
|
+
When content is None, it indicates the compaction failed to produce a valid
|
|
15
|
+
summary (e.g., malformed output from the model). Clients may round-trip
|
|
16
|
+
compaction blocks with null content; the server treats them as no-ops.
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
content: Optional[str] = None
|
|
20
|
+
"""Summary of compacted content, or null if compaction failed"""
|
|
21
|
+
|
|
22
|
+
type: Literal["compaction"]
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
7
|
+
|
|
8
|
+
from .beta_cache_control_ephemeral_param import BetaCacheControlEphemeralParam
|
|
9
|
+
|
|
10
|
+
__all__ = ["BetaCompactionBlockParam"]
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class BetaCompactionBlockParam(TypedDict, total=False):
|
|
14
|
+
"""A compaction block containing summary of previous context.
|
|
15
|
+
|
|
16
|
+
Users should round-trip these blocks from responses to subsequent requests
|
|
17
|
+
to maintain context across compaction boundaries.
|
|
18
|
+
|
|
19
|
+
When content is None, the block represents a failed compaction. The server
|
|
20
|
+
treats these as no-ops. Empty string content is not allowed.
|
|
21
|
+
"""
|
|
22
|
+
|
|
23
|
+
content: Required[Optional[str]]
|
|
24
|
+
"""Summary of previously compacted content, or null if compaction failed"""
|
|
25
|
+
|
|
26
|
+
type: Required[Literal["compaction"]]
|
|
27
|
+
|
|
28
|
+
cache_control: Optional[BetaCacheControlEphemeralParam]
|
|
29
|
+
"""Create a cache control breakpoint at this content block."""
|
|
@@ -0,0 +1,14 @@
|
|
|
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__ = ["BetaCompactionContentBlockDelta"]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class BetaCompactionContentBlockDelta(BaseModel):
|
|
12
|
+
content: Optional[str] = None
|
|
13
|
+
|
|
14
|
+
type: Literal["compaction_delta"]
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
from .beta_cache_creation import BetaCacheCreation
|
|
8
|
+
|
|
9
|
+
__all__ = ["BetaCompactionIterationUsage"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BetaCompactionIterationUsage(BaseModel):
|
|
13
|
+
"""Token usage for a compaction iteration."""
|
|
14
|
+
|
|
15
|
+
cache_creation: Optional[BetaCacheCreation] = None
|
|
16
|
+
"""Breakdown of cached tokens by TTL"""
|
|
17
|
+
|
|
18
|
+
cache_creation_input_tokens: int
|
|
19
|
+
"""The number of input tokens used to create the cache entry."""
|
|
20
|
+
|
|
21
|
+
cache_read_input_tokens: int
|
|
22
|
+
"""The number of input tokens read from the cache."""
|
|
23
|
+
|
|
24
|
+
input_tokens: int
|
|
25
|
+
"""The number of input tokens which were used."""
|
|
26
|
+
|
|
27
|
+
output_tokens: int
|
|
28
|
+
"""The number of output tokens which were used."""
|
|
29
|
+
|
|
30
|
+
type: Literal["compaction"]
|
|
31
|
+
"""Usage for a compaction iteration"""
|
|
@@ -7,6 +7,7 @@ from ..._utils import PropertyInfo
|
|
|
7
7
|
from .beta_text_block import BetaTextBlock
|
|
8
8
|
from .beta_thinking_block import BetaThinkingBlock
|
|
9
9
|
from .beta_tool_use_block import BetaToolUseBlock
|
|
10
|
+
from .beta_compaction_block import BetaCompactionBlock
|
|
10
11
|
from .beta_mcp_tool_use_block import BetaMCPToolUseBlock
|
|
11
12
|
from .beta_mcp_tool_result_block import BetaMCPToolResultBlock
|
|
12
13
|
from .beta_server_tool_use_block import BetaServerToolUseBlock
|
|
@@ -37,6 +38,7 @@ BetaContentBlock: TypeAlias = Annotated[
|
|
|
37
38
|
BetaMCPToolUseBlock,
|
|
38
39
|
BetaMCPToolResultBlock,
|
|
39
40
|
BetaContainerUploadBlock,
|
|
41
|
+
BetaCompactionBlock,
|
|
40
42
|
],
|
|
41
43
|
PropertyInfo(discriminator="type"),
|
|
42
44
|
]
|
|
@@ -10,6 +10,7 @@ from .beta_text_block_param import BetaTextBlockParam
|
|
|
10
10
|
from .beta_image_block_param import BetaImageBlockParam
|
|
11
11
|
from .beta_thinking_block_param import BetaThinkingBlockParam
|
|
12
12
|
from .beta_tool_use_block_param import BetaToolUseBlockParam
|
|
13
|
+
from .beta_compaction_block_param import BetaCompactionBlockParam
|
|
13
14
|
from .beta_tool_result_block_param import BetaToolResultBlockParam
|
|
14
15
|
from .beta_mcp_tool_use_block_param import BetaMCPToolUseBlockParam
|
|
15
16
|
from .beta_search_result_block_param import BetaSearchResultBlockParam
|
|
@@ -46,5 +47,6 @@ BetaContentBlockParam: TypeAlias = Union[
|
|
|
46
47
|
BetaMCPToolUseBlockParam,
|
|
47
48
|
BetaRequestMCPToolResultBlockParam,
|
|
48
49
|
BetaContainerUploadBlockParam,
|
|
50
|
+
BetaCompactionBlockParam,
|
|
49
51
|
BetaContentBlock,
|
|
50
52
|
]
|
|
@@ -5,12 +5,15 @@ from __future__ import annotations
|
|
|
5
5
|
from typing import Union, Iterable
|
|
6
6
|
from typing_extensions import TypeAlias, TypedDict
|
|
7
7
|
|
|
8
|
+
from .beta_compact_20260112_edit_param import BetaCompact20260112EditParam
|
|
8
9
|
from .beta_clear_thinking_20251015_edit_param import BetaClearThinking20251015EditParam
|
|
9
10
|
from .beta_clear_tool_uses_20250919_edit_param import BetaClearToolUses20250919EditParam
|
|
10
11
|
|
|
11
12
|
__all__ = ["BetaContextManagementConfigParam", "Edit"]
|
|
12
13
|
|
|
13
|
-
Edit: TypeAlias = Union[
|
|
14
|
+
Edit: TypeAlias = Union[
|
|
15
|
+
BetaClearToolUses20250919EditParam, BetaClearThinking20251015EditParam, BetaCompact20260112EditParam
|
|
16
|
+
]
|
|
14
17
|
|
|
15
18
|
|
|
16
19
|
class BetaContextManagementConfigParam(TypedDict, total=False):
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from typing import List, Union
|
|
4
|
+
from typing_extensions import TypeAlias
|
|
5
|
+
|
|
6
|
+
from .beta_message_iteration_usage import BetaMessageIterationUsage
|
|
7
|
+
from .beta_compaction_iteration_usage import BetaCompactionIterationUsage
|
|
8
|
+
|
|
9
|
+
__all__ = ["BetaIterationsUsage", "BetaIterationsUsageItem"]
|
|
10
|
+
|
|
11
|
+
BetaIterationsUsageItem: TypeAlias = Union[BetaMessageIterationUsage, BetaCompactionIterationUsage]
|
|
12
|
+
|
|
13
|
+
BetaIterationsUsage: TypeAlias = List[BetaIterationsUsageItem]
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
from typing import Optional
|
|
4
4
|
|
|
5
5
|
from ..._models import BaseModel
|
|
6
|
+
from .beta_iterations_usage import BetaIterationsUsage
|
|
6
7
|
from .beta_server_tool_usage import BetaServerToolUsage
|
|
7
8
|
|
|
8
9
|
__all__ = ["BetaMessageDeltaUsage"]
|
|
@@ -18,6 +19,17 @@ class BetaMessageDeltaUsage(BaseModel):
|
|
|
18
19
|
input_tokens: Optional[int] = None
|
|
19
20
|
"""The cumulative number of input tokens which were used."""
|
|
20
21
|
|
|
22
|
+
iterations: Optional[BetaIterationsUsage] = None
|
|
23
|
+
"""Per-iteration token usage breakdown.
|
|
24
|
+
|
|
25
|
+
Each entry represents one sampling iteration, with its own input/output token
|
|
26
|
+
counts and cache statistics. This allows you to:
|
|
27
|
+
|
|
28
|
+
- Determine which iterations exceeded long context thresholds (>=200k tokens)
|
|
29
|
+
- Calculate the true context window size from the last iteration
|
|
30
|
+
- Understand token accumulation across server-side tool use loops
|
|
31
|
+
"""
|
|
32
|
+
|
|
21
33
|
output_tokens: int
|
|
22
34
|
"""The cumulative number of output tokens which were used."""
|
|
23
35
|
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
from .beta_cache_creation import BetaCacheCreation
|
|
8
|
+
|
|
9
|
+
__all__ = ["BetaMessageIterationUsage"]
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class BetaMessageIterationUsage(BaseModel):
|
|
13
|
+
"""Token usage for a sampling iteration."""
|
|
14
|
+
|
|
15
|
+
cache_creation: Optional[BetaCacheCreation] = None
|
|
16
|
+
"""Breakdown of cached tokens by TTL"""
|
|
17
|
+
|
|
18
|
+
cache_creation_input_tokens: int
|
|
19
|
+
"""The number of input tokens used to create the cache entry."""
|
|
20
|
+
|
|
21
|
+
cache_read_input_tokens: int
|
|
22
|
+
"""The number of input tokens read from the cache."""
|
|
23
|
+
|
|
24
|
+
input_tokens: int
|
|
25
|
+
"""The number of input tokens which were used."""
|
|
26
|
+
|
|
27
|
+
output_tokens: int
|
|
28
|
+
"""The number of output tokens which were used."""
|
|
29
|
+
|
|
30
|
+
type: Literal["message"]
|
|
31
|
+
"""Usage for a sampling iteration"""
|
|
@@ -11,13 +11,8 @@ __all__ = ["BetaOutputConfigParam"]
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
class BetaOutputConfigParam(TypedDict, total=False):
|
|
14
|
-
effort: Optional[Literal["low", "medium", "high"]]
|
|
15
|
-
"""
|
|
16
|
-
|
|
17
|
-
Higher effort levels may result in more thorough analysis but take longer.
|
|
18
|
-
|
|
19
|
-
Valid values are `low`, `medium`, or `high`.
|
|
20
|
-
"""
|
|
14
|
+
effort: Optional[Literal["low", "medium", "high", "max"]]
|
|
15
|
+
"""All possible effort levels."""
|
|
21
16
|
|
|
22
17
|
format: Optional[BetaJSONOutputFormatParam]
|
|
23
18
|
"""A schema to specify Claude's output format in responses.
|
|
@@ -9,10 +9,18 @@ from .beta_thinking_delta import BetaThinkingDelta
|
|
|
9
9
|
from .beta_citations_delta import BetaCitationsDelta
|
|
10
10
|
from .beta_signature_delta import BetaSignatureDelta
|
|
11
11
|
from .beta_input_json_delta import BetaInputJSONDelta
|
|
12
|
+
from .beta_compaction_content_block_delta import BetaCompactionContentBlockDelta
|
|
12
13
|
|
|
13
14
|
__all__ = ["BetaRawContentBlockDelta"]
|
|
14
15
|
|
|
15
16
|
BetaRawContentBlockDelta: TypeAlias = Annotated[
|
|
16
|
-
Union[
|
|
17
|
+
Union[
|
|
18
|
+
BetaTextDelta,
|
|
19
|
+
BetaInputJSONDelta,
|
|
20
|
+
BetaCitationsDelta,
|
|
21
|
+
BetaThinkingDelta,
|
|
22
|
+
BetaSignatureDelta,
|
|
23
|
+
BetaCompactionContentBlockDelta,
|
|
24
|
+
],
|
|
17
25
|
PropertyInfo(discriminator="type"),
|
|
18
26
|
]
|
|
@@ -8,6 +8,7 @@ from ..._models import BaseModel
|
|
|
8
8
|
from .beta_text_block import BetaTextBlock
|
|
9
9
|
from .beta_thinking_block import BetaThinkingBlock
|
|
10
10
|
from .beta_tool_use_block import BetaToolUseBlock
|
|
11
|
+
from .beta_compaction_block import BetaCompactionBlock
|
|
11
12
|
from .beta_mcp_tool_use_block import BetaMCPToolUseBlock
|
|
12
13
|
from .beta_mcp_tool_result_block import BetaMCPToolResultBlock
|
|
13
14
|
from .beta_server_tool_use_block import BetaServerToolUseBlock
|
|
@@ -38,6 +39,7 @@ ContentBlock: TypeAlias = Annotated[
|
|
|
38
39
|
BetaMCPToolUseBlock,
|
|
39
40
|
BetaMCPToolResultBlock,
|
|
40
41
|
BetaContainerUploadBlock,
|
|
42
|
+
BetaCompactionBlock,
|
|
41
43
|
],
|
|
42
44
|
PropertyInfo(discriminator="type"),
|
|
43
45
|
]
|
|
@@ -5,5 +5,12 @@ from typing_extensions import Literal, TypeAlias
|
|
|
5
5
|
__all__ = ["BetaStopReason"]
|
|
6
6
|
|
|
7
7
|
BetaStopReason: TypeAlias = Literal[
|
|
8
|
-
"end_turn",
|
|
8
|
+
"end_turn",
|
|
9
|
+
"max_tokens",
|
|
10
|
+
"stop_sequence",
|
|
11
|
+
"tool_use",
|
|
12
|
+
"pause_turn",
|
|
13
|
+
"compaction",
|
|
14
|
+
"refusal",
|
|
15
|
+
"model_context_window_exceeded",
|
|
9
16
|
]
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing_extensions import Literal, Required, TypedDict
|
|
6
|
+
|
|
7
|
+
__all__ = ["BetaThinkingConfigAdaptiveParam"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class BetaThinkingConfigAdaptiveParam(TypedDict, total=False):
|
|
11
|
+
type: Required[Literal["adaptive"]]
|