anthropic 0.77.0__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 +112 -3
- 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.0.dist-info → anthropic-0.78.0.dist-info}/METADATA +2 -2
- {anthropic-0.77.0.dist-info → anthropic-0.78.0.dist-info}/RECORD +42 -33
- {anthropic-0.77.0.dist-info → anthropic-0.78.0.dist-info}/WHEEL +0 -0
- {anthropic-0.77.0.dist-info → anthropic-0.78.0.dist-info}/licenses/LICENSE +0 -0
anthropic/_version.py
CHANGED
|
@@ -20,6 +20,7 @@ from ._beta_types import (
|
|
|
20
20
|
BetaThinkingEvent,
|
|
21
21
|
BetaInputJsonEvent,
|
|
22
22
|
BetaSignatureEvent,
|
|
23
|
+
BetaCompactionEvent,
|
|
23
24
|
ParsedBetaTextEvent,
|
|
24
25
|
ParsedBetaMessageStopEvent,
|
|
25
26
|
ParsedBetaMessageStreamEvent,
|
|
@@ -403,6 +404,15 @@ def build_events(
|
|
|
403
404
|
)
|
|
404
405
|
)
|
|
405
406
|
pass
|
|
407
|
+
elif event.delta.type == "compaction_delta":
|
|
408
|
+
if content_block.type == "compaction":
|
|
409
|
+
events_to_fire.append(
|
|
410
|
+
build(
|
|
411
|
+
BetaCompactionEvent,
|
|
412
|
+
type="compaction",
|
|
413
|
+
content=content_block.content,
|
|
414
|
+
)
|
|
415
|
+
)
|
|
406
416
|
else:
|
|
407
417
|
# we only want exhaustive checking for linters, not at runtime
|
|
408
418
|
if TYPE_CHECKING: # type: ignore[unreachable]
|
|
@@ -512,6 +522,9 @@ def accumulate_event(
|
|
|
512
522
|
elif event.delta.type == "signature_delta":
|
|
513
523
|
if content.type == "thinking":
|
|
514
524
|
content.signature = event.delta.signature
|
|
525
|
+
elif event.delta.type == "compaction_delta":
|
|
526
|
+
if content.type == "compaction":
|
|
527
|
+
content.content = event.delta.content
|
|
515
528
|
else:
|
|
516
529
|
# we only want exhaustive checking for linters, not at runtime
|
|
517
530
|
if TYPE_CHECKING: # type: ignore[unreachable]
|
|
@@ -536,5 +549,7 @@ def accumulate_event(
|
|
|
536
549
|
current_snapshot.usage.cache_read_input_tokens = event.usage.cache_read_input_tokens
|
|
537
550
|
if event.usage.server_tool_use is not None:
|
|
538
551
|
current_snapshot.usage.server_tool_use = event.usage.server_tool_use
|
|
552
|
+
if event.usage.iterations is not None:
|
|
553
|
+
current_snapshot.usage.iterations = event.usage.iterations
|
|
539
554
|
|
|
540
555
|
return current_snapshot
|
|
@@ -75,6 +75,13 @@ class BetaInputJsonEvent(BaseModel):
|
|
|
75
75
|
"""
|
|
76
76
|
|
|
77
77
|
|
|
78
|
+
class BetaCompactionEvent(BaseModel):
|
|
79
|
+
type: Literal["compaction"]
|
|
80
|
+
|
|
81
|
+
content: Union[str, None]
|
|
82
|
+
"""The compaction content"""
|
|
83
|
+
|
|
84
|
+
|
|
78
85
|
class ParsedBetaMessageStopEvent(BetaRawMessageStopEvent, GenericModel, Generic[ResponseFormatT]):
|
|
79
86
|
type: Literal["message_stop"]
|
|
80
87
|
|
|
@@ -97,6 +104,7 @@ ParsedBetaMessageStreamEvent = Annotated[
|
|
|
97
104
|
BetaThinkingEvent,
|
|
98
105
|
BetaSignatureEvent,
|
|
99
106
|
BetaInputJsonEvent,
|
|
107
|
+
BetaCompactionEvent,
|
|
100
108
|
BetaRawMessageStartEvent,
|
|
101
109
|
BetaRawMessageDeltaEvent,
|
|
102
110
|
ParsedBetaMessageStopEvent[ResponseFormatT],
|
|
@@ -44,7 +44,7 @@ from ...._exceptions import AnthropicError
|
|
|
44
44
|
from ...._base_client import make_request_options
|
|
45
45
|
from ...._utils._utils import is_dict
|
|
46
46
|
from ....lib.streaming import BetaMessageStreamManager, BetaAsyncMessageStreamManager
|
|
47
|
-
from ...messages.messages import DEPRECATED_MODELS
|
|
47
|
+
from ...messages.messages import DEPRECATED_MODELS, MODELS_TO_WARN_WITH_THINKING_ENABLED
|
|
48
48
|
from ....types.model_param import ModelParam
|
|
49
49
|
from ....lib._parse._response import ResponseFormatT, parse_beta_response
|
|
50
50
|
from ....lib._parse._transform import transform_schema
|
|
@@ -112,6 +112,7 @@ class Messages(SyncAPIResource):
|
|
|
112
112
|
model: ModelParam,
|
|
113
113
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
114
114
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
115
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
115
116
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
116
117
|
metadata: BetaMetadataParam | Omit = omit,
|
|
117
118
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -230,6 +231,9 @@ class Messages(SyncAPIResource):
|
|
|
230
231
|
This allows you to control how Claude manages context across multiple requests,
|
|
231
232
|
such as whether to clear function results or not.
|
|
232
233
|
|
|
234
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
235
|
+
workspace's `default_inference_geo` is used.
|
|
236
|
+
|
|
233
237
|
mcp_servers: MCP servers to be utilized in this request
|
|
234
238
|
|
|
235
239
|
metadata: An object describing metadata about the request.
|
|
@@ -406,6 +410,7 @@ class Messages(SyncAPIResource):
|
|
|
406
410
|
stream: Literal[True],
|
|
407
411
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
408
412
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
413
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
409
414
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
410
415
|
metadata: BetaMetadataParam | Omit = omit,
|
|
411
416
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -527,6 +532,9 @@ class Messages(SyncAPIResource):
|
|
|
527
532
|
This allows you to control how Claude manages context across multiple requests,
|
|
528
533
|
such as whether to clear function results or not.
|
|
529
534
|
|
|
535
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
536
|
+
workspace's `default_inference_geo` is used.
|
|
537
|
+
|
|
530
538
|
mcp_servers: MCP servers to be utilized in this request
|
|
531
539
|
|
|
532
540
|
metadata: An object describing metadata about the request.
|
|
@@ -699,6 +707,7 @@ class Messages(SyncAPIResource):
|
|
|
699
707
|
stream: bool,
|
|
700
708
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
701
709
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
710
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
702
711
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
703
712
|
metadata: BetaMetadataParam | Omit = omit,
|
|
704
713
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -820,6 +829,9 @@ class Messages(SyncAPIResource):
|
|
|
820
829
|
This allows you to control how Claude manages context across multiple requests,
|
|
821
830
|
such as whether to clear function results or not.
|
|
822
831
|
|
|
832
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
833
|
+
workspace's `default_inference_geo` is used.
|
|
834
|
+
|
|
823
835
|
mcp_servers: MCP servers to be utilized in this request
|
|
824
836
|
|
|
825
837
|
metadata: An object describing metadata about the request.
|
|
@@ -991,6 +1003,7 @@ class Messages(SyncAPIResource):
|
|
|
991
1003
|
model: ModelParam,
|
|
992
1004
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
993
1005
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1006
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
994
1007
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
995
1008
|
metadata: BetaMetadataParam | Omit = omit,
|
|
996
1009
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1029,6 +1042,13 @@ class Messages(SyncAPIResource):
|
|
|
1029
1042
|
stacklevel=3,
|
|
1030
1043
|
)
|
|
1031
1044
|
|
|
1045
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1046
|
+
warnings.warn(
|
|
1047
|
+
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",
|
|
1048
|
+
UserWarning,
|
|
1049
|
+
stacklevel=3,
|
|
1050
|
+
)
|
|
1051
|
+
|
|
1032
1052
|
merged_output_config = _merge_output_configs(output_config, output_format)
|
|
1033
1053
|
|
|
1034
1054
|
extra_headers = {
|
|
@@ -1044,6 +1064,7 @@ class Messages(SyncAPIResource):
|
|
|
1044
1064
|
"model": model,
|
|
1045
1065
|
"container": container,
|
|
1046
1066
|
"context_management": context_management,
|
|
1067
|
+
"inference_geo": inference_geo,
|
|
1047
1068
|
"mcp_servers": mcp_servers,
|
|
1048
1069
|
"metadata": metadata,
|
|
1049
1070
|
"output_config": merged_output_config,
|
|
@@ -1079,6 +1100,7 @@ class Messages(SyncAPIResource):
|
|
|
1079
1100
|
model: ModelParam,
|
|
1080
1101
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1081
1102
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1103
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1082
1104
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1083
1105
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1084
1106
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1116,9 +1138,16 @@ class Messages(SyncAPIResource):
|
|
|
1116
1138
|
stacklevel=3,
|
|
1117
1139
|
)
|
|
1118
1140
|
|
|
1141
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1142
|
+
warnings.warn(
|
|
1143
|
+
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",
|
|
1144
|
+
UserWarning,
|
|
1145
|
+
stacklevel=3,
|
|
1146
|
+
)
|
|
1147
|
+
|
|
1119
1148
|
betas = [beta for beta in betas] if is_given(betas) else []
|
|
1120
1149
|
|
|
1121
|
-
if "structured-outputs-2025-12-15" not in betas
|
|
1150
|
+
if "structured-outputs-2025-12-15" not in betas:
|
|
1122
1151
|
# Ensure structured outputs beta is included for parse method
|
|
1123
1152
|
betas.append("structured-outputs-2025-12-15")
|
|
1124
1153
|
|
|
@@ -1166,6 +1195,7 @@ class Messages(SyncAPIResource):
|
|
|
1166
1195
|
"model": model,
|
|
1167
1196
|
"container": container,
|
|
1168
1197
|
"context_management": context_management,
|
|
1198
|
+
"inference_geo": inference_geo,
|
|
1169
1199
|
"mcp_servers": mcp_servers,
|
|
1170
1200
|
"metadata": metadata,
|
|
1171
1201
|
"output_config": merged_output_config,
|
|
@@ -1205,6 +1235,7 @@ class Messages(SyncAPIResource):
|
|
|
1205
1235
|
compaction_control: CompactionControl | Omit = omit,
|
|
1206
1236
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1207
1237
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1238
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1208
1239
|
max_iterations: int | Omit = omit,
|
|
1209
1240
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1210
1241
|
metadata: BetaMetadataParam | Omit = omit,
|
|
@@ -1241,6 +1272,7 @@ class Messages(SyncAPIResource):
|
|
|
1241
1272
|
max_iterations: int | Omit = omit,
|
|
1242
1273
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1243
1274
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1275
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1244
1276
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1245
1277
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1246
1278
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1275,6 +1307,7 @@ class Messages(SyncAPIResource):
|
|
|
1275
1307
|
max_iterations: int | Omit = omit,
|
|
1276
1308
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1277
1309
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1310
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1278
1311
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1279
1312
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1280
1313
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1307,6 +1340,7 @@ class Messages(SyncAPIResource):
|
|
|
1307
1340
|
max_iterations: int | Omit = omit,
|
|
1308
1341
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1309
1342
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1343
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1310
1344
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1311
1345
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1312
1346
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1339,6 +1373,20 @@ class Messages(SyncAPIResource):
|
|
|
1339
1373
|
stacklevel=3,
|
|
1340
1374
|
)
|
|
1341
1375
|
|
|
1376
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1377
|
+
warnings.warn(
|
|
1378
|
+
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",
|
|
1379
|
+
UserWarning,
|
|
1380
|
+
stacklevel=3,
|
|
1381
|
+
)
|
|
1382
|
+
|
|
1383
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1384
|
+
warnings.warn(
|
|
1385
|
+
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",
|
|
1386
|
+
UserWarning,
|
|
1387
|
+
stacklevel=3,
|
|
1388
|
+
)
|
|
1389
|
+
|
|
1342
1390
|
extra_headers = {
|
|
1343
1391
|
"X-Stainless-Helper": "BetaToolRunner",
|
|
1344
1392
|
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
|
|
@@ -1362,6 +1410,7 @@ class Messages(SyncAPIResource):
|
|
|
1362
1410
|
"model": model,
|
|
1363
1411
|
"container": container,
|
|
1364
1412
|
"context_management": context_management,
|
|
1413
|
+
"inference_geo": inference_geo,
|
|
1365
1414
|
"mcp_servers": mcp_servers,
|
|
1366
1415
|
"metadata": metadata,
|
|
1367
1416
|
"output_config": output_config,
|
|
@@ -1414,6 +1463,7 @@ class Messages(SyncAPIResource):
|
|
|
1414
1463
|
model: ModelParam,
|
|
1415
1464
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1416
1465
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1466
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1417
1467
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1418
1468
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1419
1469
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1445,6 +1495,13 @@ class Messages(SyncAPIResource):
|
|
|
1445
1495
|
stacklevel=3,
|
|
1446
1496
|
)
|
|
1447
1497
|
|
|
1498
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
1499
|
+
warnings.warn(
|
|
1500
|
+
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",
|
|
1501
|
+
UserWarning,
|
|
1502
|
+
stacklevel=3,
|
|
1503
|
+
)
|
|
1504
|
+
|
|
1448
1505
|
"""Create a Message stream"""
|
|
1449
1506
|
extra_headers = {
|
|
1450
1507
|
"X-Stainless-Helper-Method": "stream",
|
|
@@ -1488,6 +1545,7 @@ class Messages(SyncAPIResource):
|
|
|
1488
1545
|
"output_format": omit,
|
|
1489
1546
|
"container": container,
|
|
1490
1547
|
"context_management": context_management,
|
|
1548
|
+
"inference_geo": inference_geo,
|
|
1491
1549
|
"mcp_servers": mcp_servers,
|
|
1492
1550
|
"service_tier": service_tier,
|
|
1493
1551
|
"stop_sequences": stop_sequences,
|
|
@@ -1808,6 +1866,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1808
1866
|
model: ModelParam,
|
|
1809
1867
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
1810
1868
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
1869
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
1811
1870
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
1812
1871
|
metadata: BetaMetadataParam | Omit = omit,
|
|
1813
1872
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -1926,6 +1985,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
1926
1985
|
This allows you to control how Claude manages context across multiple requests,
|
|
1927
1986
|
such as whether to clear function results or not.
|
|
1928
1987
|
|
|
1988
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
1989
|
+
workspace's `default_inference_geo` is used.
|
|
1990
|
+
|
|
1929
1991
|
mcp_servers: MCP servers to be utilized in this request
|
|
1930
1992
|
|
|
1931
1993
|
metadata: An object describing metadata about the request.
|
|
@@ -2102,6 +2164,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2102
2164
|
stream: Literal[True],
|
|
2103
2165
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2104
2166
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
2167
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2105
2168
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2106
2169
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2107
2170
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2223,6 +2286,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2223
2286
|
This allows you to control how Claude manages context across multiple requests,
|
|
2224
2287
|
such as whether to clear function results or not.
|
|
2225
2288
|
|
|
2289
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
2290
|
+
workspace's `default_inference_geo` is used.
|
|
2291
|
+
|
|
2226
2292
|
mcp_servers: MCP servers to be utilized in this request
|
|
2227
2293
|
|
|
2228
2294
|
metadata: An object describing metadata about the request.
|
|
@@ -2395,6 +2461,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2395
2461
|
stream: bool,
|
|
2396
2462
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2397
2463
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
2464
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2398
2465
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2399
2466
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2400
2467
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2516,6 +2583,9 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2516
2583
|
This allows you to control how Claude manages context across multiple requests,
|
|
2517
2584
|
such as whether to clear function results or not.
|
|
2518
2585
|
|
|
2586
|
+
inference_geo: Specifies the geographic region for inference processing. If not specified, the
|
|
2587
|
+
workspace's `default_inference_geo` is used.
|
|
2588
|
+
|
|
2519
2589
|
mcp_servers: MCP servers to be utilized in this request
|
|
2520
2590
|
|
|
2521
2591
|
metadata: An object describing metadata about the request.
|
|
@@ -2687,6 +2757,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2687
2757
|
model: ModelParam,
|
|
2688
2758
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2689
2759
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
2760
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2690
2761
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2691
2762
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2692
2763
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2725,6 +2796,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2725
2796
|
stacklevel=3,
|
|
2726
2797
|
)
|
|
2727
2798
|
|
|
2799
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
2800
|
+
warnings.warn(
|
|
2801
|
+
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",
|
|
2802
|
+
UserWarning,
|
|
2803
|
+
stacklevel=3,
|
|
2804
|
+
)
|
|
2805
|
+
|
|
2728
2806
|
merged_output_config = _merge_output_configs(output_config, output_format)
|
|
2729
2807
|
|
|
2730
2808
|
extra_headers = {
|
|
@@ -2740,6 +2818,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2740
2818
|
"model": model,
|
|
2741
2819
|
"container": container,
|
|
2742
2820
|
"context_management": context_management,
|
|
2821
|
+
"inference_geo": inference_geo,
|
|
2743
2822
|
"mcp_servers": mcp_servers,
|
|
2744
2823
|
"metadata": metadata,
|
|
2745
2824
|
"output_config": merged_output_config,
|
|
@@ -2775,6 +2854,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2775
2854
|
model: ModelParam,
|
|
2776
2855
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2777
2856
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
2857
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2778
2858
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2779
2859
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2780
2860
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2811,9 +2891,16 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2811
2891
|
DeprecationWarning,
|
|
2812
2892
|
stacklevel=3,
|
|
2813
2893
|
)
|
|
2894
|
+
|
|
2895
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
2896
|
+
warnings.warn(
|
|
2897
|
+
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",
|
|
2898
|
+
UserWarning,
|
|
2899
|
+
stacklevel=3,
|
|
2900
|
+
)
|
|
2814
2901
|
betas = [beta for beta in betas] if is_given(betas) else []
|
|
2815
2902
|
|
|
2816
|
-
if "structured-outputs-2025-12-15" not in betas
|
|
2903
|
+
if "structured-outputs-2025-12-15" not in betas:
|
|
2817
2904
|
# Ensure structured outputs beta is included for parse method
|
|
2818
2905
|
betas.append("structured-outputs-2025-12-15")
|
|
2819
2906
|
|
|
@@ -2861,6 +2948,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2861
2948
|
"model": model,
|
|
2862
2949
|
"container": container,
|
|
2863
2950
|
"context_management": context_management,
|
|
2951
|
+
"inference_geo": inference_geo,
|
|
2864
2952
|
"mcp_servers": mcp_servers,
|
|
2865
2953
|
"output_config": merged_output_config,
|
|
2866
2954
|
"metadata": metadata,
|
|
@@ -2901,6 +2989,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2901
2989
|
max_iterations: int | Omit = omit,
|
|
2902
2990
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2903
2991
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
2992
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2904
2993
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2905
2994
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2906
2995
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2936,6 +3025,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2936
3025
|
max_iterations: int | Omit = omit,
|
|
2937
3026
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2938
3027
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
3028
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2939
3029
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2940
3030
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2941
3031
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -2970,6 +3060,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
2970
3060
|
max_iterations: int | Omit = omit,
|
|
2971
3061
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
2972
3062
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
3063
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
2973
3064
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
2974
3065
|
metadata: BetaMetadataParam | Omit = omit,
|
|
2975
3066
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -3002,6 +3093,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3002
3093
|
max_iterations: int | Omit = omit,
|
|
3003
3094
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
3004
3095
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
3096
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
3005
3097
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
3006
3098
|
metadata: BetaMetadataParam | Omit = omit,
|
|
3007
3099
|
output_config: BetaOutputConfigParam | Omit = omit,
|
|
@@ -3034,6 +3126,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3034
3126
|
stacklevel=3,
|
|
3035
3127
|
)
|
|
3036
3128
|
|
|
3129
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
3130
|
+
warnings.warn(
|
|
3131
|
+
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",
|
|
3132
|
+
UserWarning,
|
|
3133
|
+
stacklevel=3,
|
|
3134
|
+
)
|
|
3135
|
+
|
|
3037
3136
|
extra_headers = {
|
|
3038
3137
|
"X-Stainless-Helper": "BetaToolRunner",
|
|
3039
3138
|
**strip_not_given({"anthropic-beta": ",".join(str(e) for e in betas) if is_given(betas) else NOT_GIVEN}),
|
|
@@ -3057,6 +3156,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3057
3156
|
"model": model,
|
|
3058
3157
|
"container": container,
|
|
3059
3158
|
"context_management": context_management,
|
|
3159
|
+
"inference_geo": inference_geo,
|
|
3060
3160
|
"mcp_servers": mcp_servers,
|
|
3061
3161
|
"metadata": metadata,
|
|
3062
3162
|
"output_config": output_config,
|
|
@@ -3112,6 +3212,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3112
3212
|
output_format: None | type[ResponseFormatT] | BetaJSONOutputFormatParam | Omit = omit,
|
|
3113
3213
|
container: Optional[message_create_params.Container] | Omit = omit,
|
|
3114
3214
|
context_management: Optional[BetaContextManagementConfigParam] | Omit = omit,
|
|
3215
|
+
inference_geo: Optional[str] | Omit = omit,
|
|
3115
3216
|
mcp_servers: Iterable[BetaRequestMCPServerURLDefinitionParam] | Omit = omit,
|
|
3116
3217
|
service_tier: Literal["auto", "standard_only"] | Omit = omit,
|
|
3117
3218
|
stop_sequences: SequenceNotStr[str] | Omit = omit,
|
|
@@ -3140,6 +3241,13 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3140
3241
|
stacklevel=3,
|
|
3141
3242
|
)
|
|
3142
3243
|
|
|
3244
|
+
if model in MODELS_TO_WARN_WITH_THINKING_ENABLED and thinking and thinking["type"] == "enabled":
|
|
3245
|
+
warnings.warn(
|
|
3246
|
+
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",
|
|
3247
|
+
UserWarning,
|
|
3248
|
+
stacklevel=3,
|
|
3249
|
+
)
|
|
3250
|
+
|
|
3143
3251
|
extra_headers = {
|
|
3144
3252
|
"X-Stainless-Helper-Method": "stream",
|
|
3145
3253
|
"X-Stainless-Stream-Helper": "beta.messages",
|
|
@@ -3181,6 +3289,7 @@ class AsyncMessages(AsyncAPIResource):
|
|
|
3181
3289
|
"output_format": omit,
|
|
3182
3290
|
"container": container,
|
|
3183
3291
|
"context_management": context_management,
|
|
3292
|
+
"inference_geo": inference_geo,
|
|
3184
3293
|
"mcp_servers": mcp_servers,
|
|
3185
3294
|
"service_tier": service_tier,
|
|
3186
3295
|
"stop_sequences": stop_sequences,
|