Skip to content

feat(models): add Bedrock mappings, fix cache - #1815

Merged
steebchen merged 2 commits into
mainfrom
feat/add-missing-bedrock-mappings
Mar 12, 2026
Merged

steebchen merged 2 commits into
mainfrom
feat/add-missing-bedrock-mappings

Conversation

@rcogal

@rcogal rcogal commented Mar 11, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Add AWS Bedrock provider entries for Anthropic models missing mappings (Claude Haiku 4.5, Claude Opus 4.6)
  • Fix incorrect minCacheableTokens values across multiple Anthropic models per official docs
  • Remove Bedrock entries for models that don't support Global Cross-region inference (Claude 3 Haiku, Claude 3.5 Haiku 20241022)

Bedrock models added:

Model Bedrock ID Input/MTok Output/MTok
claude-haiku-4-5 anthropic.claude-haiku-4-5-20251001-v1:0 $1.00 $5.00
claude-haiku-4-5-20251001 anthropic.claude-haiku-4-5-20251001-v1:0 $1.00 $5.00
claude-opus-4-6 anthropic.claude-opus-4-6-v1 $5.00 $25.00

Bedrock models removed (no Global Cross-region support):

  • claude-3-haiku / claude-3-haiku-20240307
  • claude-3-5-haiku-20241022

minCacheableTokens fixes:

Model Old Correct
Claude Sonnet 4.6 (all providers) 4096/1024 2048
Claude Haiku 4.5 (all providers) 2048 4096
Claude 3 Haiku 2048 1024

Test plan

  • pnpm build passes
  • pnpm format passes
  • E2E tests pass for Bedrock models with LOG_MODE=true
  • Prompt caching e2e test passes for anthropic/claude-haiku-4-5 (cached_tokens: 5843)

🤖 Generated with Claude Code

Add aws-bedrock provider entries for Anthropic models
that were missing Bedrock mappings but are available on
AWS Bedrock. Prices verified against AWS Bedrock pricing.

Models added:
- claude-haiku-4-5
- claude-haiku-4-5-20251001
- claude-opus-4-6
- claude-3-haiku / claude-3-haiku-20240307
- claude-3-5-haiku-20241022

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Mar 11, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Updates to packages/models/src/models/anthropic.ts that modify minCacheableTokens for several Claude models and add new aws-bedrock provider entries (Haiku, Opus, and Sonnet variants), plus accompanying metadata fields (pricing, token limits, flags, jsonOutputSchema).

Changes

Cohort / File(s) Summary
Anthropic models (single file)
packages/models/src/models/anthropic.ts
Adjusted minCacheableTokens for multiple Claude models (claude-sonnet-4-6, claude-haiku-4-5, claude-3-haiku, claude-haiku-4-5-20251001, etc.). Added several aws-bedrock provider blocks for Haiku and Opus variants (new entries include pricing, token limits, context sizes, feature flags, jsonOutputSchema, and discount fields). No signature or API surface changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • smakosh
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main changes: adding AWS Bedrock mappings and fixing cache token thresholds.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/add-missing-bedrock-mappings
📝 Coding Plan for PR comments
  • Generate coding plan

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.

@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


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bc646249-f6a8-4b11-866a-2400c573880f

📥 Commits

Reviewing files that changed from the base of the PR and between bc22aef and e77b9ab.

📒 Files selected for processing (1)
  • packages/models/src/models/anthropic.ts

Comment thread packages/models/src/models/anthropic.ts Outdated
Comment on lines +734 to +746
{
providerId: "aws-bedrock",
modelName: "anthropic.claude-3-haiku-20240307-v1:0",
inputPrice: 0.25 / 1e6,
outputPrice: 1.25 / 1e6,
requestPrice: 0,
discount: 0.3,
contextSize: 200000,
maxOutput: 4096,
streaming: true,
vision: true,
tools: true,
},

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

Don't rely on cachedInputPrice omission to disable Bedrock prompt caching.

