Skip to content

Conversation

@mrubens
Copy link
Collaborator

@mrubens mrubens commented Mar 22, 2025

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.

  • Behavior:
    • Replaces polling with stream_options: { include_usage: true } in createMessage() in openrouter.ts to directly obtain usage data.
    • Removes axios-based polling for usage data in openrouter.ts and openrouter.test.ts.
  • Functions:
    • Adds processUsageMetrics() in openrouter.ts to handle usage data processing.
  • Tests:
    • Updates createMessage test in openrouter.test.ts to verify usage data is included in stream response.

This description was created by Ellipsis for 285c4b9. It will automatically update as commits are pushed.

@changeset-bot
Copy link

changeset-bot bot commented Mar 22, 2025

⚠️ No Changeset found

Latest commit: 285c4b9

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. enhancement New feature or request labels Mar 22, 2025
@mrubens mrubens force-pushed the open_router_include_usage branch from 46f5bad to ba1bc6a Compare March 22, 2025 18:40
Copy link
Contributor

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.

@mrubens mrubens force-pushed the open_router_include_usage branch from ba1bc6a to 285c4b9 Compare March 22, 2025 18:42
Copy link

@louisgv louisgv left a comment

Choose a reason for hiding this comment

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

Lgtm 👍

@mrubens mrubens merged commit 2597347 into main Mar 23, 2025
10 checks passed
@mrubens mrubens deleted the open_router_include_usage branch March 23, 2025 05:52
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants