Skip to content

fix(models): enable 1h cache TTL for fable-5 on bedrock - #2923

Merged
steebchen merged 1 commit into
mainfrom
fable5-1h-cache-ttl-ignored
Jul 5, 2026
Merged

steebchen merged 1 commit into
mainfrom
fable5-1h-cache-ttl-ignored

Conversation

@steebchen

@steebchen steebchen commented Jul 5, 2026 •

Copy link
Copy Markdown
Member

Problem

A user reported that requesting prompt caching with ttl: "1h" works on Opus 4.7/4.8 (tokens land in cache_creation.ephemeral_1h_input_tokens) but on Claude Fable 5 the exact same request lands in ephemeral_5m_input_tokens.

Cause

The gateway gates 1h TTL forwarding for AWS Bedrock on the model mapping's cacheWriteInputPrice1h field (bedrockSupports1hTtl in packages/actions/src/prepare-request-body.ts), silently downgrading ttl: "1h" cachePoints to the 5m default when the field is absent. Fable 5's aws-bedrock mapping was missing the field (the direct anthropic mapping has it), so any Fable 5 request routed through Bedrock lost the 1h TTL — Opus 4.7/4.8 have the field on both mappings, which is why they behaved correctly.

Fix

  • Add cacheWriteInputPrice1h: "20.0e-6" (2× input price, matching the direct Anthropic mapping) to Fable 5's aws-bedrock provider mapping. AWS's Fable 5 model card documents prompt caching with 5m and 1h TTLs.
  • Allowlist anthropic.claude-fable-5 in the Bedrock 1h pricing spec guard.

This also fixes billing for Fable 5 Bedrock 1h cache writes (the price was previously undefined). Geo-region (us) pricing gets the ×1.1 premium automatically via region expansion.

Testing

  • pnpm test:unit passes (the previously failing chat-projects specs were a stale local test-DB schema, fixed by pnpm push-test)
  • pnpm build passes

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added support for a new model option in AWS Bedrock pricing, including 1-hour cache write pricing.
  • Bug Fixes
    • Updated eligibility checks so pricing details are only shown for models that support 1-hour cache TTLs.

Claude Fable 5's aws-bedrock mapping was missing cacheWriteInputPrice1h,
which the gateway uses as the supports-1h-TTL gate for Bedrock cachePoints.
Caller-supplied ttl:"1h" markers were silently downgraded to the 5m
default, so all cache writes landed in ephemeral_5m_input_tokens. AWS's
Fable 5 model card documents 5m and 1h TTL support, so add the 1h write
price (2x input, matching the direct Anthropic mapping) and allowlist the
model in the bedrock 1h pricing spec.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings July 5, 2026 19:16
@coderabbitai

coderabbitai Bot commented Jul 5, 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: 1e9be53d-4ae3-479a-9c97-6cefb6836147

📥 Commits

Reviewing files that changed from the base of the PR and between cac7441 and 7e13655.

📒 Files selected for processing (2)
  • apps/gateway/src/lib/anthropic-pricing.spec.ts
  • packages/models/src/models/anthropic.ts

Walkthrough

This PR adds a cacheWriteInputPrice1h pricing field to the claude-fable-5 model's aws-bedrock provider configuration and adds the corresponding anthropic.claude-fable-5 prefix to the ONE_HOUR_BEDROCK_PREFIXES allowlist in the associated pricing test.

Changes

Bedrock 1h Pricing Update

Layer / File(s) Summary
Model pricing and eligibility test
packages/models/src/models/anthropic.ts, apps/gateway/src/lib/anthropic-pricing.spec.ts
Adds cacheWriteInputPrice1h: "20.0e-6" to the claude-fable-5 aws-bedrock provider config and adds anthropic.claude-fable-5 to the ONE_HOUR_BEDROCK_PREFIXES test allowlist.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

  • theopenco/llmgateway#2609: Both PRs update the Claude Fable 5 AWS Bedrock model pricing by adding cacheWriteInputPrice1h, with the ONE_HOUR_BEDROCK_PREFIXES allowlist also extended.
  • theopenco/llmgateway#2868: Both PRs update the same Bedrock 1-hour TTL pricing gating in the pricing test and the corresponding model pricing config.
  • theopenco/llmgateway#2607: Both PRs modify the claude-fable-5 Anthropic aws-bedrock provider entry including cache-related pricing fields.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: enabling 1h cache TTL support for Fable 5 on Bedrock.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fable5-1h-cache-ttl-ignored

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

Enables AWS Bedrock forwarding and billing for 1-hour prompt-cache TTL (ttl: "1h") for the Anthropic Claude Fable 5 model by adding the missing 1h cache write pricing field and updating the Bedrock 1h pricing-spec allowlist.

Changes:

  • Add cacheWriteInputPrice1h to the Claude Fable 5 aws-bedrock provider mapping (aligning with the direct Anthropic mapping and enabling 1h TTL support gating).
  • Allowlist anthropic.claude-fable-5 in the Bedrock 1h pricing guard test to permit cacheWriteInputPrice1h for that model on Bedrock.

Reviewed changes

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

File Description
packages/models/src/models/anthropic.ts Adds Bedrock 1h cache-write price for Claude Fable 5 so 1h TTL can be forwarded/billed correctly.
apps/gateway/src/lib/anthropic-pricing.spec.ts Extends the Bedrock 1h TTL allowlist to include Fable 5 so the pricing-spec guard matches the new mapping.

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

Comment on lines 171 to 175
const ONE_HOUR_BEDROCK_PREFIXES = [
"anthropic.claude-fable-5",
"anthropic.claude-opus-4-5",
"anthropic.claude-opus-4-6",
"anthropic.claude-opus-4-7",
@steebchen
steebchen merged commit 305f55f into main Jul 5, 2026
18 of 19 checks passed
@steebchen
steebchen deleted the fable5-1h-cache-ttl-ignored branch July 5, 2026 22:23
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