Repository navigation
feat(pricing): price what was sent, borrow Bedrock prices, count cache toward long context - #227
Merged
Merged
Conversation
…e toward long context - Record on each attempt the model a rule rewrote the request to (AttemptView.model) and price the request by the model the serving hop sent; the unpriced list names that model too, since it is the one a price has to be set for. - Bedrock ids missing from the data set borrow a price, always marked estimated: an inference profile from the model it is named after, then Anthropic's own name for the model. - Long-context tiers are read with their threshold from the data set (200K for Claude Sonnet 4/4.5, 272K for GPT-5.4 on), including their cache prices, and a request's input counts its cache reads and writes when choosing the tier. - A price the table does not list is filled in and the cost marked estimated whenever it is used: a 1-hour cache write is twice the input price, a long tier's cache prices grow with its input price. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
fylorn
force-pushed
the
feat/price-what-was-sent
branch
from
September 28, 2026 16:59
fd365d9 to
031c44c
Compare
This was referenced Sep 28, 2026
Merged
fylorn
added a commit
that referenced
this pull request
Sep 29, 2026
Minor release for #223, #224, #226, #227, #228, #229, #230 and #231, and #222 before them. - Bump the workspace version to 0.55.0 - release-notes/0.55.0.md Control-plane protocol 28 (was 27): the protocol `bedrock`, ProviderInput.aws / ProviderView.aws (AwsKeys), ProviderView.region, ProviderPreview.region and AttemptView.model. The request store schema is unchanged (22), so the request history is kept. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follows #226 (AWS Bedrock upstreams).
What changes
Priced by the model that was sent. A rule can rewrite the model (
set.model), for exampleclaude-sonnet-4-5→us.anthropic.claude-sonnet-4-5-20250929-v1:0for a Bedrock upstream. The upstream charges for the model it received, so:AttemptView.model(optional; absent when the hop sent what the client asked for, and on WebSocket hops, which never rewrite).modelstays what the client asked for, so per-model statistics are unchanged.unpriced_recent) names the model the price was looked up under, read from the stored routing JSON. That is the name a price override has to use; no schema change.Bedrock ids get a price. Ids missing from the data set borrow one, always marked estimated (
cross_platform):apac.anthropic.claude-…→anthropic.claude-…(only the geographies seen in the data set:us,eu,apac,jp,au,us-gov,global)anthropic.claude-opus-4-6-v1→claude-opus-4-6(all three version spellings)anthropic.<name>-v1:0Ids the data set lists (most
us./eu./global.profiles, with their regional prices) are exact and not estimated. System-defined profile and foundation-model ARNs resolve through their last segment; application inference profile ARNs stay unpriced.Long-context tiers are read as the data set writes them. The threshold comes from the key name (200K for Claude Sonnet 4/4.5, 272K for GPT-5.4 onwards, 128K for some older Gemini entries), together with the tier's cache prices. The tier is chosen by the request's whole input, cache reads and writes included, as Anthropic counts it. Previously only uncached input was counted, so a warm-cache 500K-token request was priced as a short one, and the 272K tier was not recognised at all.
Filled-in prices mark the cost estimated. When a price the table lacks is used, the cost is
Estimated:Price-sheet overrides are still taken exactly as written: an override's long tier keeps the cache prices written for it.
PriceFields.input_above_200k/output_above_200kshow only a 200K tier; a 272K tier is billed but not displayed there, because showing it as 200K would be wrong.The config manual now says the 200K threshold counts cache reads and writes (docs regenerated).
Verification
cargo fmt --all -- --check,cargo clippy --workspace --all-targets -- -D warnings, andcargo test --workspace(98 test binaries) all pass locally._prioritykeys ignored); the threshold counting cache; 1-hour and long-tier fill-ins marking estimates only when used; override long tiers taken as written; Bedrock borrowing order and version spellings; exactus.profile prices versus borrowedapac.ones; the recorder pricing by the served hop's rewritten model; the unpriced list naming the sent model; the gateway recording the rewritten model on the attempt, with no-op rewrites recorded as none.Not handled here
OpenAI's
priorityandflexservice tiers have their own prices in the data set. Pricing them needs the response'sservice_tier, which the gateway does not read yet.🤖 Generated with Claude Code