Skip to content

feat(ai-gateway): apply free-model rate limit to kilo-auto/free - #2945

Merged
chrarnoldus merged 2 commits into
mainfrom
feat/rate-limit-kilo-auto-free
Apr 30, 2026
Merged

chrarnoldus merged 2 commits into
mainfrom
feat/rate-limit-kilo-auto-free

Conversation

@lambertjosh

@lambertjosh lambertjosh commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Auto Free is a mix of models, some Kilo Exclusive and others via OpenRouters. Since this is a mix of models, we should also apply the rate limit to ensure that there is sufficient quota to provide a good experience for all users.

Verification

  • End-to-end testing against local dev server with seeded Redis OpenRouter model cache:
    • kilo-auto/free resolving to inclusionai/ling-2.6-1t:free — request logged to free_model_usage
    • kilo-auto/free resolving to nvidia/nemotron-3-super-120b-a12b:free — request logged to free_model_usage
    • kilo-auto/free resolving to stepfun/step-3.5-flash:free — request logged (existing behavior preserved)
    • Saturating an IP with 200 rows and sending a kilo-auto/free request returns HTTP 429
    • Direct call to inclusionai/ling-2.6-1t:free (not via kilo-auto/free) — NOT logged, NOT rate-limited (existing behavior preserved)
    • Direct call to stepfun/step-3.5-flash:free from saturated IP — HTTP 429 (existing behavior preserved)

Visual Changes

N/A

Reviewer Notes

  • The new predicate isRateLimitedFreeModelRequest checks both isKiloExclusiveFreeModel(resolvedModel) and autoModel === KILO_AUTO_FREE_MODEL.id, so the original virtual model ID is what triggers the broader gate.
  • The free_model_usage table records the resolved model slug (not kilo-auto/free), consistent with existing logging behavior.
  • Admin rate-limit testing panel (/admin/rate-limit-testing) can be used to trigger the 429 threshold manually.

The 200/hour free-model rate limit is gated by isKiloExclusiveFreeModel,
which only matches a curated allow-list of Kilo-exclusive models. When a
request resolves through kilo-auto/free, the resolved model can be any
OpenRouter :free model from the rotation pool (e.g.
inclusionai/ling-2.6-1t:free, nvidia/nemotron-3-super-120b-a12b:free) —
those bypass the gate today, so the limit applies non-uniformly across
the auto/free pool.

Treat any incoming kilo-auto/free request as rate-limit-eligible
regardless of which underlying model the resolver picks, so usage of the
auto/free virtual model is bounded the same way direct calls to
Kilo-exclusive free models already are.
@kilo-code-bot

kilo-code-bot Bot commented Apr 30, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (1 files)
  • apps/web/src/app/api/openrouter/[...path]/route.ts

Reviewed by gpt-5.5-2026-04-23 · 227,903 tokens

@kilo-code-bot kilo-code-bot Bot changed the title feat(ai-gateway): apply free-model rate limit to kilo-auto/free feat(ai-gateway): rate limit kilo-auto/free Apr 30, 2026
@kilo-code-bot
kilo-code-bot Bot force-pushed the feat/rate-limit-kilo-auto-free branch from f9b41bc to 59f4165 Compare April 30, 2026 06:00
@kilo-code-bot kilo-code-bot Bot changed the title feat(ai-gateway): rate limit kilo-auto/free feat(ai-gateway): apply free-model rate limit to kilo-auto/free Apr 30, 2026
@chrarnoldus
chrarnoldus merged commit 8caa32e into main Apr 30, 2026
13 checks passed
@chrarnoldus
chrarnoldus deleted the feat/rate-limit-kilo-auto-free branch April 30, 2026 07:36
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