Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
885b05b
chore(ai-bedrock): scaffold package
AlemTuzlak May 30, 2026
19ff7b0
chore(ai-bedrock): make aws-sigv4-fetch an optional peer dep; revert …
AlemTuzlak May 30, 2026
12797e9
chore(ai-bedrock): drop aws-sigv4-fetch from manifest (user-installed…
AlemTuzlak May 30, 2026
3805d52
feat(ai-bedrock): client config + auth resolution (apikey + SigV4 cas…
AlemTuzlak May 30, 2026
3fa84ba
fix(ai-bedrock): close apikey-mode fall-through; robust env test rest…
AlemTuzlak May 30, 2026
8498890
feat(ai-bedrock): SigV4 signing fetch behind /sigv4 subpath
AlemTuzlak May 30, 2026
00b4ae6
feat(ai-bedrock): message metadata + chat/responses provider options
AlemTuzlak May 30, 2026
0f09fe9
feat(ai-bedrock): seed model catalog (broad chat + responses subset)
AlemTuzlak May 30, 2026
fbdf6ef
fix(ai-bedrock): compile-time parity guard for model catalog arrays
AlemTuzlak May 30, 2026
aa8ac3d
feat(ai-bedrock): chat adapter with cast-free reasoning extraction
AlemTuzlak May 30, 2026
6944266
test(ai-bedrock): cover empty-string + non-array-choices reasoning gu…
AlemTuzlak May 30, 2026
a42d7ee
feat(ai-bedrock): responses adapter (mantle-only) on OpenAI Responses…
AlemTuzlak May 30, 2026
d11eb3f
feat(ai-bedrock): branching bedrockText factory (api: chat | responses)
AlemTuzlak May 30, 2026
cdc5f51
fix(ai-bedrock): export ResolvedBedrockAuth; lock api:responses type+…
AlemTuzlak May 30, 2026
7f5459c
chore(ai-bedrock): add maintainer model-catalog refresh script
AlemTuzlak May 30, 2026
33778ca
test(e2e): register bedrock + bedrock-responses providers
AlemTuzlak May 30, 2026
0c35a85
test(e2e): add feature coverage for bedrock-responses
AlemTuzlak May 30, 2026
3ef2bbd
docs(ai-bedrock): adapter guide, nav, changeset
AlemTuzlak May 30, 2026
a0050c5
docs(ai-bedrock): register Bedrock in gap-analysis skill and provider…
AlemTuzlak May 30, 2026
13b5bb6
docs(ai-bedrock): move Bedrock to first-party adapters section
AlemTuzlak May 30, 2026
89567f3
fix(ai-bedrock): SigV4 service for mantle; canonical versioned gpt-os…
AlemTuzlak May 30, 2026
f8460d2
ci: apply automated fixes
autofix-ci[bot] May 30, 2026
6ccd207
fix(ai-bedrock): address review β€” lazy auth in bedrockText, authorita…
AlemTuzlak May 30, 2026
6ac6e40
docs(ai-bedrock): keep config.json diff to just the Bedrock nav entry
AlemTuzlak May 30, 2026
7b3632b
chore(ai-bedrock): add @aws-sdk client, drop aws-sigv4-fetch optional…
AlemTuzlak May 31, 2026
43d973f
feat(ai-bedrock): unified discriminated auth resolver (bearer | sigv4)
AlemTuzlak May 31, 2026
b9fabb5
refactor(ai-bedrock): sign openai-SDK path with @aws-sdk signer; remo…
AlemTuzlak May 31, 2026
63d67fe
fix(ai-bedrock): handle Request input in createSigV4Fetch; simplify b…
AlemTuzlak May 31, 2026
57e15ce
feat(ai-bedrock): generate model catalog with per-API support flags
AlemTuzlak May 31, 2026
63b0bc9
feat(ai-bedrock): three per-API catalogs (converse default) + curated…
AlemTuzlak May 31, 2026
8602e82
feat(ai-bedrock): Converse message converter (system, role merge, too…
AlemTuzlak May 31, 2026
f345d08
feat(ai-bedrock): Converse tool & tool-choice converter
AlemTuzlak May 31, 2026
0357dab
feat(ai-bedrock): Converse stream -> AG-UI StreamChunk processor
AlemTuzlak May 31, 2026
878b615
feat(ai-bedrock): Converse structured output via forced single-tool
AlemTuzlak May 31, 2026
b1a3b4b
feat(ai-bedrock): BedrockConverseTextAdapter (streaming, tools, struc…
AlemTuzlak May 31, 2026
4b628f8
feat(ai-bedrock): converse is the default bedrockText path; chat/resp…
AlemTuzlak May 31, 2026
8cac582
docs(e2e): document Bedrock Converse coverage gap (aimock lacks AWS e…
AlemTuzlak May 31, 2026
bc75c30
docs: restore nav entries dropped by stale config.json rewrite; keep …
AlemTuzlak May 31, 2026
f0bd676
docs(ai-bedrock): document Converse-as-default + opt-in chat/responses
AlemTuzlak May 31, 2026
9bb6011
chore(ai-bedrock): satisfy PR quality gate (lint, knip, format); drop…
AlemTuzlak May 31, 2026
b5a15e7
fix(ai-bedrock): give Converse document blocks unique names
AlemTuzlak May 31, 2026
6a4e71e
fix(ai-bedrock): keep AWS SDK out of the browser bundle via non-liter…
AlemTuzlak May 31, 2026
ee3173c
fix(e2e): pin bedrock matrix entry to api: 'chat' (Converse is now th…
AlemTuzlak May 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/ai-bedrock-adapter.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@tanstack/ai-bedrock': minor
---

Add `@tanstack/ai-bedrock`: an Amazon Bedrock adapter. The default `bedrockText` path uses Bedrock's **Converse** API (`@aws-sdk/client-bedrock-runtime`), reaching the broad chat catalog including Anthropic Claude, Amazon Nova, and Meta Llama, with streaming, tools, reasoning, and structured output. Opt into Bedrock's OpenAI-compatible endpoints with `api: 'chat'` (Chat Completions) or `api: 'responses'` (gpt-oss Responses). Authentication supports Bedrock API keys or SigV4 via the AWS credential chain.
11 changes: 8 additions & 3 deletions .claude/skills/gap-analysis/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,14 @@ markdown report under `.agent/gap-analysis/`. **Do not edit source files.**

## Known providers

`openai`, `anthropic`, `gemini`, `ollama`, `grok`, `groq`, `openrouter`, `fal`
(media-only), `elevenlabs` (TTS-only). The feature matrix tracks the first
seven; `fal` and `elevenlabs` only appear in model/media audits.
`openai`, `anthropic`, `gemini`, `ollama`, `grok`, `groq`, `openrouter`,
`bedrock` (`@tanstack/ai-bedrock`; three-API surface β€” Converse default
(adapter name `bedrock-converse`), Chat Completions opt-in (`api: 'chat'`,
adapter name `bedrock`), Responses opt-in (`api: 'responses'`, adapter name
`bedrock-responses`)), `fal` (media-only), `elevenlabs` (TTS-only). The
feature matrix tracks `openai`, `anthropic`, `gemini`, `ollama`, `grok`,
`groq`, `openrouter`, `bedrock`, `bedrock-converse`, and `bedrock-responses`;
`fal` and `elevenlabs` only appear in model/media audits.

## Known features (19)

Expand Down
10 changes: 10 additions & 0 deletions .claude/skills/gap-analysis/references/provider-doc-urls.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,16 @@ WebFetch β€” call `resolve-library-id` with the SDK npm name, then `query-docs`.
- Provider routing: https://openrouter.ai/docs/features/provider-routing
- (Proxies many providers; uses OpenAI-compatible API.)

## bedrock (Amazon Bedrock)

- Models / API compatibility: https://docs.aws.amazon.com/bedrock/latest/userguide/models-api-compatibility.html
- Converse API reference (default path): https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html
- OpenAI-compatible Chat Completions: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-chat-completions-mantle.html
- Responses API (mantle): https://docs.aws.amazon.com/bedrock/latest/userguide/bedrock-mantle.html
- Cross-region inference profiles: https://docs.aws.amazon.com/bedrock/latest/userguide/inference-profiles-support.html
- API keys: https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html
- (Default path uses Converse API via `@aws-sdk/client-bedrock-runtime` (adapter `bedrock-converse`). Opt-in paths: `api: 'chat'` β†’ OpenAI-compatible Chat Completions (adapter `bedrock`); `api: 'responses'` β†’ Responses API (adapter `bedrock-responses`).)

## fal (media-only)

- Models catalog: https://fal.ai/models
Expand Down
241 changes: 241 additions & 0 deletions docs/adapters/bedrock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,241 @@
---
title: Amazon Bedrock
id: bedrock-adapter
order: 7
description: "Use Amazon Bedrock with TanStack AI β€” the Converse API is the default, reaching Claude, Nova, Llama, Mistral, DeepSeek, and more. Opt into OpenAI-compatible Chat Completions or Responses for open-weight and gpt-oss models. Supports streaming, tools, reasoning, and API-key or SigV4 auth."
keywords:
- tanstack ai
- amazon bedrock
- aws
- bedrock
- converse api
- openai compatible
- chat completions
- responses api
- sigv4
- claude
- nova
- llama
- adapter
---

The Bedrock adapter connects TanStack AI to [Amazon Bedrock](https://aws.amazon.com/bedrock/) with three API paths:

- **Converse** (default) β€” Bedrock's model-agnostic API built on `@aws-sdk/client-bedrock-runtime`. Reaches the broad chat catalog including Anthropic Claude, Amazon Nova, Meta Llama, Mistral, DeepSeek, Cohere, AI21, and OpenAI gpt-oss models.
- **Chat Completions** (`api: 'chat'`) β€” Bedrock's OpenAI-compatible Chat Completions endpoint. Reaches open-weight models only (gpt-oss, DeepSeek V3.x, Gemma, Qwen, Mistral open models, GLM, etc.). Does NOT reach Claude, Nova, or Llama.
- **Responses** (`api: 'responses'`) β€” Bedrock's OpenAI-compatible Responses API, mantle-only. Currently the OpenAI gpt-oss family.

All paths support streaming, client-side tool calling, and reasoning.

## Installation

```bash
pnpm add @tanstack/ai-bedrock
```

No additional packages are required. SigV4 authentication is handled by `@aws-sdk/client-bedrock-runtime`, which is a direct dependency.

## Quick Start (Converse β€” default)

The default `bedrockText` call uses the Converse API and reaches the broad model catalog:

```typescript
import { bedrockText } from '@tanstack/ai-bedrock'
import { chat } from '@tanstack/ai'

const adapter = bedrockText('us.anthropic.claude-haiku-4-5-20251001-v1:0', {
region: 'us-east-1',
})

for await (const chunk of chat({
adapter,
messages: [{ role: 'user', content: 'What is the capital of France?' }],
})) {
if (chunk.type === 'content') process.stdout.write(chunk.delta)
}
```

Equivalent to passing `{ api: 'converse' }` explicitly. Returns a `bedrock-converse` adapter.

## Authentication

Bedrock supports two authentication modes.

### API Key

Bedrock issues API keys from the AWS Console. See the [Bedrock API keys guide](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html) for instructions.

Set one of the following environment variables and the adapter picks it up automatically:

```bash
BEDROCK_API_KEY=your-bedrock-api-key
# or the legacy name:
AWS_BEARER_TOKEN_BEDROCK=your-bedrock-api-key
```

### SigV4 (AWS credential chain)

For workloads using IAM roles, instance profiles, or `~/.aws/credentials`, set `auth: 'sigv4'` (or leave it as `'auto'` with no API key in the environment). SigV4 works out of the box via `@aws-sdk/client-bedrock-runtime` β€” no additional packages required.

```bash
AWS_ACCESS_KEY_ID=...
AWS_SECRET_ACCESS_KEY=...
AWS_SESSION_TOKEN=... # optional, for temporary credentials
```

### Auth resolution order (`auth: 'auto'`, the default)

1. Explicit `apiKey` passed to the factory
2. `BEDROCK_API_KEY` environment variable
3. `AWS_BEARER_TOKEN_BEDROCK` environment variable
4. SigV4 via the standard AWS credential chain

## Configuration

`BedrockClientConfig` accepts the following options:

| Option | Type | Default | Description |
|--------|------|---------|-------------|
| `api` | `'converse' \| 'chat' \| 'responses'` | `'converse'` | Bedrock API to use |
| `region` | `string` | `'us-east-1'` | AWS region string (e.g. `'us-west-2'`) |
| `auth` | `'apikey' \| 'sigv4' \| 'auto'` | `'auto'` | Authentication mode |
| `apiKey` | `string` | β€” | Explicit API key (overrides env vars) |
| `baseURL` | `string` | β€” | Override the computed base URL entirely |
| `endpoint` | `'runtime' \| 'mantle'` | `'runtime'` | Bedrock endpoint to target (Chat Completions path only) |

The `endpoint` option only applies when `api: 'chat'`. The `runtime` endpoint (`bedrock-runtime`) hosts the broad open-weight catalog; `mantle` is an alternative. The Responses API always targets mantle.

## Converse API (default)

`bedrockText(model)` or `bedrockText(model, { api: 'converse' })` returns a `bedrock-converse` adapter backed by `@aws-sdk/client-bedrock-runtime`. This is Bedrock's model-agnostic conversational API and is the recommended path for most use cases.

**Model scope:** Anthropic Claude, Amazon Nova, Meta Llama, Mistral, DeepSeek, Cohere, AI21, OpenAI gpt-oss, and other models accessible in your account. See [Model availability](#model-availability) below.

```typescript
import { bedrockText } from '@tanstack/ai-bedrock'
import { chat } from '@tanstack/ai'

// Claude via Converse
const claudeAdapter = bedrockText('us.anthropic.claude-haiku-4-5-20251001-v1:0', {
region: 'us-east-1',
})

// Amazon Nova via Converse
const novaAdapter = bedrockText('us.amazon.nova-pro-v1:0', {
region: 'us-east-1',
})

// Meta Llama via Converse
const llamaAdapter = bedrockText('us.meta.llama3-3-70b-instruct-v1:0', {
region: 'us-east-1',
})
```

### Explicit API key (Converse)

```typescript
import { createBedrockText } from '@tanstack/ai-bedrock'

const adapter = createBedrockText(
'us.anthropic.claude-haiku-4-5-20251001-v1:0',
'your-bedrock-api-key',
{ region: 'us-west-2' },
)
```

## Chat Completions API (`api: 'chat'`)

Set `api: 'chat'` to use Bedrock's OpenAI-compatible Chat Completions endpoint. Returns a `bedrock` adapter.

**Model scope:** Open-weight models only β€” gpt-oss, DeepSeek V3.x, Gemma, Qwen, Mistral open models, GLM, and similar. Claude, Nova, and Llama are NOT available on this endpoint. See the [AWS API compatibility matrix](https://docs.aws.amazon.com/bedrock/latest/userguide/models-api-compatibility.html) for the current list.

```typescript
import { bedrockText } from '@tanstack/ai-bedrock'
import { chat } from '@tanstack/ai'

const adapter = bedrockText('openai.gpt-oss-mini-1:0', {
region: 'us-east-1',
api: 'chat',
})

for await (const chunk of chat({
adapter,
messages: [{ role: 'user', content: 'What is the capital of France?' }],
})) {
if (chunk.type === 'content') process.stdout.write(chunk.delta)
}
```

## Responses API (`api: 'responses'`)

Set `api: 'responses'` to use Bedrock's OpenAI-compatible Responses API. Returns a `bedrock-responses` adapter. This API is mantle-only.

**Model scope:** Currently the OpenAI gpt-oss family. The Responses API is stateful β€” pass `previous_response_id` and `store` through `modelOptions` to continue a conversation server-side.

```typescript
import { bedrockText } from '@tanstack/ai-bedrock'
import { chat } from '@tanstack/ai'

const adapter = bedrockText('openai.gpt-oss-120b-1:0', {
region: 'us-east-1',
api: 'responses',
})

for await (const chunk of chat({
adapter,
messages: [{ role: 'user', content: 'Summarize the Bedrock pricing page.' }],
})) {
if (chunk.type === 'content') process.stdout.write(chunk.delta)
}
```

## Model Availability

The adapter ships with a hand-seeded snapshot catalog (`src/model-catalog.generated.ts`) of confirmed model IDs. This catalog can be refreshed by the maintainer script `scripts/fetch-bedrock-models.ts`, which calls `ListFoundationModels` with AWS credentials.

**Actual model availability depends on your AWS account's model access configuration and the region you are targeting.** Enable model access in the [Amazon Bedrock console](https://console.aws.amazon.com/bedrock/home#/modelaccess) before use.

For the full list of models and which API endpoints they support, see the [AWS API compatibility matrix](https://docs.aws.amazon.com/bedrock/latest/userguide/models-api-compatibility.html).

## Supported Capabilities

- Streaming chat completions
- Client-side tool calling
- Reasoning (extended thinking)
- Multimodal input (text, images, documents β€” model-dependent)
- JSON schema / structured output

## API Reference

### `bedrockText(model, config?)`

Creates a Bedrock adapter using environment-variable auth.

- `model` β€” Model ID (e.g. `'us.anthropic.claude-haiku-4-5-20251001-v1:0'`)
- `config.api` β€” `'converse'` (default), `'chat'`, or `'responses'`
- `config.region` β€” AWS region string (default `'us-east-1'`)
- `config.auth` β€” `'auto'` (default), `'apikey'`, or `'sigv4'`
- `config.apiKey` β€” Explicit API key (overrides env vars)
- `config.baseURL` β€” Override base URL
- `config.endpoint` β€” `'runtime'` (default) or `'mantle'` (Chat Completions path only)

Returns a chat adapter for use with `chat()` or `generate()`.

| `api` value | Adapter name | Underlying SDK |
|---|---|---|
| `'converse'` (default) | `bedrock-converse` | `@aws-sdk/client-bedrock-runtime` |
| `'chat'` | `bedrock` | `openai` (OpenAI-compatible) |
| `'responses'` | `bedrock-responses` | `openai` (OpenAI-compatible) |

### `createBedrockText(model, apiKey, config?)`

Creates a Bedrock adapter with an explicit API key, bypassing the environment-variable lookup.

## Next Steps

- [Amazon Bedrock API keys](https://docs.aws.amazon.com/bedrock/latest/userguide/api-keys.html) β€” Create and manage API keys
- [Amazon Bedrock model access](https://docs.aws.amazon.com/bedrock/latest/userguide/model-access.html) β€” Enable models in your account
- [AWS API compatibility matrix](https://docs.aws.amazon.com/bedrock/latest/userguide/models-api-compatibility.html) β€” Which models work with which APIs
- [Converse API reference](https://docs.aws.amazon.com/bedrock/latest/APIReference/API_runtime_Converse.html) β€” Native Converse API docs
- [Streaming Guide](../chat/streaming) β€” Learn about streaming responses
- [Tools Guide](../tools/tools) β€” Learn about tool calling
4 changes: 4 additions & 0 deletions docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,10 @@
{
"label": "OpenRouter Adapter",
"to": "adapters/openrouter"
},
{
"label": "Amazon Bedrock",
"to": "adapters/bedrock"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions docs/getting-started/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ With the help of adapters, TanStack AI can connect to various LLM providers. Ava
- **@tanstack/ai-ollama** - Ollama (local models)
- **@tanstack/ai-groq** - Groq
- **@tanstack/ai-grok** - xAI Grok
- **@tanstack/ai-bedrock** - Amazon Bedrock (Claude, Nova, Llama, and more via AWS)
- **@tanstack/ai-fal** - fal (image & video generation)

## Next Steps
Expand Down
5 changes: 3 additions & 2 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"ignoreDependencies": ["@faker-js/faker"],
"ignoreDependencies": ["@faker-js/faker", "@aws-sdk/client-bedrock"],
"ignoreWorkspaces": [
"examples/**",
"testing/**",
Expand Down Expand Up @@ -43,6 +43,7 @@
},
"packages/ai-vue-ui": {
"ignore": ["src/use-chat-context.ts"]
}
},
"packages/ai-bedrock": {}
}
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
]
},
"devDependencies": {
"@aws-sdk/client-bedrock": "^3.1057.0",
"@changesets/changelog-github": "^0.7.0",
"@changesets/cli": "^2.30.0",
"@faker-js/faker": "^10.1.0",
Expand Down
Loading
Loading