-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
fix(pricing): correct swapped input/output token costs for command-r7b-12-2024 #30413
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Sameerlite
merged 2 commits into
BerriAI:litellm_oss_170626_1
from
Kropiunig:fix/command-r7b-pricing-swap
Jun 17, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| """ | ||
| Regression test: ``command-r7b-12-2024`` had its input/output per-token | ||
| costs transposed in the model-cost maps (input=1.5e-07 / output=3.75e-08), | ||
| even though Cohere publishes $0.0375/1M input and $0.15/1M output, i.e. | ||
| output is ~4x input like every other ``command-r`` entry. | ||
|
|
||
| These tests pin the corrected values in both the primary price map and the | ||
| ``litellm/`` backup, and verify ``get_model_info`` surfaces them, so the | ||
| swap cannot silently regress. | ||
| """ | ||
|
|
||
| import json | ||
| import os | ||
| import sys | ||
|
|
||
| sys.path.insert( | ||
| 0, os.path.abspath("../..") | ||
| ) # Adds the parent directory to the system path | ||
|
|
||
| import litellm | ||
|
|
||
| MODEL = "command-r7b-12-2024" | ||
| EXPECTED_INPUT_COST = 3.75e-08 | ||
| EXPECTED_OUTPUT_COST = 1.5e-07 | ||
|
|
||
|
|
||
| def _load_json(path: str) -> dict: | ||
| with open(path, encoding="utf-8") as f: | ||
| return json.load(f) | ||
|
|
||
|
|
||
| def _backup_path() -> str: | ||
| return os.path.join( | ||
| os.path.dirname(litellm.__file__), | ||
| "model_prices_and_context_window_backup.json", | ||
| ) | ||
|
|
||
|
|
||
| def _main_path() -> str: | ||
| # This test lives at ``tests/test_litellm/``; the primary price map sits at | ||
| # the repo root, two directories up. Resolve it relative to this file so the | ||
| # test works regardless of where ``litellm`` itself is installed (e.g. a pip | ||
| # install into site-packages). | ||
| return os.path.join( | ||
| os.path.dirname(__file__), | ||
| "..", | ||
| "..", | ||
| "model_prices_and_context_window.json", | ||
| ) | ||
|
|
||
|
|
||
| class TestCommandR7bPricingData: | ||
| """The JSON price maps must carry Cohere's published costs, with output | ||
| more expensive than input.""" | ||
|
|
||
| def test_backup_costs_not_swapped(self): | ||
| entry = _load_json(_backup_path())[MODEL] | ||
| assert entry["input_cost_per_token"] == EXPECTED_INPUT_COST | ||
| assert entry["output_cost_per_token"] == EXPECTED_OUTPUT_COST | ||
| assert entry["output_cost_per_token"] > entry["input_cost_per_token"] | ||
|
|
||
| def test_main_costs_not_swapped(self): | ||
| entry = _load_json(_main_path())[MODEL] | ||
| assert entry["input_cost_per_token"] == EXPECTED_INPUT_COST | ||
| assert entry["output_cost_per_token"] == EXPECTED_OUTPUT_COST | ||
| assert entry["output_cost_per_token"] > entry["input_cost_per_token"] | ||
|
|
||
|
|
||
| class TestCommandR7bPricingModelInfo: | ||
| """``get_model_info`` must report the corrected, un-swapped costs.""" | ||
|
|
||
| def test_get_model_info_costs(self): | ||
| info = litellm.get_model_info(MODEL) | ||
| assert info["input_cost_per_token"] == EXPECTED_INPUT_COST | ||
| assert info["output_cost_per_token"] == EXPECTED_OUTPUT_COST | ||
| assert info["output_cost_per_token"] > info["input_cost_per_token"] | ||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.