Skip to content

feat: add multi-region support for AWS Bedrock#1897

Open
rcogal wants to merge 16 commits intomainfrom
feat/aws-bedrock-regions
Open

feat: add multi-region support for AWS Bedrock#1897
rcogal wants to merge 16 commits intomainfrom
feat/aws-bedrock-regions

Conversation

@rcogal
Copy link
Copy Markdown
Collaborator

@rcogal rcogal commented Mar 27, 2026

Summary

  • Add regionConfig to the AWS Bedrock provider with 6 regions (us-east-1, us-west-2, eu-west-1, eu-central-1, ap-northeast-1, ap-southeast-1)
  • Add model-level regions to Claude Sonnet 4 as a proof of concept (same pattern as Alibaba)
  • Update endpoint resolution to call regional endpoints directly when a region is selected, skipping the legacy cross-region inference prefix
  • Add aws_bedrock_region to provider key options, API schemas, and UI labels

How it works

  1. Each AWS Bedrock region maps to its own endpoint: https://bedrock-runtime.<region>.amazonaws.com
  2. Models define which regions they're available in via the regions array on the provider mapping
  3. expandProviderRegions creates separate routing candidates per region (e.g., anthropic.claude-sonnet-4-20250514-v1:0:us-east-1)
  4. Users select a region in the provider key UI → gateway locks routing to that region
  5. Per-region API keys supported via LLM_AWS_BEDROCK_API_KEY__<REGION> env vars

Still TODO

  • Add regions to remaining AWS Bedrock models (anthropic.ts, meta.ts)
  • Look up per-model region availability from AWS docs
  • Consider deprecating aws_bedrock_region_prefix in favor of direct regional endpoints

Test plan

  • Verify build passes with pnpm build
  • Test region selection in provider key creation UI
  • Test request routing to different regional endpoints
  • Verify stripRegionFromModelName removes suffix before sending to AWS

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Multi-region AWS Bedrock support: selectable regions for models/endpoints and region-aware provider options.
    • Model selector now recognizes region-expanded model identifiers.
  • Improvements

    • Cost estimates resolve region-specific models for more accurate pricing.
    • UI option labels clarified ("Region" / "Cross-Region Prefix").
    • Added region metadata to models/providers; some provider entries marked deactivated.
  • Documentation

    • Example environment file includes an optional Bedrock region entry.
  • Tests

    • Added region-aware tests for endpoints, model expansion, and cost lookup.
  • Chores

    • Added a small UI runtime dependency for visual effects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Mar 27, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

Walkthrough

Adds AWS Bedrock region-awareness: new region config and UI labels, DB/provider-key option, model/provider region metadata, endpoint region-prefix logic, region-aware cost/model resolution, selector updates, and accompanying tests and minor dependency update.

Changes

Cohort / File(s) Summary
Env & DB Schema
/.env.example, packages/db/src/schema.ts
Documented optional LLM_AWS_BEDROCK_REGION in .env.example; added optional aws_bedrock_region (restricted enum) to ProviderKeyOptions.
Provider Definition
packages/models/src/providers.ts
Added regionConfig to aws-bedrock provider: storage key aws_bedrock_region, default us-east-1, supported region list, and endpointMap mapping region → bedrock runtime host.
Model Metadata
packages/models/src/models/anthropic.ts, packages/models/src/models/meta.ts, packages/models/src/models/alibaba.ts
Added regions arrays to many aws-bedrock provider entries; added deactivatedAt to three nebius alibaba provider entries.
API Validation
apps/api/src/routes/keys-provider.ts
Extended Zod schemas to accept optional options.aws_bedrock_region validated against allowed region enum.
Endpoint Resolution
packages/actions/src/get-provider-endpoint.ts, packages/actions/src/get-provider-endpoint.spec.ts
Added bedrockRegionPrefix(region) helper; prefer region-specific base URL when present; derive model path prefix from provided region (fallback to legacy prefix); expanded tests for region prefixes and streaming path selection.
Gateway Cost Lookup & Tests
apps/gateway/src/lib/costs.ts, apps/gateway/src/lib/costs.spec.ts
Added fallback model lookup expanding provider regions (expandAllProviderRegions) to resolve region-suffixed models for cost calculation; added region-aware cost tests.
Playground UI & Provider Keys UI
apps/playground/src/components/model-selector.tsx, apps/ui/src/components/provider-keys/provider-keys-list.tsx, apps/ui/package.json
ModelSelector updated to correctly resolve region-suffixed identifiers and provider mappings; provider-keys option label mapping added for aws_bedrock_region and renamed aws_bedrock_region_prefix → "Cross-Region Prefix"; added canvas-confetti dependency and types.
Region Helpers Tests
packages/models/src/region-helpers.spec.ts
New tests for stripRegionFromModelName, expandProviderRegions, and expandAllProviderRegions covering stripping/expansion/pricing inheritance behaviors.
E2E Test Filtering
apps/gateway/src/chat-helpers.e2e.ts
Default filtering added to skip region-specific expanded provider entries in test generation unless TEST_MODELS explicitly includes region suffixes.

Sequence Diagram(s)

mermaid
sequenceDiagram
participant UI as "Client / UI"
participant API as "API (keys-provider)"
participant DB as "DB (ProviderKeyOptions)"
participant Models as "Model Registry"
participant Gateway as "Gateway / Costs"
participant Bedrock as "AWS Bedrock"
UI->>API: submit provider key (may include aws_bedrock_region)
API->>DB: validate & store provider key (aws_bedrock_region)
UI->>Models: request model (may include :region suffix)
Models-->>UI: model mapping (regions metadata)
UI->>Gateway: invoke model (model or model:region)
Gateway->>Models: resolve modelInfo (expandAllProviderRegions if needed)
Gateway->>Bedrock: call endpoint (region-derived prefix/base URL)
Bedrock-->>Gateway: response (streaming or non-streaming)
Gateway->>Gateway: calculate costs (region-aware pricing)
Gateway-->>UI: return response + cost estimates

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

auto-merge

Suggested reviewers

  • steebchen
🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add multi-region support for AWS Bedrock' accurately captures the primary objective of the PR, which is implementing multi-region support for the AWS Bedrock provider across all changed files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/aws-bedrock-regions

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

romel lauron and others added 6 commits March 28, 2026 00:43
Add region availability to all AWS Bedrock provider mappings:
- All 6 regions: Claude 3.7 Sonnet, Sonnet 4/4.5/4.6, Haiku 4.5,
  Opus 4.5/4.6
- US only (us-east-1, us-west-2): Opus 4/4.1, 3.5 Haiku/Sonnet,
  all Meta Llama models

Also fix endpoint prefix: derive cross-region inference prefix
(us./eu./apac.) from the selected region instead of skipping it,
since many newer models are CR-only on AWS Bedrock.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Model names with colons (e.g. v1:0:us-east-1) broke the naive
split(":")[0] region stripping. Add fallback lookup by searching
all model mappings when direct model.id match fails.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The model lookup in calculateCosts failed for region-expanded
names like "v1:0:us-east-1" because split(":")[0] stripped the
version too. Add fallback that searches expanded providers.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
# Conflicts:
#	packages/models/src/models/anthropic.ts
@rcogal rcogal marked this pull request as ready for review April 14, 2026 14:18
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
apps/api/src/routes/keys-provider.ts (1)

72-81: Consider extracting shared region enum to avoid drift.

The aws_bedrock_region enum is duplicated between providerKeySchema and createProviderKeySchema. While this works, consider extracting a shared Zod enum constant to ensure they stay in sync:

const awsBedrockRegionEnum = z.enum([
  "us-east-1",
  "us-west-2", 
  "eu-west-1",
  "eu-central-1",
  "ap-northeast-1",
  "ap-southeast-1",
]);

This would also help keep the API schemas in sync with packages/db/src/schema.ts and packages/models/src/providers.ts.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/api/src/routes/keys-provider.ts` around lines 72 - 81, The
aws_bedrock_region enum is duplicated between providerKeySchema and
createProviderKeySchema; extract a single shared Zod enum constant (e.g.,
awsBedrockRegionEnum) and replace the inline enums in both schemas with that
constant (update references in providerKeySchema and createProviderKeySchema),
and ensure the exported/shared constant is used where other modules
(packages/db/src/schema.ts and packages/models/src/providers.ts) need the same
region list so the schemas stay in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/playground/src/components/model-selector.tsx`:
- Around line 465-470: The code incorrectly removes everything after the first
colon when computing selectedModelId from selectedModelIdRaw (variable names:
selectedModelIdRaw -> selectedModelId); change the logic so it only strips the
final colon segment (i.e., remove the last :<region> suffix) rather than
split(":")[0], or import and call stripRegionFromModelName from
packages/models/src/region-helpers.ts to derive the region-stripped model id,
ensuring names like "anthropic.claude-3-5-...:0:us-east-1" become
"anthropic.claude-3-5-...:0".

In `@packages/actions/src/get-provider-endpoint.ts`:
- Around line 13-31: The bedrockRegionPrefix function incorrectly maps Middle
East regions; update the branch in bedrockRegionPrefix to return "global." when
region.startsWith("me-") instead of "apac.", leaving other prefixes unchanged;
also consider explicitly handling or documenting regions like "sa-" and "af-"
(currently falling back to "us.") if you want different routing behavior.

---

Nitpick comments:
In `@apps/api/src/routes/keys-provider.ts`:
- Around line 72-81: The aws_bedrock_region enum is duplicated between
providerKeySchema and createProviderKeySchema; extract a single shared Zod enum
constant (e.g., awsBedrockRegionEnum) and replace the inline enums in both
schemas with that constant (update references in providerKeySchema and
createProviderKeySchema), and ensure the exported/shared constant is used where
other modules (packages/db/src/schema.ts and packages/models/src/providers.ts)
need the same region list so the schemas stay in sync.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0c59826e-07de-4c4e-8bc1-f16aca74940b

📥 Commits

Reviewing files that changed from the base of the PR and between dafb77d and 97647fb.

⛔ Files ignored due to path filters (4)
  • apps/code/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/playground/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/ui/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • ee/admin/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
📒 Files selected for processing (10)
  • .env.example
  • apps/api/src/routes/keys-provider.ts
  • apps/gateway/src/lib/costs.ts
  • apps/playground/src/components/model-selector.tsx
  • apps/ui/src/components/provider-keys/provider-keys-list.tsx
  • packages/actions/src/get-provider-endpoint.ts
  • packages/db/src/schema.ts
  • packages/models/src/models/anthropic.ts
  • packages/models/src/models/meta.ts
  • packages/models/src/providers.ts

