Skip to content

fix: apply bedrock geo pricing - #2729

Closed
analogpvt wants to merge 7 commits into
theopenco:mainfrom
analogpvt:fix/bedrock-geo-pricing
Closed

analogpvt wants to merge 7 commits into
theopenco:mainfrom
analogpvt:fix/bedrock-geo-pricing

Conversation

@analogpvt

@analogpvt analogpvt commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Depends on #2547 for the updated Bedrock Claude region/profile list.

Summary

  • Apply AWS Bedrock 1.1x pricing to every non-global regional/inference profile entry.
  • Keep AWS Bedrock global at 1x pricing.
  • Cover geo profiles and in-region cross-region entries such as eu-west-2.
  • Apply the multiplier across token pricing fields, including input, output, cache read, 5m cache write, 1h cache write, and pricing tiers.

Pricing checks

Model/region Input / 1M Output / 1M 5m cache write / 1M 1h cache write / 1M Cache read / 1M
claude-opus-4-8:global $5.00 $25.00 $6.25 $10.00 $0.50
claude-opus-4-8:us $5.50 $27.50 $6.875 $11.00 $0.55
claude-opus-4-6:eu-west-2 $5.50 $27.50 covered by multiplier covered by multiplier covered by multiplier

Validation

  • pnpm format
  • node_modules/.bin/vitest run packages/models/src/providers.spec.ts
  • node_modules/.bin/turbo run build --filter=@llmgateway/models
  • node_modules/.bin/vitest run apps/gateway/src/lib/costs.spec.ts

Summary by CodeRabbit

  • New Features

    • Expanded AWS Bedrock regional availability to include additional geographic regions (au, jp, eu-west-2, eu-west-3, ap-northeast-2, and others).
    • Implemented region-specific pricing adjustments for AWS Bedrock non-global regions.
  • Tests

    • Added validation for AWS Bedrock regional pricing and model region configuration.

analogpvt and others added 7 commits June 17, 2026 20:17
Add full region support for AWS Bedrock Claude 4.5-4.8 models
including all cross-region (global/us/eu/apac) and in-region
endpoints as per AWS Bedrock regional availability docs.

Models: Sonnet 4.5, Sonnet 4.6, Haiku 4.5, Opus 4.5-4.8
Provider: Updated regionConfig with all supported AWS regions

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

coderabbitai Bot commented Jun 17, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: eced05a5-e1c3-4154-9272-1d8a3df6f61b

📥 Commits

Reviewing files that changed from the base of the PR and between b1530c0 and 962691e.

📒 Files selected for processing (5)
  • apps/gateway/src/lib/costs.spec.ts
  • packages/models/src/models/anthropic.ts
  • packages/models/src/providers.spec.ts
  • packages/models/src/providers.ts
  • packages/models/src/region-helpers.ts

Walkthrough

Adds a 10% price uplift for non-global AWS Bedrock regions by introducing price multiplication helpers and applyAwsBedrockRegionalPricing in region-helpers.ts. The aws-bedrock provider config in providers.ts gains new regions (au, jp, expanded EU/APAC) with updated endpoints and model prefix mappings. Thirteen Anthropic model provider entries receive regions arrays, and new tests validate region coverage and pricing behavior.

Changes

AWS Bedrock Regional Pricing

Layer / File(s) Summary
Bedrock regional pricing multiplier
packages/models/src/region-helpers.ts
Adds price string multiplication helpers (including e-exponent form), applyAwsBedrockRegionalPricing that applies a 1.1x multiplier to all token price fields and PricingTier prices for non-global aws-bedrock regions, and updates expandProviderRegions to call it instead of plain object spreading.
AWS Bedrock provider regionConfig
packages/models/src/providers.ts
Reworks aws-bedrock regionConfig to add au, jp, and expanded EU/APAC geographic regions; extends endpointMap with new Bedrock runtime endpoint URLs; and updates modelPrefixMap with routing prefixes for all added regions.
Anthropic model region annotations
packages/models/src/models/anthropic.ts
Adds regions arrays to 13 AWS Bedrock-backed Anthropic model provider entries (claude-3-7-sonnet, claude-3-5-sonnet-20241022, claude-sonnet-4-5/4-6, claude-haiku-4-5, claude-opus-4-1/4-5/4-6/4-7/4-8, etc.), enumerating each model's supported region IDs.
Provider region tests
packages/models/src/providers.spec.ts
Adds describe("AWS Bedrock Anthropic regions") suite: validates modelPrefixMap defaults, checks no unused configured regions exist, asserts per-model region ID sets, and spot-checks that non-global region expansion produces a 10% uplift across all token price fields.
Cost calculation integration tests
apps/gateway/src/lib/costs.spec.ts
New it(...) block confirms calculateCosts returns global pricing for global location and 10%-higher costs for regional locations, validates cache write costs across 5-minute and 1-hour buckets, and checks cached read cost for a regional request.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • theopenco/llmgateway#2034: Adds a new claude-opus-4-7 AWS Bedrock provider entry to anthropic.ts, the same file where this PR expands region arrays for multiple Bedrock providers.
  • theopenco/llmgateway#2344: Introduced the AWS Bedrock region routing model (providers.ts regionConfig, endpointMap, modelPrefixMap) that this PR extends with new regions and a pricing multiplier.
  • theopenco/llmgateway#2542: Adds the claude-opus-4-8 AWS Bedrock provider entry in anthropic.ts, which this PR subsequently annotates with a regions array.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix: apply bedrock geo pricing' accurately and concisely describes the main change: applying geographic pricing adjustments to AWS Bedrock. It clearly identifies the primary modification across the changeset.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@analogpvt analogpvt closed this Jun 17, 2026
@analogpvt analogpvt reopened this Jun 23, 2026
@analogpvt analogpvt closed this Jun 24, 2026
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