Skip to content

feat(models): region-selectable AWS Mantle GPT-5.6 - #3369

Merged
steebchen merged 6 commits into
mainfrom
aws-mantle-gpt56-context-pricing
Aug 3, 2026
Merged

steebchen merged 6 commits into
mainfrom
aws-mantle-gpt56-context-pricing

Conversation

@steebchen

@steebchen steebchen commented Aug 1, 2026 •

Copy link
Copy Markdown
Member

Corrects the aws-mantle GPT-5.6 catalogue entries on three fronts — context size, pricing, and region support.

1. Context size

AWS's model cards advertise a "272K token" context window, which the catalogue took literally as 272000. AWS means 272 × 1024. Probing bedrock-mantle directly:

prompt tokens (278529) exceed customer model maximum (278528)
prompt tokens (278528) exceed customer model maximum (278528)   ← rejected
278527 prompt tokens                                            ← 200 OK

Identical for all three models, and it applies to prompt tokens only — a 278,527-token prompt returning 5 output tokens (278,532 total) succeeds. We were understating the usable window by 6,528 tokens, and the router's contextSize < requiredContextSize filter was excluding Mantle from requests it can serve.

2. Pricing

Bedrock in-region inference is billed at OpenAI's data-residency tier — a flat 10% premium over the standard first-party rates the mappings were copying. Every token type was undercharged by 10%.

Model input cached in cache write output
Sol was → now 5.00 → 5.50 0.50 → 0.55 6.25 → 6.875 30.00 → 33.00
Terra was → now 2.00 → 2.20 0.20 → 0.22 2.50 → 2.75 12.00 → 13.20
Luna was → now 0.20 → 0.22 0.02 → 0.022 0.25 → 0.275 1.20 → 1.32

USD per 1M tokens, already incorporating OpenAI's 2026-07-30 Terra/Luna cut.

The usual Bedrock rule — geo profiles at a ~10% premium, global at roughly base — is correct but doesn't reach Mantle, which has no global option: the model cards mark Geo and Global as Not supported, and the pricing page says "In-region inference is priced at parity with OpenAI data residency tier. Global cross-region inference pricing coming soon." OpenAI's data-residency tier is itself the +10% tier (a 10% uplift for models released on or after 2026-03-05, which covers GPT-5.6). So "parity with the data residency tier" resolves to exactly 1.1× standard.

Values were read out of the raw pricing-page HTML rather than a rendered summary (columns are input / 30m cache write / cache read / output):

['GPT-5.6 Sol',   '$5.50', '$6.88',  '$0.55',  '$33.00']
['GPT-5.6 Terra', '$2.20', '$2.75',  '$0.22',  '$13.20']
['GPT-5.6 Luna',  '$0.22', '$0.275', '$0.022', '$1.32']

Two models nothing here touches corroborate the ratio independently: our first-party GPT-5.5 is 5.00/0.50/30.00 and AWS lists 5.50/0.55/33.00; GPT-5.4 is 2.50/0.25/15.00 → 2.75/0.275/16.50. Both exactly 1.1×. Sol's $6.88 is a rounding of 6.875 — Luna's $0.275 is printed to three decimals and is exact. No long-context tier exists on Bedrock, and the 278,528 cap means OpenAI's over-272K tier could never apply, so pricingTiers stays unset.

3. Region support

aws-mantle previously had a single region pinned by LLM_AWS_MANTLE_REGION (default us-east-1), with no way for a user to choose — no regionConfig, no regions, no provider-key option. That hid two thirds of the deployment.

It now follows the Alibaba pattern: every entry is a concrete AWS region, there is no synthetic global, and pinDefaultRegion stays unset so the gateway routes across regions instead of pinning to one.

Model us-east-1 us-east-2 us-west-2
Sol ✅ ✅ ❌ 404 "the model does not exist"
Terra ✅ ✅ ✅
Luna ✅ ✅ ✅

Taken from the model cards and confirmed against the live endpoint across seven regions — there is no EU or APAC presence at all. Pricing is identical in every region, so the region entries carry no overrides.

Bedrock long-term API keys are IAM-global (one ABSK key authenticated against all three regional endpoints), so sharedCredentialAcrossRegions: true avoids requiring per-region LLM_AWS_MANTLE_API_KEY__<REGION> env keys. The provider-key dialog's hardcoded "API keys are region-specific" line is now conditional on that flag, since it's wrong for Mantle.

