@ai-sdk/anthropic 4.0.0-beta.3 → 4.0.0-beta.32

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,960 +0,0 @@
1
- import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
2
- import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
3
- import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
4
-
5
- type AnthropicMessagesModelId = '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' | (string & {});
6
-
7
- type AnthropicMessagesConfig = {
8
- provider: string;
9
- baseURL: string;
10
- headers: Resolvable<Record<string, string | undefined>>;
11
- fetch?: FetchFunction;
12
- buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
13
- transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
14
- supportedUrls?: () => LanguageModelV4['supportedUrls'];
15
- generateId?: () => string;
16
- /**
17
- * When false, the model will use JSON tool fallback for structured outputs.
18
- */
19
- supportsNativeStructuredOutput?: boolean;
20
- };
21
- declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
22
- readonly specificationVersion = "v4";
23
- readonly modelId: AnthropicMessagesModelId;
24
- private readonly config;
25
- private readonly generateId;
26
- constructor(modelId: AnthropicMessagesModelId, config: AnthropicMessagesConfig);
27
- supportsUrl(url: URL): boolean;
28
- get provider(): string;
29
- /**
30
- * Extracts the dynamic provider name from the config.provider string.
31
- * e.g., 'my-custom-anthropic.messages' -> 'my-custom-anthropic'
32
- */
33
- private get providerOptionsName();
34
- get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
35
- private getArgs;
36
- private getHeaders;
37
- private getBetasFromHeaders;
38
- private buildRequestUrl;
39
- private transformRequestBody;
40
- private extractCitationDocuments;
41
- doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
42
- doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
43
- }
44
-
45
- declare const anthropicTools: {
46
- /**
47
- * The bash tool enables Claude to execute shell commands in a persistent bash session,
48
- * allowing system operations, script execution, and command-line automation.
49
- *
50
- * Image results are supported.
51
- */
52
- bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
53
- command: string;
54
- restart?: boolean;
55
- }, {}>;
56
- /**
57
- * The bash tool enables Claude to execute shell commands in a persistent bash session,
58
- * allowing system operations, script execution, and command-line automation.
59
- *
60
- * Image results are supported.
61
- */
62
- bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
63
- command: string;
64
- restart?: boolean;
65
- }, {}>;
66
- /**
67
- * Claude can analyze data, create visualizations, perform complex calculations,
68
- * run system commands, create and edit files, and process uploaded files directly within
69
- * the API conversation.
70
- *
71
- * The code execution tool allows Claude to run Bash commands and manipulate files,
72
- * including writing code, in a secure, sandboxed environment.
73
- */
74
- codeExecution_20250522: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
75
- code: string;
76
- }, {
77
- type: "code_execution_result";
78
- stdout: string;
79
- stderr: string;
80
- return_code: number;
81
- content: Array<{
82
- type: "code_execution_output";
83
- file_id: string;
84
- }>;
85
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
86
- code: string;
87
- }, {
88
- type: "code_execution_result";
89
- stdout: string;
90
- stderr: string;
91
- return_code: number;
92
- content: Array<{
93
- type: "code_execution_output";
94
- file_id: string;
95
- }>;
96
- }>;
97
- /**
98
- * Claude can analyze data, create visualizations, perform complex calculations,
99
- * run system commands, create and edit files, and process uploaded files directly within
100
- * the API conversation.
101
- *
102
- * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
103
- * including writing code, in a secure, sandboxed environment.
104
- *
105
- * This is the latest version with enhanced Bash support and file operations.
106
- */
107
- codeExecution_20250825: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
108
- type: "programmatic-tool-call";
109
- code: string;
110
- } | {
111
- type: "bash_code_execution";
112
- command: string;
113
- } | {
114
- type: "text_editor_code_execution";
115
- command: "view";
116
- path: string;
117
- } | {
118
- type: "text_editor_code_execution";
119
- command: "create";
120
- path: string;
121
- file_text?: string | null;
122
- } | {
123
- type: "text_editor_code_execution";
124
- command: "str_replace";
125
- path: string;
126
- old_str: string;
127
- new_str: string;
128
- }, {
129
- type: "code_execution_result";
130
- stdout: string;
131
- stderr: string;
132
- return_code: number;
133
- content: Array<{
134
- type: "code_execution_output";
135
- file_id: string;
136
- }>;
137
- } | {
138
- type: "bash_code_execution_result";
139
- content: Array<{
140
- type: "bash_code_execution_output";
141
- file_id: string;
142
- }>;
143
- stdout: string;
144
- stderr: string;
145
- return_code: number;
146
- } | {
147
- type: "bash_code_execution_tool_result_error";
148
- error_code: string;
149
- } | {
150
- type: "text_editor_code_execution_tool_result_error";
151
- error_code: string;
152
- } | {
153
- type: "text_editor_code_execution_view_result";
154
- content: string;
155
- file_type: string;
156
- num_lines: number | null;
157
- start_line: number | null;
158
- total_lines: number | null;
159
- } | {
160
- type: "text_editor_code_execution_create_result";
161
- is_file_update: boolean;
162
- } | {
163
- type: "text_editor_code_execution_str_replace_result";
164
- lines: string[] | null;
165
- new_lines: number | null;
166
- new_start: number | null;
167
- old_lines: number | null;
168
- old_start: number | null;
169
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
170
- type: "programmatic-tool-call";
171
- code: string;
172
- } | {
173
- type: "bash_code_execution";
174
- command: string;
175
- } | {
176
- type: "text_editor_code_execution";
177
- command: "view";
178
- path: string;
179
- } | {
180
- type: "text_editor_code_execution";
181
- command: "create";
182
- path: string;
183
- file_text?: string | null;
184
- } | {
185
- type: "text_editor_code_execution";
186
- command: "str_replace";
187
- path: string;
188
- old_str: string;
189
- new_str: string;
190
- }, {
191
- type: "code_execution_result";
192
- stdout: string;
193
- stderr: string;
194
- return_code: number;
195
- content: Array<{
196
- type: "code_execution_output";
197
- file_id: string;
198
- }>;
199
- } | {
200
- type: "bash_code_execution_result";
201
- content: Array<{
202
- type: "bash_code_execution_output";
203
- file_id: string;
204
- }>;
205
- stdout: string;
206
- stderr: string;
207
- return_code: number;
208
- } | {
209
- type: "bash_code_execution_tool_result_error";
210
- error_code: string;
211
- } | {
212
- type: "text_editor_code_execution_tool_result_error";
213
- error_code: string;
214
- } | {
215
- type: "text_editor_code_execution_view_result";
216
- content: string;
217
- file_type: string;
218
- num_lines: number | null;
219
- start_line: number | null;
220
- total_lines: number | null;
221
- } | {
222
- type: "text_editor_code_execution_create_result";
223
- is_file_update: boolean;
224
- } | {
225
- type: "text_editor_code_execution_str_replace_result";
226
- lines: string[] | null;
227
- new_lines: number | null;
228
- new_start: number | null;
229
- old_lines: number | null;
230
- old_start: number | null;
231
- }>;
232
- /**
233
- * Claude can analyze data, create visualizations, perform complex calculations,
234
- * run system commands, create and edit files, and process uploaded files directly within
235
- * the API conversation.
236
- *
237
- * The code execution tool allows Claude to run both Python and Bash commands and manipulate files,
238
- * including writing code, in a secure, sandboxed environment.
239
- *
240
- * This is the recommended version. Does not require a beta header.
241
- *
242
- * Supported models: Claude Opus 4.6, Sonnet 4.6, Sonnet 4.5, Opus 4.5
243
- */
244
- codeExecution_20260120: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
245
- type: "programmatic-tool-call";
246
- code: string;
247
- } | {
248
- type: "bash_code_execution";
249
- command: string;
250
- } | {
251
- type: "text_editor_code_execution";
252
- command: "view";
253
- path: string;
254
- } | {
255
- type: "text_editor_code_execution";
256
- command: "create";
257
- path: string;
258
- file_text?: string | null;
259
- } | {
260
- type: "text_editor_code_execution";
261
- command: "str_replace";
262
- path: string;
263
- old_str: string;
264
- new_str: string;
265
- }, {
266
- type: "code_execution_result";
267
- stdout: string;
268
- stderr: string;
269
- return_code: number;
270
- content: Array<{
271
- type: "code_execution_output";
272
- file_id: string;
273
- }>;
274
- } | {
275
- type: "encrypted_code_execution_result";
276
- encrypted_stdout: string;
277
- stderr: string;
278
- return_code: number;
279
- content: Array<{
280
- type: "code_execution_output";
281
- file_id: string;
282
- }>;
283
- } | {
284
- type: "bash_code_execution_result";
285
- content: Array<{
286
- type: "bash_code_execution_output";
287
- file_id: string;
288
- }>;
289
- stdout: string;
290
- stderr: string;
291
- return_code: number;
292
- } | {
293
- type: "bash_code_execution_tool_result_error";
294
- error_code: string;
295
- } | {
296
- type: "text_editor_code_execution_tool_result_error";
297
- error_code: string;
298
- } | {
299
- type: "text_editor_code_execution_view_result";
300
- content: string;
301
- file_type: string;
302
- num_lines: number | null;
303
- start_line: number | null;
304
- total_lines: number | null;
305
- } | {
306
- type: "text_editor_code_execution_create_result";
307
- is_file_update: boolean;
308
- } | {
309
- type: "text_editor_code_execution_str_replace_result";
310
- lines: string[] | null;
311
- new_lines: number | null;
312
- new_start: number | null;
313
- old_lines: number | null;
314
- old_start: number | null;
315
- }, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
316
- type: "programmatic-tool-call";
317
- code: string;
318
- } | {
319
- type: "bash_code_execution";
320
- command: string;
321
- } | {
322
- type: "text_editor_code_execution";
323
- command: "view";
324
- path: string;
325
- } | {
326
- type: "text_editor_code_execution";
327
- command: "create";
328
- path: string;
329
- file_text?: string | null;
330
- } | {
331
- type: "text_editor_code_execution";
332
- command: "str_replace";
333
- path: string;
334
- old_str: string;
335
- new_str: string;
336
- }, {
337
- type: "code_execution_result";
338
- stdout: string;
339
- stderr: string;
340
- return_code: number;
341
- content: Array<{
342
- type: "code_execution_output";
343
- file_id: string;
344
- }>;
345
- } | {
346
- type: "encrypted_code_execution_result";
347
- encrypted_stdout: string;
348
- stderr: string;
349
- return_code: number;
350
- content: Array<{
351
- type: "code_execution_output";
352
- file_id: string;
353
- }>;
354
- } | {
355
- type: "bash_code_execution_result";
356
- content: Array<{
357
- type: "bash_code_execution_output";
358
- file_id: string;
359
- }>;
360
- stdout: string;
361
- stderr: string;
362
- return_code: number;
363
- } | {
364
- type: "bash_code_execution_tool_result_error";
365
- error_code: string;
366
- } | {
367
- type: "text_editor_code_execution_tool_result_error";
368
- error_code: string;
369
- } | {
370
- type: "text_editor_code_execution_view_result";
371
- content: string;
372
- file_type: string;
373
- num_lines: number | null;
374
- start_line: number | null;
375
- total_lines: number | null;
376
- } | {
377
- type: "text_editor_code_execution_create_result";
378
- is_file_update: boolean;
379
- } | {
380
- type: "text_editor_code_execution_str_replace_result";
381
- lines: string[] | null;
382
- new_lines: number | null;
383
- new_start: number | null;
384
- old_lines: number | null;
385
- old_start: number | null;
386
- }>;
387
- /**
388
- * Claude can interact with computer environments through the computer use tool, which
389
- * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
390
- *
391
- * Image results are supported.
392
- *
393
- * @param displayWidthPx - The width of the display being controlled by the model in pixels.
394
- * @param displayHeightPx - The height of the display being controlled by the model in pixels.
395
- * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
396
- */
397
- computer_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
398
- action: "key" | "type" | "mouse_move" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "screenshot" | "cursor_position";
399
- coordinate?: number[];
400
- text?: string;
401
- }, {
402
- displayWidthPx: number;
403
- displayHeightPx: number;
404
- displayNumber?: number;
405
- }>;
406
- /**
407
- * Claude can interact with computer environments through the computer use tool, which
408
- * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
409
- *
410
- * Image results are supported.
411
- *
412
- * @param displayWidthPx - The width of the display being controlled by the model in pixels.
413
- * @param displayHeightPx - The height of the display being controlled by the model in pixels.
414
- * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
415
- */
416
- computer_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
417
- action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot";
418
- coordinate?: [number, number];
419
- duration?: number;
420
- scroll_amount?: number;
421
- scroll_direction?: "up" | "down" | "left" | "right";
422
- start_coordinate?: [number, number];
423
- text?: string;
424
- }, {
425
- displayWidthPx: number;
426
- displayHeightPx: number;
427
- displayNumber?: number;
428
- }>;
429
- /**
430
- * Claude can interact with computer environments through the computer use tool, which
431
- * provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
432
- *
433
- * This version adds the zoom action for detailed screen region inspection.
434
- *
435
- * Image results are supported.
436
- *
437
- * Supported models: Claude Opus 4.5
438
- *
439
- * @param displayWidthPx - The width of the display being controlled by the model in pixels.
440
- * @param displayHeightPx - The height of the display being controlled by the model in pixels.
441
- * @param displayNumber - The display number to control (only relevant for X11 environments). If specified, the tool will be provided a display number in the tool definition.
442
- * @param enableZoom - Enable zoom action. Set to true to allow Claude to zoom into specific screen regions. Default: false.
443
- */
444
- computer_20251124: _ai_sdk_provider_utils.ProviderToolFactory<{
445
- action: "key" | "hold_key" | "type" | "cursor_position" | "mouse_move" | "left_mouse_down" | "left_mouse_up" | "left_click" | "left_click_drag" | "right_click" | "middle_click" | "double_click" | "triple_click" | "scroll" | "wait" | "screenshot" | "zoom";
446
- coordinate?: [number, number];
447
- duration?: number;
448
- region?: [number, number, number, number];
449
- scroll_amount?: number;
450
- scroll_direction?: "up" | "down" | "left" | "right";
451
- start_coordinate?: [number, number];
452
- text?: string;
453
- }, {
454
- displayWidthPx: number;
455
- displayHeightPx: number;
456
- displayNumber?: number;
457
- enableZoom?: boolean;
458
- }>;
459
- /**
460
- * The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
461
- * Claude can create, read, update, and delete files that persist between sessions,
462
- * allowing it to build knowledge over time without keeping everything in the context window.
463
- * The memory tool operates client-side—you control where and how the data is stored through your own infrastructure.
464
- *
465
- * Supported models: Claude Sonnet 4.5, Claude Sonnet 4, Claude Opus 4.1, Claude Opus 4.
466
- */
467
- memory_20250818: _ai_sdk_provider_utils.ProviderToolFactory<{
468
- command: "view";
469
- path: string;
470
- view_range?: [number, number];
471
- } | {
472
- command: "create";
473
- path: string;
474
- file_text: string;
475
- } | {
476
- command: "str_replace";
477
- path: string;
478
- old_str: string;
479
- new_str: string;
480
- } | {
481
- command: "insert";
482
- path: string;
483
- insert_line: number;
484
- insert_text: string;
485
- } | {
486
- command: "delete";
487
- path: string;
488
- } | {
489
- command: "rename";
490
- old_path: string;
491
- new_path: string;
492
- }, {}>;
493
- /**
494
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
495
- * helping you debug, fix, and improve your code or other text documents. This allows Claude
496
- * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
497
- *
498
- * Supported models: Claude Sonnet 3.5
499
- */
500
- textEditor_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
501
- command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
502
- path: string;
503
- file_text?: string;
504
- insert_line?: number;
505
- new_str?: string;
506
- insert_text?: string;
507
- old_str?: string;
508
- view_range?: number[];
509
- }, {}>;
510
- /**
511
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
512
- * helping you debug, fix, and improve your code or other text documents. This allows Claude
513
- * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
514
- *
515
- * Supported models: Claude Sonnet 3.7
516
- */
517
- textEditor_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
518
- command: "view" | "create" | "str_replace" | "insert" | "undo_edit";
519
- path: string;
520
- file_text?: string;
521
- insert_line?: number;
522
- new_str?: string;
523
- insert_text?: string;
524
- old_str?: string;
525
- view_range?: number[];
526
- }, {}>;
527
- /**
528
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
529
- * helping you debug, fix, and improve your code or other text documents. This allows Claude
530
- * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
531
- *
532
- * Note: This version does not support the "undo_edit" command.
533
- *
534
- * @deprecated Use textEditor_20250728 instead
535
- */
536
- textEditor_20250429: _ai_sdk_provider_utils.ProviderToolFactory<{
537
- command: "view" | "create" | "str_replace" | "insert";
538
- path: string;
539
- file_text?: string;
540
- insert_line?: number;
541
- new_str?: string;
542
- insert_text?: string;
543
- old_str?: string;
544
- view_range?: number[];
545
- }, {}>;
546
- /**
547
- * Claude can use an Anthropic-defined text editor tool to view and modify text files,
548
- * helping you debug, fix, and improve your code or other text documents. This allows Claude
549
- * to directly interact with your files, providing hands-on assistance rather than just suggesting changes.
550
- *
551
- * Note: This version does not support the "undo_edit" command and adds optional max_characters parameter.
552
- *
553
- * Supported models: Claude Sonnet 4, Opus 4, and Opus 4.1
554
- *
555
- * @param maxCharacters - Optional maximum number of characters to view in the file
556
- */
557
- textEditor_20250728: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactory<{
558
- command: "view" | "create" | "str_replace" | "insert";
559
- path: string;
560
- file_text?: string;
561
- insert_line?: number;
562
- new_str?: string;
563
- insert_text?: string;
564
- old_str?: string;
565
- view_range?: number[];
566
- }, {
567
- maxCharacters?: number;
568
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
569
- command: "view" | "create" | "str_replace" | "insert";
570
- path: string;
571
- file_text?: string;
572
- insert_line?: number;
573
- new_str?: string;
574
- insert_text?: string;
575
- old_str?: string;
576
- view_range?: number[];
577
- }, unknown>;
578
- /**
579
- * Creates a web fetch tool that gives Claude direct access to real-time web content.
580
- *
581
- * @param maxUses - The max_uses parameter limits the number of web fetches performed
582
- * @param allowedDomains - Only fetch from these domains
583
- * @param blockedDomains - Never fetch from these domains
584
- * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
585
- * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
586
- */
587
- webFetch_20250910: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
588
- url: string;
589
- }, {
590
- type: "web_fetch_result";
591
- url: string;
592
- content: {
593
- type: "document";
594
- title: string | null;
595
- citations?: {
596
- enabled: boolean;
597
- };
598
- source: {
599
- type: "base64";
600
- mediaType: "application/pdf";
601
- data: string;
602
- } | {
603
- type: "text";
604
- mediaType: "text/plain";
605
- data: string;
606
- };
607
- };
608
- retrievedAt: string | null;
609
- }, {
610
- maxUses?: number;
611
- allowedDomains?: string[];
612
- blockedDomains?: string[];
613
- citations?: {
614
- enabled: boolean;
615
- };
616
- maxContentTokens?: number;
617
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
618
- url: string;
619
- }, {
620
- type: "web_fetch_result";
621
- url: string;
622
- content: {
623
- type: "document";
624
- title: string | null;
625
- citations?: {
626
- enabled: boolean;
627
- };
628
- source: {
629
- type: "base64";
630
- mediaType: "application/pdf";
631
- data: string;
632
- } | {
633
- type: "text";
634
- mediaType: "text/plain";
635
- data: string;
636
- };
637
- };
638
- retrievedAt: string | null;
639
- }>;
640
- /**
641
- * Creates a web fetch tool that gives Claude direct access to real-time web content.
642
- *
643
- * @param maxUses - The max_uses parameter limits the number of web fetches performed
644
- * @param allowedDomains - Only fetch from these domains
645
- * @param blockedDomains - Never fetch from these domains
646
- * @param citations - Unlike web search where citations are always enabled, citations are optional for web fetch. Set "citations": {"enabled": true} to enable Claude to cite specific passages from fetched documents.
647
- * @param maxContentTokens - The max_content_tokens parameter limits the amount of content that will be included in the context.
648
- */
649
- webFetch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
650
- url: string;
651
- }, {
652
- type: "web_fetch_result";
653
- url: string;
654
- content: {
655
- type: "document";
656
- title: string | null;
657
- citations?: {
658
- enabled: boolean;
659
- };
660
- source: {
661
- type: "base64";
662
- mediaType: "application/pdf";
663
- data: string;
664
- } | {
665
- type: "text";
666
- mediaType: "text/plain";
667
- data: string;
668
- };
669
- };
670
- retrievedAt: string | null;
671
- }, {
672
- maxUses?: number;
673
- allowedDomains?: string[];
674
- blockedDomains?: string[];
675
- citations?: {
676
- enabled: boolean;
677
- };
678
- maxContentTokens?: number;
679
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
680
- url: string;
681
- }, {
682
- type: "web_fetch_result";
683
- url: string;
684
- content: {
685
- type: "document";
686
- title: string | null;
687
- citations?: {
688
- enabled: boolean;
689
- };
690
- source: {
691
- type: "base64";
692
- mediaType: "application/pdf";
693
- data: string;
694
- } | {
695
- type: "text";
696
- mediaType: "text/plain";
697
- data: string;
698
- };
699
- };
700
- retrievedAt: string | null;
701
- }>;
702
- /**
703
- * Creates a web search tool that gives Claude direct access to real-time web content.
704
- *
705
- * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
706
- * @param allowedDomains - Optional list of domains that Claude is allowed to search.
707
- * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
708
- * @param userLocation - Optional user location information to provide geographically relevant search results.
709
- */
710
- webSearch_20250305: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
711
- query: string;
712
- }, {
713
- type: "web_search_result";
714
- url: string;
715
- title: string | null;
716
- pageAge: string | null;
717
- encryptedContent: string;
718
- }[], {
719
- maxUses?: number;
720
- allowedDomains?: string[];
721
- blockedDomains?: string[];
722
- userLocation?: {
723
- type: "approximate";
724
- city?: string;
725
- region?: string;
726
- country?: string;
727
- timezone?: string;
728
- };
729
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
730
- query: string;
731
- }, {
732
- type: "web_search_result";
733
- url: string;
734
- title: string | null;
735
- pageAge: string | null;
736
- encryptedContent: string;
737
- }[]>;
738
- /**
739
- * Creates a web search tool that gives Claude direct access to real-time web content.
740
- *
741
- * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
742
- * @param allowedDomains - Optional list of domains that Claude is allowed to search.
743
- * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
744
- * @param userLocation - Optional user location information to provide geographically relevant search results.
745
- */
746
- webSearch_20260209: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
747
- query: string;
748
- }, {
749
- type: "web_search_result";
750
- url: string;
751
- title: string | null;
752
- pageAge: string | null;
753
- encryptedContent: string;
754
- }[], {
755
- maxUses?: number;
756
- allowedDomains?: string[];
757
- blockedDomains?: string[];
758
- userLocation?: {
759
- type: "approximate";
760
- city?: string;
761
- region?: string;
762
- country?: string;
763
- timezone?: string;
764
- };
765
- }>>[0]) => _ai_sdk_provider_utils.Tool<{
766
- query: string;
767
- }, {
768
- type: "web_search_result";
769
- url: string;
770
- title: string | null;
771
- pageAge: string | null;
772
- encryptedContent: string;
773
- }[]>;
774
- /**
775
- * Creates a tool search tool that uses regex patterns to find tools.
776
- *
777
- * The tool search tool enables Claude to work with hundreds or thousands of tools
778
- * by dynamically discovering and loading them on-demand. Instead of loading all
779
- * tool definitions into the context window upfront, Claude searches your tool
780
- * catalog and loads only the tools it needs.
781
- *
782
- * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
783
- * to mark them for deferred loading.
784
- *
785
- * Supported models: Claude Opus 4.5, Claude Sonnet 4.5
786
- */
787
- toolSearchRegex_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
788
- pattern: string;
789
- limit?: number;
790
- }, {
791
- type: "tool_reference";
792
- toolName: string;
793
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
794
- pattern: string;
795
- limit?: number;
796
- }, {
797
- type: "tool_reference";
798
- toolName: string;
799
- }[]>;
800
- /**
801
- * Creates a tool search tool that uses BM25 (natural language) to find tools.
802
- *
803
- * The tool search tool enables Claude to work with hundreds or thousands of tools
804
- * by dynamically discovering and loading them on-demand. Instead of loading all
805
- * tool definitions into the context window upfront, Claude searches your tool
806
- * catalog and loads only the tools it needs.
807
- *
808
- * Use `providerOptions: { anthropic: { deferLoading: true } }` on other tools
809
- * to mark them for deferred loading.
810
- *
811
- * Supported models: Claude Opus 4.5, Claude Sonnet 4.5
812
- */
813
- toolSearchBm25_20251119: (args?: Parameters<_ai_sdk_provider_utils.ProviderToolFactoryWithOutputSchema<{
814
- query: string;
815
- limit?: number;
816
- }, {
817
- type: "tool_reference";
818
- toolName: string;
819
- }[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
820
- query: string;
821
- limit?: number;
822
- }, {
823
- type: "tool_reference";
824
- toolName: string;
825
- }[]>;
826
- };
827
-
828
- type AnthropicCacheControl = {
829
- type: 'ephemeral';
830
- ttl?: '5m' | '1h';
831
- };
832
- type AnthropicTool = {
833
- name: string;
834
- description: string | undefined;
835
- input_schema: JSONSchema7;
836
- cache_control: AnthropicCacheControl | undefined;
837
- eager_input_streaming?: boolean;
838
- strict?: boolean;
839
- /**
840
- * When true, this tool is deferred and will only be loaded when
841
- * discovered via the tool search tool.
842
- */
843
- defer_loading?: boolean;
844
- /**
845
- * Programmatic tool calling: specifies which server-executed tools
846
- * are allowed to call this tool. When set, only the specified callers
847
- * can invoke this tool programmatically.
848
- *
849
- * @example ['code_execution_20250825']
850
- */
851
- allowed_callers?: Array<'direct' | 'code_execution_20250825' | 'code_execution_20260120'>;
852
- } | {
853
- type: 'code_execution_20250522';
854
- name: string;
855
- cache_control: AnthropicCacheControl | undefined;
856
- } | {
857
- type: 'code_execution_20250825';
858
- name: string;
859
- } | {
860
- type: 'code_execution_20260120';
861
- name: string;
862
- } | {
863
- name: string;
864
- type: 'computer_20250124' | 'computer_20241022';
865
- display_width_px: number;
866
- display_height_px: number;
867
- display_number: number;
868
- cache_control: AnthropicCacheControl | undefined;
869
- } | {
870
- name: string;
871
- type: 'computer_20251124';
872
- display_width_px: number;
873
- display_height_px: number;
874
- display_number: number;
875
- enable_zoom?: boolean;
876
- cache_control: AnthropicCacheControl | undefined;
877
- } | {
878
- name: string;
879
- type: 'text_editor_20250124' | 'text_editor_20241022' | 'text_editor_20250429';
880
- cache_control: AnthropicCacheControl | undefined;
881
- } | {
882
- name: string;
883
- type: 'text_editor_20250728';
884
- max_characters?: number;
885
- cache_control: AnthropicCacheControl | undefined;
886
- } | {
887
- name: string;
888
- type: 'bash_20250124' | 'bash_20241022';
889
- cache_control: AnthropicCacheControl | undefined;
890
- } | {
891
- name: string;
892
- type: 'memory_20250818';
893
- } | {
894
- type: 'web_fetch_20250910' | 'web_fetch_20260209';
895
- name: string;
896
- max_uses?: number;
897
- allowed_domains?: string[];
898
- blocked_domains?: string[];
899
- citations?: {
900
- enabled: boolean;
901
- };
902
- max_content_tokens?: number;
903
- cache_control: AnthropicCacheControl | undefined;
904
- } | {
905
- type: 'web_search_20250305' | 'web_search_20260209';
906
- name: string;
907
- max_uses?: number;
908
- allowed_domains?: string[];
909
- blocked_domains?: string[];
910
- user_location?: {
911
- type: 'approximate';
912
- city?: string;
913
- region?: string;
914
- country?: string;
915
- timezone?: string;
916
- };
917
- cache_control: AnthropicCacheControl | undefined;
918
- } | {
919
- type: 'tool_search_tool_regex_20251119';
920
- name: string;
921
- } | {
922
- type: 'tool_search_tool_bm25_20251119';
923
- name: string;
924
- };
925
- type AnthropicToolChoice = {
926
- type: 'auto' | 'any';
927
- disable_parallel_tool_use?: boolean;
928
- } | {
929
- type: 'tool';
930
- name: string;
931
- disable_parallel_tool_use?: boolean;
932
- };
933
-
934
- declare class CacheControlValidator {
935
- private breakpointCount;
936
- private warnings;
937
- getCacheControl(providerMetadata: SharedV4ProviderMetadata | undefined, context: {
938
- type: string;
939
- canCache: boolean;
940
- }): AnthropicCacheControl | undefined;
941
- getWarnings(): SharedV4Warning[];
942
- }
943
-
944
- declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
945
- tools: LanguageModelV4CallOptions['tools'];
946
- toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
947
- disableParallelToolUse?: boolean;
948
- cacheControlValidator?: CacheControlValidator;
949
- /**
950
- * Whether the model supports structured output.
951
- */
952
- supportsStructuredOutput: boolean;
953
- }): Promise<{
954
- tools: Array<AnthropicTool> | undefined;
955
- toolChoice: AnthropicToolChoice | undefined;
956
- toolWarnings: SharedV4Warning[];
957
- betas: Set<string>;
958
- }>;
959
-
960
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };