@ai-sdk/anthropic 2.0.0-alpha.13 → 2.0.0-alpha.14

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @ai-sdk/anthropic
2
2
 
3
+ ## 2.0.0-alpha.14
4
+
5
+ ### Patch Changes
6
+
7
+ - 2e13791: feat(anthropic): add server-side web search support
8
+ - 6392f60: fix(anthropic): resolve web search API validation errors with partial location + provider output
9
+ - Updated dependencies [b5da06a]
10
+ - Updated dependencies [63f9e9b]
11
+ - Updated dependencies [2e13791]
12
+ - @ai-sdk/provider@2.0.0-alpha.14
13
+ - @ai-sdk/provider-utils@3.0.0-alpha.14
14
+
3
15
  ## 2.0.0-alpha.13
4
16
 
5
17
  ### Patch Changes
package/dist/index.d.mts CHANGED
@@ -4,11 +4,6 @@ import { ToolResultContent, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
5
  type AnthropicMessagesModelId = 'claude-4-opus-20250514' | 'claude-4-sonnet-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
6
  declare const anthropicProviderOptions: z.ZodObject<{
7
- /**
8
- Include reasoning content in requests sent to the model. Defaults to `true`.
9
-
10
- If you are experiencing issues with the model handling requests involving
11
- */
12
7
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
13
8
  thinking: z.ZodOptional<z.ZodObject<{
14
9
  type: z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
@@ -20,107 +15,18 @@ declare const anthropicProviderOptions: z.ZodObject<{
20
15
  type: "enabled" | "disabled";
21
16
  budgetTokens?: number | undefined;
22
17
  }>>;
23
- /**
24
- * Web search tool configuration for Claude models that support it.
25
- * When provided, automatically adds the web search tool to the request.
26
- */
27
- webSearch: z.ZodOptional<z.ZodObject<{
28
- /**
29
- * Limit the number of searches per request (optional)
30
- * Defaults to 5 if not specified
31
- */
32
- maxUses: z.ZodOptional<z.ZodNumber>;
33
- /**
34
- * Only include results from these domains (optional)
35
- * Cannot be used with blockedDomains
36
- */
37
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
- /**
39
- * Never include results from these domains (optional)
40
- * Cannot be used with allowedDomains
41
- */
42
- blockedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
- /**
44
- * Localize search results based on user location (optional)
45
- */
46
- userLocation: z.ZodOptional<z.ZodObject<{
47
- type: z.ZodLiteral<"approximate">;
48
- city: z.ZodOptional<z.ZodString>;
49
- region: z.ZodOptional<z.ZodString>;
50
- country: z.ZodString;
51
- timezone: z.ZodOptional<z.ZodString>;
52
- }, "strip", z.ZodTypeAny, {
53
- type: "approximate";
54
- country: string;
55
- city?: string | undefined;
56
- region?: string | undefined;
57
- timezone?: string | undefined;
58
- }, {
59
- type: "approximate";
60
- country: string;
61
- city?: string | undefined;
62
- region?: string | undefined;
63
- timezone?: string | undefined;
64
- }>>;
65
- }, "strip", z.ZodTypeAny, {
66
- maxUses?: number | undefined;
67
- allowedDomains?: string[] | undefined;
68
- blockedDomains?: string[] | undefined;
69
- userLocation?: {
70
- type: "approximate";
71
- country: string;
72
- city?: string | undefined;
73
- region?: string | undefined;
74
- timezone?: string | undefined;
75
- } | undefined;
76
- }, {
77
- maxUses?: number | undefined;
78
- allowedDomains?: string[] | undefined;
79
- blockedDomains?: string[] | undefined;
80
- userLocation?: {
81
- type: "approximate";
82
- country: string;
83
- city?: string | undefined;
84
- region?: string | undefined;
85
- timezone?: string | undefined;
86
- } | undefined;
87
- }>>;
88
18
  }, "strip", z.ZodTypeAny, {
89
19
  sendReasoning?: boolean | undefined;
90
20
  thinking?: {
91
21
  type: "enabled" | "disabled";
92
22
  budgetTokens?: number | undefined;
93
23
  } | undefined;
94
- webSearch?: {
95
- maxUses?: number | undefined;
96
- allowedDomains?: string[] | undefined;
97
- blockedDomains?: string[] | undefined;
98
- userLocation?: {
99
- type: "approximate";
100
- country: string;
101
- city?: string | undefined;
102
- region?: string | undefined;
103
- timezone?: string | undefined;
104
- } | undefined;
105
- } | undefined;
106
24
  }, {
107
25
  sendReasoning?: boolean | undefined;
108
26
  thinking?: {
109
27
  type: "enabled" | "disabled";
110
28
  budgetTokens?: number | undefined;
111
29
  } | undefined;
112
- webSearch?: {
113
- maxUses?: number | undefined;
114
- allowedDomains?: string[] | undefined;
115
- blockedDomains?: string[] | undefined;
116
- userLocation?: {
117
- type: "approximate";
118
- country: string;
119
- city?: string | undefined;
120
- region?: string | undefined;
121
- timezone?: string | undefined;
122
- } | undefined;
123
- } | undefined;
124
30
  }>;
125
31
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
126
32
 
@@ -157,7 +63,7 @@ declare function bashTool_20241022<RESULT>(options?: {
157
63
  }, RESULT>;
158
64
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
159
65
  }): {
160
- type: 'provider-defined';
66
+ type: 'provider-defined-client';
161
67
  id: 'anthropic.bash_20241022';
162
68
  args: {};
163
69
  parameters: typeof Bash20241022Parameters;
@@ -194,7 +100,7 @@ declare function bashTool_20250124<RESULT>(options?: {
194
100
  }, RESULT>;
195
101
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
196
102
  }): {
197
- type: 'provider-defined';
103
+ type: 'provider-defined-client';
198
104
  id: 'anthropic.bash_20250124';
199
105
  args: {};
200
106
  parameters: typeof Bash20250124Parameters;
@@ -266,7 +172,7 @@ declare function textEditorTool_20241022<RESULT>(options?: {
266
172
  }, RESULT>;
267
173
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
268
174
  }): {
269
- type: 'provider-defined';
175
+ type: 'provider-defined-client';
270
176
  id: 'anthropic.text_editor_20241022';
271
177
  args: {};
272
178
  parameters: typeof TextEditor20241022Parameters;
@@ -338,7 +244,7 @@ declare function textEditorTool_20250124<RESULT>(options?: {
338
244
  }, RESULT>;
339
245
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
340
246
  }): {
341
- type: 'provider-defined';
247
+ type: 'provider-defined-client';
342
248
  id: 'anthropic.text_editor_20250124';
343
249
  args: {};
344
250
  parameters: typeof TextEditor20250124Parameters;
@@ -400,7 +306,7 @@ declare function computerTool_20241022<RESULT>(options: {
400
306
  }, RESULT>;
401
307
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
402
308
  }): {
403
- type: 'provider-defined';
309
+ type: 'provider-defined-client';
404
310
  id: 'anthropic.computer_20241022';
405
311
  args: {};
406
312
  parameters: typeof Computer20241022Parameters;
@@ -495,13 +401,50 @@ declare function computerTool_20250124<RESULT>(options: {
495
401
  }, RESULT>;
496
402
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
497
403
  }): {
498
- type: 'provider-defined';
404
+ type: 'provider-defined-client';
499
405
  id: 'anthropic.computer_20250124';
500
406
  args: {};
501
407
  parameters: typeof Computer20250124Parameters;
502
408
  execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
503
409
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
504
410
  };
411
+ /**
412
+ * Creates a web search tool that gives Claude direct access to real-time web content.
413
+ * Must have name "web_search".
414
+ *
415
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
416
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
417
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
418
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
419
+ */
420
+ declare function webSearchTool_20250305(options?: {
421
+ maxUses?: number;
422
+ allowedDomains?: string[];
423
+ blockedDomains?: string[];
424
+ userLocation?: {
425
+ type: 'approximate';
426
+ city?: string;
427
+ region?: string;
428
+ country?: string;
429
+ timezone?: string;
430
+ };
431
+ }): {
432
+ type: 'provider-defined-server';
433
+ id: 'anthropic.web_search_20250305';
434
+ name: 'web_search';
435
+ args: {
436
+ maxUses?: number;
437
+ allowedDomains?: string[];
438
+ blockedDomains?: string[];
439
+ userLocation?: {
440
+ type: 'approximate';
441
+ city?: string;
442
+ region?: string;
443
+ country?: string;
444
+ timezone?: string;
445
+ };
446
+ };
447
+ };
505
448
  declare const anthropicTools: {
506
449
  bash_20241022: typeof bashTool_20241022;
507
450
  bash_20250124: typeof bashTool_20250124;
@@ -509,6 +452,7 @@ declare const anthropicTools: {
509
452
  textEditor_20250124: typeof textEditorTool_20250124;
510
453
  computer_20241022: typeof computerTool_20241022;
511
454
  computer_20250124: typeof computerTool_20250124;
455
+ webSearch_20250305: typeof webSearchTool_20250305;
512
456
  };
513
457
 
514
458
  interface AnthropicProvider extends ProviderV2 {
package/dist/index.d.ts CHANGED
@@ -4,11 +4,6 @@ import { ToolResultContent, FetchFunction } from '@ai-sdk/provider-utils';
4
4
 
5
5
  type AnthropicMessagesModelId = 'claude-4-opus-20250514' | 'claude-4-sonnet-20250514' | 'claude-3-7-sonnet-20250219' | 'claude-3-5-sonnet-latest' | 'claude-3-5-sonnet-20241022' | 'claude-3-5-sonnet-20240620' | 'claude-3-5-haiku-latest' | 'claude-3-5-haiku-20241022' | 'claude-3-opus-latest' | 'claude-3-opus-20240229' | 'claude-3-sonnet-20240229' | 'claude-3-haiku-20240307' | (string & {});
6
6
  declare const anthropicProviderOptions: z.ZodObject<{
7
- /**
8
- Include reasoning content in requests sent to the model. Defaults to `true`.
9
-
10
- If you are experiencing issues with the model handling requests involving
11
- */
12
7
  sendReasoning: z.ZodOptional<z.ZodBoolean>;
13
8
  thinking: z.ZodOptional<z.ZodObject<{
14
9
  type: z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>;
@@ -20,107 +15,18 @@ declare const anthropicProviderOptions: z.ZodObject<{
20
15
  type: "enabled" | "disabled";
21
16
  budgetTokens?: number | undefined;
22
17
  }>>;
23
- /**
24
- * Web search tool configuration for Claude models that support it.
25
- * When provided, automatically adds the web search tool to the request.
26
- */
27
- webSearch: z.ZodOptional<z.ZodObject<{
28
- /**
29
- * Limit the number of searches per request (optional)
30
- * Defaults to 5 if not specified
31
- */
32
- maxUses: z.ZodOptional<z.ZodNumber>;
33
- /**
34
- * Only include results from these domains (optional)
35
- * Cannot be used with blockedDomains
36
- */
37
- allowedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
38
- /**
39
- * Never include results from these domains (optional)
40
- * Cannot be used with allowedDomains
41
- */
42
- blockedDomains: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
43
- /**
44
- * Localize search results based on user location (optional)
45
- */
46
- userLocation: z.ZodOptional<z.ZodObject<{
47
- type: z.ZodLiteral<"approximate">;
48
- city: z.ZodOptional<z.ZodString>;
49
- region: z.ZodOptional<z.ZodString>;
50
- country: z.ZodString;
51
- timezone: z.ZodOptional<z.ZodString>;
52
- }, "strip", z.ZodTypeAny, {
53
- type: "approximate";
54
- country: string;
55
- city?: string | undefined;
56
- region?: string | undefined;
57
- timezone?: string | undefined;
58
- }, {
59
- type: "approximate";
60
- country: string;
61
- city?: string | undefined;
62
- region?: string | undefined;
63
- timezone?: string | undefined;
64
- }>>;
65
- }, "strip", z.ZodTypeAny, {
66
- maxUses?: number | undefined;
67
- allowedDomains?: string[] | undefined;
68
- blockedDomains?: string[] | undefined;
69
- userLocation?: {
70
- type: "approximate";
71
- country: string;
72
- city?: string | undefined;
73
- region?: string | undefined;
74
- timezone?: string | undefined;
75
- } | undefined;
76
- }, {
77
- maxUses?: number | undefined;
78
- allowedDomains?: string[] | undefined;
79
- blockedDomains?: string[] | undefined;
80
- userLocation?: {
81
- type: "approximate";
82
- country: string;
83
- city?: string | undefined;
84
- region?: string | undefined;
85
- timezone?: string | undefined;
86
- } | undefined;
87
- }>>;
88
18
  }, "strip", z.ZodTypeAny, {
89
19
  sendReasoning?: boolean | undefined;
90
20
  thinking?: {
91
21
  type: "enabled" | "disabled";
92
22
  budgetTokens?: number | undefined;
93
23
  } | undefined;
94
- webSearch?: {
95
- maxUses?: number | undefined;
96
- allowedDomains?: string[] | undefined;
97
- blockedDomains?: string[] | undefined;
98
- userLocation?: {
99
- type: "approximate";
100
- country: string;
101
- city?: string | undefined;
102
- region?: string | undefined;
103
- timezone?: string | undefined;
104
- } | undefined;
105
- } | undefined;
106
24
  }, {
107
25
  sendReasoning?: boolean | undefined;
108
26
  thinking?: {
109
27
  type: "enabled" | "disabled";
110
28
  budgetTokens?: number | undefined;
111
29
  } | undefined;
112
- webSearch?: {
113
- maxUses?: number | undefined;
114
- allowedDomains?: string[] | undefined;
115
- blockedDomains?: string[] | undefined;
116
- userLocation?: {
117
- type: "approximate";
118
- country: string;
119
- city?: string | undefined;
120
- region?: string | undefined;
121
- timezone?: string | undefined;
122
- } | undefined;
123
- } | undefined;
124
30
  }>;
125
31
  type AnthropicProviderOptions = z.infer<typeof anthropicProviderOptions>;
126
32
 
@@ -157,7 +63,7 @@ declare function bashTool_20241022<RESULT>(options?: {
157
63
  }, RESULT>;
158
64
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
159
65
  }): {
160
- type: 'provider-defined';
66
+ type: 'provider-defined-client';
161
67
  id: 'anthropic.bash_20241022';
162
68
  args: {};
163
69
  parameters: typeof Bash20241022Parameters;
@@ -194,7 +100,7 @@ declare function bashTool_20250124<RESULT>(options?: {
194
100
  }, RESULT>;
195
101
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
196
102
  }): {
197
- type: 'provider-defined';
103
+ type: 'provider-defined-client';
198
104
  id: 'anthropic.bash_20250124';
199
105
  args: {};
200
106
  parameters: typeof Bash20250124Parameters;
@@ -266,7 +172,7 @@ declare function textEditorTool_20241022<RESULT>(options?: {
266
172
  }, RESULT>;
267
173
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
268
174
  }): {
269
- type: 'provider-defined';
175
+ type: 'provider-defined-client';
270
176
  id: 'anthropic.text_editor_20241022';
271
177
  args: {};
272
178
  parameters: typeof TextEditor20241022Parameters;
@@ -338,7 +244,7 @@ declare function textEditorTool_20250124<RESULT>(options?: {
338
244
  }, RESULT>;
339
245
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
340
246
  }): {
341
- type: 'provider-defined';
247
+ type: 'provider-defined-client';
342
248
  id: 'anthropic.text_editor_20250124';
343
249
  args: {};
344
250
  parameters: typeof TextEditor20250124Parameters;
@@ -400,7 +306,7 @@ declare function computerTool_20241022<RESULT>(options: {
400
306
  }, RESULT>;
401
307
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
402
308
  }): {
403
- type: 'provider-defined';
309
+ type: 'provider-defined-client';
404
310
  id: 'anthropic.computer_20241022';
405
311
  args: {};
406
312
  parameters: typeof Computer20241022Parameters;
@@ -495,13 +401,50 @@ declare function computerTool_20250124<RESULT>(options: {
495
401
  }, RESULT>;
496
402
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
497
403
  }): {
498
- type: 'provider-defined';
404
+ type: 'provider-defined-client';
499
405
  id: 'anthropic.computer_20250124';
500
406
  args: {};
501
407
  parameters: typeof Computer20250124Parameters;
502
408
  execute: ExecuteFunction<z.infer<typeof Computer20250124Parameters>, RESULT>;
503
409
  experimental_toToolResultContent?: (result: RESULT) => ToolResultContent;
504
410
  };
411
+ /**
412
+ * Creates a web search tool that gives Claude direct access to real-time web content.
413
+ * Must have name "web_search".
414
+ *
415
+ * @param maxUses - Maximum number of web searches Claude can perform during the conversation.
416
+ * @param allowedDomains - Optional list of domains that Claude is allowed to search.
417
+ * @param blockedDomains - Optional list of domains that Claude should avoid when searching.
418
+ * @param userLocation - Optional user location information to provide geographically relevant search results.
419
+ */
420
+ declare function webSearchTool_20250305(options?: {
421
+ maxUses?: number;
422
+ allowedDomains?: string[];
423
+ blockedDomains?: string[];
424
+ userLocation?: {
425
+ type: 'approximate';
426
+ city?: string;
427
+ region?: string;
428
+ country?: string;
429
+ timezone?: string;
430
+ };
431
+ }): {
432
+ type: 'provider-defined-server';
433
+ id: 'anthropic.web_search_20250305';
434
+ name: 'web_search';
435
+ args: {
436
+ maxUses?: number;
437
+ allowedDomains?: string[];
438
+ blockedDomains?: string[];
439
+ userLocation?: {
440
+ type: 'approximate';
441
+ city?: string;
442
+ region?: string;
443
+ country?: string;
444
+ timezone?: string;
445
+ };
446
+ };
447
+ };
505
448
  declare const anthropicTools: {
506
449
  bash_20241022: typeof bashTool_20241022;
507
450
  bash_20250124: typeof bashTool_20250124;
@@ -509,6 +452,7 @@ declare const anthropicTools: {
509
452
  textEditor_20250124: typeof textEditorTool_20250124;
510
453
  computer_20241022: typeof computerTool_20241022;
511
454
  computer_20250124: typeof computerTool_20250124;
455
+ webSearch_20250305: typeof webSearchTool_20250305;
512
456
  };
513
457
 
514
458
  interface AnthropicProvider extends ProviderV2 {