feat: cost for OpenRouter image models#782
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe OpenRouter image adapter's ChangesOpenRouter image adapter cost extraction
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~5 minutes Possibly related PRs
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/ai-openrouter/tests/image-adapter.test.ts (1)
114-152: ⚡ Quick winMove this new unit test to a colocated
*.test.tsfile.Line 114 adds new unit coverage in
packages/ai-openrouter/tests/image-adapter.test.ts, but repo guidance requires unit tests to live alongside source. Please move this case next topackages/ai-openrouter/src/adapters/image.ts(for example,packages/ai-openrouter/src/adapters/image.test.ts).As per coding guidelines, "Place unit tests alongside source code in
*.test.tsfiles".🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/ai-openrouter/tests/image-adapter.test.ts` around lines 114 - 152, The test case `surfaces provider-reported cost from OpenRouter image usage` is currently located in the tests directory structure but should be colocated with its source file per repository guidelines. Move this entire test case from the tests directory to a new test file that lives alongside the image adapter source code. The test should be placed in the same directory as the image adapter being tested to follow the pattern of keeping unit tests adjacent to their source implementations in dot-test files.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/ai-openrouter/tests/image-adapter.test.ts`:
- Around line 114-152: The test case `surfaces provider-reported cost from
OpenRouter image usage` is currently located in the tests directory structure
but should be colocated with its source file per repository guidelines. Move
this entire test case from the tests directory to a new test file that lives
alongside the image adapter source code. The test should be placed in the same
directory as the image adapter being tested to follow the pattern of keeping
unit tests adjacent to their source implementations in dot-test files.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: b901dcb3-cf85-40f6-93b8-52a4bd2f8fd2
📒 Files selected for processing (3)
.changeset/openrouter-image-cost.mdpackages/ai-openrouter/src/adapters/image.tspackages/ai-openrouter/tests/image-adapter.test.ts
|
View your CI Pipeline Execution ↗ for commit cf3122d
☁️ Nx Cloud last updated this comment at |
@tanstack/ai
@tanstack/ai-angular
@tanstack/ai-anthropic
@tanstack/ai-client
@tanstack/ai-code-mode
@tanstack/ai-code-mode-skills
@tanstack/ai-devtools-core
@tanstack/ai-elevenlabs
@tanstack/ai-event-client
@tanstack/ai-fal
@tanstack/ai-gemini
@tanstack/ai-grok
@tanstack/ai-groq
@tanstack/ai-isolate-cloudflare
@tanstack/ai-isolate-node
@tanstack/ai-isolate-quickjs
@tanstack/ai-mcp
@tanstack/ai-ollama
@tanstack/ai-openai
@tanstack/ai-openrouter
@tanstack/ai-preact
@tanstack/ai-react
@tanstack/ai-react-ui
@tanstack/ai-solid
@tanstack/ai-solid-ui
@tanstack/ai-svelte
@tanstack/ai-utils
@tanstack/ai-vue
@tanstack/ai-vue-ui
@tanstack/openai-base
@tanstack/preact-ai-devtools
@tanstack/react-ai-devtools
@tanstack/solid-ai-devtools
commit: |
🎯 Changes
Fix OpenRouter image generation usage reporting so provider-reported request cost is surfaced on
result.usage, matching the existing OpenRouter text adapter behavior.OpenRouter image generation already normalized token usage via
buildOpenRouterUsage(...), but did not merge inextractUsageCost(...). This meantcostandcost_detailswere dropped for image generation responses even when OpenRouter returned them.Adds a regression test covering image usage with provider-reported
costand snake_casecost_details.I also tested in my test project via
pnpm link. Costs are now surfaced.✅ Checklist
pnpm run test:pr.🚀 Release Impact
Summary by CodeRabbit
New Features
Tests