-
-
Notifications
You must be signed in to change notification settings - Fork 607
OpenRouter: Fix token usage response #560
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
Conversation
I'm not really leaning towards this being the right fix. This seems to more lie and keep a structured approach, which reads as returning all 0's for implementations that don't support it. That doesn't seem right to me. Nullable/removed sure, but falling back to 0's to keep parity doesn't seem like the play. |
d736a9c
to
3da1e66
Compare
Thanks for feedback, i have taken it into account. |
Thanks, so just to confirm the test you added -
|
Test is a real openRouter response. If this is a good direction, i'll also check non completion request. Might be good to wait with review. |
Thanks - I guess I'm just a bit confused. You changed the detail objects, but those are missing entirely in your OpenRouter summary payload. So in my head - those objects in entirety (details) would be just be missing. You instead patched the object to be nullable on each property inside of it (audio, reasoning, rejected, accepted) - which was moot since the detail object ( |
Depends on a model. Will share a few.
|
ahh - thank you. This helps a lot more. Its dependent on the model routed through OpenRouter. |
So I believe what we should do is augment one or both of these tests to confirm these partial returns you see from Grok/Gemini above. That way full confidence it returns as we expect with the different iterations of (null, full, partial) |
724ad7b
to
2a4ad85
Compare
Tested on response schemas of models:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks! I think we are set now
Hi, I was running into this issue as well—thanks for the quick fix! Do you know when the fix will be released? Or should I switch to dev-main in the meantime? I’m was using v0.10.3, by the way. |
I'm the newest maintainer so I cannot release until I'm more trusted. I have pinged the other maintainers in email (5d ago and 1d ago). I'm trying my best to get a release out. |
What:
fixes: #524
Description:
Inconsistencies in how token usage details are handled from provider OpenRouter.
Changes
Before
OpenRouter and OpenAI responses had different structures, with OpenRouter omitting zero-valued token fields while OpenAI included them:
After
Both providers now return consistent response structures with all token fields present:
This change ensures consistent behavior across both supported providers by the client.