Repository navigation
fix(pricing): correct Bedrock Mantle gpt-oss-20b and safeguard-20b token rates - #39866
mateo-berri wants to merge 3 commits into
Conversation
Greptile SummaryCorrects Bedrock Mantle token pricing to match AWS’s standard-tier rates and strengthens regression coverage.
Confidence Score: 5/5The PR appears safe to merge; the corrected rates are synchronized and covered by valid local regression tests. Both previous findings are resolved: the stale pricing assertion now expects the corrected rate, and the pricing regression coverage was moved into the required existing Bedrock Mantle test module. No new actionable failures remain.
|
| Filename | Overview |
|---|---|
| model_prices_and_context_window.json | Updates the primary Mantle pricing rows to the stated AWS input and safeguard output rates. |
| litellm/model_prices_and_context_window_backup.json | Mirrors the corrected rates in the packaged backup cost map. |
| tests/test_litellm/llms/bedrock_mantle/test_bedrock_mantle_transformation.py | Updates the stale expectation and adds local, parametrized coverage for both price maps and matching Converse rows. |
Reviews (3): Last reviewed commit: "test(bedrock_mantle): consolidate the pr..." | Re-trigger Greptile
| }, | ||
| "bedrock_mantle/openai.gpt-oss-20b": { | ||
| "input_cost_per_token": 7.5e-08, | ||
| "input_cost_per_token": 7e-08, |
There was a problem hiding this comment.
Stale pricing test expectation
The rate is now 7e-08, but the existing Mantle pricing test expects 7.5e-8, causing that test to fail
Knowledge Base Used: Spend, budgets, and rate limits
There was a problem hiding this comment.
Fixed in 5cc06c3: the assertion now pins 7e-8, matching the offer file and the rate this PR sets.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
…st file TestBedrockMantlePricing set LITELLM_LOCAL_MODEL_COST_MAP after import and never reloaded litellm.model_cost, so it only passed by side effect of the module-level map and failed against the network map once the rate changed. It now uses the file's local_cost_map fixture, which reloads the bundled map, clears the get_model_info cache, and restores everything afterwards. The offer-file and Converse-parity checks move from a sibling top-level file into this mapped test file, per the repository test layout rule.
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 6e0ebd2. Configure here.
|
Absorbed into the rolling registry PR #31884 along with the test expectation update. Closing this one to keep a single registry PR. |
Pull request was closed
TLDR
Problem this solves:
bedrock_mantle/openai.gpt-oss-20bcharges input at 7.5e-08/token; AWS bills 7e-08bedrock_mantle/openai.gpt-oss-safeguard-20bhas the same input error plus 3e-07 output; AWS bills 2e-07How it solves it:
User Flow
Before: a developer routing gpt-oss-20b through Bedrock Mantle sees the gateway charge more input tokens than AWS does
{"model": "mantle-gpt-oss-20b", "messages": [{"role": "user", "content": "Reply with the single word pong."}], "max_tokens": 32}prompt_tokens: 74and the headerx-litellm-response-cost-input: 5.549999999999999e-06, but their AWS bill meters those 74 tokens at $0.00007 per 1K, so 5.18e-06{"completion_response": {"model": "bedrock_mantle/openai.gpt-oss-20b", "usage": {"prompt_tokens": 1000000, "completion_tokens": 0, "total_tokens": 1000000}}}and get back{"cost": 0.075}instead of the $0.07 AWS chargesmantle-gpt-oss-safeguard-20bcomes back withx-litellm-response-cost-output: 9.6e-06for 32 completion tokens, where AWS charges $0.0002 per 1K, so 6.4e-06After: the same requests are priced at the rates AWS bills
{"model": "mantle-gpt-oss-20b", "messages": [{"role": "user", "content": "Reply with the single word pong."}], "max_tokens": 32}prompt_tokens: 74and the headerx-litellm-response-cost-input: 5.18e-06, matching the AWS rate{"cost": 0.07}mantle-gpt-oss-safeguard-20bcomes back withx-litellm-response-cost-output: 6.4e-06for 32 completion tokens, matching the AWS rateRelevant issues
Linear ticket
Resolves LIT-6950
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*,make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more@greptileaito re-request a review after pushing changes)Delays in PR merge?
If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).
Screenshots / Proof of Fix
Primary source: the AWS us-east-1 Bedrock offer file (publication 2026-09-01), https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonBedrock/current/us-east-1/index.csv, standard-tier Mantle SKUs per 1K tokens:
Shared setup: each side is a proxy with no database,
LITELLM_LOCAL_MODEL_COST_MAP=TrueandAWS_BEARER_TOKEN_BEDROCKin the environment, booted withpython litellm/proxy/proxy_cli.py --config config.yaml --port <port> --num_workers 2from a checkout of that side's commit (PYTHONPATHpointed at it,litellm.__file__checked to sit inside it). Same config on both sides:Every case sends the same prompt (
Reply with the single word pong., 32 output tokens max) to the three deployments and reads the per-request cost headers next to the usage block. The converse deployment is the control: it was already priced at the offer-file rate on both sides. Real Mantle calls, real AWS spend. Mantle sometimes reports 48 of the 74 prompt tokens as cached; both sides price cached tokens at $0, so those requests show 26 x the input rateBefore (78ad88f)
POST /v1/chat/completions
curl -s http://127.0.0.1:49687/v1/chat/completions -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","messages":[{"role":"user","content":"Reply with the single word pong."}],"max_tokens":32}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /v1/responses
curl -s http://127.0.0.1:49687/v1/responses -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","input":"Reply with the single word pong.","max_output_tokens":32}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /v1/messages
curl -s http://127.0.0.1:49687/v1/messages -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","max_tokens":32,"messages":[{"role":"user","content":"Reply with the single word pong."}]}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /spend/calculate at 1,000,000 tokens
curl -s http://127.0.0.1:49687/spend/calculate -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"completion_response":{"model":"bedrock_mantle/openai.gpt-oss-20b","usage":{"prompt_tokens":1000000,"completion_tokens":0,"total_tokens":1000000}}}'{"cost":0.075}(AWS: $0.07)"prompt_tokens":0,"completion_tokens":1000000, observed:{"cost":0.3}"model":"bedrock_mantle/openai.gpt-oss-safeguard-20b", observed:{"cost":0.075}for prompt (AWS: $0.07) and{"cost":0.3}for completion (AWS: $0.20)"model":"bedrock/converse/openai.gpt-oss-20b-1:0"(control), observed:{"cost":0.07}and{"cost":0.3}After (5cc06c3)
Tip 6e0ebd2 adds one test-only commit on top of 5cc06c3 (the pricing tests load the bundled map through the file's fixture and the offer-file checks move into the mapped test file), which cannot change what the proxy returns, so the run below stands
POST /v1/chat/completions
curl -s http://127.0.0.1:23294/v1/chat/completions -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","messages":[{"role":"user","content":"Reply with the single word pong."}],"max_tokens":32}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /v1/responses
curl -s http://127.0.0.1:23294/v1/responses -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","input":"Reply with the single word pong.","max_output_tokens":32}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /v1/messages
curl -s http://127.0.0.1:23294/v1/messages -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"model":"mantle-gpt-oss-20b","max_tokens":32,"messages":[{"role":"user","content":"Reply with the single word pong."}]}' -D - | grep -iE 'x-litellm-response-cost-(input|output)|"usage"'"model":"mantle-gpt-oss-safeguard-20b", observed:"model":"converse-gpt-oss-20b"(control), observed:POST /spend/calculate at 1,000,000 tokens
curl -s http://127.0.0.1:23294/spend/calculate -H 'Authorization: Bearer sk-lit6950' -H 'Content-Type: application/json' -d '{"completion_response":{"model":"bedrock_mantle/openai.gpt-oss-20b","usage":{"prompt_tokens":1000000,"completion_tokens":0,"total_tokens":1000000}}}'{"cost":0.07}"prompt_tokens":0,"completion_tokens":1000000, observed:{"cost":0.3}"model":"bedrock_mantle/openai.gpt-oss-safeguard-20b", observed:{"cost":0.07}for prompt and{"cost":0.19999999999999998}for completion"model":"bedrock/converse/openai.gpt-oss-20b-1:0"(control), observed:{"cost":0.07}and{"cost":0.3}Observations from the run:
input_tokens_details: nullonce; pre-existing, unrelatedType
🐛 Bug Fix
Caveats (if any)
Medium
bedrock_mantle/<region>/openai.gpt-oss-*rows (nor EU or AP Converse rows), so the region lookup falls back to the base row: up to 22% under-charge on input and 25% on output for EU deployments. Pre-existing, outside this base-rate fix; PR feat(pricing): add GovCloud pricing for every live but unpriced Bedrock model #39764 adds the GovCloud Mantle rows; the rest is LIT-7046. Workaround:input_cost_per_tokenandoutput_cost_per_tokenon the deploymentcache_read_input_token_cost, so the cost calculator multiplies cache-hit tokens by 0: the after run above charged 26 of 74 prompt tokens on a request that reported 48 cached. The offer files carry no gpt-oss cache-read SKU in any region or tier, so what AWS bills for those tokens is unverified and most likely the full input rate. Pre-existing and left alone here rather than guessing a rate; LIT-7047 verifies it against Cost Explorer and sets it. Workaround:cache_read_input_token_coston the deploymentLow
service_tierflex and priority requests (and batch) are priced at the standard rate: the offer file lists flex, priority, and batch SKUs for these models but the Mantle rows carry no per-tier fields, which predates this PR and is folded into LIT-7047LITELLM_LOCAL_MODEL_COST_MAPpicks the fix up only once the JSON on main carries it/spend/calculatereturn aboveFinal Attestation
The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR
6e0ebd2 passes /live-pr-risk