feat(billing): use inputPrice fallback - #1114
Conversation
Calculate and log input, output, cached input, request, and total costs along with discounts and estimation flags for cached chat responses. Also updated default cachedInputPrice fallback logic to use inputPrice when cachedInputPrice is undefined. This enhancement improves cost tracking accuracy and visibility in cached scenarios. Co-authored-by: terragon-labs[bot] <terragon-labs[bot]@users.noreply.github.com>
WalkthroughAdded cost calculation logging for cached chat responses across three code paths (streaming from cache, non-streaming cache hits, and newly cached streaming responses) by computing costs via Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Possibly related PRs
Pre-merge checks and finishing touches✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (2)
🧰 Additional context used📓 Path-based instructions (4)**/*.{ts,tsx,js,jsx}📄 CodeRabbit inference engine (AGENTS.md)
Files:
apps/{gateway,api}/**/*.ts📄 CodeRabbit inference engine (AGENTS.md)
Files:
**/*.{ts,tsx}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
{apps/{api,gateway}/**/*.ts,packages/db/**/*.ts}📄 CodeRabbit inference engine (CLAUDE.md)
Files:
🧬 Code graph analysis (1)apps/gateway/src/chat/chat.ts (1)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
🔇 Additional comments (2)
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 |
Summary
Changes
Backend
apps/gateway/src/chat/chat.ts
apps/gateway/src/lib/costs.ts
Why this helps
Examples of impact
Testing
Notes
🌿 Generated by Terry
ℹ️ Tag @terragon-labs to ask questions and address PR feedback
📎 Task: https://www.terragonlabs.com/task/30d762a7-b081-414d-aeaa-f24ca887d05a
Summary by CodeRabbit