@ai-sdk/amazon-bedrock 3.0.0-canary.8 → 3.0.0

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/dist/index.d.mts CHANGED
@@ -1,62 +1,21 @@
1
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV1 } from '@ai-sdk/provider';
1
+ import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod';
3
+ import { anthropicTools } from '@ai-sdk/anthropic/internal';
4
+ import { z } from 'zod/v4';
4
5
 
5
- type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
+ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
7
  declare const bedrockProviderOptions: z.ZodObject<{
7
- /**
8
- * Additional inference parameters that the model supports,
9
- * beyond the base set of inference parameters that Converse
10
- * supports in the inferenceConfig field
11
- */
12
8
  additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
13
- reasoningConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
14
- type: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>>;
15
- budgetTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
- }, "strip", z.ZodTypeAny, {
17
- type?: "enabled" | "disabled" | null | undefined;
18
- budgetTokens?: number | null | undefined;
19
- }, {
20
- type?: "enabled" | "disabled" | null | undefined;
21
- budgetTokens?: number | null | undefined;
22
- }>>>;
23
- }, "strip", z.ZodTypeAny, {
24
- additionalModelRequestFields?: Record<string, any> | undefined;
25
- reasoningConfig?: {
26
- type?: "enabled" | "disabled" | null | undefined;
27
- budgetTokens?: number | null | undefined;
28
- } | null | undefined;
29
- }, {
30
- additionalModelRequestFields?: Record<string, any> | undefined;
31
- reasoningConfig?: {
32
- type?: "enabled" | "disabled" | null | undefined;
33
- budgetTokens?: number | null | undefined;
34
- } | null | undefined;
35
- }>;
9
+ reasoningConfig: z.ZodOptional<z.ZodObject<{
10
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
11
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
12
+ }, z.core.$strip>>;
13
+ }, z.core.$strip>;
36
14
  type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
37
15
 
38
16
  type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
39
- interface BedrockEmbeddingSettings {
40
- /**
41
- The number of dimensions the resulting output embeddings should have (defaults to 1024).
42
- Only supported in amazon.titan-embed-text-v2:0.
43
- */
44
- dimensions?: 1024 | 512 | 256;
45
- /**
46
- Flag indicating whether or not to normalize the output embeddings. Defaults to true
47
- Only supported in amazon.titan-embed-text-v2:0.
48
- */
49
- normalize?: boolean;
50
- }
51
17
 
52
18
  type BedrockImageModelId = 'amazon.nova-canvas-v1:0' | (string & {});
53
- interface BedrockImageSettings {
54
- /**
55
- * Override the maximum number of images per call (default is dependent on the
56
- * model, or 1 for an unknown model).
57
- */
58
- maxImagesPerCall?: number;
59
- }
60
19
 
