-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Use openrouter stream_options include_usage #1905
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
|
46f5bad to
ba1bc6a
Compare
src/api/providers/openrouter.ts
Outdated
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.
Consider replacing the any type in processUsageMetrics with a properly defined interface for the usage object. This helps ensure type safety and clarity for the expected structure.
ba1bc6a to
285c4b9
Compare
louisgv
left a comment
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.
Lgtm 👍
Context
Per OpenRouter: "Now you can send us stream_options: {include_usage: true} to get the usage directly in the completion request."
Implementation
This replaces the previous polling and grabs the usage information directly.
Important
Update OpenRouter integration to use
stream_options: { include_usage: true }for direct usage data retrieval, removing polling.stream_options: { include_usage: true }increateMessage()inopenrouter.tsto directly obtain usage data.openrouter.tsandopenrouter.test.ts.processUsageMetrics()inopenrouter.tsto handle usage data processing.createMessagetest inopenrouter.test.tsto verify usage data is included in stream response.This description was created by
for 285c4b9. It will automatically update as commits are pushed.