Skip to content

Amazon Bedrock

AmazonBedrockProvider in the Vercel.AI.AmazonBedrock namespace creates the Amazon Bedrock models that this port implements. The API reference lists every option: AmazonBedrockProvider.

Browse the upstream catalog of Amazon Bedrock models and their pricing on the Vercel AI Gateway models page.

Kind Factory method Model ids in this port’s tests and docs
Language Chat, LanguageModel openai.gpt-oss-20b, anthropic.claude-3-haiku-20240307-v1:0
Embedding EmbeddingModel amazon.nova-2-multimodal-embeddings-v1:0, amazon.titan-embed-text-v2:0, amazon.titan-embed-text-v1
Image Image amazon.titan-image-generator, amazon.nova-canvas-v1:0
Reranking RerankingModel cohere.rerank-v3-5:0, amazon.rerank-v1:0

A model id in the table is one that the tests or docs use. It is not the complete list of ids the provider accepts. Pass any id that the provider documents.

Language model:

var model = AmazonBedrockProvider.Create().LanguageModel("openai.gpt-oss-20b");
var result = await Ai.GenerateTextAsync(
new GenerateTextOptions
{
Model = model,
Prompt = "Invent a new holiday and describe its traditions.",
}
);
Console.WriteLine(result.Text);

snippet source | anchor

See the Providers guide for authentication and provider options.

Pass these under the amazon-bedrock provider options key.

  • structuredOutputMode is outputFormat, jsonTool, or auto (the default). Any other value, or a value that is not a string, throws ArgumentException before the request is sent.
  • serviceTier is reserved, priority, default, or flex. Any other value throws ArgumentException.
  • requestMetadata is an object whose values are all strings.

Call Amazon Ergo with an inference profile id such as us.amazon.ergo-1.0 or global.amazon.ergo-1.0. The model always reasons, so Reasoning = "none" or "minimal" is sent as low effort with a warning. Set the effort (low, medium, high, xhigh, or max) with Reasoning or reasoningConfig.maxReasoningEffort. It is sent as a nested reasoning.effort. For a readable reasoning summary, set additionalModelRequestFields to { "reasoning": { "summary": "auto" } }. The model accepts text input only and rejects Temperature, TopP, and StopSequences on Converse, so the provider removes them with a warning. When you set MaxOutputTokens, AWS recommends at least 8192, because reasoning uses part of the limit.

AmazonBedrockApiTypes.CreateAmazonBedrockCachePoint(ttl) is the C# name of upstream createAmazonBedrockCachePoint. It returns the complete { "cachePoint": { "type": "default", "ttl": ... } } block. The ttl is 5m or 1h. When it is null, the ttl field is left out and Bedrock uses its default of five minutes. Pass the cachePoint value of the block, not the block itself, as the cachePoint provider option.

AmazonBedrockOptions signs requests with SigV4 unless an API key is set.

  • ApiKey (or the AWS_BEARER_TOKEN_BEDROCK environment variable) sends a bearer token and takes precedence over SigV4.
  • AccessKeyId, SecretAccessKey and SessionToken fall back to the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN environment variables. When both AccessKeyId and SecretAccessKey are set in the options, only SessionToken from the options is used, and AWS_SESSION_TOKEN is ignored.
  • CredentialProvider is the C# name of upstream credentialProvider. It resolves the keys before each request, and its keys replace the three static settings. The region still comes from Region. A failure is reported as AWS credential provider failed: ....

Set citations.enabled to true under the amazonBedrock (or bedrock) provider options of a document file part to turn on citations for that document. The document block then carries citations: { enabled: true }. A top-level-only media type such as image, video or application takes its subtype from the file bytes. When the bytes do not identify it, the call throws UnsupportedFunctionalityException.

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product