---
title: Amazon Bedrock
description: Learn how to use Amazon Bedrock with AI Gateway and the direct provider.
url: "https://ai-sdk.dev/providers/ai-sdk-providers/amazon-bedrock"
docs_index: /llms.txt
---

> For an index of all documentation, see [/llms.txt](/llms.txt).

The Amazon Bedrock provider for the [AI SDK](/docs) contains language model support for the [Amazon Bedrock](https://aws.amazon.com/bedrock) APIs.
Start with [AI Gateway](/providers/ai-sdk-providers/ai-gateway) for models in its catalog (recommended), or use `@ai-sdk/amazon-bedrock` to connect directly to Amazon Bedrock.

```ts provider="amazon" model="amazon/nova-pro"
import { generateText } from 'ai';

const { text } = await generateText({
  model: "amazon/nova-pro",
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
  providerOptions: {
    gateway: {
      order: ['bedrock'],
    },
  },
});

console.log(text);
```

## Using AI Gateway

The AI SDK uses AI Gateway by default for model strings. Gateway provides access to models across providers through a single API key, with usage and cost tracking. Install `ai`:

```bash
pnpm add ai
```

Set an [AI Gateway API key](https://vercel.com/docs/ai-gateway/getting-started) in your environment:

```bash
export AI_GATEWAY_API_KEY=your_api_key_here
```

Vercel deployments can also use [OIDC authentication](/providers/ai-sdk-providers/ai-gateway#oidc-authentication-vercel-deployments).
See the [AI Gateway provider documentation](/providers/ai-sdk-providers/ai-gateway) for configuration and the [model catalog](https://vercel.com/ai-gateway/models) for available models.

The example sets `providerOptions.gateway.order` to `['bedrock']`. This sends the request to Amazon Bedrock first, then falls back to other available providers of the same model if Amazon Bedrock is unavailable or the request fails. `order` sets a preference; it does not restrict fallback to Amazon Bedrock. See [provider ordering](https://vercel.com/docs/ai-gateway/models-and-providers/provider-filtering-and-ordering).

The dropdown lists models served by Amazon Bedrock through Gateway with a corresponding direct-provider example. Provider availability depends on the model and your team's [Provider Allowlist](https://vercel.com/docs/ai-gateway/models-and-providers/provider-filtering-and-ordering).

## Using `@ai-sdk/amazon-bedrock`

For direct access to Amazon Bedrock, install `ai` and `@ai-sdk/amazon-bedrock`:

```bash
pnpm add ai @ai-sdk/amazon-bedrock
```

Set your Amazon Bedrock API credential in the `AWS_BEARER_TOKEN_BEDROCK` environment variable:

```bash
export AWS_BEARER_TOKEN_BEDROCK=your_api_key_here
export AWS_REGION=us-east-1
```

Use the direct provider for AWS authentication, account-specific inference profiles, or Bedrock-specific APIs. Gateway and Bedrock use different model IDs.

The following sections document the direct `@ai-sdk/amazon-bedrock` provider,
including its model factories and settings. Gateway model and feature
availability can differ.

### Prerequisites

Access to Amazon Bedrock foundation models isn't granted by default. In order to gain access to a foundation model, an IAM user with sufficient permissions needs to request access to it through the console. Once access is provided to a model, it is available for all users in the account.

See the [Model Access Docs](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) for more information.

### Authentication

The Amazon Bedrock provider supports two authentication methods with automatic fallback: API key authentication (recommended) and AWS SigV4 authentication using IAM credentials or the AWS SDK credentials chain.

#### Using an API Key (Recommended)

API key authentication provides a simpler setup compared to AWS SigV4 authentication. When an API key is supplied, it takes precedence over any SigV4 credentials.

Generate a bedrock API key from the [AWS console](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html), then either set it as the `AWS_BEARER_TOKEN_BEDROCK` environment variable:

```bash
AWS_BEARER_TOKEN_BEDROCK=your-api-key-here
```

or pass it directly to `createAmazonBedrock`:

```ts
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';

const amazonBedrock = createAmazonBedrock({
  apiKey: 'your-api-key-here',
  region: 'us-east-1',
});
```

When `apiKey` is omitted, the provider falls back to `AWS_BEARER_TOKEN_BEDROCK`, and then to SigV4 authentication if neither is set.

#### Using IAM Access Key and Secret Key

**Step 1: Creating AWS Access Key and Secret Key**

To get started, you'll need to create an AWS access key and secret key. Here's how:

**Login to AWS Management Console**

- Go to the [AWS Management Console](https://console.aws.amazon.com/) and log in with your AWS account credentials.

**Create an IAM User**

- Navigate to the [IAM dashboard](https://console.aws.amazon.com/iam/home) and click on "Users" in the left-hand navigation menu.
- Click on "Create user" and fill in the required details to create a new IAM user.
- Make sure to select "Programmatic access" as the access type.
- The user account needs the `AmazonBedrockFullAccess` policy attached to it.

**Create Access Key**

- Click on the "Security credentials" tab and then click on "Create access key".
- Click "Create access key" to generate a new access key pair.
- Download the `.csv` file containing the access key ID and secret access key.

**Step 2: Configuring the Access Key and Secret Key**

Within your project add a `.env` file if you don't already have one. This file will be used to set the access key and secret key as environment variables. Add the following lines to the `.env` file:

```makefile
AWS_ACCESS_KEY_ID=YOUR_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY=YOUR_SECRET_ACCESS_KEY
AWS_REGION=YOUR_REGION
```

Many frameworks such as [Next.js](https://nextjs.org/) load the `.env` file
automatically. If you're using a different framework, you may need to load the
`.env` file manually using a package like
[`dotenv`](https://github.com/motdotla/dotenv).

Remember to replace `YOUR_ACCESS_KEY_ID`, `YOUR_SECRET_ACCESS_KEY`, and `YOUR_REGION` with the actual values from your AWS account.

#### Using AWS SDK Credentials Chain (instance profiles, instance roles, ECS roles, EKS Service Accounts, etc.)

When using AWS SDK, the SDK will automatically use the credentials chain to determine the credentials to use. This includes instance profiles, instance roles, ECS roles, EKS Service Accounts, etc. A similar behavior is possible using the AI SDK by not specifying the `accessKeyId` and `secretAccessKey`, `sessionToken` properties in the provider settings and instead passing a `credentialProvider` property.

*Usage:*

`@aws-sdk/credential-providers` package provides a set of credential providers that can be used to create a credential provider chain.

```bash
pnpm add @aws-sdk/credential-providers
```

```ts
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';
import { fromNodeProviderChain } from '@aws-sdk/credential-providers';

const amazonBedrock = createAmazonBedrock({
  region: 'us-east-1',
  credentialProvider: fromNodeProviderChain(),
});
```

## Provider Instance

You can import the default provider instance `amazonBedrock` from `@ai-sdk/amazon-bedrock`:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
```

If you need a customized setup, you can import `createAmazonBedrock` from `@ai-sdk/amazon-bedrock` and create a provider instance with your settings:

```ts
import { createAmazonBedrock } from '@ai-sdk/amazon-bedrock';

const amazonBedrock = createAmazonBedrock({
  region: 'us-east-1',
  accessKeyId: 'xxxxxxxxx',
  secretAccessKey: 'xxxxxxxxx',
  sessionToken: 'xxxxxxxxx',
});
```

Omitted options use the environment variables below. When **both**
`accessKeyId` and `secretAccessKey` are strings, SigV4 uses a **`sessionToken`
only if you pass one** - not `AWS_SESSION_TOKEN` from the environment - so
static keys are not mixed with workload tokens (e.g. EKS IRSA).

You can use the following optional settings to customize the Amazon Bedrock provider instance:

- **region** *string*

  The AWS region that you want to use for the API calls.
  It uses the `AWS_REGION` environment variable by default.

- **accessKeyId** *string*

  The AWS access key ID that you want to use for the API calls.
  It uses the `AWS_ACCESS_KEY_ID` environment variable by default.

- **secretAccessKey** *string*

  The AWS secret access key that you want to use for the API calls.
  It uses the `AWS_SECRET_ACCESS_KEY` environment variable by default.

- **sessionToken** *string*

  Optional. For temporary credentials. With **both** access keys set as strings,
  pass the token here if needed; `AWS_SESSION_TOKEN` from the environment is not
  used. If either key is taken from the environment, omitting `sessionToken`
  allows `AWS_SESSION_TOKEN`.

- **credentialProvider** *() => Promise\<\{ accessKeyId: string; secretAccessKey: string; sessionToken?: string; }>*

  Optional. The AWS credential provider chain that you want to use for the API calls.
  It uses the specified credentials by default.

- **apiKey** *string | PromiseLike\<string> | (() => string | PromiseLike\<string>)*

  Pass a callback to resolve the API key before each request. The callback can
  return a string or a promise; token caching and renewal are handled by the caller.
  A callback or promise selects API key authentication and must resolve to a
  non-empty string; lookup failures do not switch authentication methods.

  Optional. API key for authenticating requests using Bearer token authentication.
  When provided, this will be used instead of AWS SigV4 authentication.
  It uses the `AWS_BEARER_TOKEN_BEDROCK` environment variable by default.

- **baseURL** *string*

  Optional. Base URL for the Bedrock API calls.
  Useful for custom endpoints or proxy configurations.
  When omitted, the provider also supports the service-specific
  `AWS_ENDPOINT_URL_BEDROCK_RUNTIME` and
  `AWS_ENDPOINT_URL_BEDROCK_AGENT_RUNTIME` environment variables, which take
  precedence over the global `AWS_ENDPOINT_URL` environment variable.

- **headers** *Record\<string, string>*

  Optional. Custom headers to include in the requests.

- **fetch** *(input: RequestInfo, init?: RequestInit) => Promise\<Response>*

  Optional. Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
  You can use it as a middleware to intercept requests,
  or to provide a custom fetch implementation for e.g. testing.

## Language Models

You can create models that call the Bedrock API using the provider instance.
The first argument is the model id, e.g. `meta.llama3-70b-instruct-v1:0`.

```ts
const model = amazonBedrock('meta.llama3-70b-instruct-v1:0');
```

Amazon Bedrock models also support some model specific provider options that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
You can pass them in the `providerOptions` argument:

```ts
const model = amazonBedrock('anthropic.claude-3-sonnet-20240229-v1:0');

await generateText({
  model,
  providerOptions: {
    anthropic: {
      additionalModelRequestFields: { top_k: 350 },
    },
  },
});
```

Documentation for additional settings based on the selected model can be found within the [Amazon Bedrock Inference Parameter Documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/model-parameters.html).

You can use Amazon Bedrock language models to generate text with the `generateText` function:

```ts
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 language models can also be used in the `streamText` function
(see [AI SDK Core](/docs/ai-sdk-core)).

### Structured Outputs

For Anthropic models, you can use the `structuredOutputMode` provider option to
choose how Amazon Bedrock generates structured outputs:

- `"outputFormat"`: Use Bedrock's native `output_config.format` parameter.
- `"jsonTool"`: Use a special `json` tool with required tool choice.
- `"auto"`: Use native structured output when supported and otherwise fall
  back to the JSON tool. This is the default.

In `"auto"` mode, supported Claude 5 models use native output for compatible
schemas. Recursive references, open objects, and schemas with more than ten
optional properties fall back to the JSON tool, or JSON instructions for models
that reject forced tool use.

The JSON-tool fallback limits which application tools are available:
`toolChoice: 'none'` sends only the internal JSON response tool, and a named tool
choice sends only that application tool alongside the JSON response tool. The
fallback can produce a JSON response without calling the named application tool;
verify the selected call if your application requires it.

In `"auto"` mode, Claude Sonnet 4.6 and Claude Haiku 4.5 use the JSON tool
fallback because native structured output can be unreliable across workloads
and Bedrock accounts. You can set `"outputFormat"` to opt into native structured
output when it works for your account and workload, or use `"jsonTool"` to force
the fallback for any model:

```ts
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,
  },
});
```

The legacy `providerOptions.bedrock` key remains supported. For parity with the
Anthropic provider, `providerOptions.anthropic.structuredOutputMode` is also
honored for Anthropic models on Bedrock. When both are provided, the
`amazonBedrock` or legacy `bedrock` value takes precedence.

For an Anthropic application inference profile, prefer the Bedrock Anthropic
provider. It uses Bedrock's native InvokeModel API, which accepts application
inference profile ARNs, and identifies the model as Anthropic automatically:

```ts
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';

const profileArn =
  'arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/qibm5eutlkcy';

const model = bedrockAnthropic(profileArn);
```

Use `modelFamily: 'anthropic'` only when you need to use the generic
`@ai-sdk/amazon-bedrock` provider, which uses Bedrock's Converse API (for
example, when IAM permits Converse but not InvokeModel). Application inference
profile ARNs do not identify their underlying model, so declaring the family
allows Anthropic-specific features, including native structured output:

```ts
import {
  amazonBedrock,
  type AmazonBedrockChatModelSettings,
} from '@ai-sdk/amazon-bedrock';

const profileArn =
  'arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/qibm5eutlkcy';

const model = amazonBedrock(profileArn, {
  modelFamily: 'anthropic',
} satisfies AmazonBedrockChatModelSettings);
```

For an underlying model that does not reliably support native structured
output, set `structuredOutputMode` to `"jsonTool"`.

### File Inputs

Amazon Bedrock supports file inputs in combination with specific models, e.g.
`anthropic.claude-3-haiku-20240307-v1:0`.

The Amazon Bedrock provider supports file inputs, e.g. PDF files.

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { generateText } from 'ai';

const result = await generateText({
  model: amazonBedrock('us.anthropic.claude-haiku-5-5'),
  messages: [
    {
      role: 'user',
      content: [
        { type: 'text', text: 'Describe the pdf in detail.' },
        {
          type: 'file',
          data: readFileSync('./data/ai.pdf'),
          mediaType: 'application/pdf',
        },
      ],
    },
  ],
});
```

### Guardrails

You can use the `bedrock` provider options to utilize [Amazon Bedrock Guardrails](https://aws.amazon.com/bedrock/guardrails/):

```ts
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,
  },
});
```

Tracing information will be returned in the provider metadata if you have tracing enabled.

```ts
if (result.providerMetadata?.bedrock.trace) {
  // ...
}
```

See the [Amazon Bedrock Guardrails documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails.html) for more information.

#### Guard Content

You can mark individual text or image parts as guard content using `providerOptions` on the part itself. This wraps the part in a [`guardContent`](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_GuardrailConverseContentBlock.html) block, which tells Bedrock Guardrails to evaluate that content specifically.

For text parts, you can also specify `guardContentQualifiers` to indicate how the content should be treated by the guardrail (e.g. as a grounding source, a query, or guard content):

```ts
const result = await generateText({
  model: bedrock('anthropic.claude-3-sonnet-20240229-v1:0'),
  providerOptions: {
    bedrock: {
      guardrailConfig: {
        guardrailIdentifier: '1abcd2ef34gh',
        guardrailVersion: '1',
      },
    },
  },
  messages: [
    {
      role: 'user',
      content: [
        {
          type: 'text',
          text: 'London is the capital of UK. Tokyo is the capital of Japan.',
          providerOptions: {
            bedrock: {
              guardContent: true,
              guardContentQualifiers: ['grounding_source'],
            },
          },
        },
        {
          type: 'text',
          text: 'Some additional background information.',
        },
        {
          type: 'text',
          text: 'What is the capital of Japan?',
          providerOptions: {
            bedrock: {
              guardContent: true,
              guardContentQualifiers: ['query'],
            },
          },
        },
      ],
    },
  ],
});
```

Image parts can also be marked as guard content:

```ts
{
  type: 'file',
  data: {
    type: 'data',
    data: imageBase64,
  },
  mediaType: 'image/png',
  providerOptions: {
    bedrock: {
      guardContent: true,
    },
  },
}
```

The available `guardContentQualifiers` are:

- `'grounding_source'` — content used as a grounding source for the guardrail
- `'query'` — content treated as a query to evaluate
- `'guard_content'` — content to be evaluated by the guardrail

See the [Amazon Bedrock Guardrails with Converse API documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/guardrails-use-converse-api.html) for more information.

### Citations

Amazon Bedrock supports citations for document-based inputs across compatible models. When enabled:

- Some models can read documents with visual understanding, not just extracting text
- Models can cite specific parts of documents you provide, making it easier to trace information back to its source (the AI SDK does not return citation data in results yet)

```ts
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 },
            },
          },
        },
      ],
    },
  ],
});

console.log('Response:', result.output);
```

### Cache Points

Amazon Bedrock prompt caching is currently in preview release. To request
access, visit the [Amazon Bedrock prompt caching
page](https://aws.amazon.com/bedrock/prompt-caching/).

In messages, you can use the `providerOptions` property to set cache points. Set the `bedrock` property in the `providerOptions` object to `{ cachePoint: { type: 'default' } }` to create a cache point.

You can also specify a TTL (time-to-live) for cache points using the `ttl` property. Supported values are `'5m'` (5 minutes, default) and `'1h'` (1 hour). The 1-hour TTL is only supported by Claude Opus 4.5, Claude Haiku 4.5, and Claude Sonnet 4.5.

```ts
providerOptions: {
  bedrock: { cachePoint: { type: 'default', ttl: '1h' } },
}
```

When using multiple cache points with different TTLs, cache entries with
longer TTL must appear before shorter TTLs (i.e., 1-hour cache entries must
come before 5-minute cache entries).

Cache usage information is returned in the `providerMetadata` object. See examples below.

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. See the [Amazon Bedrock prompt caching
documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html)
for details on supported models, regions, and limits.

```ts
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('us.anthropic.claude-sonnet-5-5'),
  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.text);
console.log(result.providerMetadata?.bedrock?.usage);
// Shows cache read/write token usage, e.g.:
// {
//   cacheReadInputTokens: 1337,
//   cacheWriteInputTokens: 42,
// }
```

Cache points also work with streaming responses:

```ts
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('us.anthropic.claude-sonnet-5-5'),
  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,
);
// Shows cache read/write token usage, e.g.:
// {
//   cacheReadInputTokens: 1337,
//   cacheWriteInputTokens: 42,
// }
```

### Provider Metadata

The following Bedrock-specific metadata may be returned in `providerMetadata.bedrock`:

- **trace** *(optional)*
  Guardrail tracing information (when tracing is enabled).
- **performanceConfig** *(optional)*
  Performance configuration, e.g. `{ latency: 'optimized' }`.
- **serviceTier** *(optional)*
  Service tier information, 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.

## Reasoning

Amazon Bedrock supports model creator-specific reasoning features:

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

You can also use the top-level `reasoning` parameter.

Bedrock combines partial `providerOptions.amazonBedrock.reasoningConfig` with
portable reasoning, preserving explicit values and deriving missing fields for
the model's reasoning API. An explicit `maxReasoningEffort` replaces the effort
mapping without emitting a coercion warning for the overridden value. For
budget-based Anthropic models, `{ budgetTokens: 5000 }` preserves that budget and
uses portable reasoning to fill a missing `type: 'enabled'`. Type-only,
display-only, and empty configurations also retain portable reasoning.

Effort-based Anthropic models can combine portable effort with an explicit
thinking configuration. A disabled type prevents effort/budget derivation;
portable `reasoning: 'none'` requests disabled thinking on Anthropic models even
when an enabled type or budget is supplied. Omitting portable reasoning or using
`'provider-default'` uses the provider configuration. The legacy
`bedrock` provider options key follows the same rules. See the
[reasoning guide](/docs/ai-sdk-core/reasoning#precedence-rules) for precedence details.

Both `reasoning: 'none'` and `reasoningConfig: { type: 'disabled' }` explicitly
send `thinking: { type: 'disabled' }` for Anthropic models that support it.
For Claude 3.5 and earlier, the provider omits `thinking` because these models
do not support the field.
Models that require thinking use `between_tools` when supported, or adaptive
thinking otherwise. For the adaptive fallback, portable `reasoning: 'none'`
uses explicit `maxReasoningEffort`, then raw `output_config.effort`, and defaults
to low effort when neither is supplied. Unsupported disabled settings produce warnings.
If a model rejects disabled or `between_tools`
thinking at `xhigh` or `max` effort, the provider lowers the effort to `high`
with a warning.

```ts
import {
  amazonBedrock,
  type AmazonBedrockLanguageModelChatOptions,
} from '@ai-sdk/amazon-bedrock';
import { generateText } from 'ai';

// Anthropic example
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); // reasoning text
console.log(anthropicResult.text); // text response

// Nova 2 example
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); // reasoning text
console.log(amazonResult.text); // text response
```

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

See [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details
on how to integrate reasoning into your chatbot.

## Service Tiers

Amazon Bedrock supports selecting an inference service tier per request via the `serviceTier` provider option.

```ts
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,
  },
});
```

Supported values are:

- `reserved`
- `priority`
- `default`
- `flex`

See the [Amazon Bedrock service tiers documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/service-tiers-inference.html) for model availability and behavior.

## 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.

```ts
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,
  },
});
```

## Computer Use

Via Anthropic, Amazon Bedrock provides three provider-defined tools that can be used to interact with external systems:

1. **Bash Tool**: Allows running bash commands.
2. **Text Editor Tool**: Provides functionality for viewing and editing text files.
3. **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.

### Bash Tool

The Bash Tool allows running bash commands. Here's how to create and use it:

```ts
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 the tool is being restarted.
- `restart` (boolean, optional): Specifying true will restart this tool.

### Text Editor Tool

The Text Editor Tool provides functionality for viewing and editing text files.

**For Claude 4 models (Opus & Sonnet):**

```ts
const textEditorTool = amazonBedrock.tools.textEditor_20250429({
  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
  },
});
```

