fix(billing): price Anthropic 1-hour cache writes separately - #1203
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
Signed-off-by: Atirna <288419661+atirna@users.noreply.github.com>
Rewrite of #1201. Co-authored-by: Atirna <288419661+atirna@users.noreply.github.com>
This branch has not been deployed
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.
Summary
Rewrite of #1201 by @atirna (credited as co-author) to match repo conventions; the fix itself is unchanged.
Anthropic reports a TTL breakdown under
usage.cache_creation.{ephemeral_5m,ephemeral_1h}_input_tokens; the aggregatecache_creation_input_tokenswas priced entirely at the 5-minute 1.25x rate, under-billing 1-hour writes (2x).catalog.PricinggainsCacheWriteMultiplier1h(+DefaultCacheWriteMultiplier1h = 2.0,EffectiveCacheWriteMultiplier1h()).catalog.EffectiveInputCost(input, cacheCreation, cacheCreation1h, cacheRead, p, provider):cacheCreation1his clamped tocacheCreation; the remainder prices at the 5-minute rate, so aggregate-only payloads (Bedrock/Vertex,cacheCreation1h == 0) are unchanged.otel.UsageExtractor(SSEmessage_start+ non-stream JSON),translate.UsageSink.RecordCacheCreation1hTokens,handover.Usage.CacheCreation1handstreamCostWriterintobilling.DebitInferenceParams.CacheCreation1h, telemetry cost columns, cost headers and policy-outcome cost.Deltas from #1201: test comments in
cost_test.gorewritten as invariant descriptions (no issue refs / pre-fix narrative, per AGENTS.md comment rule);routerCostCalculator/routerResponseCostFromPricingparameter order aligned withEffectiveInputCost(cacheCreation, cacheCreation1h, cacheRead).Fixes #867
make precommitclean.Link to Devin session: https://app.devin.ai/sessions/e1c3317bd01c4d7b8a4639c5ef2bae64
Open in Devin Desktop: https://app.devin.ai/desktop/session/e1c3317bd01c4d7b8a4639c5ef2bae64?variant=devin
Requested by: @steventohme