Skip to content

Conversation

@chrarnoldus
Copy link
Contributor

@chrarnoldus chrarnoldus commented Jun 11, 2025

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 OpenRouterHandler for BYOK by multiplying reported cost by 20.

  • Behavior:
    • Fix cost calculation in OpenRouterHandler for BYOK (Bring Your Own Key) by multiplying reported cost by 20.
    • Adds is_byok field to CompletionUsage interface in openrouter.ts to identify BYOK usage.
  • Constants:
    • Introduces BYOK_COST_MULTIPLIER constant set to 20 in openrouter.ts.

This description was created by Ellipsis for 1bd1d87. You can customize this summary. It will automatically update as commits are pushed.

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.

Co-authored-by: Johan Otten <[email protected]>
Co-authored-by: Eamon Nerbonne <[email protected]>
@chrarnoldus chrarnoldus requested review from cte, jr and mrubens as code owners June 11, 2025 09:38
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. bug Something isn't working labels Jun 11, 2025
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Prelim Review] in Roo Code Roadmap Jun 11, 2025
Copy link
Member

@daniel-lxs daniel-lxs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @chrarnoldus for the contribution!

I tested and confirmed the presence of is_byok in the response although it doesn't seem to be documented on the OpenRouter docs

LGTM

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jun 12, 2025
@daniel-lxs daniel-lxs removed the status in Roo Code Roadmap Jun 12, 2025
@daniel-lxs daniel-lxs moved this to PR [Needs Review] in Roo Code Roadmap Jun 12, 2025
@mrubens mrubens merged commit 11668af into RooCodeInc:main Jun 12, 2025
28 checks passed
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jun 12, 2025
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jun 12, 2025
@chrarnoldus chrarnoldus deleted the christiaan/byok branch June 17, 2025 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

4 participants