UNPKG

@ai-sdk/amazon-bedrock

Version:
438 lines • 19.8 kB
import { anthropicTools } from "@ai-sdk/anthropic/internal"; import { FetchFunction, InferSchema, Resolvable } from "@ai-sdk/provider-utils"; import { z } from "zod/v4"; import { EmbeddingModelV4, ImageModelV4, LanguageModelV4, ModelEntry, ProviderV4, RerankingModelV4 } from "@ai-sdk/provider"; import { AnthropicProviderOptions } from "@ai-sdk/anthropic"; //#region src/amazon-bedrock-model-catalog.d.ts declare const amazonBedrockImageModelCatalog: { 'amazon.nova-canvas-v1:0': { capabilities: { image: { sizes: { description: string; }; fileInput: true; maskInput: true; maxImagesPerCall: number; }; }; providerOptions: { image: { quality: true; negativeText: true; cfgScale: true; style: true; taskType: true; maskPrompt: true; outPaintingMode: true; similarityStrength: true; }; }; }; }; declare const languageModelIds: readonly ["amazon.titan-tg1-large", "amazon.titan-text-express-v1", "anthropic.claude-v2", "anthropic.claude-v2:1", "anthropic.claude-instant-v1", "anthropic.claude-sonnet-5", "anthropic.claude-sonnet-5-5", "anthropic.claude-haiku-5-5", "anthropic.claude-fable-5", "anthropic.claude-fable-5-1", "anthropic.claude-fable-5-2", "anthropic.claude-opus-5", "anthropic.claude-opus-5-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-haiku-4-5-20251001-v1:0", "anthropic.claude-sonnet-4-5-20250929-v1:0", "anthropic.claude-sonnet-4-20250514-v1:0", "anthropic.claude-opus-4-20250514-v1:0", "anthropic.claude-opus-4-1-20250805-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", "openai.gpt-oss-120b-1:0", "openai.gpt-oss-20b-1:0", "amazon.titan-text-lite-v1", "us.amazon.nova-premier-v1:0", "us.amazon.nova-pro-v1:0", "us.amazon.nova-micro-v1:0", "us.amazon.nova-lite-v1:0", "us.anthropic.claude-3-sonnet-20240229-v1:0", "us.anthropic.claude-3-opus-20240229-v1:0", "us.anthropic.claude-3-haiku-20240307-v1:0", "us.anthropic.claude-3-5-sonnet-20240620-v1:0", "us.anthropic.claude-3-5-haiku-20241022-v1:0", "us.anthropic.claude-3-5-sonnet-20241022-v2:0", "us.anthropic.claude-3-7-sonnet-20250219-v1:0", "us.anthropic.claude-sonnet-5", "us.anthropic.claude-sonnet-5-5", "us.anthropic.claude-haiku-5-5", "us.anthropic.claude-fable-5", "us.anthropic.claude-fable-5-1", "us.anthropic.claude-fable-5-2", "us.anthropic.claude-opus-5", "us.anthropic.claude-opus-5-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-sonnet-4-20250514-v1:0", "us.anthropic.claude-opus-4-20250514-v1:0", "us.anthropic.claude-opus-4-1-20250805-v1:0", "us.anthropic.claude-haiku-4-5-20251001-v1:0", "global.anthropic.claude-fable-5-1", "global.anthropic.claude-fable-5-2", "us.meta.llama3-2-11b-instruct-v1:0", "us.meta.llama3-2-3b-instruct-v1:0", "us.meta.llama3-2-90b-instruct-v1:0", "us.meta.llama3-2-1b-instruct-v1:0", "us.meta.llama3-1-8b-instruct-v1:0", "us.meta.llama3-1-70b-instruct-v1:0", "us.meta.llama3-3-70b-instruct-v1:0", "us.deepseek.r1-v1:0", "us.mistral.pixtral-large-2502-v1:0", "us.meta.llama4-scout-17b-instruct-v1:0", "us.meta.llama4-maverick-17b-instruct-v1:0", "amazon.nova-2-lite-v1:0"]; declare const amazonBedrockEmbeddingModelEntries: { 'amazon.titan-embed-text-v1': ModelEntry; 'amazon.titan-embed-text-v2:0': ModelEntry; 'amazon.nova-embed-text-v2:0': ModelEntry; 'cohere.embed-english-v3': ModelEntry; 'cohere.embed-multilingual-v3': ModelEntry; 'cohere.embed-v4:0': ModelEntry; }; declare const amazonBedrockRerankingModelEntries: { 'amazon.rerank-v1:0': { capabilities: { reranking: { documents: { text: true; object: true; }; topN: true; }; }; providerOptions: { reranking: { nextToken: true; additionalModelRequestFields: true; }; }; }; 'cohere.rerank-v3-5:0': { capabilities: { reranking: { documents: { text: true; object: true; }; topN: true; }; }; providerOptions: { reranking: { nextToken: true; additionalModelRequestFields: true; }; }; }; }; /** Capabilities of the native Anthropic endpoint, distinct from Converse. */ declare const nativeAnthropicModels: { 'us.anthropic.claude-fable-5-1': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-fable-5-2': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-sonnet-5-5': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-sonnet-5': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-haiku-5-5': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-fable-5': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-8': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-7': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-6-v1': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-5-20251101-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-sonnet-4-5-20250929-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-20250514-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-sonnet-4-20250514-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-opus-4-1-20250805-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-haiku-4-5-20251001-v1:0': { computerUse: boolean; reasoning: boolean; }; 'us.anthropic.claude-3-5-sonnet-20241022-v2:0': { computerUse: boolean; reasoning: boolean; }; 'anthropic.claude-3-5-haiku-20241022-v1:0': undefined; 'anthropic.claude-3-5-sonnet-20240620-v1:0': undefined; 'anthropic.claude-3-5-sonnet-20241022-v2:0': undefined; 'anthropic.claude-3-7-sonnet-20250219-v1:0': undefined; 'anthropic.claude-3-haiku-20240307-v1:0': undefined; 'anthropic.claude-3-opus-20240229-v1:0': undefined; 'anthropic.claude-3-sonnet-20240229-v1:0': undefined; 'anthropic.claude-fable-5': undefined; 'anthropic.claude-fable-5-1': undefined; 'anthropic.claude-fable-5-2': undefined; 'anthropic.claude-haiku-4-5-20251001-v1:0': undefined; 'anthropic.claude-haiku-5-5': undefined; 'anthropic.claude-opus-4-1-20250805-v1:0': undefined; 'anthropic.claude-opus-4-20250514-v1:0': undefined; 'anthropic.claude-opus-4-5-20251101-v1:0': undefined; 'anthropic.claude-opus-4-6-v1': undefined; 'anthropic.claude-opus-4-7': undefined; 'anthropic.claude-opus-4-8': undefined; 'anthropic.claude-opus-5': undefined; 'anthropic.claude-opus-5-5': undefined; 'anthropic.claude-sonnet-4-20250514-v1:0': undefined; 'anthropic.claude-sonnet-4-5-20250929-v1:0': undefined; 'anthropic.claude-sonnet-4-6-v1': undefined; 'anthropic.claude-sonnet-5': undefined; 'anthropic.claude-sonnet-5-5': undefined; 'global.anthropic.claude-fable-5-1': undefined; 'global.anthropic.claude-fable-5-2': undefined; 'us.anthropic.claude-3-5-haiku-20241022-v1:0': undefined; 'us.anthropic.claude-3-5-sonnet-20240620-v1:0': undefined; 'us.anthropic.claude-3-7-sonnet-20250219-v1:0': undefined; 'us.anthropic.claude-3-haiku-20240307-v1:0': undefined; 'us.anthropic.claude-3-opus-20240229-v1:0': undefined; 'us.anthropic.claude-3-sonnet-20240229-v1:0': undefined; 'us.anthropic.claude-opus-5': undefined; 'us.anthropic.claude-opus-5-5': undefined; 'us.anthropic.claude-sonnet-4-6-v1': undefined; }; /** Endpoint availability documented for Mantle's known GPT-OSS models. */ declare const mantleModels: { readonly 'openai.gpt-oss-20b': { readonly chatCompletions: true; readonly responses: true; }; readonly 'openai.gpt-oss-120b': { readonly chatCompletions: true; readonly responses: true; }; readonly 'openai.gpt-oss-safeguard-20b': { readonly chatCompletions: true; readonly responses: false; }; readonly 'openai.gpt-oss-safeguard-120b': { readonly chatCompletions: true; readonly responses: false; }; }; /** Known model IDs, derived from the declarations used to build the catalog. */ type AmazonBedrockModelIds = { language: (typeof languageModelIds)[number]; embedding: keyof typeof amazonBedrockEmbeddingModelEntries; reranking: keyof typeof amazonBedrockRerankingModelEntries; image: keyof typeof amazonBedrockImageModelCatalog; anthropic: keyof typeof nativeAnthropicModels; mantleChat: keyof typeof mantleModels; mantleResponses: { [Id in keyof typeof mantleModels]: (typeof mantleModels)[Id]['responses'] extends true ? Id : never; }[keyof typeof mantleModels]; }; //#endregion //#region src/amazon-bedrock-embedding-model-options.d.ts type AmazonBedrockEmbeddingModelId = AmazonBedrockModelIds['embedding'] | (string & {}); type AmazonBedrockEmbeddingModelSettings = { /** * The embedding model family. * * Specify this when the model ID does not identify the underlying model, * such as an application inference profile ARN. */ modelFamily?: 'titan' | 'cohere' | 'nova'; }; declare const amazonBedrockEmbeddingModelOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{ dimensions?: 1024 | 512 | 256 | undefined; normalize?: boolean | undefined; embeddingDimension?: 1024 | 256 | 384 | 3072 | undefined; embeddingPurpose?: "GENERIC_INDEX" | "TEXT_RETRIEVAL" | "IMAGE_RETRIEVAL" | "VIDEO_RETRIEVAL" | "DOCUMENT_RETRIEVAL" | "AUDIO_RETRIEVAL" | "GENERIC_RETRIEVAL" | "CLASSIFICATION" | "CLUSTERING" | undefined; inputType?: "search_document" | "search_query" | "classification" | "clustering" | undefined; truncate?: "NONE" | "START" | "END" | undefined; outputDimension?: 1024 | 512 | 256 | 1536 | undefined; }>; type AmazonBedrockEmbeddingModelOptions = InferSchema<typeof amazonBedrockEmbeddingModelOptionsSchema>; //#endregion //#region src/amazon-bedrock-image-model-options.d.ts declare const amazonBedrockImageModelOptionsSchema: import("@ai-sdk/provider-utils").LazySchema<{ quality?: "standard" | "premium" | undefined; negativeText?: string | undefined; cfgScale?: number | undefined; style?: "3D_ANIMATED_FAMILY_FILM" | "DESIGN_SKETCH" | "FLAT_VECTOR_ILLUSTRATION" | "GRAPHIC_NOVEL_ILLUSTRATION" | "MAXIMALISM" | "MIDCENTURY_RETRO" | "PHOTOREALISM" | "SOFT_DIGITAL_PAINTING" | undefined; taskType?: "TEXT_IMAGE" | "IMAGE_VARIATION" | "INPAINTING" | "OUTPAINTING" | "BACKGROUND_REMOVAL" | undefined; maskPrompt?: string | undefined; outPaintingMode?: "DEFAULT" | "PRECISE" | undefined; similarityStrength?: number | undefined; }>; type AmazonBedrockImageModelOptions = InferSchema<typeof amazonBedrockImageModelOptionsSchema>; //#endregion //#region src/amazon-bedrock-chat-language-model-options.d.ts type AmazonBedrockChatModelId = AmazonBedrockModelIds['language'] | (string & {}); type AmazonBedrockChatModelSettings = { /** * The chat model family. * * Specify this when the model ID does not identify the underlying model, * such as an application inference profile ARN. */ modelFamily?: 'anthropic'; }; declare const amazonBedrockLanguageModelChatOptions: z.ZodObject<{ structuredOutputMode: z.ZodOptional<z.ZodEnum<{ outputFormat: "outputFormat"; jsonTool: "jsonTool"; auto: "auto"; }>>; additionalModelRequestFields: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; reasoningConfig: z.ZodOptional<z.ZodObject<{ type: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<"enabled">, z.ZodLiteral<"disabled">, z.ZodLiteral<"adaptive">]>>; budgetTokens: z.ZodOptional<z.ZodNumber>; maxReasoningEffort: z.ZodOptional<z.ZodEnum<{ low: "low"; medium: "medium"; high: "high"; xhigh: "xhigh"; max: "max"; }>>; display: z.ZodOptional<z.ZodEnum<{ omitted: "omitted"; summarized: "summarized"; }>>; }, z.core.$strip>>; anthropicBeta: z.ZodOptional<z.ZodArray<z.ZodString>>; serviceTier: z.ZodOptional<z.ZodEnum<{ default: "default"; reserved: "reserved"; priority: "priority"; flex: "flex"; }>>; requestMetadata: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; }, z.core.$strip>; type AmazonBedrockLanguageModelChatOptions = z.infer<typeof amazonBedrockLanguageModelChatOptions>; //#endregion //#region src/amazon-bedrock-image-settings.d.ts type AmazonBedrockImageModelId = AmazonBedrockModelIds['image'] | (string & {}); //#endregion //#region src/amazon-bedrock-sigv4-fetch.d.ts interface AmazonBedrockCredentials { region: string; accessKeyId: string; secretAccessKey: string; sessionToken?: string; } //#endregion //#region src/reranking/amazon-bedrock-reranking-model-options.d.ts type AmazonBedrockRerankingModelId = AmazonBedrockModelIds['reranking'] | (string & {}); type AmazonBedrockRerankingModelOptions = { /** * If the total number of results was greater than could fit in a response, a token is returned in the nextToken field. You can enter that token in this field to return the next batch of results. */ nextToken?: string; /** * Additional model request fields to pass to the model. */ additionalModelRequestFields?: Record<string, unknown>; }; //#endregion //#region src/amazon-bedrock-provider.d.ts interface AmazonBedrockProviderSettings { /** * 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. * A callback is resolved before each request and must return a non-empty key. * When provided, this will be used instead of AWS SigV4 authentication. * Defaults to the value of the `AWS_BEARER_TOKEN_BEDROCK` environment variable. * * @example * ```typescript * // Using API key directly * const bedrock = createAmazonBedrock({ * apiKey: 'your-api-key-here', * region: 'us-east-1' * }); * * // Using environment variable AWS_BEARER_TOKEN_BEDROCK * const bedrock = createAmazonBedrock({ * region: 'us-east-1' * }); * ``` * * Note: When `apiKey` is provided, it takes precedence over AWS SigV4 authentication. * If neither `apiKey` nor `AWS_BEARER_TOKEN_BEDROCK` environment variable is set, * the provider will fall back to AWS SigV4 authentication using AWS credentials. */ apiKey?: Resolvable<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. When `accessKeyId` and * `secretAccessKey` are both passed explicitly as options, only this field is used * If either access key field is omitted and resolved from the environment, the * session token also falls back to `AWS_SESSION_TOKEN` when not set here. */ sessionToken?: string; /** * Base URL for the Bedrock API calls. */ baseURL?: string; /** * Custom headers to include in the requests. */ headers?: Record<string, string>; /** * 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'>>; generateId?: () => string; } interface AmazonBedrockProvider extends ProviderV4 { (modelId: AmazonBedrockChatModelId, settings?: AmazonBedrockChatModelSettings): LanguageModelV4; languageModel(modelId: AmazonBedrockChatModelId, settings?: AmazonBedrockChatModelSettings): LanguageModelV4; /** * Creates a model for text embeddings. */ embedding(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4; /** * Creates a model for text embeddings. */ embeddingModel(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4; /** * @deprecated Use `embedding` instead. */ textEmbedding(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4; /** * @deprecated Use `embeddingModel` instead. */ textEmbeddingModel(modelId: AmazonBedrockEmbeddingModelId, settings?: AmazonBedrockEmbeddingModelSettings): EmbeddingModelV4; /** * Creates a model for image generation. */ image(modelId: AmazonBedrockImageModelId): ImageModelV4; /** * Creates a model for image generation. */ imageModel(modelId: AmazonBedrockImageModelId): ImageModelV4; /** * Creates a model for reranking documents. */ reranking(modelId: AmazonBedrockRerankingModelId): RerankingModelV4; /** * Creates a model for reranking documents. */ rerankingModel(modelId: AmazonBedrockRerankingModelId): RerankingModelV4; /** * Anthropic-specific tools that can be used with Anthropic models on Bedrock. */ tools: typeof anthropicTools; } /** * Create an Amazon Bedrock provider instance. */ export declare function createAmazonBedrock(options?: AmazonBedrockProviderSettings): AmazonBedrockProvider; /** * Default Amazon Bedrock provider instance. */ export declare const amazonBedrock: AmazonBedrockProvider; //#endregion //#region src/version.d.ts export declare const VERSION: string; //#endregion export { type AmazonBedrockChatModelSettings, type AmazonBedrockEmbeddingModelOptions, type AmazonBedrockEmbeddingModelSettings, type AmazonBedrockImageModelOptions, type AmazonBedrockLanguageModelChatOptions, type AmazonBedrockLanguageModelChatOptions as AmazonBedrockLanguageModelOptions, type AmazonBedrockLanguageModelChatOptions as BedrockProviderOptions, type AmazonBedrockProvider, type AmazonBedrockProviderSettings, type AmazonBedrockRerankingModelOptions, type AmazonBedrockRerankingModelOptions as BedrockRerankingOptions, type AnthropicProviderOptions, amazonBedrock as bedrock }; //# sourceMappingURL=index.d.ts.map