Claude Platform on AWS feature parity with Anthropic
Claude Platform on AWS uses Anthropic's runtime directly, so it supports the same features as the first-party Anthropic provider including streaming, prompt caching, tool use, computer use, Agent Skills, and anthropic-beta headers. All features work identically.
Bedrock extended context window for Claude Sonnet 4
Claude Sonnet 4 models on Amazon Bedrock support an extended context window of up to 1 million tokens when using the `context-1m-2025-08-07` beta feature. Enable via `providerOptions.bedrock.anthropicBeta: ['context-1m-2025-08-07']`.
Bedrock generateText example
Use Amazon Bedrock language models with the `generateText` function: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const { text } = await generateText({ model: amazonBedrock('meta.llama3-70b-instruct-v1:0'), prompt: 'Write a vegetarian lasagna recipe for 4 people.' });`
Bedrock file input support with specific models
Amazon Bedrock supports file inputs (e.g., PDF files) in combination with specific models like `anthropic.claude-3-haiku-20240307-v1:0`. Files are passed in the `content` array with `type: 'file'`, `data` as the file buffer, and `mediaType` specifying the format.
Bedrock guardrails support
Amazon Bedrock supports Guardrails via the `bedrock` provider options with `guardrailConfig` object containing: `guardrailIdentifier` (string), `guardrailVersion` (string), `trace` (set to 'enabled' for tracing), and `streamProcessingMode` (e.g., 'async'). Tracing information is returned in `providerMetadata.bedrock.trace` when enabled.
Bedrock citations for document inputs
Amazon Bedrock supports citations for document-based inputs across compatible models. Enable citations by setting `providerOptions.bedrock.citations: { enabled: true }` on file content. Some models can read documents with visual understanding, not just extracting text.
Bedrock prompt caching with cache points
Amazon Bedrock prompt caching is currently in preview release. In messages, use `providerOptions.bedrock.cachePoint: { type: 'default' }` to create a cache point. Optionally specify TTL with `ttl: '5m'` (default) or `ttl: '1h'` (1-hour TTL supported only by Claude Opus 4.5, Claude Haiku 4.5, and Claude Sonnet 4.5). Cache usage information is returned in `providerMetadata.bedrock.usage`.
Bedrock cache point constraints
When using multiple cache points with different TTLs, cache entries with longer TTL must appear before shorter TTLs (1-hour cache entries must come before 5-minute cache entries). Cache points have model-specific token minimums and limits; for example, Claude 3.5 Sonnet v2 requires at least 1,024 tokens for a cache point and allows up to 4 cache points.
Bedrock cache point generateText example
Example using cache points with generateText: `const result = await generateText({ model: amazonBedrock('anthropic.claude-3-5-sonnet-20241022-v2:0'), messages: [{ role: 'system', content: 'Academic analysis text...', providerOptions: { bedrock: { cachePoint: { type: 'default' } } } }, { role: 'user', content: 'Question?' }] }); console.log(result.providerMetadata?.bedrock?.usage);` Returns cache read/write token usage like `{ cacheReadInputTokens: 1337, cacheWriteInputTokens: 42 }`.
Bedrock provider metadata fields
The following Bedrock-specific metadata may be returned in `providerMetadata.bedrock`: `trace` (optional, guardrail tracing info when enabled), `performanceConfig` (optional, e.g. `{ latency: 'optimized' }`), `serviceTier` (optional, e.g. `{ type: 'on-demand' }`), `usage` (optional, cache token usage details including `cacheWriteInputTokens` and `cacheDetails`), `stopSequence` (string | null, the stop sequence that triggered the stop if any).
Bedrock reasoning configuration for Anthropic models
Anthropic models on Bedrock support reasoning via the `reasoningConfig` provider option. Enable with `{ type: 'enabled', budgetTokens: number }` where minimum is 1024 and maximum is 64000 tokens. The provider adds `budgetTokens` to `maxOutputTokens` when setting `maxTokens`. When `maxOutputTokens` is omitted, the provider adds `budgetTokens` to the default of 4096.
Bedrock reasoning for Amazon Nova models
Amazon Nova models (e.g. `us.amazon.nova-2-lite-v1:0`) support reasoning via the `reasoningConfig` provider option with `{ type: 'enabled', maxReasoningEffort: 'low' | 'medium' | 'high' }`.
Bedrock service tiers per request
Amazon Bedrock supports selecting an inference service tier per request via the `serviceTier` provider option. Supported values are: `reserved`, `priority`, `default`, `flex`. Pass via `providerOptions.bedrock.serviceTier`.
Bedrock reranking model usage example
Use reranking models with the `rerank` function: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { rerank } from 'ai'; const { ranking } = await rerank({ model: amazonBedrock.reranking('cohere.rerank-v3-5:0'), documents: ['sunny day at the beach', 'rainy afternoon in the city', 'snowy night in the mountains'], query: 'talk about rain', topN: 2 });`
Bedrock generateImage example
Use image models with the `generateImage` function: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateImage } from 'ai'; const { image } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: 'A beautiful sunset over a calm ocean', size: '512x512', seed: 42 });`
Bedrock image editing task types
Amazon Nova Canvas supports image editing with the following task types: IMAGE_VARIATION (create variations while maintaining core characteristics), INPAINTING (edit specific parts using mask or text prompt), OUTPAINTING (extend image beyond original boundaries), BACKGROUND_REMOVAL (remove background). When you provide input images via `prompt.images`, the model automatically detects the appropriate editing mode, or specify `taskType` explicitly in provider options.
Bedrock image variation example
Create image variations: `const { images } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: { text: 'Modernize the style', images: [imageBuffer] }, providerOptions: { amazonBedrock: { taskType: 'IMAGE_VARIATION', similarityStrength: 0.7, negativeText: 'bad quality' } } });`
Bedrock inpainting with mask prompt
Edit specific parts using text-based mask: `const { images } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: { text: 'a cute corgi dog', images: [imageBuffer] }, providerOptions: { amazonBedrock: { maskPrompt: 'cat' } }, seed: 42 });` The `maskPrompt` describes what to replace.
Bedrock inpainting with mask image
Edit using a mask image: `const { images } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: { text: 'A sunlit indoor lounge area with a pool containing a flamingo', images: [image], mask: mask } });` Mask image white pixels indicate area to change.
Bedrock outpainting example
Extend image beyond boundaries: `const { images } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: { text: 'A beautiful sunset landscape with mountains', images: [imageBuffer] }, providerOptions: { amazonBedrock: { taskType: 'OUTPAINTING', maskPrompt: 'background', outPaintingMode: 'DEFAULT' } } });`
Bedrock background removal example
Remove background: `const { images } = await generateImage({ model: amazonBedrock.image('amazon.nova-canvas-v1:0'), prompt: { images: [imageBuffer] }, providerOptions: { amazonBedrock: { taskType: 'BACKGROUND_REMOVAL' } } });` Background removal does not require a text prompt.
Amazon Nova Canvas size constraints
Amazon Nova Canvas model supports custom image sizes with constraints: each side must be 320-4096 pixels (inclusive) and divisible by 16; aspect ratio must be between 1:4 and 4:1; total pixel count must be less than 4,194,304.
Bedrock response headers access
The Amazon Bedrock provider returns response headers from network requests to Bedrock servers. Access via `result.response.headers`. Headers include items like `x-amzn-requestid` which can be useful for correlating Bedrock API calls with AI SDK requests.
Bedrock response headers with streamText
With `streamText`, access response headers via `(await result.response).headers` after the stream completes. Example: `console.log('Response headers:', (await result.response).headers);`
Bedrock Anthropic generateText example
Use Bedrock Anthropic models with generateText: `import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic'; import { generateText } from 'ai'; const { text } = await generateText({ model: bedrockAnthropic('us.anthropic.claude-3-5-sonnet-20241022-v2:0'), prompt: 'Write a vegetarian lasagna recipe for 4 people.' });`
Bedrock Anthropic cache control setup
In messages and message parts, use `providerOptions.anthropic` to set cache control breakpoints with `{ cacheControl: { type: 'ephemeral' } }`. Cache control requires a minimum of 1024 tokens before the cache checkpoint.
Bedrock Anthropic cache control example
Set cache control: `const result = await generateText({ model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'), messages: [{ role: 'system', content: 'You are an expert assistant.', providerOptions: { anthropic: { cacheControl: { type: 'ephemeral' } } } }, { role: 'user', content: 'Explain quantum computing.' }] });`
Bedrock Anthropic reasoning enable via thinking option
Enable Anthropic reasoning using the `thinking` provider option with `{ type: 'enabled', budgetTokens: number }`. Anthropic's `max_tokens` limit includes both thinking and final text, so the provider adds `budgetTokens` to `maxOutputTokens` when setting `max_tokens`. For known models, the combined value is capped at the model's maximum output token limit.
Bedrock Anthropic reasoning example
Enable reasoning: `const { text, reasoningText, reasoning } = await generateText({ model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'), prompt: 'How many people will live in the world in 2040?', providerOptions: { anthropic: { thinking: { type: 'enabled', budgetTokens: 12000 } } } }); console.log(reasoningText); console.log(reasoning); console.log(text);`
Bedrock Anthropic provider Files API limitation
The Bedrock Anthropic provider uses the native InvokeModel API and supports all features available in the Anthropic API, except for the Files API and MCP Connector which are not supported on Bedrock.
Claude Sonnet 3.5 and Gemini 2.0 support PDF understanding
Anthropic's Claude Sonnet 3.5 and Google's Gemini 2.0 can understand PDFs and respond to questions about their contents.