new·Earn with mozg — 20% of every monthSend somebody here and take a fifth of every plan payment they make, for as long as they keep paying — not a bounty on the first invoice. Your handle is the link, the window is thirty days, and the commission lands on your balance the second they pay. Free to join: if you have signed in, you already have the link. mozg.sh/earnall news →
mozg.beta
Sign in

AI SDK · Providers · all subjects

bedrock/capabilities

27 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Amazon Bedrock generateText usage

Amazon Bedrock language models can be used with the `generateText` function. Example: `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.' });`

Amazon Bedrock streamText support

Amazon Bedrock language models can be used with the `streamText` function from AI SDK Core.

Amazon Bedrock structured output example

Example of using structured outputs with Amazon Bedrock: `import { amazonBedrock, type AmazonBedrockLanguageModelChatOptions } from '@ai-sdk/amazon-bedrock'; import { generateText, Output } from 'ai'; import { z } from 'zod'; const { output } = await generateText({ model: amazonBedrock('eu.anthropic.claude-sonnet-4-6'), output: Output.object({ schema: z.object({ summary: z.string(), findings: z.array(z.string()) }) }), prompt: 'Summarize the inspection report.', providerOptions: { amazonBedrock: { structuredOutputMode: 'jsonTool' } satisfies AmazonBedrockLanguageModelChatOptions } });`

Amazon Bedrock file inputs support

The Amazon Bedrock provider supports file inputs such as PDF files. File inputs work with specific models like `anthropic.claude-3-haiku-20240307-v1:0`. File content is passed as a message part with type 'file', data, and mediaType properties.

Amazon Bedrock file input example

Example of using file inputs with Amazon Bedrock: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const result = await generateText({ model: amazonBedrock('anthropic.claude-3-haiku-20240307-v1:0'), messages: [{ role: 'user', content: [{ type: 'text', text: 'Describe the pdf in detail.' }, { type: 'file', data: readFileSync('./data/ai.pdf'), mediaType: 'application/pdf' }] }] });`

Amazon Bedrock Guardrails example

Example of using Amazon Bedrock Guardrails: `import { type AmazonBedrockLanguageModelChatOptions } from '@ai-sdk/amazon-bedrock'; const result = await generateText({ model: amazonBedrock('anthropic.claude-3-sonnet-20240229-v1:0'), prompt: 'Write a story about space exploration.', providerOptions: { bedrock: { guardrailConfig: { guardrailIdentifier: '1abcd2ef34gh', guardrailVersion: '1', trace: 'enabled' as const, streamProcessingMode: 'async' } } satisfies AmazonBedrockLanguageModelChatOptions } });`

Amazon Bedrock guard content marking example

Text parts can be marked as guard content with qualifiers: `{ type: 'text', text: 'London is the capital of UK. Tokyo is the capital of Japan.', providerOptions: { bedrock: { guardContent: true, guardContentQualifiers: ['grounding_source'] } } }`. Image parts can also be marked: `{ type: 'file', data: { type: 'data', data: imageBase64 }, mediaType: 'image/png', providerOptions: { bedrock: { guardContent: true } } }`

Amazon Bedrock citations support

Amazon Bedrock supports citations for document-based inputs across compatible models. When enabled, some models can read documents with visual understanding and cite specific parts of provided documents. This feature is currently in progress for retrieval support.

Amazon Bedrock citations example

Example of using citations with Amazon Bedrock: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateText, Output } from 'ai'; import { z } from 'zod'; import fs from 'fs'; const result = await generateText({ model: amazonBedrock('apac.anthropic.claude-sonnet-4-20250514-v1:0'), output: Output.object({ schema: z.object({ summary: z.string().describe('Summary of the PDF document'), keyPoints: z.array(z.string()).describe('Key points from the PDF') }) }), messages: [{ role: 'user', content: [{ type: 'text', text: 'Summarize this PDF and provide key points.' }, { type: 'file', data: readFileSync('./document.pdf'), mediaType: 'application/pdf', providerOptions: { bedrock: { citations: { enabled: true } } } }] }] });`

Amazon Bedrock cache point example

