@ai-sdk/anthropic 1.2.12 → 2.0.0-alpha.10

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,64 +1,39 @@
1
- import { LanguageModelV1 } from '@ai-sdk/provider';
2
- import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
1
+ import { LanguageModelV2 } from '@ai-sdk/provider';
2
+ import { Resolvable, FetchFunction, ToolResultContent } from '@ai-sdk/provider-utils';
3
3
  import { z } from 'zod';
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
- interface AnthropicMessagesSettings {
7
- /**
8
- Enable Anthropic cache control. This will allow you to use provider-specific
9
- `cacheControl` metadata.
10
-
11
- @deprecated cache control is now enabled by default (meaning you are able to
12
- optionally mark content for caching) and this setting is no longer needed.
13
- */
14
- cacheControl?: boolean;
15
- /**
16
- Include reasoning content in requests sent to the model. Defaults to `true`.
17
-
18
- If you are experiencing issues with the model handling requests involving
19
- reasoning content, you can set this to `false` to omit them from the request.
20
- */
21
- sendReasoning?: boolean;
22
- }
23
6
 
24
7
  type AnthropicMessagesConfig = {
25
8
  provider: string;
26
9
  baseURL: string;
27
10
  headers: Resolvable<Record<string, string | undefined>>;
28
- supportsImageUrls: boolean;
29
11
  fetch?: FetchFunction;
30
12
  buildRequestUrl?: (baseURL: string, isStreaming: boolean) => string;
31
13
  transformRequestBody?: (args: Record<string, any>) => Record<string, any>;
14
+ supportedUrls?: () => LanguageModelV2['supportedUrls'];
15
+ generateId?: () => string;
32
16
  };
33
- declare class AnthropicMessagesLanguageModel implements LanguageModelV1 {
34
- readonly specificationVersion = "v1";
35
- readonly defaultObjectGenerationMode = "tool";
17
+ declare class AnthropicMessagesLanguageModel implements LanguageModelV2 {
18
+ readonly specificationVersion = "v2";
36
19
  readonly modelId: AnthropicMessagesModelId;
37
- readonly settings: AnthropicMessagesSettings;
38
20
  private readonly config;
39
- constructor(modelId: AnthropicMessagesModelId, settings: AnthropicMessagesSettings, config: AnthropicMessagesConfig);
21
+ private readonly generateId;
22
+ constructor(modelId: AnthropicMessagesModelId, config: AnthropicMessagesConfig);
40
23
  supportsUrl(url: URL): boolean;
41
24
  get provider(): string;
42
- get supportsImageUrls(): boolean;
25
+ get supportedUrls(): Record<string, RegExp[]> | PromiseLike<Record<string, RegExp[]>>;
43
26
  private getArgs;
44
27
  private getHeaders;
45
28
  private buildRequestUrl;
46
29
  private transformRequestBody;
47
- doGenerate(options: Parameters<LanguageModelV1['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doGenerate']>>>;
48
- doStream(options: Parameters<LanguageModelV1['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV1['doStream']>>>;
30
+ doGenerate(options: Parameters<LanguageModelV2['doGenerate']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doGenerate']>>>;
31
+ doStream(options: Parameters<LanguageModelV2['doStream']>[0]): Promise<Awaited<ReturnType<LanguageModelV2['doStream']>>>;
49
32
  }
50
33
 
51
34
  type ExecuteFunction<PARAMETERS, RESULT> = undefined | ((args: PARAMETERS, options: {
52
35
  abortSignal?: AbortSignal;
53
36
  }) => Promise<RESULT>);
54
- type ToolResultContent = Array<{
55
- type: 'text';
56
- text: string;
57
- } | {
58
- type: 'image';
59
- data: string;
60
- mimeType?: string;
61
- }>;
62
37
  declare const Bash20241022Parameters: z.ZodObject<{
63
38
  command: z.ZodString;
64
39
  restart: z.ZodOptional<z.ZodBoolean>;
@@ -443,4 +418,4 @@ declare const anthropicTools: {
443
418
  computer_20250124: typeof computerTool_20250124;
444
419
  };
445
420
 
446
- export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, type AnthropicMessagesSettings, anthropicTools };
421
+ export { AnthropicMessagesLanguageModel, type AnthropicMessagesModelId, anthropicTools };