Skip to content

fix(ai-gateway): strip upstream cost for custom-priced models - #4853

Merged
chrarnoldus merged 3 commits into
mainfrom
fix/rewrite-custom-pricing-cost-removal
Jul 29, 2026
Merged

fix(ai-gateway): strip upstream cost for custom-priced models#4853
chrarnoldus merged 3 commits into
mainfrom
fix/rewrite-custom-pricing-cost-removal

Conversation

@chrarnoldus

Copy link
Copy Markdown
Contributor

Summary

  • isFreeModelRequiringCostRemoval in rewriteModelResponse is now also true for models with custom pricing (getCustomPricing(model) !== undefined), in addition to Kilo-exclusive free models. The gateway condition (openrouter/vercel) still applies. The upstream-reported cost does not reflect Kilo's custom pricing, so it must be removed from the response just like for free models.
  • All optional/defaulted parameters in rewriteModelResponse.ts (removeCost = true, capture?, vercelRequestId? on the three exported rewrite functions, capture? on readResponseText/rewriteSseStream) are now required so call sites are explicit.

Test plan

  • Added a regression test asserting cost fields are stripped for a custom-priced model (qwen/qwen3.7-plus); existing free-model/paid-model coverage unchanged.
  • Test call sites updated for the now-required parameters.
  • Relying on CI for the web test suite.

…itten responses

isFreeModelRequiringCostRemoval now also covers models with custom
pricing (gateway condition unchanged), since the upstream-reported cost
does not reflect the custom pricing. Also make the rewrite functions'
parameters required instead of optional/defaulted so call sites are
explicit.
@chrarnoldus chrarnoldus self-assigned this Jul 29, 2026
@kilo-code-bot

kilo-code-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

No new commits since the last review; the incremental diff since the previously reviewed commit remains a pure rename (isFreeModelRequiringCostRemoval -> requiresCostRemoval) plus formatting-only changes in rewriteModelResponse.ts, with no logic change; no issues found.

Files Reviewed (2 files)
  • apps/web/src/lib/rewriteModelResponse.ts - rename and formatting only, no logic change
  • apps/web/src/lib/rewriteModelResponse.test.ts - unchanged since last review
Previous Review Summary (commit 13b364f)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 13b364f)

Status: No Issues Found | Recommendation: Merge

Executive Summary

Incremental diff since the last review is a pure rename (isFreeModelRequiringCostRemoval -> requiresCostRemoval) and a comment removal in rewriteModelResponse.ts, with no logic change; no issues found.

Files Reviewed (2 files)
  • apps/web/src/lib/rewriteModelResponse.ts - changed in this increment (rename only)
  • apps/web/src/lib/rewriteModelResponse.test.ts - unchanged since last review

Reviewed by claude-sonnet-5 · Input: 18 · Output: 5.7K · Cached: 384.1K

Review guidance: REVIEW.md from base branch main

@chrarnoldus
chrarnoldus merged commit 897cb58 into main Jul 29, 2026
16 checks passed
@chrarnoldus
chrarnoldus deleted the fix/rewrite-custom-pricing-cost-removal branch July 29, 2026 10:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants