Fix OpenRouter cost calculation with BYOK #4543
Merged
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.
Hello, Kilo maintainer here upstreaming a fix (Kilo-Org/kilocode#671)
Currently, when you use OpenRouter with your own key for the underlying service, the costs shown by Roo Code are way off what it actually costs.
With bring your own key, OpenRouter charges 5% of what it normally would (see https://openrouter.ai/docs/use-cases/byok) so we have to multiply the reported cost by 20 to get an estimate of what it actually costs.
Important
Fixes cost calculation in
OpenRouterHandlerfor BYOK by multiplying reported cost by 20.OpenRouterHandlerfor BYOK (Bring Your Own Key) by multiplying reported cost by 20.is_byokfield toCompletionUsageinterface inopenrouter.tsto identify BYOK usage.BYOK_COST_MULTIPLIERconstant set to 20 inopenrouter.ts.This description was created by
for 1bd1d87. You can customize this summary. It will automatically update as commits are pushed.