Also adds aws_mantle_region to ProviderKeyOptions and both provider-key zod schemas, and routes the endpoint through regionConfig.endpointMap (the env var stays as a deployment-level override).

Verification

  • Live probes establishing the context boundary and the per-region availability matrix for all three models.
  • Region expansion produces the expected 11 mappings (3 synthetic roots + 2 Sol + 3 Terra + 3 Luna), and all 11 pass chat-basic e2e — including :us-west-2 for Terra/Luna and correctly no :us-west-2 for Sol.
  • A gateway request at 275,494 prompt tokens — inside the 272,000–278,527 band the old value wrongly excluded — returns 200 on all three.
  • Unit specs: 104 passing across openai-gpt56-pricing.spec.ts, get-provider-endpoint.spec.ts and providers.spec.ts. New coverage asserts the 1.1× premium against the first-party mapping, the surviving 1.25× cache-write ratio, contextSize === 272 * 1024, absence of pricingTiers, the exact per-model region lists, that no cross-region profile leaks into the config, that every declared region has an endpoint, and that expansion preserves pricing.
  • pnpm format and pnpm build pass.

Note on e2e flakiness

Running the full suite against all 11 Mantle mappings at the default 16-way concurrency produced intermittent 60s timeouts — but on a different mapping each run (luna:us-east-2 once, sol:us-east-1 the next, while sol:us-east-2 answered in 1.2s). Individually each mapping responds in about a second. That points at account-level Mantle throughput rather than any one deployment, so nothing is marked test: "skip". Worth knowing that this PR triples the number of Mantle mappings the e2e job exercises.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added regional configuration for AWS Bedrock Mantle deployments in us-east-1, us-east-2, and us-west-2.
    • Added region-specific endpoint routing with a default region fallback.
    • Added “Any region” selection where supported when creating provider keys.
  • Updates

    • Updated GPT-5.6 Mantle pricing, including cached usage, with the applicable premium.
    • Increased supported context limits to approximately 278K tokens.
    • Clarified in-region availability and cache-write pricing.

AWS advertises a "272K" context window for GPT-5.6 Sol/Terra/Luna on
Bedrock Mantle, which the catalogue read as 272,000 tokens. The real
limit is 272 * 1024 = 278,528: upstream accepts prompts up to 278,527
tokens and rejects 278,528 or more with a validation_error naming the
exact ceiling. Verified live against bedrock-mantle for all three
models, plus a gateway request at 275,494 prompt tokens — inside the
band the old value wrongly excluded from routing.

Bedrock in-region inference is also priced at OpenAI's data-residency
tier, a flat 10% premium over the standard first-party rates, so the
mappings were undercharging by 10% on every token type.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings August 1, 2026 22:19
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@coderabbitai

coderabbitai Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Warning

Review limit reached

@steebchen, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 28 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 586b2aee-7582-40bc-a61c-47c0785ed66e

📥 Commits

Reviewing files that changed from the base of the PR and between 3d91677 and 3b3fa89.

📒 Files selected for processing (5)
  • apps/api/src/routes/keys-provider.ts
  • packages/actions/src/get-provider-endpoint.ts
  • packages/actions/src/validate-provider-key.spec.ts
  • packages/models/src/models/openai.ts
  • packages/models/src/providers.ts

Walkthrough

AWS Mantle now supports three US regions with regional endpoint routing and shared credentials. GPT-5.6 Sol, Terra, and Luna entries use updated pricing, regional metadata, and 278,528-token context limits. API, UI, endpoint, and pricing tests cover the changes.

Changes

AWS Mantle regional configuration and routing

