UNPKG

@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

100 lines (95 loc) 3.98 kB
import { ProviderV4, LanguageModelV4 } from '@ai-sdk/provider'; import { FetchFunction } from '@ai-sdk/provider-utils'; interface AmazonBedrockCredentials { region: string; accessKeyId: string; secretAccessKey: string; sessionToken?: string; } type BedrockMantleChatModelId = 'openai.gpt-oss-20b' | 'openai.gpt-oss-120b' | 'openai.gpt-oss-safeguard-20b' | 'openai.gpt-oss-safeguard-120b' | (string & {}); type BedrockMantleResponsesModelId = 'openai.gpt-oss-20b' | 'openai.gpt-oss-120b' | (string & {}); type BedrockMantleModelId = BedrockMantleChatModelId | BedrockMantleResponsesModelId; interface BedrockMantleProvider extends ProviderV4 { /** * Creates a model for text generation using the Chat Completions API. * Chat Completions has the broadest model support on Mantle. */ (modelId: BedrockMantleChatModelId): LanguageModelV4; /** * Creates a model for text generation using the Chat Completions API. */ languageModel(modelId: BedrockMantleChatModelId): LanguageModelV4; /** * Creates a model for text generation using the Chat Completions API. */ chat(modelId: BedrockMantleChatModelId): LanguageModelV4; /** * Creates a model for text generation using the Responses API. * Not all Mantle models support this API. Notably, gpt-oss-safeguard models * are Chat-only. */ responses(modelId: BedrockMantleResponsesModelId): LanguageModelV4; /** * @deprecated Mantle does not support embedding models. */ textEmbeddingModel(modelId: string): never; } interface BedrockMantleProviderSettings { /** * The AWS region to use for the Bedrock Mantle endpoint. 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 SigV4 authentication. Defaults to the value of the * `AWS_ACCESS_KEY_ID` environment variable. */ accessKeyId?: string; /** * The AWS secret access key to use for SigV4 authentication. Defaults to the value of the * `AWS_SECRET_ACCESS_KEY` environment variable. */ secretAccessKey?: string; /** * The AWS session token to use for SigV4 authentication. Defaults to the value of the * `AWS_SESSION_TOKEN` environment variable. */ sessionToken?: string; /** * Base URL for the Bedrock Mantle API calls. */ baseURL?: string; /** * Custom headers to include in the requests. */ headers?: 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 SigV4 authentication 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 Mantle provider instance. * This provider uses the OpenAI-compatible Mantle API for models that are * only available through the Mantle endpoint (e.g. openai.gpt-oss-20b). */ declare function createBedrockMantle(options?: BedrockMantleProviderSettings): BedrockMantleProvider; /** * Default Bedrock Mantle provider instance. */ declare const bedrockMantle: BedrockMantleProvider; export { type BedrockMantleModelId, type BedrockMantleProvider, type BedrockMantleProviderSettings, bedrockMantle, createBedrockMantle };