Skip to content

Get completion cost directly from OpenRouter - #15448

Merged
2 commits merged into
BerriAI:mainfrom
dhruvyad:main
Oct 13, 2025
Merged

Get completion cost directly from OpenRouter#15448
2 commits merged into
BerriAI:mainfrom
dhruvyad:main

Conversation

@dhruvyad

@dhruvyad dhruvyad commented Oct 11, 2025

Copy link
Copy Markdown
Contributor

Fixes #13653

Context

OpenRouter completion calls have the option to include {"usage": {"include": true}} to return the actual completion associated costs. Since OpenRouter picks a provider based on availability, the costs for completions could potentially vary.

This PR leverages the usage inclusion option to directly calculate completion calls from OpenRouter.

@vercel

vercel Bot commented Oct 11, 2025

Copy link
Copy Markdown

@dhruvyad is attempting to deploy a commit to the CLERKIEAI Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

CLAassistant commented Oct 11, 2025

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@neo-noclick

Copy link
Copy Markdown

Some tests are failing regarding linting for Pypi.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

add testing in test_litellm/
add coverage for streaming

thanks for this PR @dhruvyad

@dhruvyad
dhruvyad requested a review from a user October 12, 2025 07:12
@ghost
ghost merged commit 2ea7005 into BerriAI:main Oct 13, 2025
3 of 6 checks passed
@ghost

ghost commented Oct 13, 2025

Copy link
Copy Markdown

@dhruvyad can you add support for streaming as well?

fzowl pushed a commit to fzowl/litellm that referenced this pull request Jun 24, 2026
Get completion cost directly from OpenRouter
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Getting Cost directly from OpenRouter api call

3 participants