61
20
  interface BedrockCredentials {
62
21
  region: string;
@@ -72,6 +31,30 @@ interface AmazonBedrockProviderSettings {
72
31
  */
73
32
  region?: string;
74
33
  /**
34
+ API key for authenticating requests using Bearer token authentication.
35
+ When provided, this will be used instead of AWS SigV4 authentication.
36
+ Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.
37
+
38
+ @example
39
+ ```typescript
40
+ // Using API key directly
41
+ const bedrock = createAmazonBedrock({
42
+ apiKey: 'your-api-key-here',
43
+ region: 'us-east-1'
44
+ });
45
+
46
+ // Using environment variable AWS_BEARER_TOKEN_BEDROCK
47
+ const bedrock = createAmazonBedrock({
48
+ region: 'us-east-1'
49
+ });
50
+ ```
51
+
52
+ Note: When `apiKey` is provided, it takes precedence over AWS SigV4 authentication.
53
+ If neither `apiKey` nor `AWS_BEARER_TOKEN_BEDROCK` environment variable is set,
54
+ the provider will fall back to AWS SigV4 authentication using AWS credentials.
55
+ */
56
+ apiKey?: string;
57
+ /**
75
58
  The AWS access key ID to use for the Bedrock provider. Defaults to the value of the
76
59
  `AWS_ACCESS_KEY_ID` environment variable.
77
60
  */
@@ -111,9 +94,19 @@ interface AmazonBedrockProviderSettings {
111
94
  interface AmazonBedrockProvider extends ProviderV2 {
112
95
  (modelId: BedrockChatModelId): LanguageModelV2;
113
96
  languageModel(modelId: BedrockChatModelId): LanguageModelV2;
114
- embedding(modelId: BedrockEmbeddingModelId, settings?: BedrockEmbeddingSettings): EmbeddingModelV2<string>;
115
- image(modelId: BedrockImageModelId, settings?: BedrockImageSettings): ImageModelV1;
116
- imageModel(modelId: BedrockImageModelId, settings?: BedrockImageSettings): ImageModelV1;
97
+ embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV2<string>;
98
+ /**
99
+ Creates a model for image generation.
100
+ */
101
+ image(modelId: BedrockImageModelId): ImageModelV2;
102
+ /**
103
+ Creates a model for image generation.
104
+ */
105
+ imageModel(modelId: BedrockImageModelId): ImageModelV2;
106
+ /**
107
+ Anthropic-specific tools that can be used with Anthropic models on Bedrock.
108
+ */
109
+ tools: typeof anthropicTools;
117
110
  }
118
111
  /**
119
112
  Create an Amazon Bedrock provider instance.
package/dist/index.d.ts CHANGED
@@ -1,62 +1,21 @@
1
- import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV1 } from '@ai-sdk/provider';
1
+ import { ProviderV2, LanguageModelV2, EmbeddingModelV2, ImageModelV2 } from '@ai-sdk/provider';
2
2
  import { FetchFunction } from '@ai-sdk/provider-utils';
3
- import { z } from 'zod';
3
+ import { anthropicTools } from '@ai-sdk/anthropic/internal';
4
+ import { z } from 'zod/v4';
4
5
 
5
- type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
+ type BedrockChatModelId = 'amazon.titan-tg1-large' | 'amazon.titan-text-express-v1' | 'anthropic.claude-v2' | 'anthropic.claude-v2:1' | 'anthropic.claude-instant-v1' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'cohere.command-text-v14' | 'cohere.command-light-text-v14' | 'cohere.command-r-v1:0' | 'cohere.command-r-plus-v1:0' | 'meta.llama3-70b-instruct-v1:0' | 'meta.llama3-8b-instruct-v1:0' | 'meta.llama3-1-405b-instruct-v1:0' | 'meta.llama3-1-70b-instruct-v1:0' | 'meta.llama3-1-8b-instruct-v1:0' | 'meta.llama3-2-11b-instruct-v1:0' | 'meta.llama3-2-1b-instruct-v1:0' | 'meta.llama3-2-3b-instruct-v1:0' | 'meta.llama3-2-90b-instruct-v1:0' | 'mistral.mistral-7b-instruct-v0:2' | 'mistral.mixtral-8x7b-instruct-v0:1' | 'mistral.mistral-large-2402-v1:0' | 'mistral.mistral-small-2402-v1:0' | 'amazon.titan-text-express-v1' | 'amazon.titan-text-lite-v1' | (string & {});
6
7
  declare const bedrockProviderOptions: z.ZodObject<{
7
- /**
8
- * Additional inference parameters that the model supports,
9
- * beyond the base set of inference parameters that Converse
10
- * supports in the inferenceConfig field
11
- */
12
8
  additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
13
- reasoningConfig: z.ZodOptional<z.ZodNullable<z.ZodObject<{
14
- type: z.ZodOptional<z.ZodNullable<z.ZodUnion<[z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>>;
15
- budgetTokens: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
- }, "strip", z.ZodTypeAny, {
17
- type?: "enabled" | "disabled" | null | undefined;
18
- budgetTokens?: number | null | undefined;
19
- }, {
20
- type?: "enabled" | "disabled" | null | undefined;
21
- budgetTokens?: number | null | undefined;
22
- }>>>;
23
- }, "strip", z.ZodTypeAny, {
24
- additionalModelRequestFields?: Record<string, any> | undefined;
25
- reasoningConfig?: {
26
- type?: "enabled" | "disabled" | null | undefined;
27
- budgetTokens?: number | null | undefined;
28
- } | null | undefined;
29
- }, {
30
- additionalModelRequestFields?: Record<string, any> | undefined;
31
- reasoningConfig?: {
32
- type?: "enabled" | "disabled" | null | undefined;
33
- budgetTokens?: number | null | undefined;
34
- } | null | undefined;
35
- }>;
9
+ reasoningConfig: z.ZodOptional<z.ZodObject<{
10
+ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">]>>;
11
+ budgetTokens: z.ZodOptional<z.ZodNumber>;
12
+ }, z.core.$strip>>;
13
+ }, z.core.$strip>;
36
14
  type BedrockProviderOptions = z.infer<typeof bedrockProviderOptions>;
37
15
 
38
16
  type BedrockEmbeddingModelId = 'amazon.titan-embed-text-v1' | 'amazon.titan-embed-text-v2:0' | 'cohere.embed-english-v3' | 'cohere.embed-multilingual-v3' | (string & {});
39
- interface BedrockEmbeddingSettings {
40
- /**
41
- The number of dimensions the resulting output embeddings should have (defaults to 1024).
42
- Only supported in amazon.titan-embed-text-v2:0.
43
- */
44
- dimensions?: 1024 | 512 | 256;
45
- /**
46
- Flag indicating whether or not to normalize the output embeddings. Defaults to true
47
- Only supported in amazon.titan-embed-text-v2:0.
48
- */
49
- normalize?: boolean;
50
- }
51
17
 
52
18
  type BedrockImageModelId = 'amazon.nova-canvas-v1:0' | (string & {});
53
- interface BedrockImageSettings {
54
- /**
55
- * Override the maximum number of images per call (default is dependent on the
56
- * model, or 1 for an unknown model).
57
- */
58
- maxImagesPerCall?: number;
59
- }
60
19
 
61
20
  interface BedrockCredentials {
62
21
  region: string;
@@ -72,6 +31,30 @@ interface AmazonBedrockProviderSettings {
72
31
  */
73
32
  region?: string;
74
33
  /**
34
+ API key for authenticating requests using Bearer token authentication.
35
+ When provided, this will be used instead of AWS SigV4 authentication.
36
+ Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.
37
+
38
+ @example
39
+ ```typescript
40
+ // Using API key directly
41
+ const bedrock = createAmazonBedrock({
42
+ apiKey: 'your-api-key-here',
43
+ region: 'us-east-1'
44
+ });
45
+
46
+ // Using environment variable AWS_BEARER_TOKEN_BEDROCK
47
+ const bedrock = createAmazonBedrock({
48
+ region: 'us-east-1'
49
+ });
50
+ ```
51
+
52
+ Note: When `apiKey` is provided, it takes precedence over AWS SigV4 authentication.
53
+ If neither `apiKey` nor `AWS_BEARER_TOKEN_BEDROCK` environment variable is set,
54
+ the provider will fall back to AWS SigV4 authentication using AWS credentials.
55
+ */
56
+ apiKey?: string;
57
+ /**
75
58
  The AWS access key ID to use for the Bedrock provider. Defaults to the value of the
76
59
  `AWS_ACCESS_KEY_ID` environment variable.
77
60
  */
@@ -111,9 +94,19 @@ interface AmazonBedrockProviderSettings {
111
94
  interface AmazonBedrockProvider extends ProviderV2 {
112
95
  (modelId: BedrockChatModelId): LanguageModelV2;
113
96
  languageModel(modelId: BedrockChatModelId): LanguageModelV2;
114
- embedding(modelId: BedrockEmbeddingModelId, settings?: BedrockEmbeddingSettings): EmbeddingModelV2<string>;
115
- image(modelId: BedrockImageModelId, settings?: BedrockImageSettings): ImageModelV1;
116
- imageModel(modelId: BedrockImageModelId, settings?: BedrockImageSettings): ImageModelV1;
97
+ embedding(modelId: BedrockEmbeddingModelId): EmbeddingModelV2<string>;
98
+ /**
99
+ Creates a model for image generation.
100
+ */
101
+ image(modelId: BedrockImageModelId): ImageModelV2;
102
+ /**
103
+ Creates a model for image generation.
104
+ */
105
+ imageModel(modelId: BedrockImageModelId): ImageModelV2;
106
+ /**
107
+ Anthropic-specific tools that can be used with Anthropic models on Bedrock.
108
+ */
109
+ tools: typeof anthropicTools;
117
110
  }
118
111
  /**
119
112
  Create an Amazon Bedrock provider instance.