Layer / File(s) Summary
Define regional provider contracts
packages/db/src/schema.ts, apps/api/src/routes/keys-provider.ts, packages/models/src/providers.ts, apps/ui/src/components/provider-keys/create-provider-key-dialog.tsx
Provider-key schemas and database options accept us-east-1, us-east-2, and us-west-2. AWS Mantle metadata defines regional endpoints, a default region, and shared credentials. The UI supports an “Any region” option for shared credentials.
Resolve regional endpoints
packages/actions/src/get-provider-endpoint.ts, packages/actions/src/get-provider-endpoint.spec.ts
Endpoint resolution checks variant-aware environment configuration, regional endpoints, and the default regional URL. Tests cover supported regions, precedence, environment fallback, explicit base URLs, and environment cleanup.
Update GPT-5.6 Mantle models
packages/models/src/models/openai.ts, apps/gateway/src/lib/openai-gpt56-pricing.spec.ts
Sol, Terra, and Luna use a 10% premium, updated cache-write pricing, in-region metadata, and a 278,528-token context limit. Tests validate mappings, pricing relationships, concrete regions, endpoints, and regional expansion.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Possibly related PRs

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant ProviderKeyDialog
  participant ProviderKeyAPI
  participant EndpointResolver
  participant AWSMantle
  Client->>ProviderKeyDialog: select region or Any region
  ProviderKeyDialog->>ProviderKeyAPI: submit provider-key options
  ProviderKeyAPI->>AWSMantle: validate and store region
  Client->>EndpointResolver: send AWS Mantle request
  EndpointResolver->>AWSMantle: resolve configured or fallback region
  AWSMantle-->>EndpointResolver: return regional endpoint
  EndpointResolver->>AWSMantle: send request to endpoint
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding region selection for AWS Mantle GPT-5.6 models.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch aws-mantle-gpt56-context-pricing

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the GPT‑5.6 model catalogue to accurately represent AWS Bedrock Mantle’s effective context window and token pricing, and adds a regression test to prevent future drift between first‑party OpenAI mappings and Mantle’s premium tier.

Changes:

  • Adjust aws-mantle GPT‑5.6 Sol/Terra/Luna contextSize to 272 * 1024 (278,528) and update all token prices to the 10% data‑residency premium.
  • Add a gateway unit spec asserting the 1.1× premium vs OpenAI, the cache-write ratio invariants, contextSize === 272 * 1024, and no pricingTiers for Mantle.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
packages/models/src/models/openai.ts Updates Bedrock Mantle GPT‑5.6 mappings for corrected context size and +10% pricing premium.
apps/gateway/src/lib/openai-gpt56-pricing.spec.ts Adds test coverage to lock in Mantle-vs-OpenAI pricing ratios and Mantle context sizing expectations.
Suppressed comments (2)

packages/models/src/models/openai.ts:2107

  • Same as above: the comment implies the over-272K tier can’t apply due to the cap, but the cap is 278,528 > 272,000. Clarify that Bedrock pricing doesn’t have the long-context tier instead of tying it to the cap.
				// AWS caps the Mantle deployment at a 272K context (vs 1.05M
				// first-party), so OpenAI's over-272K pricing tier never applies.
				// AWS's "272K" is 272 * 1024: upstream rejects prompts of 278528
				// tokens or more.

packages/models/src/models/openai.ts:2256

  • Same clarification needed here: with contextSize set to 278,528, the comment shouldn’t claim the over-272K tier can’t apply because of the cap. It’s better to state that Bedrock doesn’t offer the long-context tier for Mantle pricing.
				// AWS caps the Mantle deployment at a 272K context (vs 1.05M
				// first-party), so OpenAI's over-272K pricing tier never applies.
				// AWS's "272K" is 272 * 1024: upstream rejects prompts of 278528
				// tokens or more.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread packages/models/src/models/openai.ts Outdated
Comment on lines +1955 to +1958
// AWS caps the Mantle deployment at a 272K context (vs 1.05M
// first-party), so OpenAI's over-272K pricing tier never applies.
contextSize: 272000,
// AWS's "272K" is 272 * 1024: upstream rejects prompts of 278528
// tokens or more.
Comment on lines +122 to +125
// Bedrock Mantle in-region inference is priced at OpenAI's data-residency
// tier, a flat 10% premium over the first-party rates, and AWS caps the
// deployment at a 272 * 1024 token context (upstream rejects prompts of
// 278528 tokens or more), so the over-272K tier can never apply.
steebchen and others added 2 commits August 2, 2026 00:23
AWS lists global cross-region pricing for Mantle as "coming soon" and
the model cards mark Geo/Global as unsupported, so the usual Bedrock
geo-premium/global-parity split does not apply — in-region is the only
rate that exists, and AWS prices it at OpenAI's data-residency tier.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Mantle serves each model from concrete AWS regions with no cross-region
inference profiles, so a single env-var-pinned region hid two thirds of
the deployment. Give aws-mantle a regionConfig and per-model region
lists instead, following the Alibaba pattern: every entry is a real
region, there is no synthetic "global", and pinDefaultRegion stays unset
so the gateway routes across regions rather than to a fixed default.

Regions come from the model cards and were confirmed against the live
endpoint: Sol is us-east-1/us-east-2 only (us-west-2 404s "the model
does not exist"), Terra and Luna add us-west-2. Pricing is identical in
every region, so the entries carry no per-region overrides.

Bedrock long-term API keys are IAM-global, so sharedCredentialAcrossRegions
lets one key reach every region without per-region env keys, and the
provider-key dialog now says so instead of claiming keys are regional.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@steebchen steebchen changed the title fix(models): correct AWS Mantle GPT-5.6 context + price feat(models): region-selectable AWS Mantle GPT-5.6 Aug 2, 2026

@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: 3

🤖 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 `@apps/gateway/src/lib/openai-gpt56-pricing.spec.ts`:
- Around line 245-261: Update the test “expands each region without altering
pricing” to assert that the expanded root entry has no region, and that all
subsequent entries’ region values exactly match EXPECTED_REGIONS[modelId] in
order. Keep the existing length and pricing assertions unchanged.

In `@packages/actions/src/get-provider-endpoint.ts`:
- Around line 390-392: Update the Mantle base URL resolution in
get-provider-endpoint to preserve the current variant by using envValueOrDefault
or passing undefined and variant to getProviderEnvValue. Add a regression test
covering a variant-specific Mantle base URL and verifying the resolved endpoint
uses that value.
- Around line 393-398: Update the AWS Mantle branch in getProviderEndpoint to
use the incoming validationRegion/region value as the Mantle region before
falling back to environment defaults, so provider-key options take precedence.
Add a BYOK/spec case that starts with provider-key options and verifies the
resulting Mantle endpoint uses the configured region.
🪄 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 Plus

Run ID: e2bf5ba9-bff3-4d20-8c60-ef7dfa4d6ed1

📥 Commits

Reviewing files that changed from the base of the PR and between 31767ab and bfe9077.

📒 Files selected for processing (8)
  • apps/api/src/routes/keys-provider.ts
  • apps/gateway/src/lib/openai-gpt56-pricing.spec.ts
  • apps/ui/src/components/provider-keys/create-provider-key-dialog.tsx
  • packages/actions/src/get-provider-endpoint.spec.ts
  • packages/actions/src/get-provider-endpoint.ts
  • packages/db/src/schema.ts
  • packages/models/src/models/openai.ts
  • packages/models/src/providers.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/models/src/models/openai.ts

Comment thread apps/gateway/src/lib/openai-gpt56-pricing.spec.ts
Comment thread packages/actions/src/get-provider-endpoint.ts Outdated
Comment thread packages/actions/src/get-provider-endpoint.ts
steebchen and others added 3 commits August 2, 2026 19:03
Storing a region on a provider key locks routing to it, which is right
for data residency but wrong as a default: the dialog pre-filled the
provider's defaultRegion, so a BYOK user who never opened the dropdown
was silently pinned to one region.

For providers whose credential works everywhere (aws-mantle, aws-bedrock)
the dropdown now defaults to "Any region" and stores nothing, leaving all
regions as routing candidates. Region-scoped providers like Alibaba keep
defaulting, since their keys really do belong to one region. Picking a
region explicitly still locks it.

Also addresses PR review: pass `variant` through Mantle's baseUrl lookup
so variant-specific overrides are honoured, and reword the pricing-tier
comments, which claimed the over-272K tier was unreachable when the real
reason is that AWS never exposes it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
The endpoint spec pinned region precedence by passing the region
directly, which skipped the chain the BYOK path actually uses: the
region stored on a provider key resolves through regionConfig.optionsKey
into the request. These drive validateProviderKey from provider-key
options and assert the resulting Mantle URL, plus that a key pinned to
us-west-2 does not validate against Sol, which AWS does not deploy
there.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@steebchen
steebchen enabled auto-merge August 3, 2026 16:25
@steebchen
steebchen added this pull request to the merge queue Aug 3, 2026
Merged via the queue into main with commit 6d5ac7d Aug 3, 2026
11 checks passed
@steebchen
steebchen deleted the aws-mantle-gpt56-context-pricing branch August 3, 2026 17:07
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