Skip to content
This repository was archived by the owner on Apr 30, 2026. It is now read-only.

Commit c7ec456

Browse files
committed
docs(aws): update Readme with new cross-region example
1 parent 43ed898 commit c7ec456

4 files changed

Lines changed: 241 additions & 11 deletions

File tree

.changeset/wicked-trees-sink.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,20 @@ Add new AWS Bedrock models and fix incomplete entries:
1414
- Add new AU, JP, and Global inference profile prefixes for supported models
1515
- Remove legacy US and EU Claude 3.5 Sonnet v1 cross-region inference models
1616
- Make topP optional for Bedrock params and fix type compatibility with exactOptionalPropertyTypes
17+
- Fix Claude Opus 4.6 max output tokens: 32K → 128K (per Anthropic docs)
18+
- Fix Amazon Nova 2 Lite context window: 300K → 1M and max output: 5,120 → 65,536 (per AWS docs)
19+
20+
### BREAKING CHANGES — Removed Cross-Region Inference Models
21+
22+
The following `INFERENCE_BEDROCK_MODELS` entries have been removed because they are not supported by AWS for cross-region inference. If you reference any of these, update your code to use the recommended replacement:
23+
24+
| Removed Model ID | Replacement |
25+
| --------------------------------------------------- | ------------------------------------------------------------------------------------------------------------ |
26+
| `us.anthropic.claude-3-sonnet-20240229-v1:0` | Use base `BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_SONNET` directly, or migrate to `US_ANTHROPIC_CLAUDE_3_7_SONNET` |
27+
| `us.anthropic.claude-3-opus-20240229-v1:0` | Use base `BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_OPUS` directly, or migrate to `US_ANTHROPIC_CLAUDE_OPUS_4_6` |
28+
| `us.anthropic.claude-3-5-sonnet-20240620-v1:0` (v1) | `US_ANTHROPIC_CLAUDE_3_5_SONNET_V2` (`us.anthropic.claude-3-5-sonnet-20241022-v2:0`) |
29+
| `eu.anthropic.claude-3-5-sonnet-20240620-v1:0` (v1) | Use base model or `EU_ANTHROPIC_CLAUDE_4_5_SONNET` |
30+
| `eu.anthropic.claude-3-5-haiku-20241022-v1:0` | Use base `BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_5_HAIKU` directly (not available in EU cross-region) |
31+
| `eu.anthropic.claude-opus-4-20250514-v1:0` | `EU_ANTHROPIC_CLAUDE_OPUS_4_5` or `EU_ANTHROPIC_CLAUDE_OPUS_4_6` |
32+
| `eu.anthropic.claude-opus-4-1-20250805-v1:0` | `EU_ANTHROPIC_CLAUDE_OPUS_4_5` or `EU_ANTHROPIC_CLAUDE_OPUS_4_6` |
33+
| `eu.amazon.nova-premier-v1:0` | Use base `BEDROCK_MODELS.AMAZON_NOVA_PREMIER_1` directly (not available in EU cross-region) |

packages/providers/aws/README.md

Lines changed: 71 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ AWS package for LlamaIndexTS
44

55
## Current Features:
66

7-
- Bedrock support for Amazon Nova models (Premier, Pro, Lite and Micro)
8-
- Bedrock support for the Anthropic Claude Models including the latest Claude 4 (Sonnet and Opus)
9-
- Bedrock support for the Meta LLama 2, 3, 3.1, 3.2 and 3.3 Models
10-
- Meta LLama3.1 405b and Llama3.2 tool call support
11-
- Meta 3.2 11B and 90B vision support
12-
- Anthropic Claude models (Sonnet, Haiku, Opus) multimodal support
7+
- Bedrock support for Amazon Nova models (Premier, Pro, Lite, Micro, and Nova 2 Lite)
8+
- Bedrock support for Anthropic Claude models including Claude 4.5/4.6 (Sonnet and Opus), Claude 4 (Sonnet and Opus), Claude 3.7 Sonnet, Claude 3.5 (Sonnet and Haiku), Claude 3 (Haiku, Sonnet, Opus)
9+
- Bedrock support for Meta Llama models: Llama 2, 3, 3.1, 3.2, 3.3, and Llama 4 (Scout 17B, Maverick 17B)
10+
- Meta Llama 3.1 405B, Llama 3.2, Llama 3.3, and Llama 4 tool calling support
11+
- Meta Llama 3.2 11B and 90B vision support
12+
- Anthropic Claude models multimodal support (text, images, documents)
1313
- Bedrock support for querying Knowledge Base
14-
- Support for Bedrock Inference endpoints with regional models
14+
- Cross-region inference with regional prefixes (`us.`, `eu.`, `au.`, `jp.`, `global.`, `apac.`)
1515
- Bedrock: [Supported Regions and models for cross-region inference](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference-support.html)
1616