Example of using cache points with Amazon Bedrock: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const cyberpunkAnalysis = '... literary analysis of cyberpunk themes and concepts ...'; const result = await generateText({ model: amazonBedrock('anthropic.claude-3-5-sonnet-20241022-v2:0'), messages: [{ role: 'system', content: \`You are an expert on William Gibson's cyberpunk literature and themes. You have access to the following academic analysis: \${cyberpunkAnalysis}\`, providerOptions: { bedrock: { cachePoint: { type: 'default' } } } }, { role: 'user', content: 'What are the key cyberpunk themes that Gibson explores in Neuromancer?' }] }); console.log(result.providerMetadata?.bedrock?.usage);`

Amazon Bedrock cache points with streaming example

Cache points work with streaming responses: `import { amazonBedrock } from '@ai-sdk/amazon-bedrock'; import { streamText } from 'ai'; const cyberpunkAnalysis = '... literary analysis of cyberpunk themes and concepts ...'; const result = streamText({ model: amazonBedrock('anthropic.claude-3-5-sonnet-20241022-v2:0'), messages: [{ role: 'assistant', content: [{ type: 'text', text: 'You are an expert on cyberpunk literature.' }, { type: 'text', text: \`Academic analysis: \${cyberpunkAnalysis}\` }], providerOptions: { bedrock: { cachePoint: { type: 'default' } } } }, { role: 'user', content: 'How does Gibson explore the relationship between humanity and technology?' }] }); for await (const textPart of result.textStream) { process.stdout.write(textPart); } console.log('Cache token usage:', (await result.providerMetadata)?.bedrock?.usage);`

Amazon Bedrock provider metadata fields

The following Bedrock-specific metadata may be returned in `providerMetadata.bedrock`: trace (optional, Guardrail tracing information when tracing is enabled), performanceConfig (optional, e.g. { latency: 'optimized' }), serviceTier (optional, service tier information e.g. { type: 'on-demand' }), usage (optional, cache token usage details including cacheWriteInputTokens and cacheDetails), and stopSequence (string | null, the stop sequence that triggered the stop, if any).

Amazon Bedrock reasoning features

Amazon Bedrock supports model creator-specific reasoning features: Anthropic models (e.g. claude-sonnet-4-5-20250929) enable via the `reasoningConfig` provider option with a thinking budget in tokens (minimum: 1024, maximum: 64000). Amazon models (e.g. us.amazon.nova-2-lite-v1:0) enable via the `reasoningConfig` provider option with a maximum reasoning effort level ('low' | 'medium' | 'high').

Amazon Bedrock reasoning example

Example of using reasoning with Amazon Bedrock for Anthropic models: `import { amazonBedrock, type AmazonBedrockLanguageModelChatOptions } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const anthropicResult = await generateText({ model: amazonBedrock('us.anthropic.claude-sonnet-4-5-20250929-v1:0'), prompt: 'How many people will live in the world in 2040?', providerOptions: { bedrock: { reasoningConfig: { type: 'enabled', budgetTokens: 1024 } } satisfies AmazonBedrockLanguageModelChatOptions } }); console.log(anthropicResult.reasoningText); console.log(anthropicResult.text);` And for Nova 2 models: `const amazonResult = await generateText({ model: amazonBedrock('us.amazon.nova-2-lite-v1:0'), prompt: 'How many people will live in the world in 2040?', providerOptions: { bedrock: { reasoningConfig: { type: 'enabled', maxReasoningEffort: 'medium' } } satisfies AmazonBedrockLanguageModelChatOptions } }); console.log(amazonResult.reasoningText); console.log(amazonResult.text);`

Amazon Bedrock maxTokens adjustment for reasoning

For Anthropic models, Bedrock's `maxTokens` limit includes both thinking and final text. The provider adds `budgetTokens` to `maxOutputTokens` when setting `maxTokens`. When `maxOutputTokens` is omitted, the provider adds `budgetTokens` to the default of 4096.

Amazon Bedrock service tier example

Example of using service tiers with Amazon Bedrock: `import { amazonBedrock, type AmazonBedrockLanguageModelChatOptions } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const result = await generateText({ model: amazonBedrock('us.anthropic.claude-sonnet-4-20250514-v1:0'), prompt: 'Summarize this support ticket backlog.', providerOptions: { bedrock: { serviceTier: 'priority' } satisfies AmazonBedrockLanguageModelChatOptions } });`

Amazon Bedrock extended context window

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 via the `anthropicBeta` provider option.

Amazon Bedrock extended context window example

Example of using extended context window with Amazon Bedrock: `import { amazonBedrock, type AmazonBedrockLanguageModelChatOptions } from '@ai-sdk/amazon-bedrock'; import { generateText } from 'ai'; const result = await generateText({ model: amazonBedrock('us.anthropic.claude-sonnet-4-20250514-v1:0'), prompt: 'analyze this large document...', providerOptions: { bedrock: { anthropicBeta: ['context-1m-2025-08-07'] } satisfies AmazonBedrockLanguageModelChatOptions } });`

Amazon Bedrock Computer Use tools

Via Anthropic, Amazon Bedrock provides three provider-defined tools: Bash Tool (allows running bash commands), Text Editor Tool (provides functionality for viewing and editing text files), and Computer Tool (enables control of keyboard and mouse actions on a computer). They are available via the `tools` property of the provider instance. Amazon Bedrock does not support strict mode on tool definitions; setting `strict: true` on a tool will be ignored and a warning will be emitted.

Amazon Bedrock Bash Tool

The Bash Tool allows running bash commands. Create it with: `const bashTool = amazonBedrock.tools.bash_20241022({ execute: async ({ command, restart }) => { // Implement your bash command execution logic here // Return the result of the command execution } });` Parameters: command (string, the bash command to run, required unless restarting), restart (boolean, optional, specifying true will restart this tool).

Amazon Bedrock Text Editor Tool for Claude 3.5 Sonnet and earlier

For Claude 3.5 Sonnet and earlier models, create the Text Editor Tool with: `const textEditorTool = amazonBedrock.tools.textEditor_20241022({ execute: async ({ command, path, file_text, insert_line, new_str, insert_text, old_str, view_range }) => { // Implement your text editing logic here // Return the result of the text editing operation } });` Parameters: command ('view' | 'create' | 'str_replace' | 'insert' | 'undo_edit'), path (string, absolute path to file or directory), file_text (string, optional, required for create command), insert_line (number, optional, required for insert command), new_str (string, optional, for str_replace command), insert_text (string, optional, required for insert command), old_str (string, optional, required for str_replace command), view_range (number[], optional, for view command). Use key `str_replace_editor` in tools object. Note: undo_edit is only available in Claude 3.5 Sonnet and earlier models.

Amazon Bedrock Text Editor Tool usage examples

For Claude 4 models, use `str_replace_based_edit_tool` key: `const response = await generateText({ model: amazonBedrock('us.anthropic.claude-sonnet-4-20250514-v1:0'), prompt: "Create a new file called example.txt, write 'Hello World' to it, and run 'cat example.txt' in the terminal", tools: { str_replace_based_edit_tool: textEditorTool } });` For Claude 3.5 Sonnet and earlier, use `str_replace_editor` key: `const response = await generateText({ model: amazonBedrock('anthropic.claude-3-5-sonnet-20241022-v2:0'), prompt: "Create a new file called example.txt, write 'Hello World' to it, and run 'cat example.txt' in the terminal", tools: { str_replace_editor: textEditorTool } });`

Amazon Bedrock Computer Tool

The Computer Tool enables control of keyboard and mouse actions. Create it with: `const computerTool = amazonBedrock.tools.computer_20241022({ displayWidthPx: 1920, displayHeightPx: 1080, displayNumber: 0, // Optional, for X11 environments execute: async ({ action, coordinate, text }) => { // Implement your computer control logic here // Return the result of the action // Example code: switch (action) { case 'screenshot': { return { type: 'image', data: fs.readFileSync('./data/screenshot-editor.png').toString('base64') }; } default: { console.log('Action:', action); console.log('Coordinate:', coordinate); console.log('Text:', text); return \`executed \${action}\`; } } }, toModelOutput({ output }) { return typeof output === 'string' ? [{ type: 'text', text: output }] : [{ type: 'file-data', data: output.data, mediaType: 'image/png' }]; } });` Parameters: action ('key' | 'type' | 'mouse_move' | 'left_click' | 'left_click_drag' | 'right_click' | 'middle_click' | 'double_click' | 'screenshot' | 'cursor_position'), coordinate (number[], optional, required for mouse_move and left_click_drag), text (string, optional, required for type and key actions).

Bedrock model capabilities table

Amazon Bedrock supports the following models with their capabilities across Image Input, Object Generation, Tool Usage, and Tool Streaming: amazon.titan-tg1-large (no support), amazon.titan-text-express-v1 (no support), amazon.titan-text-lite-v1 (no support), us.amazon.nova-premier-v1:0 (all supported), us.amazon.nova-pro-v1:0 (all supported), us.amazon.nova-lite-v1:0 (all supported), us.amazon.nova-micro-v1:0 (no image input, others supported), anthropic.claude-haiku-4-5-20251001-v1:0 (all supported), anthropic.claude-sonnet-4-20250514-v1:0 (all supported), anthropic.claude-sonnet-4-5-20250929-v1:0 (all supported), anthropic.claude-opus-4-20250514-v1:0 (all supported), anthropic.claude-opus-4-1-20250805-v1:0 (all supported), anthropic.claude-3-5-sonnet-20241022-v2:0 (all supported), anthropic.claude-3-5-sonnet-20240620-v1:0 (all supported), anthropic.claude-3-opus-20240229-v1:0 (all supported), anthropic.claude-3-sonnet-20240229-v1:0 (all supported), anthropic.claude-3-haiku-20240307-v1:0 (all supported), us.anthropic.claude-sonnet-4-20250514-v1:0 (all supported), us.anthropic.claude-sonnet-4-5-20250929-v1:0 (all supported), us.anthropic.claude-opus-4-20250514-v1:0 (all supported), us.anthropic.claude-opus-4-1-20250805-v1:0 (all supported), us.anthropic.claude-3-5-sonnet-20241022-v2:0 (all supported), us.anthropic.claude-3-5-sonnet-20240620-v1:0 (all supported), us.anthropic.claude-3-sonnet-20240229-v1:0 (all supported), us.anthropic.claude-3-opus-20240229-v1:0 (all supported), us.anthropic.claude-3-haiku-20240307-v1:0 (all supported), anthropic.claude-v2 (no support), anthropic.claude-v2:1 (no support), anthropic.claude-instant-v1 (no support), cohere.command-text-v14 (no support), cohere.command-light-text-v14 (no support), cohere.command-r-v1:0 (tool usage supported only), cohere.command-r-plus-v1:0 (tool usage supported only), us.deepseek.r1-v1:0 (no image input, others supported), meta.llama3-8b-instruct-v1:0 (no support), meta.llama3-70b-instruct-v1:0 (no support), meta.llama3-1-8b-instruct-v1:0 (no support), meta.llama3-1-70b-instruct-v1:0 (no support), meta.llama3-1-405b-instruct-v1:0 (no support), meta.llama3-2-1b-instruct-v1:0 (no support), meta.llama3-2-3b-instruct-v1:0 (no support), meta.llama3-2-11b-instruct-v1:0 (no support), meta.llama3-2-90b-instruct-v1:0 (no support), us.meta.llama3-2-1b-instruct-v1:0 (no image input, others supported), us.meta.llama3-2-3b-instruct-v1:0 (no image input, others supported), us.meta.llama3-2-11b-instruct-v1:0 (no image input, others supported), us.meta.llama3-2-90b-instruct-v1:0 (no image input, others supported), us.meta.llama3-1-8b-instruct-v1:0 (no image input, others supported), us.meta.llama3-1-70b-instruct-v1:0 (no image input, others supported), us.meta.llama3-3-70b-instruct-v1:0 (no image input, others supported), us.meta.llama4-scout-17b-instruct-v1:0 (no image input, others supported), us.meta.llama4-maverick-17b-instruct-v1:0 (no image input, others supported), mistral.mistral-7b-instruct-v0:2 (no support), mistral.mixtral-8x7b-instruct-v0:1 (no support), mistral.mistral-large-2402-v1:0 (no support), mistral.mistral-small-2402-v1:0 (no support), us.mistral.pixtral-large-2502-v1:0 (all supported), openai.gpt-oss-120b-1:0 (no image input, others supported), openai.gpt-oss-20b-1:0 (no image input, others supported).

Bedrock Anthropic computer use tools available

The Bedrock Anthropic provider supports Anthropic's computer use tools: Bash Tool (allows running bash commands via bedrockAnthropic.tools.bash_20241022()), Text Editor Tool (functionality for viewing and editing text files via bedrockAnthropic.tools.textEditor_20241022()), Computer Tool (enables control of keyboard and mouse actions). Computer use tools require Claude 3.7 Sonnet or newer models. Claude 3.5 Sonnet v2 does not support these tools.

Example: Bedrock Anthropic bash tool

import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic'; import { generateText, isStepCount } from 'ai'; const result = await generateText({ model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'), tools: { bash: bedrockAnthropic.tools.bash_20241022({ execute: async ({ command }) => { return [{ type: 'text', text: `Executed: ${command}` }]; }, }), }, prompt: 'List the files in my directory.', stopWhen: isStepCount(2), });

Example: Bedrock Anthropic text editor tool

import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic'; import { generateText, isStepCount } from 'ai'; const result = await generateText({ model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'), tools: { str_replace_editor: bedrockAnthropic.tools.textEditor_20241022({ execute: async ({ command, path, old_str, new_str, insert_text }) => { return 'File updated successfully'; }, }), }, prompt: 'Update my README file.', stopWhen: isStepCount(5), });

Give your agent this brain