Skip to content

feat: for openrouter session uses cost from metadata#9518

Closed
proAlexandr wants to merge 1 commit into
anomalyco:devfrom
proAlexandr:cost-from-provider-metadata
Closed

feat: for openrouter session uses cost from metadata#9518
proAlexandr wants to merge 1 commit into
anomalyco:devfrom
proAlexandr:cost-from-provider-metadata

Conversation

@proAlexandr

Copy link
Copy Markdown

What does this PR do?

It takes cost of the message from provider's metadata for openrouter.
If there is no cost in metadata, it calculates it in an old way based on price and used tokens.

How did you verify your code works?

  1. Added log.info("***** use metadata cost: ${usage.cost}") to packages/opencode/src/session/index.ts:419
  2. bun dev web
  3. opened a project, sent message to chat
  4. Found INFO 2026-01-19T22:41:13 +0ms service=session ***** use metadata cost: 0.00073491 in logs (~/.local/share/opencode/log/dev.log)
  5. Verified cost in web: image

@github-actions

Copy link
Copy Markdown
Contributor

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@proAlexandr

Copy link
Copy Markdown
Author

Fixes #454

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Mar 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant