Allow custom model pricing without modifying source code#227
Open
elronbandel wants to merge 1 commit into
Open
Allow custom model pricing without modifying source code#227elronbandel wants to merge 1 commit into
elronbandel wants to merge 1 commit into
Conversation
Users can now configure custom model pricing without modifying source code by creating a ~/.exgentic/pricing.json file. This addresses the issue where every new model required a code change to the name_map. Changes: - Added _load_custom_pricing() function that reads ~/.exgentic/pricing.json and registers models with litellm.register_model() - Function is called automatically on first cost lookup - Updated error message to mention the pricing.json config file - Added comprehensive tests for the new functionality - Updated documentation with config file examples and usage The config file approach works for both CLI and Python API usage, making it the recommended solution for users who need to add pricing for custom models. Signed-off-by: Elron Bandel <elron.bandel@ibm.com>
elronbandel
commented
May 18, 2026
elronbandel
left a comment
Contributor
Author
There was a problem hiding this comment.
Solid implementation that solves issue #106. The config file approach works for both CLI and Python API. Tests are comprehensive, error handling is appropriate, and there are no breaking changes. Ready to merge.
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.
Closes #106
Summary
Users can now configure custom model pricing without modifying source code by creating a
~/.exgentic/pricing.jsonfile. This solves the problem where every new model required a code change to thename_mapinexgentic/utils/cost.py.The implementation automatically loads the pricing file on first cost lookup and registers all models with LiteLLM's
register_model()API. This works seamlessly for both CLI and Python API usage.Changes
_load_custom_pricing()function insrc/exgentic/utils/cost.pythat:~/.exgentic/pricing.jsonif it existslitellm.register_model()~/.exgentic/pricing.jsonconfig file as the first optiontests/utils/test_cost_custom_pricing.pycovering:litellm_tokens_cost()docs/custom-models.md:Testing
All tests pass:
Example Usage
Create
~/.exgentic/pricing.json:{ "my-custom-model": { "input_cost_per_token": 0.0001, "output_cost_per_token": 0.0002, "litellm_provider": "openai" } }Then use the model normally:
Cost tracking will work automatically without any code changes.