Lines 734-746 and 771-783 intentionally drop cached pricing, but the Bedrock request path still falls back minCacheableTokens to 1024 when that field is missing in packages/actions/src/prepare-request-body.ts Lines 1139-1144, then emits cachePoint blocks from that threshold in Lines 1185-1190. For Claude 3 Haiku, cache-controlled requests can still be serialized as prompt-caching even though these mappings are supposed to represent a non-cacheable Bedrock model. Please gate cachePoint generation on an explicit caching capability instead of inferring it from price fields.

Also applies to: 771-783

Fix incorrect minCacheableTokens thresholds per official
Anthropic docs: Haiku 4.5 → 4096, Sonnet 4.6 → 2048,
Claude 3 Haiku → 1024. Remove Bedrock entries for models
that don't support Global Cross-region inference.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@rcogal rcogal changed the title feat(models): add missing Bedrock mappings feat(models): add Bedrock mappings, fix cache Mar 12, 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: 1

🤖 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/models/src/models/anthropic.ts`:
- Line 709: Update the Claude 3 Haiku model entries to use a 2,048-token cache
threshold: find the model config(s) that set minCacheableTokens (the Claude 3
Haiku model identifier / config object) and change minCacheableTokens from 1024
to 2048 so the client won’t mark prompts as cacheable when Anthropic requires
≥2048 tokens; apply the same change to the other Claude 3 Haiku occurrence noted
in the review (the second minCacheableTokens instance).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0ed7ee65-1461-4e18-b1b6-e792d33964f2

📥 Commits

Reviewing files that changed from the base of the PR and between e77b9ab and 3d384fe.

📒 Files selected for processing (1)
  • packages/models/src/models/anthropic.ts

outputPrice: 1.25 / 1e6,
cachedInputPrice: 0.03 / 1e6,
minCacheableTokens: 2048,
minCacheableTokens: 1024,

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

🧩 Analysis chain

🏁 Script executed:

# Find and examine the anthropic.ts file to understand the context around lines 709 and 733
cd packages/models/src/models && cat -n anthropic.ts | sed -n '700,740p'

Repository: theopenco/llmgateway

Length of output: 1326


🏁 Script executed:

# Search for all minCacheableTokens occurrences in the file to see all affected instances
rg "minCacheableTokens" packages/models/src/models/anthropic.ts -n

Repository: theopenco/llmgateway

Length of output: 1249


🌐 Web query:

Anthropic Claude 3 Haiku prompt caching minimum token threshold requirements 2025 2026

💡 Result:

For Anthropic prompt caching in the Anthropic API, the minimum cacheable prompt length for Claude 3 Haiku (and Claude 3.5 Haiku) is 2,048 tokens. Prompts shorter than that won’t be cached even if you set cache_control. [1], [2]


Use 2,048-token cache threshold for Claude 3 Haiku models.

Anthropic's prompt-caching documentation requires a minimum of 2,048 tokens for Claude 3 Haiku. Setting minCacheableTokens to 1,024 will cause the request body preparation to mark prompts below 2,048 tokens as cacheable, but Anthropic's API will not actually cache them.

🔧 Suggested fix
-				minCacheableTokens: 1024,
+				minCacheableTokens: 2048,

Also applies to: 733

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

In `@packages/models/src/models/anthropic.ts` at line 709, Update the Claude 3
Haiku model entries to use a 2,048-token cache threshold: find the model
config(s) that set minCacheableTokens (the Claude 3 Haiku model identifier /
config object) and change minCacheableTokens from 1024 to 2048 so the client
won’t mark prompts as cacheable when Anthropic requires ≥2048 tokens; apply the
same change to the other Claude 3 Haiku occurrence noted in the review (the
second minCacheableTokens instance).

@steebchen
steebchen added this pull request to the merge queue Mar 12, 2026
@steebchen
steebchen removed this pull request from the merge queue due to a manual request Mar 12, 2026
@steebchen
steebchen added this pull request to the merge queue Mar 12, 2026
Merged via the queue into main with commit 2e5e055 Mar 12, 2026
14 of 15 checks passed
@steebchen
steebchen deleted the feat/add-missing-bedrock-mappings branch March 12, 2026 17:00
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