**For Claude 3.5 Sonnet and earlier models:**

```ts
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'): The command to run. Note: `undo_edit` is only available in Claude 3.5 Sonnet and earlier models.
- `path` (string): Absolute path to file or directory, e.g. `/repo/file.py` or `/repo`.
- `file_text` (string, optional): Required for `create` command, with the content of the file to be created.
- `insert_line` (number, optional): Required for `insert` command. The line number after which to insert the new string.
- `new_str` (string, optional): New string for `str_replace` command.
- `insert_text` (string, optional): Required for `insert` command, containing the text to insert.
- `old_str` (string, optional): Required for `str_replace` command, containing the string to replace.
- `view_range` (number\[], optional): Optional for `view` command to specify line range to show.

When using the Text Editor Tool, make sure to name the key in the tools object correctly:

- **Claude 4 models**: Use `str_replace_based_edit_tool`
- **Claude 3.5 Sonnet and earlier**: Use `str_replace_editor`

```ts
// For Claude 4 models
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, // Claude 4 tool name
  },
});

// For Claude 3.5 Sonnet and earlier
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, // Earlier models tool name
  },
});
```

### Computer Tool

The Computer Tool enables control of keyboard and mouse actions on a computer:

```ts
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': {
        // multipart result:
        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}`;
      }
    }
  },

  // map to tool result content for LLM consumption:
  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'): The action to perform.
- `coordinate` (number\[], optional): Required for `mouse_move` and `left_click_drag` actions. Specifies the (x, y) coordinates.
- `text` (string, optional): Required for `type` and `key` actions.

These tools can be used in conjunction with the `anthropic.claude-3-5-sonnet-20240620-v1:0` model to enable more complex interactions and tasks.

### Model Capabilities

| Model                                          | Image Input | Object Generation | Tool Usage | Tool Streaming |
| ---------------------------------------------- | ----------- | ----------------- | ---------- | -------------- |
| `amazon.titan-tg1-large`                       | ✗           | ✗                 | ✗          | ✗              |
| `amazon.titan-text-express-v1`                 | ✗           | ✗                 | ✗          | ✗              |
| `anthropic.claude-v2`                          | ✗           | ✗                 | ✗          | ✗              |
| `anthropic.claude-v2:1`                        | ✗           | ✗                 | ✗          | ✗              |
| `anthropic.claude-instant-v1`                  | ✗           | ✗                 | ✗          | ✗              |
| `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-5-sonnet-20240620-v1:0`    | ✓           | ✓                 | ✓          | ✓              |
| `anthropic.claude-3-5-sonnet-20241022-v2: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-sonnet-20241022-v2: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.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`    | ✗           | ✓                 | ✓          | ✓              |

The table above lists popular models. Please see the [Amazon Bedrock
docs](https://docs.aws.amazon.com/bedrock/latest/userguide/conversation-inference-supported-models-features.html)
for a full list of available models. You can also pass any available provider
model ID as a string if needed.

## Embedding Models

You can create models that call the Bedrock API [Bedrock API](https://docs.aws.amazon.com/bedrock/latest/userguide/titan-embedding-models.html)
using the `.embedding()` factory method.

```ts
const model = amazonBedrock.embedding('amazon.titan-embed-text-v1');
```

Bedrock Titan embedding model amazon.titan-embed-text-v2:0 supports several additional settings.
You can pass them as an options argument:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';

const model = amazonBedrock.embedding('amazon.titan-embed-text-v2:0');

const { embedding } = await embed({
  model,
  value: 'sunny day at the beach',
  providerOptions: {
    bedrock: {
      dimensions: 512, // optional, number of dimensions for the embedding
      normalize: true, // optional, normalize the output embeddings
    } satisfies AmazonBedrockEmbeddingModelOptions,
  },
});
```

The following optional provider options are available for Bedrock Titan embedding models:

- **dimensions**: *number*

  The number of dimensions the output embeddings should have. The following values are accepted: 1024 (default), 512, 256.

- **normalize** *boolean*

  Flag indicating whether or not to normalize the output embeddings. Defaults to true.

### Nova Embedding Models

Amazon Nova embedding models support additional provider options:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';

const { embedding } = await embed({
  model: amazonBedrock.embedding('amazon.nova-embed-text-v2:0'),
  value: 'sunny day at the beach',
  providerOptions: {
    bedrock: {
      embeddingDimension: 1024, // optional, number of dimensions
      embeddingPurpose: 'TEXT_RETRIEVAL', // optional, purpose of embedding
      truncate: 'END', // optional, truncation behavior
    } satisfies AmazonBedrockEmbeddingModelOptions,
  },
});
```

The following optional provider options are available for Nova embedding models:

- **embeddingDimension** *number*

  The number of dimensions for the output embeddings. Supported values: 256, 384, 1024 (default), 3072.

- **embeddingPurpose** *string*

  The purpose of the embedding. Accepts: `GENERIC_INDEX` (default), `TEXT_RETRIEVAL`, `IMAGE_RETRIEVAL`, `VIDEO_RETRIEVAL`, `DOCUMENT_RETRIEVAL`, `AUDIO_RETRIEVAL`, `GENERIC_RETRIEVAL`, `CLASSIFICATION`, `CLUSTERING`.

- **truncate** *string*

  Truncation behavior when input exceeds the model's context length. Accepts: `NONE`, `START`, `END` (default).

### Cohere Embedding Models

Cohere embedding models on Bedrock require an `inputType` and support truncation:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { type AmazonBedrockEmbeddingModelOptions } from '@ai-sdk/amazon-bedrock';
import { embed } from 'ai';

const { embedding } = await embed({
  model: amazonBedrock.embedding('cohere.embed-english-v3'),
  value: 'sunny day at the beach',
  providerOptions: {
    bedrock: {
      inputType: 'search_document', // required for Cohere
      truncate: 'END', // optional, truncation behavior
    } satisfies AmazonBedrockEmbeddingModelOptions,
  },
});
```

The following provider options are available for Cohere embedding models:

- **inputType** *string*

  Input type for Cohere embedding models. Accepts: `search_document`, `search_query` (default), `classification`, `clustering`.

- **truncate** *string*

  Truncation behavior when input exceeds the model's context length. Accepts: `NONE`, `START`, `END`.

### Application Inference Profiles

Application inference profile ARNs do not identify their underlying model. Pass
the model family when creating an embedding model so the provider can select
the correct request format and batch size:

```ts
import {
  amazonBedrock,
  type AmazonBedrockEmbeddingModelSettings,
} from '@ai-sdk/amazon-bedrock';
import { embedMany } from 'ai';

const profileArn =
  'arn:aws:bedrock:us-east-1:123456789012:application-inference-profile/qibm5eutlkcy';

const { embeddings } = await embedMany({
  model: amazonBedrock.embedding(profileArn, {
    modelFamily: 'cohere',
  } satisfies AmazonBedrockEmbeddingModelSettings),
  values: ['hello', 'world'],
});
```

### Model Capabilities

| Model                          | Default Dimensions | Custom Dimensions |
| ------------------------------ | ------------------ | ----------------- |
| `amazon.titan-embed-text-v1`   | 1536               | ✗                 |
| `amazon.titan-embed-text-v2:0` | 1024               | ✓                 |
| `amazon.nova-embed-text-v2:0`  | 1024               | ✓                 |
| `cohere.embed-english-v3`      | 1024               | ✗                 |
| `cohere.embed-multilingual-v3` | 1024               | ✗                 |
| `cohere.embed-v4:0`            | 1536               | ✓                 |

## Reranking Models

You can create models that call the [Bedrock Rerank API](https://docs.aws.amazon.com/bedrock/latest/userguide/rerank-api.html)
using the `.reranking()` factory method.

```ts
const model = amazonBedrock.reranking('cohere.rerank-v3-5:0');
```

You can use Amazon Bedrock reranking models to rerank documents with the `rerank` function:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { rerank } from 'ai';

const documents = [
  'sunny day at the beach',
  'rainy afternoon in the city',
  'snowy night in the mountains',
];

const { ranking } = await rerank({
  model: amazonBedrock.reranking('cohere.rerank-v3-5:0'),
  documents,
  query: 'talk about rain',
  topN: 2,
});

console.log(ranking);
// [
//   { originalIndex: 1, score: 0.9, document: 'rainy afternoon in the city' },
//   { originalIndex: 0, score: 0.3, document: 'sunny day at the beach' }
// ]
```

Amazon Bedrock reranking models support additional provider options that can be passed via `providerOptions.bedrock`:

```ts
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'],
  query: 'talk about rain',
  providerOptions: {
    bedrock: {
      nextToken: 'pagination_token_here',
    },
  },
});
```

The following provider options are available:

- **nextToken** *string*

  Token for pagination of results.

- **additionalModelRequestFields** *Record\<string, unknown>*

  Additional model-specific request fields.

### Model Capabilities

| Model                  | Text Documents | Object Documents | Top N |
| ---------------------- | -------------- | ---------------- | ----- |
| `amazon.rerank-v1:0`   | ✓              | ✓                | ✓     |
| `cohere.rerank-v3-5:0` | ✓              | ✓                | ✓     |

## Image Models

You can create models that call the Bedrock API [Bedrock API](https://docs.aws.amazon.com/nova/latest/userguide/image-generation.html)
using the `.image()` factory method.

For more on the Amazon Nova Canvas image model, see the [Nova Canvas
Overview](https://docs.aws.amazon.com/ai/responsible-ai/nova-canvas/overview.html).

The `amazon.nova-canvas-v1:0` model is available in the `us-east-1`,
`eu-west-1`, and `ap-northeast-1` regions.

```ts
const model = amazonBedrock.image('amazon.nova-canvas-v1:0');
```

You can then generate images with the `generateImage` function:

```ts
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,
});
```

You can also pass the `providerOptions` object to the `generateImage` function to customize the generation behavior. Use the `AmazonBedrockImageModelOptions` type to validate Amazon Bedrock image provider options. The preferred provider option key is `providerOptions.amazonBedrock`; the legacy `providerOptions.bedrock` key remains supported for backward compatibility:

```ts
import {
  amazonBedrock,
  type AmazonBedrockImageModelOptions,
} 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,
  providerOptions: {
    amazonBedrock: {
      quality: 'premium',
      negativeText: 'blurry, low quality',
      cfgScale: 7.5,
      style: 'PHOTOREALISM',
    } satisfies AmazonBedrockImageModelOptions,
  },
});
```

The following optional provider options are available for Amazon Nova Canvas:

- **quality** *string*

  The quality level for image generation. Accepts `'standard'` or `'premium'`.

- **negativeText** *string*

  Text describing what you don't want in the generated image.

- **cfgScale** *number*

  Controls how closely the generated image adheres to the prompt. Higher values result in images that are more closely aligned to the prompt.

- **style** *string*

  Predefined visual style for image generation.
  Accepts one of:
  `3D_ANIMATED_FAMILY_FILM` · `DESIGN_SKETCH` · `FLAT_VECTOR_ILLUSTRATION` ·
  `GRAPHIC_NOVEL_ILLUSTRATION` · `MAXIMALISM` · `MIDCENTURY_RETRO` ·
  `PHOTOREALISM` · `SOFT_DIGITAL_PAINTING`.

Documentation for additional settings can be found within the [Amazon Bedrock
User Guide for Amazon Nova
Documentation](https://docs.aws.amazon.com/nova/latest/userguide/image-gen-req-resp-structure.html).

### Image Editing

Amazon Nova Canvas supports several image editing task types. When you provide input images via `prompt.images`, the model automatically detects the appropriate editing mode, or you can explicitly specify the `taskType` in provider options.

#### Image Variation

Create variations of an existing image while maintaining its core characteristics:

```ts
const imageBuffer = readFileSync('./input-image.png');

const { images } = await generateImage({
  model: amazonBedrock.image('amazon.nova-canvas-v1:0'),
  prompt: {
    text: 'Modernize the style, photo-realistic, 8k, hdr',
    images: [imageBuffer],
  },
  providerOptions: {
    amazonBedrock: {
      taskType: 'IMAGE_VARIATION',
      similarityStrength: 0.7, // 0.2-1.0, higher = closer to original
      negativeText: 'bad quality, low resolution',
    } satisfies AmazonBedrockImageModelOptions,
  },
});
```

- **similarityStrength** *number*

  Controls how similar the output is to the input image. Values range from 0.2 to 1.0, where higher values produce results closer to the original.

#### Inpainting

Edit specific parts of an image. You can define the area to modify using either a mask image or a text prompt:

**Using a mask prompt (text-based selection):**

```ts
const imageBuffer = readFileSync('./input-image.png');

const { images } = await generateImage({
  model: amazonBedrock.image('amazon.nova-canvas-v1:0'),
  prompt: {
    text: 'a cute corgi dog in the same style',
    images: [imageBuffer],
  },
  providerOptions: {
    amazonBedrock: {
      maskPrompt: 'cat', // Describe what to replace
    } satisfies AmazonBedrockImageModelOptions,
  },
  seed: 42,
});
```

**Using a mask image:**

```ts
const image = readFileSync('./input-image.png');
const mask = readFileSync('./mask.png'); // White pixels = area to change

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,
  },
});
```

- **maskPrompt** *string*

  A text description of the area to modify. The model will automatically identify and mask the described region.

#### Outpainting

Extend an image beyond its original boundaries:

```ts
const imageBuffer = readFileSync('./input-image.png');

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', // or 'PRECISE'
    } satisfies AmazonBedrockImageModelOptions,
  },
});
```

- **outPaintingMode** *string*

  Controls how the outpainting is performed. Accepts `'DEFAULT'` or `'PRECISE'`.

#### Background Removal

Remove the background from an image:

```ts
const imageBuffer = readFileSync('./input-image.png');