1717
## Basic Usage
@@ -20,7 +20,7 @@ AWS package for LlamaIndexTS
2020
import { BEDROCK_MODELS, Bedrock } from "@llamaindex/aws";
2121

2222
Settings.llm = new Bedrock({
23-
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_3_HAIKU,
23+
model: BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6,
2424
region: "us-east-1", // can be provided via env AWS_REGION
2525
credentials: {
2626
accessKeyId: "...", // optional and can be provided via env AWS_ACCESS_KEY_ID
@@ -29,6 +29,69 @@ Settings.llm = new Bedrock({
2929
});
3030
```
3131

32+
## Cross-Region Inference
33+
34+
AWS Bedrock supports cross-region inference, allowing you to route requests to models in different regions. Use the `INFERENCE_BEDROCK_MODELS` constants with regional prefixes:
35+
36+
```ts
37+
import { INFERENCE_BEDROCK_MODELS, Bedrock } from "@llamaindex/aws";
38+
39+
// US cross-region inference
40+
const llm = new Bedrock({
41+
model: INFERENCE_BEDROCK_MODELS.US_ANTHROPIC_CLAUDE_SONNET_4_6,
42+
region: "us-east-1",
43+
});
44+
45+
// EU cross-region inference
46+
const euLlm = new Bedrock({
47+
model: INFERENCE_BEDROCK_MODELS.EU_ANTHROPIC_CLAUDE_SONNET_4_6,
48+
region: "eu-west-1",
49+
});
50+
```
51+
52+
Available regional prefixes:
53+
54+
| Prefix | Region | Example |
55+
| --------- | ------------- | ------------------------------------ |
56+
| `us.` | United States | `US_ANTHROPIC_CLAUDE_SONNET_4_6` |
57+
| `eu.` | Europe | `EU_ANTHROPIC_CLAUDE_SONNET_4_6` |
58+
| `au.` | Australia | `AU_ANTHROPIC_CLAUDE_SONNET_4_6` |
59+
| `jp.` | Japan | `JP_ANTHROPIC_CLAUDE_SONNET_4_6` |
60+
| `apac.` | Asia-Pacific | `APAC_ANTHROPIC_CLAUDE_4_SONNET` |
61+
| `global.` | Global | `GLOBAL_ANTHROPIC_CLAUDE_SONNET_4_6` |
62+
63+
Not all models are available in all regions. See the [AWS cross-region inference documentation](https://docs.aws.amazon.com/bedrock/latest/userguide/cross-region-inference-support.html) for availability.
64+
65+
## Supported Models
66+
67+
### Anthropic Claude
68+
69+
- Claude 4.6 Sonnet and Opus
70+
- Claude 4.5 Sonnet and Opus
71+
- Claude 4.1 Opus
72+
- Claude 4 Sonnet and Opus
73+
- Claude 3.7 Sonnet
74+
- Claude 3.5 Sonnet (v1 and v2) and Haiku
75+
- Claude 3 Haiku, Sonnet, and Opus
76+
- Claude Haiku 4.5
77+
78+
### Meta Llama
79+
80+
- Llama 4 Scout 17B and Maverick 17B
81+
- Llama 3.3 70B
82+
- Llama 3.2 (1B, 3B, 11B, 90B)
83+
- Llama 3.1 (8B, 70B, 405B)
84+
- Llama 3 (8B, 70B)
85+
- Llama 2 (13B, 70B)
86+
87+
### Amazon Nova
88+
89+
- Nova Premier
90+
- Nova Pro
91+
- Nova Lite
92+
- Nova Micro
93+
- Nova 2 Lite
94+
3295
## LICENSE
3396

3497
MIT

packages/providers/aws/src/llm/bedrock/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -390,7 +390,7 @@ const CHAT_ONLY_MODELS = {
390390
[BEDROCK_MODELS.AMAZON_NOVA_PRO_1]: 300000,
391391
[BEDROCK_MODELS.AMAZON_NOVA_LITE_1]: 300000,
392392
[BEDROCK_MODELS.AMAZON_NOVA_MICRO_1]: 130000,
393-
[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]: 300000,
393+
[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]: 1000000,
394394
};
395395

396396
const BEDROCK_FOUNDATION_LLMS = { ...COMPLETION_MODELS, ...CHAT_ONLY_MODELS };
@@ -512,7 +512,7 @@ export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
512512
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_4_1_OPUS]: 32000,
513513
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_4_5_SONNET]: 64000,
514514
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_5]: 32000,
515-
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6]: 32000,
515+
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6]: 128000,
516516
[BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6]: 64000,
517517
[BEDROCK_MODELS.META_LLAMA2_13B_CHAT]: 2048,
518518
[BEDROCK_MODELS.META_LLAMA2_70B_CHAT]: 2048,
@@ -528,7 +528,7 @@ export const BEDROCK_MODEL_MAX_TOKENS: Partial<Record<BEDROCK_MODELS, number>> =
528528
[BEDROCK_MODELS.META_LLAMA3_3_70B_INSTRUCT]: 2048,
529529
[BEDROCK_MODELS.META_LLAMA4_SCOUT_17B_INSTRUCT]: 16384,
530530
[BEDROCK_MODELS.META_LLAMA4_MAVERICK_17B_INSTRUCT]: 16384,
531-
[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]: 5120,
531+
[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]: 65536,
532532
};
533533

534534
const DEFAULT_BEDROCK_PARAMS = {
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
import { describe, expect, test } from "vitest";
2+
import {
3+
BEDROCK_MODEL_MAX_TOKENS,
4+
BEDROCK_MODELS,
5+
INFERENCE_BEDROCK_MODELS,
6+
INFERENCE_TO_BEDROCK_MAP,
7+
STREAMING_MODELS,
8+
TOOL_CALL_MODELS,
9+
} from "../src/llm/bedrock/index";
10+
11+
const allBedrockModelValues = Object.values(BEDROCK_MODELS);
12+
const allInferenceModelValues = Object.values(INFERENCE_BEDROCK_MODELS);
13+
14+
describe("BEDROCK_MODELS", () => {
15+
test("all model IDs should be unique", () => {
16+
const seen = new Set<string>();
17+
for (const value of allBedrockModelValues) {
18+
expect(seen.has(value), `Duplicate model ID: ${value}`).toBe(false);
19+
seen.add(value);
20+
}
21+
});
22+
});
23+
24+
describe("INFERENCE_TO_BEDROCK_MAP", () => {
25+
test("every inference model should map to a valid BEDROCK_MODELS entry", () => {
26+
for (const [inferenceModel, bedrockModel] of Object.entries(
27+
INFERENCE_TO_BEDROCK_MAP,
28+
)) {
29+
expect(
30+
allBedrockModelValues.includes(bedrockModel),
31+
`Inference model ${inferenceModel} maps to ${bedrockModel} which is not in BEDROCK_MODELS`,
32+
).toBe(true);
33+
}
34+
});
35+
36+
test("every INFERENCE_BEDROCK_MODELS value should have a mapping", () => {
37+
const mappedInferenceModels = Object.keys(INFERENCE_TO_BEDROCK_MAP);
38+
for (const inferenceModel of allInferenceModelValues) {
39+
expect(
40+
mappedInferenceModels.includes(inferenceModel),
41+
`Inference model ${inferenceModel} has no entry in INFERENCE_TO_BEDROCK_MAP`,
42+
).toBe(true);
43+
}
44+
});
45+
});
46+
47+
describe("STREAMING_MODELS", () => {
48+
test("all TOOL_CALL_MODELS should also be in STREAMING_MODELS", () => {
49+
for (const model of TOOL_CALL_MODELS) {
50+
expect(
51+
STREAMING_MODELS.has(model),
52+
`Tool call model ${model} is not in STREAMING_MODELS`,
53+
).toBe(true);
54+
}
55+
});
56+
});
57+
58+
describe("BEDROCK_MODEL_MAX_TOKENS", () => {
59+
test("new Claude models should have max tokens entries", () => {
60+
const expectedModels = [
61+
BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6,
62+
BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6,
63+
BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_5,
64+
BEDROCK_MODELS.ANTHROPIC_CLAUDE_4_5_SONNET,
65+
BEDROCK_MODELS.ANTHROPIC_CLAUDE_HAIKU_4_5,
66+
];
67+
for (const model of expectedModels) {
68+
expect(
69+
BEDROCK_MODEL_MAX_TOKENS[model],
70+
`Model ${model} should have a max tokens entry`,
71+
).toBeDefined();
72+
}
73+
});
74+
75+
test("new Meta Llama 4 models should have max tokens entries", () => {
76+
const expectedModels = [
77+
BEDROCK_MODELS.META_LLAMA4_SCOUT_17B_INSTRUCT,
78+
BEDROCK_MODELS.META_LLAMA4_MAVERICK_17B_INSTRUCT,
79+
];
80+
for (const model of expectedModels) {
81+
expect(
82+
BEDROCK_MODEL_MAX_TOKENS[model],
83+
`Model ${model} should have a max tokens entry`,
84+
).toBeDefined();
85+
}
86+
});
87+
88+
test("Nova 2 Lite should have max tokens entry", () => {
89+
expect(
90+
BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.AMAZON_NOVA_2_LITE],
91+
).toBeDefined();
92+
});
93+
});
94+
95+
describe("Removed models", () => {
96+
const removedInferenceModels = [
97+
"us.anthropic.claude-3-sonnet-20240229-v1:0",
98+
"us.anthropic.claude-3-opus-20240229-v1:0",
99+
"us.anthropic.claude-3-5-sonnet-20240620-v1:0",
100+
"eu.anthropic.claude-3-5-sonnet-20240620-v1:0",
101+
"eu.anthropic.claude-3-5-haiku-20241022-v1:0",
102+
"eu.anthropic.claude-opus-4-20250514-v1:0",
103+
"eu.anthropic.claude-opus-4-1-20250805-v1:0",
104+
"eu.amazon.nova-premier-v1:0",
105+
];
106+
107+
test("removed cross-region inference models should not be present", () => {
108+
const inferenceValues: string[] = allInferenceModelValues;
109+
for (const modelId of removedInferenceModels) {
110+
expect(
111+
inferenceValues.includes(modelId),
112+
`Removed model ${modelId} should not be in INFERENCE_BEDROCK_MODELS`,
113+
).toBe(false);
114+
}
115+
});
116+
});
117+
118+
describe("Model data values", () => {
119+
test("Claude Opus 4.6 max tokens should be 128000", () => {
120+
expect(
121+
BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.ANTHROPIC_CLAUDE_OPUS_4_6],
122+
).toBe(128000);
123+
});
124+
125+
test("Claude Sonnet 4.6 max tokens should be 64000", () => {
126+
expect(
127+
BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.ANTHROPIC_CLAUDE_SONNET_4_6],
128+
).toBe(64000);
129+
});
130+
131+
test("Llama 4 Scout max tokens should be 16384", () => {
132+
expect(
133+
BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.META_LLAMA4_SCOUT_17B_INSTRUCT],
134+
).toBe(16384);
135+
});
136+
137+
test("Llama 4 Maverick max tokens should be 16384", () => {
138+
expect(
139+
BEDROCK_MODEL_MAX_TOKENS[
140+
BEDROCK_MODELS.META_LLAMA4_MAVERICK_17B_INSTRUCT
141+
],
142+
).toBe(16384);
143+
});
144+
145+
test("Nova 2 Lite max tokens should be 65536", () => {
146+
expect(BEDROCK_MODEL_MAX_TOKENS[BEDROCK_MODELS.AMAZON_NOVA_2_LITE]).toBe(
147+
65536,
148+
);
149+
});
150+
});

0 commit comments

Comments
 (0)