Comment thread apps/playground/src/components/model-selector.tsx Outdated
Comment on lines +13 to +31
/**
* Derive the AWS Bedrock cross-region inference prefix from a region ID.
* Many newer models are only available through cross-region inference profiles.
*/
function bedrockRegionPrefix(region: string): string {
if (region.startsWith("us-")) {
return "us.";
}
if (region.startsWith("eu-")) {
return "eu.";
}
if (region.startsWith("ap-")) {
return "apac.";
}
if (region.startsWith("me-")) {
return "apac.";
}
return "us.";
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

AWS Bedrock cross-region inference prefix Middle East region

💡 Result:

For AWS Bedrock cross-region inference in Middle East regions (me-central-1 UAE and me-south-1 Bahrain), the prefix for global cross-region inference profiles is "global.". These profiles route inference requests from the source Middle East region to optimal commercial AWS Regions worldwide for higher throughput. Example model ID from me-central-1: global.anthropic.claude-sonnet-4-6 Usage example (Python boto3): bedrock = boto3.client('bedrock-runtime', region_name='me-central-1') model_id = "global.anthropic.claude-sonnet-4-6" response = bedrock.converse(... , modelId=model_id) Supported models include Anthropic Claude Opus 4.6, Sonnet 4.6, Haiku 4.5, Sonnet 4.5, Opus 4.5 as source regions me-central-1 and me-south-1, destination: commercial regions. ARN pattern: arn:aws:bedrock:REGION:ACCOUNT:inference-profile/global.MODEL-NAME Geographic profiles use prefixes like "us.", "eu.", but for Middle East global CRIS, it's "global.". No specific "me." geographic prefix found; global provides worldwide routing.

Citations:


Middle East region should use "global." prefix, not "apac."

AWS Bedrock cross-region inference for Middle East regions (me-central-1, me-south-1) requires the "global." prefix to route requests globally, not "apac.". Update the mapping:

if (region.startsWith("me-")) {
    return "global.";
}

Additionally, regions like sa- (South America) and af- (Africa) will default to "us." and should either be explicitly mapped or handled based on their available inference profile configurations.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/actions/src/get-provider-endpoint.ts` around lines 13 - 31, The
bedrockRegionPrefix function incorrectly maps Middle East regions; update the
branch in bedrockRegionPrefix to return "global." when region.startsWith("me-")
instead of "apac.", leaving other prefixes unchanged; also consider explicitly
handling or documenting regions like "sa-" and "af-" (currently falling back to
"us.") if you want different routing behavior.

Add unit tests for bedrockRegionPrefix(), region-helpers,
and region-aware cost calculation. Update Meta Llama model
regions per AWS docs (add us-east-2, us-west-1). Add
us-east-2 and us-west-1 to provider config and schemas.
Fix missing canvas-confetti dependency in UI app.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
packages/models/src/region-helpers.spec.ts (1)

93-100: Add inherited outputPrice assertion for the non-overridden region.

The inheritance case currently validates only inputPrice; add outputPrice too so a regression in one direction doesn’t slip through.

Diff suggestion
 		// Singapore inherits parent pricing
 		const singapore = result.find((r) => r.region === "singapore");
 		expect(singapore?.inputPrice).toBe(0.4 / 1e6);
+		expect(singapore?.outputPrice).toBe(1.6 / 1e6);

 		// Beijing overrides pricing
 		const beijing = result.find((r) => r.region === "cn-beijing");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/models/src/region-helpers.spec.ts` around lines 93 - 100, The test
checks that the "singapore" region inherits inputPrice but misses asserting its
inherited outputPrice; update the test by adding an assertion that
singapore?.outputPrice equals the parent region's outputPrice (locate the parent
via result.find(...) or compare against the known parent value) so the
"singapore" variable in the spec is verified for both inputPrice and outputPrice
inheritance.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@packages/actions/src/get-provider-endpoint.spec.ts`:
- Around line 276-292: The test case in get-provider-endpoint.spec.ts is using
an unsupported me- region ("me-south-1"); update the test to use an
API-supported me- region (replace "me-south-1" with "me-central-1") so the
getProviderEndpoint call and the LLM_AWS_BEDROCK_BASE_URL reflect a valid,
selectable region for the provider schema.
- Around line 184-343: The tests currently assert legacy region-prefixed model
IDs; update the expectations in the get-provider-endpoint tests that call
getProviderEndpoint (the cases for "us-east-1", "us-west-2", "eu-west-1",
"ap-northeast-1", "me-south-1", "ca-central-1" and the streaming case) to assert
direct regional routing: expect the returned endpoint to contain
"/model/anthropic.claude-sonnet-4-5-20250929-v1:0/converse" (or
"/converse-stream" when streaming) instead of
"/model/{us.|eu.|apac.}anthropic..."; keep test inputs the same but change the
expected string to remove the legacy prefix so tests validate direct region
routing.

---

Nitpick comments:
In `@packages/models/src/region-helpers.spec.ts`:
- Around line 93-100: The test checks that the "singapore" region inherits
inputPrice but misses asserting its inherited outputPrice; update the test by
adding an assertion that singapore?.outputPrice equals the parent region's
outputPrice (locate the parent via result.find(...) or compare against the known
parent value) so the "singapore" variable in the spec is verified for both
inputPrice and outputPrice inheritance.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 550d80be-67b5-48fb-94b8-97d1a69faddc

📥 Commits

Reviewing files that changed from the base of the PR and between 97647fb and 0d9a1eb.

⛔ Files ignored due to path filters (5)
  • apps/code/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/playground/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • apps/ui/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • ee/admin/src/lib/api/v1.d.ts is excluded by !**/v1.d.ts
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (8)
  • apps/api/src/routes/keys-provider.ts
  • apps/gateway/src/lib/costs.spec.ts
  • apps/ui/package.json
  • packages/actions/src/get-provider-endpoint.spec.ts
  • packages/db/src/schema.ts
  • packages/models/src/models/meta.ts
  • packages/models/src/providers.ts
  • packages/models/src/region-helpers.spec.ts
✅ Files skipped from review due to trivial changes (4)
  • apps/ui/package.json
  • apps/api/src/routes/keys-provider.ts
  • packages/models/src/providers.ts
  • apps/gateway/src/lib/costs.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/db/src/schema.ts
  • packages/models/src/models/meta.ts

Comment on lines +184 to +343
it("uses 'us.' prefix for us-east-1 region", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.us-east-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"us-east-1",
);

expect(endpoint).toContain(
"/model/us.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("uses 'us.' prefix for us-west-2 region", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.us-west-2.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"us-west-2",
);

expect(endpoint).toContain(
"/model/us.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("uses 'eu.' prefix for eu-west-1 region", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.eu-west-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"eu-west-1",
);

expect(endpoint).toContain(
"/model/eu.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("uses 'apac.' prefix for ap-northeast-1 region", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.ap-northeast-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"ap-northeast-1",
);

expect(endpoint).toContain(
"/model/apac.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("uses 'apac.' prefix for me- regions", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.me-south-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"me-south-1",
);

expect(endpoint).toContain(
"/model/apac.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("falls back to 'us.' prefix for unknown region prefixes", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.ca-central-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
false,
undefined,
undefined,
undefined,
undefined,
undefined,
"ca-central-1",
);

expect(endpoint).toContain(
"/model/us.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
);
});

it("uses converse-stream endpoint when streaming", () => {
process.env.LLM_AWS_BEDROCK_BASE_URL =
"https://bedrock-runtime.us-east-1.amazonaws.com";

const endpoint = getProviderEndpoint(
"aws-bedrock",
undefined,
"anthropic.claude-sonnet-4-5-20250929-v1:0",
undefined,
true,
undefined,
undefined,
undefined,
undefined,
undefined,
"us-east-1",
);

expect(endpoint).toContain(
"/model/us.anthropic.claude-sonnet-4-5-20250929-v1:0/converse-stream",
);
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

These assertions lock in legacy cross-region model-prefix behavior instead of direct regional routing.

The region-selected cases assert /model/us.|eu.|apac.<model>/.... Per the PR objective, selected regions should route directly to bedrock-runtime.<region>.amazonaws.com and skip legacy prefixing in the model identifier. These tests currently enforce the old behavior.

Suggested test expectation direction
- expect(endpoint).toContain(
-   "/model/us.anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
- );
+ expect(endpoint).toContain(
+   "https://bedrock-runtime.us-east-1.amazonaws.com/model/anthropic.claude-sonnet-4-5-20250929-v1:0/converse",
+ );
+ expect(endpoint).not.toContain("/model/us.");
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/actions/src/get-provider-endpoint.spec.ts` around lines 184 - 343,
The tests currently assert legacy region-prefixed model IDs; update the
expectations in the get-provider-endpoint tests that call getProviderEndpoint
(the cases for "us-east-1", "us-west-2", "eu-west-1", "ap-northeast-1",
"me-south-1", "ca-central-1" and the streaming case) to assert direct regional
routing: expect the returned endpoint to contain
"/model/anthropic.claude-sonnet-4-5-20250929-v1:0/converse" (or
"/converse-stream" when streaming) instead of
"/model/{us.|eu.|apac.}anthropic..."; keep test inputs the same but change the
expected string to remove the legacy prefix so tests validate direct region
routing.

Comment thread packages/actions/src/get-provider-endpoint.spec.ts
romel lauron and others added 4 commits April 14, 2026 23:01
nebius/qwen3-coder-480b, qwen3-coder-30b, and
qwen3-30b-thinking consistently time out in E2E tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Nebius status page and model availability confirm these
models are stable. CI timeouts were transient.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
These models don't exist on Nebius AI Studio API
(404 Not Found). They appear on Token Factory pricing
but are not available at api.studio.nebius.com.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Region-expanded models (e.g. model:us-east-1) were included
as separate E2E test cases, causing 400 errors since CI
lacks region-aware provider keys. Now skipped by default,
opt-in via TEST_MODELS with region suffix.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
apps/gateway/src/chat-helpers.e2e.ts (1)

362-365: Extract the region-skip predicate to avoid logic drift.

Line 363 duplicates the same condition used at Line 270. A shared helper would keep testModels and providerModels behavior in sync.

♻️ Proposed refactor
+function shouldSkipRegionSpecificProvider(provider: ProviderModelMapping): boolean {
+	return Boolean(provider.region) && !specifiedModels;
+}
+
 ...
-			if (provider.region && !specifiedModels) {
+			if (shouldSkipRegionSpecificProvider(provider)) {
 				continue;
 			}
 ...
-			if (provider.region && !specifiedModels) {
+			if (shouldSkipRegionSpecificProvider(provider)) {
 				continue;
 			}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/gateway/src/chat-helpers.e2e.ts` around lines 362 - 365, Extract the
duplicated region-check logic into a single predicate function (e.g.,
shouldSkipRegion or isRegionMismatch) and replace the inline conditions in both
locations that currently use "provider.region && !specifiedModels" (the
occurrences inside testModels and providerModels) to call that helper; ensure
the helper accepts the same inputs used in both sites (provider and
specifiedModels flag) and returns a boolean, then update both call sites to use
the helper so the region-skipping behavior remains centralized and in sync.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@apps/gateway/src/chat-helpers.e2e.ts`:
- Around line 362-365: Extract the duplicated region-check logic into a single
predicate function (e.g., shouldSkipRegion or isRegionMismatch) and replace the
inline conditions in both locations that currently use "provider.region &&
!specifiedModels" (the occurrences inside testModels and providerModels) to call
that helper; ensure the helper accepts the same inputs used in both sites
(provider and specifiedModels flag) and returns a boolean, then update both call
sites to use the helper so the region-skipping behavior remains centralized and
in sync.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 53297c7b-8316-4546-b868-f32c35ae1ce4

📥 Commits

Reviewing files that changed from the base of the PR and between 3fcf9e7 and c4f6525.

📒 Files selected for processing (1)
  • apps/gateway/src/chat-helpers.e2e.ts

romel lauron and others added 4 commits April 14, 2026 23:52
Deactivate Qwen/Qwen2.5-Coder-7B-fast and moonshotai/Kimi-K2-Instruct
on Nebius — both confirmed absent from the Nebius AI Studio API
(api.studio.nebius.com/v1/models). This also fixes the
keys-provider.e2e.ts Nebius validation failure, which was selecting
the now-deactivated Qwen2.5-Coder-7B-fast as the cheapest validation
model.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Deactivate grok-4, grok-4-fast-reasoning, grok-4-fast-non-reasoning
  — no longer listed in xAI docs (docs.x.ai/docs/models), superseded
  by grok-4-1-fast and grok-4.20 variants
- Fix model names: grok-4.20-beta-0309-* → grok-4.20-0309-* (remove
  "beta" per xAI docs)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix model selector colon stripping to only remove last :region
  segment, preserving model names like "anthropic.claude-v1:0"
- Use me-central-1 instead of me-south-1 in bedrock region test
- Add outputPrice assertion for inherited region pricing test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant