@ai-sdk/anthropic 4.0.32 → 4.0.34

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.
@@ -1,6 +1,7 @@
1
- import { FilesV4, FilesV4UploadFileCallOptions, FilesV4UploadFileResult, LanguageModelV4, JSONObject, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning, SkillsV4 } from '@ai-sdk/provider';
1
+ import * as _ai_sdk_provider from '@ai-sdk/provider';
2
+ import { FilesV4, FilesV4UploadFileCallOptions, FilesV4UploadFileResult, JSONSchema7, LanguageModelV4, JSONObject, LanguageModelV4CallOptions, SharedV4Warning, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, SharedV4ProviderMetadata, SkillsV4 } from '@ai-sdk/provider';
2
3
  import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { FetchFunction, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, Resolvable, ToolExecuteFunction, Tool, Experimental_SandboxSession, ProviderDefinedTool } from '@ai-sdk/provider-utils';
4
+ import { FetchFunction, InferSchema, Resolvable, WORKFLOW_SERIALIZE, WORKFLOW_DESERIALIZE, ToolExecuteFunction, Tool, Experimental_SandboxSession, ProviderDefinedTool } from '@ai-sdk/provider-utils';
4
5
 
5
6
  interface AnthropicFilesConfig {
6
7
  provider: string;
@@ -16,6 +17,694 @@ declare class AnthropicFiles implements FilesV4 {
16
17
  uploadFile({ data, mediaType, filename, }: FilesV4UploadFileCallOptions): Promise<FilesV4UploadFileResult>;
17
18
  }
18
19
 
20
+ type AnthropicMessage = AnthropicUserMessage | AnthropicAssistantMessage | AnthropicSystemMessage;
21
+ type AnthropicCacheControl = {
22
+ type: 'ephemeral';
23
+ ttl?: '5m' | '1h';
24
+ };
25
+ interface AnthropicSystemMessage {
26
+ role: 'system';
27
+ content: Array<AnthropicTextContent | AnthropicToolChangeContent>;
28
+ }
29
+ /**
30
+ * Mid-conversation tool change content block. Adds or removes a tool from the
31
+ * conversation's tool set without invalidating the prompt cache.
32
+ *
33
+ * Only valid inside system messages that appear in the `messages` array.
34
+ * Requires the `mid-conversation-tool-changes-2026-07-01` beta.
35
+ */
36
+ interface AnthropicToolChangeContent {
37
+ type: 'tool_addition' | 'tool_removal';
38
+ tool: {
39
+ type: 'tool_reference';
40
+ name: string;
41
+ };
42
+ cache_control?: never;
43
+ }
44
+ interface AnthropicUserMessage {
45
+ role: 'user';
46
+ content: Array<AnthropicTextContent | AnthropicImageContent | AnthropicDocumentContent | AnthropicContainerUploadContent | AnthropicToolResultContent>;
47
+ }
48
+ interface AnthropicAssistantMessage {
49
+ role: 'assistant';
50
+ content: Array<AnthropicTextContent | AnthropicThinkingContent | AnthropicRedactedThinkingContent | AnthropicToolCallContent | AnthropicServerToolUseContent | AnthropicCodeExecutionToolResultContent | AnthropicWebFetchToolResultContent | AnthropicWebSearchToolResultContent | AnthropicToolSearchToolResultContent | AnthropicBashCodeExecutionToolResultContent | AnthropicTextEditorCodeExecutionToolResultContent | AnthropicAdvisorToolResultContent | AnthropicMcpToolUseContent | AnthropicMcpToolResultContent | AnthropicCompactionContent>;
51
+ }
52
+ interface AnthropicCompactionContent {
53
+ type: 'compaction';
54
+ content: string;
55
+ cache_control?: AnthropicCacheControl;
56
+ }
57
+ interface AnthropicTextContent {
58
+ type: 'text';
59
+ text: string;
60
+ citations?: Citation[];
61
+ cache_control: AnthropicCacheControl | undefined;
62
+ }
63
+ interface AnthropicThinkingContent {
64
+ type: 'thinking';
65
+ thinking: string;
66
+ signature: string;
67
+ cache_control?: never;
68
+ }
69
+ interface AnthropicRedactedThinkingContent {
70
+ type: 'redacted_thinking';
71
+ data: string;
72
+ cache_control?: never;
73
+ }
74
+ type AnthropicContentSource = {
75
+ type: 'base64';
76
+ media_type: string;
77
+ data: string;
78
+ } | {
79
+ type: 'url';
80
+ url: string;
81
+ } | {
82
+ type: 'text';
83
+ media_type: 'text/plain';
84
+ data: string;
85
+ } | {
86
+ type: 'file';
87
+ file_id: string;
88
+ };
89
+ interface AnthropicImageContent {
90
+ type: 'image';
91
+ source: AnthropicContentSource;
92
+ cache_control: AnthropicCacheControl | undefined;
93
+ }
94
+ interface AnthropicDocumentContent {
95
+ type: 'document';
96
+ source: AnthropicContentSource;
97
+ title?: string;
98
+ context?: string;
99
+ citations?: {
100
+ enabled: boolean;
101
+ };
102
+ cache_control: AnthropicCacheControl | undefined;
103
+ }
104
+ interface AnthropicContainerUploadContent {
105
+ type: 'container_upload';
106
+ file_id: string;
107
+ cache_control?: never;
108
+ }
109
+ /**
110
+ * The caller information for programmatic tool calling.
111
+ * Present when a tool is called from within code execution.
112
+ */
113
+ type AnthropicToolCallCaller = {
114
+ type: 'code_execution_20250825';
115
+ tool_id: string;
116
+ } | {
117
+ type: 'code_execution_20260120';
118
+ tool_id: string;
119
+ } | {
120
+ type: 'direct';
121
+ };
122
+ interface AnthropicToolCallContent {
123
+ type: 'tool_use';
124
+ id: string;
125
+ name: string;
126
+ input: unknown;
127
+ /**
128
+ * Present when this tool call was triggered by a server-executed tool
129
+ * (e.g., code execution calling a user-defined tool programmatically).
130
+ */
131
+ caller?: AnthropicToolCallCaller;
132
+ cache_control: AnthropicCacheControl | undefined;
133
+ }
134
+ interface AnthropicServerToolUseContent {
135
+ type: 'server_tool_use';
136
+ id: string;
137
+ name: 'web_fetch' | 'web_search' | 'code_execution' | 'bash_code_execution' | 'text_editor_code_execution' | 'tool_search_tool_regex' | 'tool_search_tool_bm25' | 'advisor';
138
+ input: unknown;
139
+ cache_control: AnthropicCacheControl | undefined;
140
+ }
141
+ type AnthropicNestedTextContent = Omit<AnthropicTextContent, 'cache_control'> & {
142
+ cache_control?: never;
143
+ };
144
+ type AnthropicNestedImageContent = Omit<AnthropicImageContent, 'cache_control'> & {
145
+ cache_control?: never;
146
+ };
147
+ type AnthropicNestedDocumentContent = Omit<AnthropicDocumentContent, 'cache_control'> & {
148
+ cache_control?: never;
149
+ };
150
+ interface AnthropicToolReferenceContent {
151
+ type: 'tool_reference';
152
+ tool_name: string;
153
+ }
154
+ interface AnthropicToolResultContent {
155
+ type: 'tool_result';
156
+ tool_use_id: string;
157
+ content: string | Array<AnthropicNestedTextContent | AnthropicNestedImageContent | AnthropicNestedDocumentContent | AnthropicToolReferenceContent>;
158
+ is_error: boolean | undefined;
159
+ cache_control: AnthropicCacheControl | undefined;
160
+ }
161
+ interface AnthropicWebSearchToolResultContent {
162
+ type: 'web_search_tool_result';
163
+ tool_use_id: string;
164
+ content: Array<{
165
+ url: string;
166
+ title: string | null;
167
+ page_age: string | null;
168
+ encrypted_content: string;
169
+ type: string;
170
+ }> | {
171
+ type: 'web_search_tool_result_error';
172
+ error_code: string;
173
+ };
174
+ cache_control: AnthropicCacheControl | undefined;
175
+ }
176
+ interface AnthropicToolSearchToolResultContent {
177
+ type: 'tool_search_tool_result';
178
+ tool_use_id: string;
179
+ content: {
180
+ type: 'tool_search_tool_search_result';
181
+ tool_references: Array<{
182
+ type: 'tool_reference';
183
+ tool_name: string;
184
+ }>;
185
+ } | {
186
+ type: 'tool_search_tool_result_error';
187
+ error_code: string;
188
+ };
189
+ cache_control: AnthropicCacheControl | undefined;
190
+ }
191
+ interface AnthropicCodeExecutionToolResultContent {
192
+ type: 'code_execution_tool_result';
193
+ tool_use_id: string;
194
+ content: {
195
+ type: 'code_execution_result';
196
+ stdout: string;
197
+ stderr: string;
198
+ return_code: number;
199
+ content: Array<{
200
+ type: 'code_execution_output';
201
+ file_id: string;
202
+ }>;
203
+ } | {
204
+ type: 'encrypted_code_execution_result';
205
+ encrypted_stdout: string;
206
+ stderr: string;
207
+ return_code: number;
208
+ content: Array<{
209
+ type: 'code_execution_output';
210
+ file_id: string;
211
+ }>;
212
+ } | {
213
+ type: 'code_execution_tool_result_error';
214
+ error_code: string;
215
+ };
216
+ cache_control: AnthropicCacheControl | undefined;
217
+ }
218
+ interface AnthropicTextEditorCodeExecutionToolResultContent {
219
+ type: 'text_editor_code_execution_tool_result';
220
+ tool_use_id: string;
221
+ content: {
222
+ type: 'text_editor_code_execution_tool_result_error';
223
+ error_code: string;
224
+ } | {
225
+ type: 'text_editor_code_execution_create_result';
226
+ is_file_update: boolean;
227
+ } | {
228
+ type: 'text_editor_code_execution_view_result';
229
+ content: string;
230
+ file_type: string;
231
+ num_lines: number | null;
232
+ start_line: number | null;
233
+ total_lines: number | null;
234
+ } | {
235
+ type: 'text_editor_code_execution_str_replace_result';
236
+ lines: string[] | null;
237
+ new_lines: number | null;
238
+ new_start: number | null;
239
+ old_lines: number | null;
240
+ old_start: number | null;
241
+ };
242
+ cache_control: AnthropicCacheControl | undefined;
243
+ }
244
+ interface AnthropicBashCodeExecutionToolResultContent {
245
+ type: 'bash_code_execution_tool_result';
246
+ tool_use_id: string;
247
+ content: {
248
+ type: 'bash_code_execution_result';
249
+ stdout: string;
250
+ stderr: string;
251
+ return_code: number;
252
+ content: {
253
+ type: 'bash_code_execution_output';
254
+ file_id: string;
255
+ }[];
256
+ } | {
257
+ type: 'bash_code_execution_tool_result_error';
258
+ error_code: string;
259
+ };
260
+ cache_control: AnthropicCacheControl | undefined;
261
+ }
262
+ interface AnthropicAdvisorToolResultContent {
263
+ type: 'advisor_tool_result';
264
+ tool_use_id: string;
265
+ content: {
266
+ type: 'advisor_result';
267
+ text: string;
268
+ stop_reason?: string;
269
+ } | {
270
+ type: 'advisor_redacted_result';
271
+ encrypted_content: string;
272
+ stop_reason?: string;
273
+ } | {
274
+ type: 'advisor_tool_result_error';
275
+ /**
276
+ * Available options: `max_uses_exceeded`, `too_many_requests`,
277
+ * `overloaded`, `prompt_too_long`, `execution_time_exceeded`,
278
+ * `unavailable`.
279
+ */
280
+ error_code: string;
281
+ };
282
+ cache_control: AnthropicCacheControl | undefined;
283
+ }
284
+ interface AnthropicWebFetchToolResultContent {
285
+ type: 'web_fetch_tool_result';
286
+ tool_use_id: string;
287
+ content: {
288
+ type: 'web_fetch_result';
289
+ url: string;
290
+ retrieved_at: string | null;
291
+ content: {
292
+ type: 'document';
293
+ title: string | null;
294
+ citations?: {
295
+ enabled: boolean;
296
+ };
297
+ source: {
298
+ type: 'base64';
299
+ media_type: 'application/pdf';
300
+ data: string;
301
+ } | {
302
+ type: 'text';
303
+ media_type: 'text/plain';
304
+ data: string;
305
+ };
306
+ };
307
+ } | {
308
+ type: 'web_fetch_tool_result_error';
309
+ error_code: string;
310
+ };
311
+ cache_control: AnthropicCacheControl | undefined;
312
+ }
313
+ interface AnthropicMcpToolUseContent {
314
+ type: 'mcp_tool_use';
315
+ id: string;
316
+ name: string;
317
+ server_name: string;
318
+ input: unknown;
319
+ cache_control: AnthropicCacheControl | undefined;
320
+ }
321
+ interface AnthropicMcpToolResultContent {
322
+ type: 'mcp_tool_result';
323
+ tool_use_id: string;
324
+ is_error: boolean;
325
+ content: string | Array<{
326
+ type: 'text';
327
+ text: string;
328
+ }>;
329
+ cache_control: AnthropicCacheControl | undefined;
330
+ }
331
+ type AnthropicTool = {
332
+ name: string;
333
+ description: string | undefined;
334
+ input_schema: JSONSchema7;
335
+ cache_control: AnthropicCacheControl | undefined;
336
+ eager_input_streaming?: boolean;
337
+ strict?: boolean;
338
+ /**
339
+ * When true, this tool is deferred and will only be loaded when
340
+ * discovered via the tool search tool.
341
+ */
342
+ defer_loading?: boolean;
343
+ /**
344
+ * Programmatic tool calling: specifies which server-executed tools
345
+ * are allowed to call this tool. When set, only the specified callers
346
+ * can invoke this tool programmatically.
347
+ *
348
+ * @example ['code_execution_20250825']
349
+ */
350
+ allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
351
+ } | {
352
+ type: 'code_execution_20250522';
353
+ name: string;
354
+ cache_control: AnthropicCacheControl | undefined;
355
+ } | {
356
+ type: 'code_execution_20250825';
357
+ name: string;
358
+ } | {
359
+ type: 'code_execution_20260120';
360
+ name: string;
361
+ } | {
362
+ name: string;
363
+ type: 'computer_20250124' | 'computer_20241022';
364
+ display_width_px: number;
365
+ display_height_px: number;
366
+ display_number: number;
367
+ cache_control: AnthropicCacheControl | undefined;
368
+ } | {
369
+ name: string;
370
+ type: 'computer_20251124';
371
+ display_width_px: number;
372
+ display_height_px: number;
373
+ display_number: number;
374
+ enable_zoom?: boolean;
375
+ cache_control: AnthropicCacheControl | undefined;
376
+ } | {
377
+ name: string;
378
+ type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
379
+ cache_control: AnthropicCacheControl | undefined;
380
+ } | {
381
+ name: string;
382
+ type: 'text_editor_20250728';
383
+ max_characters?: number;
384
+ cache_control: AnthropicCacheControl | undefined;
385
+ } | {
386
+ name: string;
387
+ type: 'bash_20250124' | 'bash_20241022';
388
+ cache_control: AnthropicCacheControl | undefined;
389
+ } | {
390
+ name: string;
391
+ type: 'memory_20250818';
392
+ } | {
393
+ type: 'web_fetch_20250910' | 'web_fetch_20260209';
394
+ name: string;
395
+ max_uses?: number;
396
+ allowed_domains?: string[];
397
+ blocked_domains?: string[];
398
+ citations?: {
399
+ enabled: boolean;
400
+ };
401
+ max_content_tokens?: number;
402
+ cache_control: AnthropicCacheControl | undefined;
403
+ } | {
404
+ type: 'web_search_20250305' | 'web_search_20260209';
405
+ name: string;
406
+ max_uses?: number;
407
+ allowed_domains?: string[];
408
+ blocked_domains?: string[];
409
+ user_location?: {
410
+ type: 'approximate';
411
+ city?: string;
412
+ region?: string;
413
+ country?: string;
414
+ timezone?: string;
415
+ };
416
+ cache_control: AnthropicCacheControl | undefined;
417
+ } | {
418
+ type: 'tool_search_tool_regex_20251119';
419
+ name: string;
420
+ } | {
421
+ type: 'tool_search_tool_bm25_20251119';
422
+ name: string;
423
+ } | {
424
+ type: 'advisor_20260301';
425
+ name: 'advisor';
426
+ model: string;
427
+ max_uses?: number;
428
+ max_tokens?: number;
429
+ caching?: {
430
+ type: 'ephemeral';
431
+ ttl: '5m' | '1h';
432
+ };
433
+ };
434
+ type AnthropicToolChoice = {
435
+ type: 'auto' | 'any';
436
+ disable_parallel_tool_use?: boolean;
437
+ } | {
438
+ type: 'tool';
439
+ name: string;
440
+ disable_parallel_tool_use?: boolean;
441
+ };
442
+ declare const anthropicResponseSchema: _ai_sdk_provider_utils.LazySchema<{
443
+ type: "message";
444
+ content: ({
445
+ type: "text";
446
+ text: string;
447
+ citations?: ({
448
+ type: "web_search_result_location";
449
+ cited_text: string;
450
+ url: string;
451
+ title: string;
452
+ encrypted_index: string;
453
+ } | {
454
+ type: "page_location";
455
+ cited_text: string;
456
+ document_index: number;
457
+ document_title: string | null;
458
+ start_page_number: number;
459
+ end_page_number: number;
460
+ } | {
461
+ type: "char_location";
462
+ cited_text: string;
463
+ document_index: number;
464
+ document_title: string | null;
465
+ start_char_index: number;
466
+ end_char_index: number;
467
+ })[] | undefined;
468
+ } | {
469
+ type: "thinking";
470
+ thinking: string;
471
+ signature: string;
472
+ } | {
473
+ type: "redacted_thinking";
474
+ data: string;
475
+ } | {
476
+ type: "compaction";
477
+ content: string;
478
+ } | {
479
+ type: "tool_use";
480
+ id: string;
481
+ name: string;
482
+ input: unknown;
483
+ caller?: {
484
+ type: "code_execution_20250825";
485
+ tool_id: string;
486
+ } | {
487
+ type: "code_execution_20260120";
488
+ tool_id: string;
489
+ } | {
490
+ type: "direct";
491
+ } | undefined;
492
+ } | {
493
+ type: "server_tool_use";
494
+ id: string;
495
+ name: string;
496
+ input?: Record<string, unknown> | null | undefined;
497
+ caller?: {
498
+ type: "code_execution_20260120";
499
+ tool_id: string;
500
+ } | {
501
+ type: "direct";
502
+ } | undefined;
503
+ } | {
504
+ type: "mcp_tool_use";
505
+ id: string;
506
+ name: string;
507
+ input: unknown;
508
+ server_name: string;
509
+ } | {
510
+ type: "mcp_tool_result";
511
+ tool_use_id: string;
512
+ is_error: boolean;
513
+ content: (string | {
514
+ type: "text";
515
+ text: string;
516
+ })[];
517
+ } | {
518
+ type: "web_fetch_tool_result";
519
+ tool_use_id: string;
520
+ content: {
521
+ type: "web_fetch_result";
522
+ url: string;
523
+ retrieved_at: string;
524
+ content: {
525
+ type: "document";
526
+ title: string | null;
527
+ source: {
528
+ type: "base64";
529
+ media_type: "application/pdf";
530
+ data: string;
531
+ } | {
532
+ type: "text";
533
+ media_type: "text/plain";
534
+ data: string;
535
+ };
536
+ citations?: {
537
+ enabled: boolean;
538
+ } | undefined;
539
+ };
540
+ } | {
541
+ type: "web_fetch_tool_result_error";
542
+ error_code: string;
543
+ };
544
+ } | {
545
+ type: "web_search_tool_result";
546
+ tool_use_id: string;
547
+ content: {
548
+ type: "web_search_result";
549
+ url: string;
550
+ title: string;
551
+ encrypted_content: string;
552
+ page_age?: string | null | undefined;
553
+ }[] | {
554
+ type: "web_search_tool_result_error";
555
+ error_code: string;
556
+ };
557
+ } | {
558
+ type: "code_execution_tool_result";
559
+ tool_use_id: string;
560
+ content: {
561
+ type: "code_execution_result";
562
+ stdout: string;
563
+ stderr: string;
564
+ return_code: number;
565
+ content: {
566
+ type: "code_execution_output";
567
+ file_id: string;
568
+ }[];
569
+ } | {
570
+ type: "encrypted_code_execution_result";
571
+ encrypted_stdout: string;
572
+ stderr: string;
573
+ return_code: number;
574
+ content: {
575
+ type: "code_execution_output";
576
+ file_id: string;
577
+ }[];
578
+ } | {
579
+ type: "code_execution_tool_result_error";
580
+ error_code: string;
581
+ };
582
+ } | {
583
+ type: "bash_code_execution_tool_result";
584
+ tool_use_id: string;
585
+ content: {
586
+ type: "bash_code_execution_result";
587
+ content: {
588
+ type: "bash_code_execution_output";
589
+ file_id: string;
590
+ }[];
591
+ stdout: string;
592
+ stderr: string;
593
+ return_code: number;
594
+ } | {
595
+ type: "bash_code_execution_tool_result_error";
596
+ error_code: string;
597
+ };
598
+ } | {
599
+ type: "text_editor_code_execution_tool_result";
600
+ tool_use_id: string;
601
+ content: {
602
+ type: "text_editor_code_execution_tool_result_error";
603
+ error_code: string;
604
+ } | {
605
+ type: "text_editor_code_execution_view_result";
606
+ content: string;
607
+ file_type: string;
608
+ num_lines: number | null;
609
+ start_line: number | null;
610
+ total_lines: number | null;
611
+ } | {
612
+ type: "text_editor_code_execution_create_result";
613
+ is_file_update: boolean;
614
+ } | {
615
+ type: "text_editor_code_execution_str_replace_result";
616
+ lines: string[] | null;
617
+ new_lines: number | null;
618
+ new_start: number | null;
619
+ old_lines: number | null;
620
+ old_start: number | null;
621
+ };
622
+ } | {
623
+ type: "tool_search_tool_result";
624
+ tool_use_id: string;
625
+ content: {
626
+ type: "tool_search_tool_search_result";
627
+ tool_references: {
628
+ type: "tool_reference";
629
+ tool_name: string;
630
+ }[];
631
+ } | {
632
+ type: "tool_search_tool_result_error";
633
+ error_code: string;
634
+ };
635
+ } | {
636
+ type: "advisor_tool_result";
637
+ tool_use_id: string;
638
+ content: {
639
+ type: "advisor_result";
640
+ text: string;
641
+ stop_reason?: string | null | undefined;
642
+ } | {
643
+ type: "advisor_redacted_result";
644
+ encrypted_content: string;
645
+ stop_reason?: string | null | undefined;
646
+ } | {
647
+ type: "advisor_tool_result_error";
648
+ error_code: string;
649
+ };
650
+ } | {
651
+ type: "fallback";
652
+ })[];
653
+ usage: {
654
+ [x: string]: unknown;
655
+ input_tokens: number;
656
+ output_tokens: number;
657
+ output_tokens_details?: {
658
+ thinking_tokens?: number | null | undefined;
659
+ } | null | undefined;
660
+ cache_creation_input_tokens?: number | null | undefined;
661
+ cache_read_input_tokens?: number | null | undefined;
662
+ iterations?: {
663
+ type: "message" | "compaction" | "advisor_message" | "fallback_message";
664
+ input_tokens: number;
665
+ output_tokens: number;
666
+ model?: string | null | undefined;
667
+ cache_creation_input_tokens?: number | null | undefined;
668
+ cache_read_input_tokens?: number | null | undefined;
669
+ }[] | null | undefined;
670
+ };
671
+ id?: string | null | undefined;
672
+ model?: string | null | undefined;
673
+ stop_reason?: string | null | undefined;
674
+ stop_sequence?: string | null | undefined;
675
+ stop_details?: {
676
+ type: string;
677
+ category?: string | null | undefined;
678
+ explanation?: string | null | undefined;
679
+ recommended_model?: string | null | undefined;
680
+ } | null | undefined;
681
+ container?: {
682
+ expires_at: string;
683
+ id: string;
684
+ skills?: {
685
+ type: "custom" | "anthropic";
686
+ skill_id: string;
687
+ version: string;
688
+ }[] | null | undefined;
689
+ } | null | undefined;
690
+ context_management?: {
691
+ applied_edits: ({
692
+ type: "clear_tool_uses_20250919";
693
+ cleared_tool_uses: number;
694
+ cleared_input_tokens: number;
695
+ } | {
696
+ type: "clear_thinking_20251015";
697
+ cleared_thinking_turns: number;
698
+ cleared_input_tokens: number;
699
+ } | {
700
+ type: "compact_20260112";
701
+ })[];
702
+ } | null | undefined;
703
+ }>;
704
+ type Citation = NonNullable<(InferSchema<typeof anthropicResponseSchema>['content'][number] & {
705
+ type: 'text';
706
+ })['citations']>[number];
707
+
19
708
  type AnthropicModelId = 'claude-3-haiku-20240307' | 'claude-haiku-4-5-20251001' | 'claude-haiku-4-5' | 'claude-opus-4-0' | 'claude-opus-4-20250514' | 'claude-opus-4-1-20250805' | 'claude-opus-4-1' | 'claude-opus-4-5' | 'claude-opus-4-5-20251101' | 'claude-sonnet-4-0' | 'claude-sonnet-4-20250514' | 'claude-sonnet-4-5-20250929' | 'claude-sonnet-4-5' | 'claude-sonnet-4-6' | 'claude-opus-4-6' | 'claude-opus-4-7' | 'claude-opus-4-8' | 'claude-opus-5' | 'claude-fable-5' | 'claude-sonnet-5' | (string & {});
20
709
 
21
710
  type AnthropicLanguageModelConfig = {
@@ -40,7 +729,7 @@ type AnthropicLanguageModelConfig = {
40
729
  declare class AnthropicLanguageModel implements LanguageModelV4 {
41
730
  readonly specificationVersion = "v4";
42
731
  readonly modelId: AnthropicModelId;
43
- private readonly config;
732
+ protected readonly config: AnthropicLanguageModelConfig;
44
733
  private readonly generateId;
45
734
  static [WORKFLOW_SERIALIZE](model: AnthropicLanguageModel): {
46
735
  modelId: string;
@@ -59,11 +748,121 @@ declare class AnthropicLanguageModel implements LanguageModelV4 {
59
748
  */
60
749
  private get providerOptionsName();
61
750
  get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
62
- private getArgs;
751
+ protected getArgs({ userSuppliedBetas, prompt, maxOutputTokens, temperature, topP, topK, frequencyPenalty, presencePenalty, stopSequences, responseFormat, seed, tools, toolChoice, reasoning, providerOptions, stream, }: LanguageModelV4CallOptions & {
752
+ stream: boolean;
753
+ userSuppliedBetas: Set<string>;
754
+ }): Promise<{
755
+ args: {
756
+ tools: AnthropicTool[] | undefined;
757
+ tool_choice: AnthropicToolChoice | undefined;
758
+ stream: boolean | undefined;
759
+ context_management?: {
760
+ edits: ({
761
+ exclude_tools?: string[] | undefined;
762
+ clear_tool_inputs?: boolean | undefined;
763
+ clear_at_least?: {
764
+ type: "input_tokens";
765
+ value: number;
766
+ } | undefined;
767
+ keep?: {
768
+ type: "tool_uses";
769
+ value: number;
770
+ } | undefined;
771
+ trigger?: {
772
+ type: "input_tokens";
773
+ value: number;
774
+ } | {
775
+ type: "tool_uses";
776
+ value: number;
777
+ } | undefined;
778
+ type: "clear_tool_uses_20250919";
779
+ } | {
780
+ keep?: "all" | {
781
+ type: "thinking_turns";
782
+ value: number;
783
+ } | undefined;
784
+ type: "clear_thinking_20251015";
785
+ } | {
786
+ instructions?: string | undefined;
787
+ pause_after_compaction?: boolean | undefined;
788
+ trigger?: {
789
+ type: "input_tokens";
790
+ value: number;
791
+ } | undefined;
792
+ type: "compact_20260112";
793
+ })[];
794
+ } | undefined;
795
+ system: AnthropicTextContent[] | undefined;
796
+ messages: AnthropicMessage[];
797
+ container?: string | {
798
+ id: string | undefined;
799
+ skills: {
800
+ type: "custom" | "anthropic";
801
+ skill_id: string;
802
+ version: string | undefined;
803
+ }[];
804
+ } | undefined;
805
+ mcp_servers?: {
806
+ type: "url";
807
+ name: string;
808
+ url: string;
809
+ authorization_token: string | null | undefined;
810
+ tool_configuration: {
811
+ allowed_tools: string[] | null | undefined;
812
+ enabled: boolean | null | undefined;
813
+ } | undefined;
814
+ }[] | undefined;
815
+ metadata?: {
816
+ user_id: string;
817
+ } | undefined;
818
+ cache_control?: {
819
+ type: "ephemeral";
820
+ ttl?: "5m" | "1h" | undefined;
821
+ } | undefined;
822
+ fallbacks?: "default" | {
823
+ model: string;
824
+ max_tokens?: number | undefined;
825
+ thinking?: Record<string, unknown> | undefined;
826
+ output_config?: Record<string, unknown> | undefined;
827
+ speed?: "fast" | "standard" | undefined;
828
+ }[] | undefined;
829
+ inference_geo?: "us" | "global" | undefined;
830
+ speed?: "fast" | "standard" | undefined;
831
+ output_config?: {
832
+ format?: {
833
+ type: string;
834
+ schema: _ai_sdk_provider.JSONSchema7;
835
+ } | undefined;
836
+ task_budget?: {
837
+ remaining?: number | undefined;
838
+ type: "tokens";
839
+ total: number;
840
+ } | undefined;
841
+ effort?: "low" | "medium" | "high" | "xhigh" | "max" | undefined;
842
+ } | undefined;
843
+ thinking?: {
844
+ display?: "omitted" | "summarized" | undefined;
845
+ budget_tokens?: number | undefined;
846
+ type: "enabled" | "adaptive" | "disabled";
847
+ } | undefined;
848
+ model: AnthropicModelId;
849
+ max_tokens: number;
850
+ temperature: number | undefined;
851
+ top_k: number | undefined;
852
+ top_p: number | undefined;
853
+ stop_sequences: string[] | undefined;
854
+ };
855
+ warnings: SharedV4Warning[];
856
+ betas: Set<string>;
857
+ usesJsonResponseTool: boolean;
858
+ toolNameMapping: _ai_sdk_provider_utils.ToolNameMapping;
859
+ providerOptionsName: string;
860
+ usedCustomProviderKey: boolean;
861
+ }>;
63
862
  private getHeaders;
64
863
  private getBetasFromHeaders;
65
864
  private buildRequestUrl;
66
- private transformRequestBody;
865
+ protected transformRequestBody(args: Record<string, any>, betas: Set<string>): Record<string, any>;
67
866
  private extractCitationDocuments;
68
867
  doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
69
868
  doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
@@ -980,122 +1779,6 @@ declare const anthropicTools: {
980
1779
  }[], {}>;
981
1780
  };
982
1781
 
983
- type AnthropicCacheControl = {
984
- type: 'ephemeral';
985
- ttl?: '5m' | '1h';
986
- };
987
- type AnthropicTool = {
988
- name: string;
989
- description: string | undefined;
990
- input_schema: JSONSchema7;
991
- cache_control: AnthropicCacheControl | undefined;
992
- eager_input_streaming?: boolean;
993
- strict?: boolean;
994
- /**
995
- * When true, this tool is deferred and will only be loaded when
996
- * discovered via the tool search tool.
997
- */
998
- defer_loading?: boolean;
999
- /**
1000
- * Programmatic tool calling: specifies which server-executed tools
1001
- * are allowed to call this tool. When set, only the specified callers
1002
- * can invoke this tool programmatically.
1003
- *
1004
- * @example ['code_execution_20250825']
1005
- */
1006
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
1007
- } | {
1008
- type: 'code_execution_20250522';
1009
- name: string;
1010
- cache_control: AnthropicCacheControl | undefined;
1011
- } | {
1012
- type: 'code_execution_20250825';
1013
- name: string;
1014
- } | {
1015
- type: 'code_execution_20260120';
1016
- name: string;
1017
- } | {
1018
- name: string;
1019
- type: 'computer_20250124' | 'computer_20241022';
1020
- display_width_px: number;
1021
- display_height_px: number;
1022
- display_number: number;
1023
- cache_control: AnthropicCacheControl | undefined;
1024
- } | {
1025
- name: string;
1026
- type: 'computer_20251124';
1027
- display_width_px: number;
1028
- display_height_px: number;
1029
- display_number: number;
1030
- enable_zoom?: boolean;
1031
- cache_control: AnthropicCacheControl | undefined;
1032
- } | {
1033
- name: string;
1034
- type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
1035
- cache_control: AnthropicCacheControl | undefined;
1036
- } | {
1037
- name: string;
1038
- type: 'text_editor_20250728';
1039
- max_characters?: number;
1040
- cache_control: AnthropicCacheControl | undefined;
1041
- } | {
1042
- name: string;
1043
- type: 'bash_20250124' | 'bash_20241022';
1044
- cache_control: AnthropicCacheControl | undefined;
1045
- } | {
1046
- name: string;
1047
- type: 'memory_20250818';
1048
- } | {
1049
- type: 'web_fetch_20250910' | 'web_fetch_20260209';
1050
- name: string;
1051
- max_uses?: number;
1052
- allowed_domains?: string[];
1053
- blocked_domains?: string[];
1054
- citations?: {
1055
- enabled: boolean;
1056
- };
1057
- max_content_tokens?: number;
1058
- cache_control: AnthropicCacheControl | undefined;
1059
- } | {
1060
- type: 'web_search_20250305' | 'web_search_20260209';
1061
- name: string;
1062
- max_uses?: number;
1063
- allowed_domains?: string[];
1064
- blocked_domains?: string[];
1065
- user_location?: {
1066
- type: 'approximate';
1067
- city?: string;
1068
- region?: string;
1069
- country?: string;
1070
- timezone?: string;
1071
- };
1072
- cache_control: AnthropicCacheControl | undefined;
1073
- } | {
1074
- type: 'tool_search_tool_regex_20251119';
1075
- name: string;
1076
- } | {
1077
- type: 'tool_search_tool_bm25_20251119';
1078
- name: string;
1079
- } | {
1080
- type: 'advisor_20260301';
1081
- name: 'advisor';
1082
- model: string;
1083
- max_uses?: number;
1084
- max_tokens?: number;
1085
- caching?: {
1086
- type: 'ephemeral';
1087
- ttl: '5m' | '1h';
1088
- };
1089
- };
1090
- type AnthropicToolChoice = {
1091
- type: 'auto' | 'any';
1092
- disable_parallel_tool_use?: boolean;
1093
- } | {
1094
- type: 'tool';
1095
- name: string;
1096
- disable_parallel_tool_use?: boolean;
1097
- };
1098
-
1099
1782
  declare class CacheControlValidator {
1100
1783
  private breakpointCount;
1101
1784
  private warnings;