const { images } = await generateImage({
  model: amazonBedrock.image('amazon.nova-canvas-v1:0'),
  prompt: {
    images: [imageBuffer],
  },
  providerOptions: {
    amazonBedrock: {
      taskType: 'BACKGROUND_REMOVAL',
    } satisfies AmazonBedrockImageModelOptions,
  },
});
```

Background removal does not require a text prompt - only the input image is
needed.

#### Image Editing Provider Options

The following additional provider options are available for image editing:

- **taskType** *string*

  Explicitly set the editing task type. Accepts `'TEXT_IMAGE'` (default for text-only), `'IMAGE_VARIATION'`, `'INPAINTING'`, `'OUTPAINTING'`, or `'BACKGROUND_REMOVAL'`. When images are provided without an explicit taskType, the model defaults to `'IMAGE_VARIATION'` (or `'INPAINTING'` if a mask is provided).

- **maskPrompt** *string*

  Text description of the area to modify (for inpainting/outpainting). Alternative to providing a mask image.

- **similarityStrength** *number*

  For `IMAGE_VARIATION`: Controls similarity to the original (0.2-1.0).

- **outPaintingMode** *string*

  For `OUTPAINTING`: Controls the outpainting behavior (`'DEFAULT'` or `'PRECISE'`).

### Image Model Settings

You can customize the generation behavior with optional options:

```ts
await generateImage({
  model: amazonBedrock.image('amazon.nova-canvas-v1:0'),
  prompt: 'A beautiful sunset over a calm ocean',
  size: '512x512',
  seed: 42,
  maxImagesPerCall: 1, // Maximum number of images to generate per API call
});
```

- **maxImagesPerCall** *number*

  Override the maximum number of images generated per API call. Default can vary
  by model, with 5 as a common default.

### Model Capabilities

The Amazon Nova Canvas model supports custom sizes with constraints as follows:

- Each side must be between 320-4096 pixels, inclusive.
- Each side must be evenly divisible by 16.
- The aspect ratio must be between 1:4 and 4:1. That is, one side can't be more than 4 times longer than the other side.
- The total pixel count must be less than 4,194,304.

For more, see [Image generation access and
usage](https://docs.aws.amazon.com/nova/latest/userguide/image-gen-access.html).

| Model                     | Sizes                                                                                            | Image Editing | Mask Input | Max Images Per Call |
| ------------------------- | ------------------------------------------------------------------------------------------------ | ------------- | ---------- | ------------------- |
| `amazon.nova-canvas-v1:0` | 320–4096 pixels per side, divisible by 16; aspect ratio 1:4 to 4:1; fewer than 4,194,304 pixels. | ✓             | ✓          | 5                   |

## Response Headers

The Amazon Bedrock provider will return the response headers associated with
network requests made of the Bedrock servers.

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { generateText } from 'ai';

const result = await generateText({
  model: amazonBedrock('meta.llama3-70b-instruct-v1:0'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});

console.log(result.response.headers);
```

Below is sample output where you can see the `x-amzn-requestid` header. This can
be useful for correlating Bedrock API calls with requests made by the AI SDK:

```js {6}
{
  connection: 'keep-alive',
  'content-length': '2399',
  'content-type': 'application/json',
  date: 'Fri, 07 Feb 2025 04:28:30 GMT',
  'x-amzn-requestid': 'c9f3ace4-dd5d-49e5-9807-39aedfa47c8e'
}
```

This information is also available with `streamText`:

```ts
import { amazonBedrock } from '@ai-sdk/amazon-bedrock';
import { streamText } from 'ai';

const result = streamText({
  model: amazonBedrock('meta.llama3-70b-instruct-v1:0'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
}
console.log('Response headers:', (await result.response).headers);
```

With sample output as:

```js {6}
{
  connection: 'keep-alive',
  'content-type': 'application/vnd.amazon.eventstream',
  date: 'Fri, 07 Feb 2025 04:33:37 GMT',
  'transfer-encoding': 'chunked',
  'x-amzn-requestid': 'a976e3fc-0e45-4241-9954-b9bdd80ab407'
}
```

## Bedrock Anthropic Provider Usage

The Bedrock Anthropic provider offers support for Anthropic's Claude models through Amazon Bedrock's native InvokeModel API. This provides full feature parity with the [Anthropic API](https://platform.claude.com/docs/en/build-with-claude/overview), including features that may not be available through the Converse API (such as `stop_sequence` in streaming responses).

For more information on Claude models available on Amazon Bedrock, see [Claude on Amazon Bedrock](https://platform.claude.com/docs/en/build-with-claude/claude-on-amazon-bedrock).

### Provider Instance

You can import the default provider instance `bedrockAnthropic` from `@ai-sdk/amazon-bedrock/anthropic`:

```typescript
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
```

If you need a customized setup, you can import `createBedrockAnthropic` from `@ai-sdk/amazon-bedrock/anthropic` and create a provider instance with your settings:

```typescript
import { createBedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';

const bedrockAnthropic = createBedrockAnthropic({
  region: 'us-east-1', // optional
  accessKeyId: 'xxxxxxxxx', // optional
  secretAccessKey: 'xxxxxxxxx', // optional
  sessionToken: 'xxxxxxxxx', // optional
});
```

#### Provider Settings

You can use the following optional settings to customize the Bedrock Anthropic provider instance:

- **region** *string*

  The AWS region that you want to use for the API calls.
  It uses the `AWS_REGION` environment variable by default.

- **accessKeyId** *string*

  The AWS access key ID that you want to use for the API calls.
  It uses the `AWS_ACCESS_KEY_ID` environment variable by default.

- **secretAccessKey** *string*

  The AWS secret access key that you want to use for the API calls.
  It uses the `AWS_SECRET_ACCESS_KEY` environment variable by default.

- **sessionToken** *string*

  Optional. For temporary credentials. With **both** access keys set as strings,
  pass the token here if needed; `AWS_SESSION_TOKEN` from the environment is not
  used. If either key is taken from the environment, omitting `sessionToken`
  allows `AWS_SESSION_TOKEN`.

- **apiKey** *string | PromiseLike\<string> | (() => string | PromiseLike\<string>)*

  Pass a callback to resolve the API key before each request. The callback can
  return a string or a promise; token caching and renewal are handled by the caller.
  A callback or promise selects API key authentication and must resolve to a
  non-empty string; lookup failures do not switch authentication methods.

  API key for authenticating requests using Bearer token authentication.
  When provided, this will be used instead of AWS SigV4 authentication.
  It uses the `AWS_BEARER_TOKEN_BEDROCK` environment variable by default.

- **baseURL** *string*

  Base URL for the Bedrock API calls.
  Useful for custom endpoints or proxy configurations.
  When omitted, the provider also supports the service-specific
  `AWS_ENDPOINT_URL_BEDROCK_RUNTIME` environment variable, which takes
  precedence over the global `AWS_ENDPOINT_URL` environment variable.

- **headers** *Resolvable\<Record\<string, string | undefined>>*

  Headers to include in the requests.

- **fetch** *(input: RequestInfo, init?: RequestInit) => Promise\<Response>*

  Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
  You can use it as a middleware to intercept requests,
  or to provide a custom fetch implementation for e.g. testing.

- **credentialProvider** *() => PromiseLike\<BedrockCredentials>*

  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.

### Language Models

You can create models that call the [Anthropic Messages API](https://docs.anthropic.com/claude/reference/messages_post) using the provider instance.
The first argument is the model id, e.g. `us.anthropic.claude-sonnet-5-5`.

```ts
const model = bedrockAnthropic('us.anthropic.claude-sonnet-5-5');
```

You can use Bedrock Anthropic language models to generate text with the `generateText` function:

```ts
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
import { generateText } from 'ai';

const { text } = await generateText({
  model: bedrockAnthropic('us.anthropic.claude-sonnet-5-5'),
  prompt: 'Write a vegetarian lasagna recipe for 4 people.',
});
```

### Provider Options

The following optional provider options are available for Bedrock Anthropic models:

- `metadata` *object*

  Optional. Metadata to include with the request. See the [Anthropic API documentation](https://platform.claude.com/docs/en/api/messages/create) for details.

  - `userId` *string* - An external identifier for the end-user.

### Cache Control

In the messages and message parts, you can use the `providerOptions` property to set cache control breakpoints.
You need to set the `anthropic` property in the `providerOptions` object to `{ cacheControl: { type: 'ephemeral' } }` to set a cache control breakpoint.

```ts
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
import { generateText } from 'ai';

const result = await generateText({
  model: bedrockAnthropic('us.anthropic.claude-sonnet-5-5'),
  messages: [
    {
      role: 'system',
      content: 'You are an expert assistant.',
      providerOptions: {
        anthropic: { cacheControl: { type: 'ephemeral' } },
      },
    },
    {
      role: 'user',
      content: 'Explain quantum computing.',
    },
  ],
});
```

Cache control requires a minimum of 1024 tokens before the cache checkpoint.
See the [Amazon Bedrock prompt caching
documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/prompt-caching.html)
for details on supported models and limits.

### Computer Use

The Bedrock Anthropic provider supports Anthropic's computer use tools:

1. **Bash Tool**: Allows running bash commands.
2. **Text Editor Tool**: Provides functionality for viewing and editing text files.
3. **Computer Tool**: Enables control of keyboard and mouse actions on a computer.

They are available via the `tools` property of the provider instance.

Computer use tools require Claude 3.7 Sonnet or newer models. Claude 3.5
Sonnet v2 does not support these tools.

#### Bash Tool

```ts
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 }) => {
        // Implement your bash command execution logic here
        return [{ type: 'text', text: `Executed: ${command}` }];
      },
    }),
  },
  prompt: 'List the files in my directory.',
  stopWhen: isStepCount(2),
});
```

#### Text Editor Tool

```ts
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 }) => {
        // Implement your text editing logic here
        return 'File updated successfully';
      },
    }),
  },
  prompt: 'Update my README file.',
  stopWhen: isStepCount(5),
});
```

#### Computer Tool

```ts
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
import { generateText, isStepCount } from 'ai';
import fs from 'fs';

const result = await generateText({
  model: bedrockAnthropic('us.anthropic.claude-sonnet-4-5-20250929-v1:0'),
  tools: {
    computer: bedrockAnthropic.tools.computer_20241022({
      displayWidthPx: 1024,
      displayHeightPx: 768,
      execute: async ({ action, coordinate, text }) => {
        if (action === 'screenshot') {
          return {
            type: 'image',
            data: fs.readFileSync('./screenshot.png').toString('base64'),
          };
        }
        return `executed ${action}`;
      },
      toModelOutput({ output }) {
        return {
          type: 'content',
          value: [
            typeof output === 'string'
              ? { type: 'text', text: output }
              : {
                  type: 'image-data',
                  data: output.data,
                  mediaType: 'image/png',
                },
          ],
        };
      },
    }),
  },
  prompt: 'Take a screenshot.',
  stopWhen: isStepCount(3),
});
```

### Reasoning

Anthropic has reasoning support for Claude 3.7 and Claude 4 models on Bedrock, including:

- `us.anthropic.claude-fable-5-2`
- `us.anthropic.claude-fable-5-1`
- `us.anthropic.claude-sonnet-5-5`
- `us.anthropic.claude-sonnet-5`
- `us.anthropic.claude-fable-5`
- `us.anthropic.claude-opus-4-8`
- `us.anthropic.claude-opus-4-7`
- `us.anthropic.claude-opus-4-6-v1`
- `us.anthropic.claude-opus-4-5-20251101-v1:0`
- `us.anthropic.claude-sonnet-4-5-20250929-v1:0`
- `us.anthropic.claude-opus-4-20250514-v1:0`
- `us.anthropic.claude-sonnet-4-20250514-v1:0`
- `us.anthropic.claude-opus-4-1-20250805-v1:0`
- `us.anthropic.claude-haiku-4-5-20251001-v1:0`

You can enable it using the `thinking` provider option and specifying a thinking budget in tokens.

```ts
import { bedrockAnthropic } from '@ai-sdk/amazon-bedrock/anthropic';
import { generateText } from 'ai';

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); // reasoning text
console.log(reasoning); // reasoning details including redacted reasoning
console.log(text); // text response
```

Anthropic's `max_tokens` limit includes both thinking and final text. To reserve
room for both, 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.

See [AI SDK UI: Chatbot](/docs/ai-sdk-ui/chatbot#reasoning) for more details
on how to integrate reasoning into your chatbot.

### Model Capabilities

| Model                                          | Image Input | Object Generation | Tool Usage | Computer Use | Reasoning |
| ---------------------------------------------- | ----------- | ----------------- | ---------- | ------------ | --------- |
| `us.anthropic.claude-fable-5-1`                | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-fable-5-2`                | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-sonnet-5-5`               | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-sonnet-5`                 | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-haiku-5-5`                | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-fable-5`                  | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-8`                 | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-7`                 | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-6-v1`              | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-5-20251101-v1:0`   | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-sonnet-4-5-20250929-v1:0` | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-20250514-v1:0`     | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-sonnet-4-20250514-v1:0`   | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-opus-4-1-20250805-v1:0`   | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-haiku-4-5-20251001-v1:0`  | ✓           | ✓                 | ✓          | ✓            | ✓         |
| `us.anthropic.claude-3-5-sonnet-20241022-v2:0` | ✓           | ✓                 | ✓          | ✗            | ✗         |

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.

## Bedrock Mantle Provider Usage

The Bedrock Mantle provider offers access to OpenAI-compatible models through Amazon Bedrock's Mantle API. It automatically selects the `/v1` or `/openai/v1` route based on the model. These endpoints support the Chat Completions API and the Responses API, and provide access to models that may only be available through the Mantle endpoint (such as `openai.gpt-oss-120b`).

### Provider Instance

You can import the default provider instance `bedrockMantle` from `@ai-sdk/amazon-bedrock/mantle`:

```typescript
import { bedrockMantle } from '@ai-sdk/amazon-bedrock/mantle';
```

If you need a customized setup, you can import `createBedrockMantle` from `@ai-sdk/amazon-bedrock/mantle` and create a provider instance with your settings:

```typescript
import { createBedrockMantle } from '@ai-sdk/amazon-bedrock/mantle';

const bedrockMantle = createBedrockMantle({
  region: 'us-east-1', // optional
  accessKeyId: 'xxxxxxxxx', // optional
  secretAccessKey: 'xxxxxxxxx', // optional
  sessionToken: 'xxxxxxxxx', // optional
});
```

#### Provider Settings

You can use the following optional settings to customize the Bedrock Mantle provider instance:

- **region** *string*

  The AWS region that you want to use for the API calls.
  It uses the `AWS_REGION` environment variable by default.

- **accessKeyId** *string*

  The AWS access key ID that you want to use for the API calls.
  It uses the `AWS_ACCESS_KEY_ID` environment variable by default.

- **secretAccessKey** *string*

  The AWS secret access key that you want to use for the API calls.
  It uses the `AWS_SECRET_ACCESS_KEY` environment variable by default.

- **sessionToken** *string*

  Optional. The AWS session token that you want to use for the API calls.
  It uses the `AWS_SESSION_TOKEN` environment variable by default.

- **apiKey** *string | PromiseLike\<string> | (() => string | PromiseLike\<string>)*

  Pass a callback to resolve the API key before each request. The callback can
  return a string or a promise; token caching and renewal are handled by the caller.
  A callback or promise selects API key authentication and must resolve to a
  non-empty string; lookup failures do not switch authentication methods.

  API key for authenticating requests using Bearer token authentication.
  When provided, this will be used instead of AWS SigV4 authentication.
  It uses the `AWS_BEARER_TOKEN_BEDROCK` environment variable by default.

- **baseURL** *string*

  Base URL for the Bedrock Mantle API calls.
  By default, the provider selects either
  `https://bedrock-mantle.{region}.api.aws/v1` or
  `https://bedrock-mantle.{region}.api.aws/openai/v1` based on the model.

- **headers** *Record\<string, string | undefined>*

  Headers to include in the requests.

- **fetch** *(input: RequestInfo, init?: RequestInit) => Promise\<Response>*

  Custom [fetch](https://developer.mozilla.org/en-US/docs/Web/API/fetch) implementation.
  You can use it as a middleware to intercept requests,
  or to provide a custom fetch implementation for e.g. testing.

- **credentialProvider** *() => PromiseLike\<BedrockCredentials>*

  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.

### Language Models

You can create models using the Mantle provider instance. By default, the provider creates models using the Chat Completions API, which has the broadest model support on Mantle:

```ts
const model = bedrockMantle('openai.gpt-oss-120b');
```

You can also explicitly select the Chat Completions API or the Responses API:

```ts
const chatModel = bedrockMantle.chat('openai.gpt-oss-120b');
const responsesModel = bedrockMantle.responses('openai.gpt-oss-120b');
```

Note that not all Mantle models support the Responses API. See the model capabilities table below.

You can use Bedrock Mantle language models to generate text with the `generateText` function:

```ts
import { bedrockMantle } from '@ai-sdk/amazon-bedrock/mantle';
import { generateText } from 'ai';

const { text } = await generateText({
  model: bedrockMantle('openai.gpt-oss-120b'),
  prompt: 'Invent a new holiday and describe its traditions.',
});
```

Or stream text with the `streamText` function:

```ts
import { bedrockMantle } from '@ai-sdk/amazon-bedrock/mantle';
import { streamText } from 'ai';

const result = streamText({
  model: bedrockMantle('openai.gpt-oss-120b'),
  prompt: 'Invent a new holiday and describe its traditions.',
});

for await (const textPart of result.textStream) {
  process.stdout.write(textPart);
}
```

### Provider Options

Since the Mantle API is OpenAI-compatible, provider options are passed under the `openai` namespace:

```ts
import { bedrockMantle } from '@ai-sdk/amazon-bedrock/mantle';
import { generateText } from 'ai';

const { text } = await generateText({
  model: bedrockMantle('openai.gpt-oss-120b'),
  prompt: 'Hello!',
  providerOptions: {
    openai: {
      // OpenAI-compatible provider options
    },
  },
});
```

### Model Capabilities

| Model                           | Chat Completions | Responses API |
| ------------------------------- | ---------------- | ------------- |
| `openai.gpt-oss-20b`            | ✓                | ✓             |
| `openai.gpt-oss-120b`           | ✓                | ✓             |
| `openai.gpt-oss-safeguard-20b`  | ✓                | ✗             |
| `openai.gpt-oss-safeguard-120b` | ✓                | ✗             |

The Bedrock Mantle provider uses the OpenAI-compatible API format. Models
available through the Mantle endpoint may differ from those available through
the Bedrock Converse API. Use the Mantle endpoint's model listing API to
discover all available models.

## Migrating to `@ai-sdk/amazon-bedrock` 2.x

The Amazon Bedrock provider was rewritten in version 2.x to remove the
dependency on the `@aws-sdk/client-bedrock-runtime` package.

The `bedrockOptions` provider setting previously available has been removed. If
you were using the `bedrockOptions` object, you should now use the `region`,
`accessKeyId`, `secretAccessKey`, and `sessionToken` settings directly instead.

Static IAM user keys do not require `sessionToken`.

## Provider Option Reference

The following option definitions are generated from the provider catalog.

| Operation | Option                         | Description                                                            |
| --------- | ------------------------------ | ---------------------------------------------------------------------- |
| language  | `structuredOutputMode`         | Select native structured output or JSON tools.                         |
| language  | `additionalModelRequestFields` | Additional model-specific inference fields.                            |
| language  | `reasoningConfig`              | Thinking mode, budget, effort, and display.                            |
| language  | `anthropicBeta`                | Anthropic beta features to enable.                                     |
| language  | `serviceTier`                  | Request service tier.                                                  |
| language  | `requestMetadata`              | Invocation logging and cost attribution metadata.                      |
| embedding | `dimensions`                   | Titan v2 output dimensions.                                            |
| embedding | `normalize`                    | Normalize Titan v2 embeddings.                                         |
| embedding | `embeddingDimension`           | Nova output dimensions.                                                |
| embedding | `embeddingPurpose`             | Nova embedding purpose.                                                |
| embedding | `inputType`                    | Cohere embedding input type.                                           |
| embedding | `truncate`                     | Cohere or Nova truncation mode.                                        |
| embedding | `outputDimension`              | Cohere v4 output dimensions.                                           |
| image     | `quality`                      | Image quality.                                                         |
| image     | `negativeText`                 | Content to avoid.                                                      |
| image     | `cfgScale`                     | Prompt adherence scale.                                                |
| image     | `style`                        | Image generation style.                                                |
| image     | `taskType`                     | Generation, variation, inpainting, outpainting, or background removal. |
| image     | `maskPrompt`                   | Text describing the region to mask.                                    |
| image     | `outPaintingMode`              | Outpainting mode.                                                      |
| image     | `similarityStrength`           | Similarity to reference images.                                        |
| reranking | `nextToken`                    | Pagination token.                                                      |
| reranking | `additionalModelRequestFields` | Additional model-specific reranking fields.                            |

---

For a semantic overview of all documentation, see [/sitemap.md](/sitemap.md)

For an index of all available documentation, see [/llms.txt](/llms.txt)

For agent-facing discovery, including API and MCP surfaces, see [/agents.md](/agents.md)