Skip to content

Conversation

@proAlexandr
Copy link

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
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
Contributor

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

No duplicate PRs found

@proAlexandr
Copy link
Author

Fixes #454

@proAlexandr proAlexandr force-pushed the cost-from-provider-metadata branch from fc59ff2 to d536e45 Compare January 19, 2026 23:38
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