Skip to content

fix: apply regional pricing multiplier to all non-global regions - #2806

Merged
steebchen merged 2 commits into
theopenco:mainfrom
analogpvt:fix/bedrock-regional-pricing
Jun 30, 2026
Merged

steebchen merged 2 commits into
theopenco:mainfrom
analogpvt:fix/bedrock-regional-pricing

Conversation

@analogpvt

@analogpvt analogpvt commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR applies a 1.1x pricing multiplier to non-global AWS Bedrock regional mappings.

  • Keeps "global" mappings at 1x pricing.
  • Applies regional price multiplication to AWS Bedrock mappings whose region is set and is not global.
  • Includes unit tests verifying pricing multiplication logic across token pricing fields, including input/output costs, caching, and tiers.

This PR targets only the pricing changes, as the region configs themselves are already merged in main.

Pricing rationale (why 1.1x)

The 1.1x is not arbitrary — it matches AWS Bedrock's real pricing structure, verified against the AWS pricing calculator and AWS docs:

  • Global is the cheapest route and the baseline (equal to the direct provider price), which is why global mappings keep 1x.
  • Every non-global route carries a +10% premium over the global baseline — this includes both single-region in-region routing and the geographic cross-region inference (CRIS) profiles us / eu / apac (jp, au). The AWS pricing calculator shows this as an exact × 1.10 (e.g. $1.00 → $1.10 input, $5.00 → $5.50 output), not a rounded approximation.

Note that AWS markets this delta as "global cross-Region inference offers approximately 10% savings ... compared to geographic cross-Region inference" (AWS docs). That framing describes the same fact from the opposite end: non-global routing is a ~10% premium, and global simply avoids it. Measured as a discount the figure is actually 1 − 1/1.1 = 9.09%, which AWS rounds up to "approximately 10%." Modeling it as a × 1.1 uplift on the non-global regions (rather than a × 0.9 discount on global) is therefore the correct and exact representation.

Summary by CodeRabbit

  • New Features
    • Added AWS Bedrock regional token pricing with a 10% uplift for non-Global regions.
    • Updated provider region expansion to apply regional token and tier price scaling for applicable AWS Bedrock models.
    • Improved cost coverage for cache write pricing across split durations and for in-region cache read costs.
  • Tests
    • Added/expanded automated tests verifying Bedrock regional uplift, cross-region billing at target-region rates, and cache pricing scenarios.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Adds AWS Bedrock regional token-price scaling for non-global regions and updates tests to cover provider expansion and downstream cost calculations, including cache-write and cache-read scenarios.

Changes

AWS Bedrock Regional Pricing Uplift

Layer / File(s) Summary
Regional pricing helpers and wiring into expandProviderRegions
packages/models/src/region-helpers.ts
Introduces token price field selection, price-multiplication helpers, and applyAwsBedrockRegionalPricing; expandProviderRegions now passes each merged region entry through the regional pricing adjustment before returning it.
Provider spec: region uplift assertions
packages/models/src/providers.spec.ts
Imports expandAllProviderRegions and TOKEN_PRICE_FIELDS, then adds assertions that expanded aws-bedrock mappings scale token price fields by 1.1 for non-global regions and preserve the expected pricing structure for claude-opus-4-8 and claude-opus-4-6.
Gateway costs spec: regional Bedrock pricing
apps/gateway/src/lib/costs.spec.ts
Adds calculateCosts scenarios for global versus regional token rates, cross-region Claude billing, cache-write inputs with and without 1h splits, and cache-read token costs.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

🚥 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
Title check ✅ Passed The title matches the main change by describing the regional pricing multiplier update for non-global mappings.
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.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ 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.

@analogpvt
analogpvt force-pushed the fix/bedrock-regional-pricing branch 2 times, most recently from b9d559c to 559ae0d Compare June 23, 2026 19:26
@analogpvt
analogpvt force-pushed the fix/bedrock-regional-pricing branch from b80bd3d to e2fe036 Compare June 24, 2026 17:03

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/models/src/region-helpers.ts`:
- Around line 56-77: The regional pricing helper is still gated to aws-bedrock
only, so non-global regions for other providers never get the uplift. Update
applyAwsBedrockRegionalPricing in region-helpers.ts to apply the multiplier to
every mapping with a non-global region, and remove the providerId check so
expandProviderRegions() consistently adjusts all regional pricing while still
skipping global mappings.
🪄 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: 31c557fd-7f82-408c-b357-0ffc19e55e16

📥 Commits

Reviewing files that changed from the base of the PR and between b80bd3d and d53e25a.

📒 Files selected for processing (3)
  • apps/gateway/src/lib/costs.spec.ts
  • packages/models/src/providers.spec.ts
  • packages/models/src/region-helpers.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/models/src/providers.spec.ts
  • apps/gateway/src/lib/costs.spec.ts

Comment thread packages/models/src/region-helpers.ts
@steebchen
steebchen merged commit ecef8fd into theopenco:main Jun 30, 2026
14 checks passed
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.

2 participants