@ai-sdk/amazon-bedrock
Version:
The **[Amazon Bedrock provider](https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the Amazon Bedrock [converse API](https://docs.aws.amazon.com/bedrock/latest/APIR
92 lines (87 loc) • 5.32 kB
TypeScript
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider';
import { Resolvable, FetchFunction } from '@ai-sdk/provider-utils';
import { anthropicTools } from '@ai-sdk/anthropic/internal';
interface AmazonBedrockCredentials {
region: string;
accessKeyId: string;
secretAccessKey: string;
sessionToken?: string;
}
type AmazonBedrockAnthropicModelId = 'anthropic.claude-sonnet-5' | 'anthropic.claude-fable-5' | 'anthropic.claude-opus-4-8' | 'anthropic.claude-opus-4-7' | 'anthropic.claude-opus-4-6-v1' | 'anthropic.claude-sonnet-4-6-v1' | 'anthropic.claude-opus-4-5-20251101-v1:0' | 'anthropic.claude-sonnet-4-5-20250929-v1:0' | 'anthropic.claude-opus-4-20250514-v1:0' | 'anthropic.claude-sonnet-4-20250514-v1:0' | 'anthropic.claude-opus-4-1-20250805-v1:0' | 'anthropic.claude-haiku-4-5-20251001-v1:0' | 'anthropic.claude-3-7-sonnet-20250219-v1:0' | 'anthropic.claude-3-5-sonnet-20241022-v2:0' | 'anthropic.claude-3-5-sonnet-20240620-v1:0' | 'anthropic.claude-3-5-haiku-20241022-v1:0' | 'anthropic.claude-3-opus-20240229-v1:0' | 'anthropic.claude-3-sonnet-20240229-v1:0' | 'anthropic.claude-3-haiku-20240307-v1:0' | 'us.anthropic.claude-sonnet-5' | 'us.anthropic.claude-fable-5' | 'us.anthropic.claude-opus-4-8' | 'us.anthropic.claude-opus-4-7' | 'us.anthropic.claude-opus-4-6-v1' | 'us.anthropic.claude-sonnet-4-6-v1' | 'us.anthropic.claude-opus-4-5-20251101-v1:0' | 'us.anthropic.claude-sonnet-4-5-20250929-v1:0' | 'us.anthropic.claude-opus-4-20250514-v1:0' | 'us.anthropic.claude-sonnet-4-20250514-v1:0' | 'us.anthropic.claude-opus-4-1-20250805-v1:0' | 'us.anthropic.claude-haiku-4-5-20251001-v1:0' | 'us.anthropic.claude-3-7-sonnet-20250219-v1:0' | 'us.anthropic.claude-3-5-sonnet-20241022-v2:0' | 'us.anthropic.claude-3-5-sonnet-20240620-v1:0' | 'us.anthropic.claude-3-5-haiku-20241022-v1:0' | 'us.anthropic.claude-3-opus-20240229-v1:0' | 'us.anthropic.claude-3-sonnet-20240229-v1:0' | 'us.anthropic.claude-3-haiku-20240307-v1:0' | (string & {});
interface AmazonBedrockAnthropicProvider extends ProviderV4 {
/**
* Creates a model for text generation.
*/
(modelId: AmazonBedrockAnthropicModelId): LanguageModelV4;
/**
* Creates a model for text generation.
*/
languageModel(modelId: AmazonBedrockAnthropicModelId): LanguageModelV4;
/**
* Anthropic-specific computer use tool.
*/
tools: typeof anthropicTools;
/**
* @deprecated Use `embeddingModel` instead.
*/
textEmbeddingModel(modelId: string): never;
}
interface AmazonBedrockAnthropicProviderSettings {
/**
* The AWS region to use for the Bedrock provider. Defaults to the value of the
* `AWS_REGION` environment variable.
*/
region?: string;
/**
* API key for authenticating requests using Bearer token authentication.
* When provided, this will be used instead of AWS SigV4 authentication.
* Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable.
*/
apiKey?: string;
/**
* The AWS access key ID to use for the Bedrock provider. Defaults to the value of the
* `AWS_ACCESS_KEY_ID` environment variable.
*/
accessKeyId?: string;
/**
* The AWS secret access key to use for the Bedrock provider. Defaults to the value of the
* `AWS_SECRET_ACCESS_KEY` environment variable.
*/
secretAccessKey?: string;
/**
* The AWS session token to use for the Bedrock provider. Defaults to the value of the
* `AWS_SESSION_TOKEN` environment variable.
*/
sessionToken?: string;
/**
* Base URL for the Bedrock API calls.
*/
baseURL?: string;
/**
* Custom headers to include in the requests.
*/
headers?: Resolvable<Record<string, string | undefined>>;
/**
* Custom fetch implementation. You can use it as a middleware to intercept requests,
* or to provide a custom fetch implementation for e.g. testing.
*/
fetch?: FetchFunction;
/**
* The AWS credential provider to use for the Bedrock provider to get dynamic
* credentials similar to the AWS SDK. Setting a provider here will cause its
* credential values to be used instead of the `accessKeyId`, `secretAccessKey`,
* and `sessionToken` settings.
*/
credentialProvider?: () => PromiseLike<Omit<AmazonBedrockCredentials, 'region'>>;
}
/**
* Create an Amazon Bedrock Anthropic provider instance.
* This provider uses the native Anthropic API through Bedrock's InvokeModel endpoint,
* bypassing the Converse API for better feature compatibility.
*/
declare function createAmazonBedrockAnthropic(options?: AmazonBedrockAnthropicProviderSettings): AmazonBedrockAnthropicProvider;
/**
* Default Bedrock Anthropic provider instance.
*/
declare const amazonBedrockAnthropic: AmazonBedrockAnthropicProvider;
export { type AmazonBedrockAnthropicModelId, type AmazonBedrockAnthropicProvider, type AmazonBedrockAnthropicProviderSettings, type AmazonBedrockAnthropicModelId as BedrockAnthropicModelId, type AmazonBedrockAnthropicProvider as BedrockAnthropicProvider, type AmazonBedrockAnthropicProviderSettings as BedrockAnthropicProviderSettings, amazonBedrockAnthropic, amazonBedrockAnthropic as bedrockAnthropic, createAmazonBedrockAnthropic, createAmazonBedrockAnthropic as createBedrockAnthropic };