Skip to content

fix(gateway): persist provider-funded route billing decision#3447

Open
markijbema wants to merge 4 commits into
mainfrom
mark/persist-provider-funded-route
Open

fix(gateway): persist provider-funded route billing decision#3447
markijbema wants to merge 4 commits into
mainfrom
mark/persist-provider-funded-route

Conversation

@markijbema
Copy link
Copy Markdown
Contributor

@markijbema markijbema commented May 25, 2026

Summary

  • Persist one request-scoped effective is_free decision and consume it for billable cost zeroing and usage metadata instead of re-evaluating model classification during accounting.
  • Make isFreeModel() classify intrinsic free models only; after provider resolution, a selected active experiment route is folded into is_free for that request.
  • Prevent stale positive experiment membership from allowing anonymous paid fallback traffic, and only log free-model quota after provider resolution accepts the request.
  • Add regression coverage proving selected funded traffic remains zero-cost while ordinary preview-like traffic is billed normally.

Verification

N/A - backend billing/routing correctness change with no meaningful manual UI or API smoke workflow performed locally.

Visual Changes

N/A

Reviewer Notes

  • MicrodollarUsageContext.is_free is the finalized per-request billing classification. Experiment attribution IDs remain independent reporting data, while accounting no longer imports or calls isFreeModel().
  • The route retains the existing early rate-limit check. The quota increment moves after provider resolution so paused, unavailable, or stale-membership paid fallback requests do not consume free-model quota.

@kilo-code-bot
Copy link
Copy Markdown
Contributor

kilo-code-bot Bot commented May 25, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Executive Summary

The previous WARNING (logFreeModelRequest counting rejected preview traffic against the rate-limit quota) has been fixed — the call is now correctly placed after getProvider succeeds and after the anonymous/stale-experiment guard, so rejected requests no longer consume quota.

Files Reviewed (2 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts — previous WARNING resolved

Reviewed by claude-sonnet-4.6 · 317,291 tokens

Review guidance: REVIEW.md from base branch main

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.

1 participant