@ai-sdk/anthropic 4.0.0-beta.2 → 4.0.0-beta.21
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.
- package/CHANGELOG.md +148 -4
- package/README.md +2 -0
- package/dist/index.d.mts +50 -38
- package/dist/index.d.ts +50 -38
- package/dist/index.js +1403 -1075
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1440 -1091
- package/dist/index.mjs.map +1 -1
- package/dist/internal/index.d.mts +64 -43
- package/dist/internal/index.d.ts +64 -43
- package/dist/internal/index.js +143 -25
- package/dist/internal/index.js.map +1 -1
- package/dist/internal/index.mjs +146 -23
- package/dist/internal/index.mjs.map +1 -1
- package/docs/05-anthropic.mdx +53 -6
- package/package.json +3 -5
- package/src/anthropic-files.ts +106 -0
- package/src/anthropic-messages-api.ts +4 -0
- package/src/anthropic-messages-language-model.ts +147 -38
- package/src/anthropic-messages-options.ts +29 -5
- package/src/anthropic-prepare-tools.ts +22 -10
- package/src/anthropic-provider.ts +38 -9
- package/src/convert-anthropic-messages-usage.ts +2 -2
- package/src/convert-to-anthropic-messages-prompt.ts +40 -18
- package/src/get-cache-control.ts +5 -5
- package/src/internal/index.ts +4 -1
- package/src/map-anthropic-stop-reason.ts +2 -2
- package/src/skills/anthropic-skills-api.ts +44 -0
- package/src/skills/anthropic-skills.ts +136 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
@@ -11,15 +11,20 @@ type AnthropicMessagesConfig = {
|
|
|
11
11
|
fetch?: FetchFunction;
|
|
12
12
|
buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
|
|
13
13
|
transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
|
|
14
|
-
supportedUrls?: () =>
|
|
14
|
+
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
15
15
|
generateId?: () => string;
|
|
16
16
|
/**
|
|
17
17
|
* When false, the model will use JSON tool fallback for structured outputs.
|
|
18
18
|
*/
|
|
19
19
|
supportsNativeStructuredOutput?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* When false, `strict` on tool definitions will be ignored and a warning emitted.
|
|
22
|
+
* Defaults to true.
|
|
23
|
+
*/
|
|
24
|
+
supportsStrictTools?: boolean;
|
|
20
25
|
};
|
|
21
|
-
declare class AnthropicMessagesLanguageModel implements
|
|
22
|
-
readonly specificationVersion = "
|
|
26
|
+
declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
27
|
+
readonly specificationVersion = "v4";
|
|
23
28
|
readonly modelId: AnthropicMessagesModelId;
|
|
24
29
|
private readonly config;
|
|
25
30
|
private readonly generateId;
|
|
@@ -38,9 +43,21 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
38
43
|
private buildRequestUrl;
|
|
39
44
|
private transformRequestBody;
|
|
40
45
|
private extractCitationDocuments;
|
|
41
|
-
doGenerate(options:
|
|
42
|
-
doStream(options:
|
|
46
|
+
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
47
|
+
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
43
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the capabilities of a Claude model that are used for defaults and feature selection.
|
|
51
|
+
*
|
|
52
|
+
* @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
|
|
53
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
54
|
+
*/
|
|
55
|
+
declare function getModelCapabilities(modelId: string): {
|
|
56
|
+
maxOutputTokens: number;
|
|
57
|
+
supportsStructuredOutput: boolean;
|
|
58
|
+
supportsAdaptiveThinking: boolean;
|
|
59
|
+
isKnownModel: boolean;
|
|
60
|
+
};
|
|
44
61
|
|
|
45
62
|
declare const anthropicTools: {
|
|
46
63
|
/**
|
|
@@ -52,7 +69,7 @@ declare const anthropicTools: {
|
|
|
52
69
|
bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
53
70
|
command: string;
|
|
54
71
|
restart?: boolean;
|
|
55
|
-
}, {}>;
|
|
72
|
+
}, {}, {}>;
|
|
56
73
|
/**
|
|
57
74
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
58
75
|
* allowing system operations, script execution, and command-line automation.
|
|
@@ -62,7 +79,7 @@ declare const anthropicTools: {
|
|
|
62
79
|
bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
63
80
|
command: string;
|
|
64
81
|
restart?: boolean;
|
|
65
|
-
}, {}>;
|
|
82
|
+
}, {}, {}>;
|
|
66
83
|
/**
|
|
67
84
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
68
85
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -82,7 +99,7 @@ declare const anthropicTools: {
|
|
|
82
99
|
type: "code_execution_output";
|
|
83
100
|
file_id: string;
|
|
84
101
|
}>;
|
|
85
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
102
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
86
103
|
code: string;
|
|
87
104
|
}, {
|
|
88
105
|
type: "code_execution_result";
|
|
@@ -93,7 +110,7 @@ declare const anthropicTools: {
|
|
|
93
110
|
type: "code_execution_output";
|
|
94
111
|
file_id: string;
|
|
95
112
|
}>;
|
|
96
|
-
}>;
|
|
113
|
+
}, {}>;
|
|
97
114
|
/**
|
|
98
115
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
99
116
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -166,7 +183,7 @@ declare const anthropicTools: {
|
|
|
166
183
|
new_start: number | null;
|
|
167
184
|
old_lines: number | null;
|
|
168
185
|
old_start: number | null;
|
|
169
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
186
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
170
187
|
type: "programmatic-tool-call";
|
|
171
188
|
code: string;
|
|
172
189
|
} | {
|
|
@@ -228,7 +245,7 @@ declare const anthropicTools: {
|
|
|
228
245
|
new_start: number | null;
|
|
229
246
|
old_lines: number | null;
|
|
230
247
|
old_start: number | null;
|
|
231
|
-
}>;
|
|
248
|
+
}, {}>;
|
|
232
249
|
/**
|
|
233
250
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
234
251
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -312,7 +329,7 @@ declare const anthropicTools: {
|
|
|
312
329
|
new_start: number | null;
|
|
313
330
|
old_lines: number | null;
|
|
314
331
|
old_start: number | null;
|
|
315
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
332
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
316
333
|
type: "programmatic-tool-call";
|
|
317
334
|
code: string;
|
|
318
335
|
} | {
|
|
@@ -383,7 +400,7 @@ declare const anthropicTools: {
|
|
|
383
400
|
new_start: number | null;
|
|
384
401
|
old_lines: number | null;
|
|
385
402
|
old_start: number | null;
|
|
386
|
-
}>;
|
|
403
|
+
}, {}>;
|
|
387
404
|
/**
|
|
388
405
|
* Claude can interact with computer environments through the computer use tool, which
|
|
389
406
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -402,7 +419,7 @@ declare const anthropicTools: {
|
|
|
402
419
|
displayWidthPx: number;
|
|
403
420
|
displayHeightPx: number;
|
|
404
421
|
displayNumber?: number;
|
|
405
|
-
}>;
|
|
422
|
+
}, {}>;
|
|
406
423
|
/**
|
|
407
424
|
* Claude can interact with computer environments through the computer use tool, which
|
|
408
425
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -425,7 +442,7 @@ declare const anthropicTools: {
|
|
|
425
442
|
displayWidthPx: number;
|
|
426
443
|
displayHeightPx: number;
|
|
427
444
|
displayNumber?: number;
|
|
428
|
-
}>;
|
|
445
|
+
}, {}>;
|
|
429
446
|
/**
|
|
430
447
|
* Claude can interact with computer environments through the computer use tool, which
|
|
431
448
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -455,7 +472,7 @@ declare const anthropicTools: {
|
|
|
455
472
|
displayHeightPx: number;
|
|
456
473
|
displayNumber?: number;
|
|
457
474
|
enableZoom?: boolean;
|
|
458
|
-
}>;
|
|
475
|
+
}, {}>;
|
|
459
476
|
/**
|
|
460
477
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
461
478
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -489,7 +506,7 @@ declare const anthropicTools: {
|
|
|
489
506
|
command: "rename";
|
|
490
507
|
old_path: string;
|
|
491
508
|
new_path: string;
|
|
492
|
-
}, {}>;
|
|
509
|
+
}, {}, {}>;
|
|
493
510
|
/**
|
|
494
511
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
495
512
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -506,7 +523,7 @@ declare const anthropicTools: {
|
|
|
506
523
|
insert_text?: string;
|
|
507
524
|
old_str?: string;
|
|
508
525
|
view_range?: number[];
|
|
509
|
-
}, {}>;
|
|
526
|
+
}, {}, {}>;
|
|
510
527
|
/**
|
|
511
528
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
512
529
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -523,7 +540,7 @@ declare const anthropicTools: {
|
|
|
523
540
|
insert_text?: string;
|
|
524
541
|
old_str?: string;
|
|
525
542
|
view_range?: number[];
|
|
526
|
-
}, {}>;
|
|
543
|
+
}, {}, {}>;
|
|
527
544
|
/**
|
|
528
545
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
529
546
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -542,7 +559,7 @@ declare const anthropicTools: {
|
|
|
542
559
|
insert_text?: string;
|
|
543
560
|
old_str?: string;
|
|
544
561
|
view_range?: number[];
|
|
545
|
-
}, {}>;
|
|
562
|
+
}, {}, {}>;
|
|
546
563
|
/**
|
|
547
564
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
548
565
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -565,7 +582,7 @@ declare const anthropicTools: {
|
|
|
565
582
|
view_range?: number[];
|
|
566
583
|
}, {
|
|
567
584
|
maxCharacters?: number;
|
|
568
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
585
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
569
586
|
command: "view" | "create" | "str_replace" | "insert";
|
|
570
587
|
path: string;
|
|
571
588
|
file_text?: string;
|
|
@@ -574,7 +591,7 @@ declare const anthropicTools: {
|
|
|
574
591
|
insert_text?: string;
|
|
575
592
|
old_str?: string;
|
|
576
593
|
view_range?: number[];
|
|
577
|
-
}, unknown>;
|
|
594
|
+
}, unknown, {}>;
|
|
578
595
|
/**
|
|
579
596
|
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
580
597
|
*
|
|
@@ -614,7 +631,7 @@ declare const anthropicTools: {
|
|
|
614
631
|
enabled: boolean;
|
|
615
632
|
};
|
|
616
633
|
maxContentTokens?: number;
|
|
617
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
634
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
618
635
|
url: string;
|
|
619
636
|
}, {
|
|
620
637
|
type: "web_fetch_result";
|
|
@@ -636,7 +653,7 @@ declare const anthropicTools: {
|
|
|
636
653
|
};
|
|
637
654
|
};
|
|
638
655
|
retrievedAt: string | null;
|
|
639
|
-
}>;
|
|
656
|
+
}, {}>;
|
|
640
657
|
/**
|
|
641
658
|
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
642
659
|
*
|
|
@@ -676,7 +693,7 @@ declare const anthropicTools: {
|
|
|
676
693
|
enabled: boolean;
|
|
677
694
|
};
|
|
678
695
|
maxContentTokens?: number;
|
|
679
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
696
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
680
697
|
url: string;
|
|
681
698
|
}, {
|
|
682
699
|
type: "web_fetch_result";
|
|
@@ -698,7 +715,7 @@ declare const anthropicTools: {
|
|
|
698
715
|
};
|
|
699
716
|
};
|
|
700
717
|
retrievedAt: string | null;
|
|
701
|
-
}>;
|
|
718
|
+
}, {}>;
|
|
702
719
|
/**
|
|
703
720
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
704
721
|
*
|
|
@@ -726,7 +743,7 @@ declare const anthropicTools: {
|
|
|
726
743
|
country?: string;
|
|
727
744
|
timezone?: string;
|
|
728
745
|
};
|
|
729
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
746
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
730
747
|
query: string;
|
|
731
748
|
}, {
|
|
732
749
|
type: "web_search_result";
|
|
@@ -734,7 +751,7 @@ declare const anthropicTools: {
|
|
|
734
751
|
title: string | null;
|
|
735
752
|
pageAge: string | null;
|
|
736
753
|
encryptedContent: string;
|
|
737
|
-
}[]>;
|
|
754
|
+
}[], {}>;
|
|
738
755
|
/**
|
|
739
756
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
740
757
|
*
|
|
@@ -762,7 +779,7 @@ declare const anthropicTools: {
|
|
|
762
779
|
country?: string;
|
|
763
780
|
timezone?: string;
|
|
764
781
|
};
|
|
765
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
782
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
766
783
|
query: string;
|
|
767
784
|
}, {
|
|
768
785
|
type: "web_search_result";
|
|
@@ -770,7 +787,7 @@ declare const anthropicTools: {
|
|
|
770
787
|
title: string | null;
|
|
771
788
|
pageAge: string | null;
|
|
772
789
|
encryptedContent: string;
|
|
773
|
-
}[]>;
|
|
790
|
+
}[], {}>;
|
|
774
791
|
/**
|
|
775
792
|
* Creates a tool search tool that uses regex patterns to find tools.
|
|
776
793
|
*
|
|
@@ -790,13 +807,13 @@ declare const anthropicTools: {
|
|
|
790
807
|
}, {
|
|
791
808
|
type: "tool_reference";
|
|
792
809
|
toolName: string;
|
|
793
|
-
}[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
810
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
794
811
|
pattern: string;
|
|
795
812
|
limit?: number;
|
|
796
813
|
}, {
|
|
797
814
|
type: "tool_reference";
|
|
798
815
|
toolName: string;
|
|
799
|
-
}[]>;
|
|
816
|
+
}[], {}>;
|
|
800
817
|
/**
|
|
801
818
|
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
802
819
|
*
|
|
@@ -816,13 +833,13 @@ declare const anthropicTools: {
|
|
|
816
833
|
}, {
|
|
817
834
|
type: "tool_reference";
|
|
818
835
|
toolName: string;
|
|
819
|
-
}[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
836
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
820
837
|
query: string;
|
|
821
838
|
limit?: number;
|
|
822
839
|
}, {
|
|
823
840
|
type: "tool_reference";
|
|
824
841
|
toolName: string;
|
|
825
|
-
}[]>;
|
|
842
|
+
}[], {}>;
|
|
826
843
|
};
|
|
827
844
|
|
|
828
845
|
type AnthropicCacheControl = {
|
|
@@ -934,27 +951,31 @@ type AnthropicToolChoice = {
|
|
|
934
951
|
declare class CacheControlValidator {
|
|
935
952
|
private breakpointCount;
|
|
936
953
|
private warnings;
|
|
937
|
-
getCacheControl(providerMetadata:
|
|
954
|
+
getCacheControl(providerMetadata: SharedV4ProviderMetadata | undefined, context: {
|
|
938
955
|
type: string;
|
|
939
956
|
canCache: boolean;
|
|
940
957
|
}): AnthropicCacheControl | undefined;
|
|
941
|
-
getWarnings():
|
|
958
|
+
getWarnings(): SharedV4Warning[];
|
|
942
959
|
}
|
|
943
960
|
|
|
944
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
|
|
945
|
-
tools:
|
|
946
|
-
toolChoice:
|
|
961
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, }: {
|
|
962
|
+
tools: LanguageModelV4CallOptions['tools'];
|
|
963
|
+
toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
|
|
947
964
|
disableParallelToolUse?: boolean;
|
|
948
965
|
cacheControlValidator?: CacheControlValidator;
|
|
949
966
|
/**
|
|
950
|
-
* Whether the model supports structured output.
|
|
967
|
+
* Whether the model supports native structured output response format.
|
|
951
968
|
*/
|
|
952
969
|
supportsStructuredOutput: boolean;
|
|
970
|
+
/**
|
|
971
|
+
* Whether the model supports strict mode on tool definitions.
|
|
972
|
+
*/
|
|
973
|
+
supportsStrictTools: boolean;
|
|
953
974
|
}): Promise<{
|
|
954
975
|
tools: Array<AnthropicTool> | undefined;
|
|
955
976
|
toolChoice: AnthropicToolChoice | undefined;
|
|
956
|
-
toolWarnings:
|
|
977
|
+
toolWarnings: SharedV4Warning[];
|
|
957
978
|
betas: Set<string>;
|
|
958
979
|
}>;
|
|
959
980
|
|
|
960
|
-
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
|
|
981
|
+
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };
|
package/dist/internal/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { LanguageModelV4, LanguageModelV4CallOptions, LanguageModelV4GenerateResult, LanguageModelV4StreamResult, JSONSchema7, SharedV4ProviderMetadata, SharedV4Warning } from '@ai-sdk/provider';
|
|
2
2
|
import * as _ai_sdk_provider_utils from '@ai-sdk/provider-utils';
|
|
3
3
|
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
|
|
4
4
|
|
|
@@ -11,15 +11,20 @@ type AnthropicMessagesConfig = {
|
|
|
11
11
|
fetch?: FetchFunction;
|
|
12
12
|
buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
|
|
13
13
|
transformRequestBody?: (args: Record<string, any>, betas: Set<string>) => Record<string, any>;
|
|
14
|
-
supportedUrls?: () =>
|
|
14
|
+
supportedUrls?: () => LanguageModelV4['supportedUrls'];
|
|
15
15
|
generateId?: () => string;
|
|
16
16
|
/**
|
|
17
17
|
* When false, the model will use JSON tool fallback for structured outputs.
|
|
18
18
|
*/
|
|
19
19
|
supportsNativeStructuredOutput?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* When false, `strict` on tool definitions will be ignored and a warning emitted.
|
|
22
|
+
* Defaults to true.
|
|
23
|
+
*/
|
|
24
|
+
supportsStrictTools?: boolean;
|
|
20
25
|
};
|
|
21
|
-
declare class AnthropicMessagesLanguageModel implements
|
|
22
|
-
readonly specificationVersion = "
|
|
26
|
+
declare class AnthropicMessagesLanguageModel implements LanguageModelV4 {
|
|
27
|
+
readonly specificationVersion = "v4";
|
|
23
28
|
readonly modelId: AnthropicMessagesModelId;
|
|
24
29
|
private readonly config;
|
|
25
30
|
private readonly generateId;
|
|
@@ -38,9 +43,21 @@ declare class AnthropicMessagesLanguageModel implements LanguageModelV3 {
|
|
|
38
43
|
private buildRequestUrl;
|
|
39
44
|
private transformRequestBody;
|
|
40
45
|
private extractCitationDocuments;
|
|
41
|
-
doGenerate(options:
|
|
42
|
-
doStream(options:
|
|
46
|
+
doGenerate(options: LanguageModelV4CallOptions): Promise<LanguageModelV4GenerateResult>;
|
|
47
|
+
doStream(options: LanguageModelV4CallOptions): Promise<LanguageModelV4StreamResult>;
|
|
43
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Returns the capabilities of a Claude model that are used for defaults and feature selection.
|
|
51
|
+
*
|
|
52
|
+
* @see https://docs.claude.com/en/docs/about-claude/models/overview#model-comparison-table
|
|
53
|
+
* @see https://platform.claude.com/docs/en/build-with-claude/structured-outputs
|
|
54
|
+
*/
|
|
55
|
+
declare function getModelCapabilities(modelId: string): {
|
|
56
|
+
maxOutputTokens: number;
|
|
57
|
+
supportsStructuredOutput: boolean;
|
|
58
|
+
supportsAdaptiveThinking: boolean;
|
|
59
|
+
isKnownModel: boolean;
|
|
60
|
+
};
|
|
44
61
|
|
|
45
62
|
declare const anthropicTools: {
|
|
46
63
|
/**
|
|
@@ -52,7 +69,7 @@ declare const anthropicTools: {
|
|
|
52
69
|
bash_20241022: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
53
70
|
command: string;
|
|
54
71
|
restart?: boolean;
|
|
55
|
-
}, {}>;
|
|
72
|
+
}, {}, {}>;
|
|
56
73
|
/**
|
|
57
74
|
* The bash tool enables Claude to execute shell commands in a persistent bash session,
|
|
58
75
|
* allowing system operations, script execution, and command-line automation.
|
|
@@ -62,7 +79,7 @@ declare const anthropicTools: {
|
|
|
62
79
|
bash_20250124: _ai_sdk_provider_utils.ProviderToolFactory<{
|
|
63
80
|
command: string;
|
|
64
81
|
restart?: boolean;
|
|
65
|
-
}, {}>;
|
|
82
|
+
}, {}, {}>;
|
|
66
83
|
/**
|
|
67
84
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
68
85
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -82,7 +99,7 @@ declare const anthropicTools: {
|
|
|
82
99
|
type: "code_execution_output";
|
|
83
100
|
file_id: string;
|
|
84
101
|
}>;
|
|
85
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
102
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
86
103
|
code: string;
|
|
87
104
|
}, {
|
|
88
105
|
type: "code_execution_result";
|
|
@@ -93,7 +110,7 @@ declare const anthropicTools: {
|
|
|
93
110
|
type: "code_execution_output";
|
|
94
111
|
file_id: string;
|
|
95
112
|
}>;
|
|
96
|
-
}>;
|
|
113
|
+
}, {}>;
|
|
97
114
|
/**
|
|
98
115
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
99
116
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -166,7 +183,7 @@ declare const anthropicTools: {
|
|
|
166
183
|
new_start: number | null;
|
|
167
184
|
old_lines: number | null;
|
|
168
185
|
old_start: number | null;
|
|
169
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
186
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
170
187
|
type: "programmatic-tool-call";
|
|
171
188
|
code: string;
|
|
172
189
|
} | {
|
|
@@ -228,7 +245,7 @@ declare const anthropicTools: {
|
|
|
228
245
|
new_start: number | null;
|
|
229
246
|
old_lines: number | null;
|
|
230
247
|
old_start: number | null;
|
|
231
|
-
}>;
|
|
248
|
+
}, {}>;
|
|
232
249
|
/**
|
|
233
250
|
* Claude can analyze data, create visualizations, perform complex calculations,
|
|
234
251
|
* run system commands, create and edit files, and process uploaded files directly within
|
|
@@ -312,7 +329,7 @@ declare const anthropicTools: {
|
|
|
312
329
|
new_start: number | null;
|
|
313
330
|
old_lines: number | null;
|
|
314
331
|
old_start: number | null;
|
|
315
|
-
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
332
|
+
}, {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
316
333
|
type: "programmatic-tool-call";
|
|
317
334
|
code: string;
|
|
318
335
|
} | {
|
|
@@ -383,7 +400,7 @@ declare const anthropicTools: {
|
|
|
383
400
|
new_start: number | null;
|
|
384
401
|
old_lines: number | null;
|
|
385
402
|
old_start: number | null;
|
|
386
|
-
}>;
|
|
403
|
+
}, {}>;
|
|
387
404
|
/**
|
|
388
405
|
* Claude can interact with computer environments through the computer use tool, which
|
|
389
406
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -402,7 +419,7 @@ declare const anthropicTools: {
|
|
|
402
419
|
displayWidthPx: number;
|
|
403
420
|
displayHeightPx: number;
|
|
404
421
|
displayNumber?: number;
|
|
405
|
-
}>;
|
|
422
|
+
}, {}>;
|
|
406
423
|
/**
|
|
407
424
|
* Claude can interact with computer environments through the computer use tool, which
|
|
408
425
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -425,7 +442,7 @@ declare const anthropicTools: {
|
|
|
425
442
|
displayWidthPx: number;
|
|
426
443
|
displayHeightPx: number;
|
|
427
444
|
displayNumber?: number;
|
|
428
|
-
}>;
|
|
445
|
+
}, {}>;
|
|
429
446
|
/**
|
|
430
447
|
* Claude can interact with computer environments through the computer use tool, which
|
|
431
448
|
* provides screenshot capabilities and mouse/keyboard control for autonomous desktop interaction.
|
|
@@ -455,7 +472,7 @@ declare const anthropicTools: {
|
|
|
455
472
|
displayHeightPx: number;
|
|
456
473
|
displayNumber?: number;
|
|
457
474
|
enableZoom?: boolean;
|
|
458
|
-
}>;
|
|
475
|
+
}, {}>;
|
|
459
476
|
/**
|
|
460
477
|
* The memory tool enables Claude to store and retrieve information across conversations through a memory file directory.
|
|
461
478
|
* Claude can create, read, update, and delete files that persist between sessions,
|
|
@@ -489,7 +506,7 @@ declare const anthropicTools: {
|
|
|
489
506
|
command: "rename";
|
|
490
507
|
old_path: string;
|
|
491
508
|
new_path: string;
|
|
492
|
-
}, {}>;
|
|
509
|
+
}, {}, {}>;
|
|
493
510
|
/**
|
|
494
511
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
495
512
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -506,7 +523,7 @@ declare const anthropicTools: {
|
|
|
506
523
|
insert_text?: string;
|
|
507
524
|
old_str?: string;
|
|
508
525
|
view_range?: number[];
|
|
509
|
-
}, {}>;
|
|
526
|
+
}, {}, {}>;
|
|
510
527
|
/**
|
|
511
528
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
512
529
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -523,7 +540,7 @@ declare const anthropicTools: {
|
|
|
523
540
|
insert_text?: string;
|
|
524
541
|
old_str?: string;
|
|
525
542
|
view_range?: number[];
|
|
526
|
-
}, {}>;
|
|
543
|
+
}, {}, {}>;
|
|
527
544
|
/**
|
|
528
545
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
529
546
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -542,7 +559,7 @@ declare const anthropicTools: {
|
|
|
542
559
|
insert_text?: string;
|
|
543
560
|
old_str?: string;
|
|
544
561
|
view_range?: number[];
|
|
545
|
-
}, {}>;
|
|
562
|
+
}, {}, {}>;
|
|
546
563
|
/**
|
|
547
564
|
* Claude can use an Anthropic-defined text editor tool to view and modify text files,
|
|
548
565
|
* helping you debug, fix, and improve your code or other text documents. This allows Claude
|
|
@@ -565,7 +582,7 @@ declare const anthropicTools: {
|
|
|
565
582
|
view_range?: number[];
|
|
566
583
|
}, {
|
|
567
584
|
maxCharacters?: number;
|
|
568
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
585
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
569
586
|
command: "view" | "create" | "str_replace" | "insert";
|
|
570
587
|
path: string;
|
|
571
588
|
file_text?: string;
|
|
@@ -574,7 +591,7 @@ declare const anthropicTools: {
|
|
|
574
591
|
insert_text?: string;
|
|
575
592
|
old_str?: string;
|
|
576
593
|
view_range?: number[];
|
|
577
|
-
}, unknown>;
|
|
594
|
+
}, unknown, {}>;
|
|
578
595
|
/**
|
|
579
596
|
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
580
597
|
*
|
|
@@ -614,7 +631,7 @@ declare const anthropicTools: {
|
|
|
614
631
|
enabled: boolean;
|
|
615
632
|
};
|
|
616
633
|
maxContentTokens?: number;
|
|
617
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
634
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
618
635
|
url: string;
|
|
619
636
|
}, {
|
|
620
637
|
type: "web_fetch_result";
|
|
@@ -636,7 +653,7 @@ declare const anthropicTools: {
|
|
|
636
653
|
};
|
|
637
654
|
};
|
|
638
655
|
retrievedAt: string | null;
|
|
639
|
-
}>;
|
|
656
|
+
}, {}>;
|
|
640
657
|
/**
|
|
641
658
|
* Creates a web fetch tool that gives Claude direct access to real-time web content.
|
|
642
659
|
*
|
|
@@ -676,7 +693,7 @@ declare const anthropicTools: {
|
|
|
676
693
|
enabled: boolean;
|
|
677
694
|
};
|
|
678
695
|
maxContentTokens?: number;
|
|
679
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
696
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
680
697
|
url: string;
|
|
681
698
|
}, {
|
|
682
699
|
type: "web_fetch_result";
|
|
@@ -698,7 +715,7 @@ declare const anthropicTools: {
|
|
|
698
715
|
};
|
|
699
716
|
};
|
|
700
717
|
retrievedAt: string | null;
|
|
701
|
-
}>;
|
|
718
|
+
}, {}>;
|
|
702
719
|
/**
|
|
703
720
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
704
721
|
*
|
|
@@ -726,7 +743,7 @@ declare const anthropicTools: {
|
|
|
726
743
|
country?: string;
|
|
727
744
|
timezone?: string;
|
|
728
745
|
};
|
|
729
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
746
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
730
747
|
query: string;
|
|
731
748
|
}, {
|
|
732
749
|
type: "web_search_result";
|
|
@@ -734,7 +751,7 @@ declare const anthropicTools: {
|
|
|
734
751
|
title: string | null;
|
|
735
752
|
pageAge: string | null;
|
|
736
753
|
encryptedContent: string;
|
|
737
|
-
}[]>;
|
|
754
|
+
}[], {}>;
|
|
738
755
|
/**
|
|
739
756
|
* Creates a web search tool that gives Claude direct access to real-time web content.
|
|
740
757
|
*
|
|
@@ -762,7 +779,7 @@ declare const anthropicTools: {
|
|
|
762
779
|
country?: string;
|
|
763
780
|
timezone?: string;
|
|
764
781
|
};
|
|
765
|
-
}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
782
|
+
}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
766
783
|
query: string;
|
|
767
784
|
}, {
|
|
768
785
|
type: "web_search_result";
|
|
@@ -770,7 +787,7 @@ declare const anthropicTools: {
|
|
|
770
787
|
title: string | null;
|
|
771
788
|
pageAge: string | null;
|
|
772
789
|
encryptedContent: string;
|
|
773
|
-
}[]>;
|
|
790
|
+
}[], {}>;
|
|
774
791
|
/**
|
|
775
792
|
* Creates a tool search tool that uses regex patterns to find tools.
|
|
776
793
|
*
|
|
@@ -790,13 +807,13 @@ declare const anthropicTools: {
|
|
|
790
807
|
}, {
|
|
791
808
|
type: "tool_reference";
|
|
792
809
|
toolName: string;
|
|
793
|
-
}[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
810
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
794
811
|
pattern: string;
|
|
795
812
|
limit?: number;
|
|
796
813
|
}, {
|
|
797
814
|
type: "tool_reference";
|
|
798
815
|
toolName: string;
|
|
799
|
-
}[]>;
|
|
816
|
+
}[], {}>;
|
|
800
817
|
/**
|
|
801
818
|
* Creates a tool search tool that uses BM25 (natural language) to find tools.
|
|
802
819
|
*
|
|
@@ -816,13 +833,13 @@ declare const anthropicTools: {
|
|
|
816
833
|
}, {
|
|
817
834
|
type: "tool_reference";
|
|
818
835
|
toolName: string;
|
|
819
|
-
}[], {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
836
|
+
}[], {}, {}>>[0]) => _ai_sdk_provider_utils.Tool<{
|
|
820
837
|
query: string;
|
|
821
838
|
limit?: number;
|
|
822
839
|
}, {
|
|
823
840
|
type: "tool_reference";
|
|
824
841
|
toolName: string;
|
|
825
|
-
}[]>;
|
|
842
|
+
}[], {}>;
|
|
826
843
|
};
|
|
827
844
|
|
|
828
845
|
type AnthropicCacheControl = {
|
|
@@ -934,27 +951,31 @@ type AnthropicToolChoice = {
|
|
|
934
951
|
declare class CacheControlValidator {
|
|
935
952
|
private breakpointCount;
|
|
936
953
|
private warnings;
|
|
937
|
-
getCacheControl(providerMetadata:
|
|
954
|
+
getCacheControl(providerMetadata: SharedV4ProviderMetadata | undefined, context: {
|
|
938
955
|
type: string;
|
|
939
956
|
canCache: boolean;
|
|
940
957
|
}): AnthropicCacheControl | undefined;
|
|
941
|
-
getWarnings():
|
|
958
|
+
getWarnings(): SharedV4Warning[];
|
|
942
959
|
}
|
|
943
960
|
|
|
944
|
-
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, }: {
|
|
945
|
-
tools:
|
|
946
|
-
toolChoice:
|
|
961
|
+
declare function prepareTools({ tools, toolChoice, disableParallelToolUse, cacheControlValidator, supportsStructuredOutput, supportsStrictTools, }: {
|
|
962
|
+
tools: LanguageModelV4CallOptions['tools'];
|
|
963
|
+
toolChoice: LanguageModelV4CallOptions['toolChoice'] | undefined;
|
|
947
964
|
disableParallelToolUse?: boolean;
|
|
948
965
|
cacheControlValidator?: CacheControlValidator;
|
|
949
966
|
/**
|
|
950
|
-
* Whether the model supports structured output.
|
|
967
|
+
* Whether the model supports native structured output response format.
|
|
951
968
|
*/
|
|
952
969
|
supportsStructuredOutput: boolean;
|
|
970
|
+
/**
|
|
971
|
+
* Whether the model supports strict mode on tool definitions.
|
|
972
|
+
*/
|
|
973
|
+
supportsStrictTools: boolean;
|
|
953
974
|
}): Promise<{
|
|
954
975
|
tools: Array<AnthropicTool> | undefined;
|
|
955
976
|
toolChoice: AnthropicToolChoice | undefined;
|
|
956
|
-
toolWarnings:
|
|
977
|
+
toolWarnings: SharedV4Warning[];
|
|
957
978
|
betas: Set<string>;
|
|
958
979
|
}>;
|
|
959
980
|
|
|
960
|
-
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, prepareTools };
|
|
981
|
+
export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools, getModelCapabilities, prepareTools };
|