Skip to content

feat(usage): support quota fetch for kimi-coding-apikey - #4435

Merged
diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.32from
janeza2:feat/kimi-coding-apikey-quota
Jun 21, 2026
Merged

diegosouzapw merged 2 commits into
cheaper-inference:release/v3.8.32from
janeza2:feat/kimi-coding-apikey-quota

Conversation

@janeza2

@janeza2 janeza2 commented Jun 20, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Adds kimi-coding-apikey to PROVIDER_LIMITS_APIKEY_PROVIDERS so its usage/quota can be fetched on the dashboard Quota page (parity with the OAuth-only kimi-coding provider).
  • Extends getKimiUsage to accept an optional apiKey and switch the auth header accordingly: x-api-key for API-key connections, Authorization: Bearer + device headers for the existing OAuth path.

Why

The kimi-coding-apikey provider (added in #463) currently shows no quota in the dashboard, while its OAuth counterpart kimi-coding does. Kimi's /coding/v1/usages endpoint already accepts the same API key used for /v1/messages — a live request returns authentication.method: METHOD_API_KEY and the standard { usage, limits, user } payload — so the only thing missing was wiring the provider into the API-key quota allowlist and passing the key through to the existing parser.

Verified against api.kimi.com with a real API key:

{
  "user": { "userId": "...", "membership": { "level": "LEVEL_STANDARD" } },
  "usage": { "limit": "100", "used": "6", "remaining": "94", "resetTime": "..." },
  "limits": [{ "window": { "duration": 300, "timeUnit": "TIME_UNIT_MINUTE" }, "detail": { ... } }],
  "authentication": { "method": "METHOD_API_KEY", "scope": "FEATURE_CODING" }
}

The existing parser in getKimiUsage already handles this shape (it reads usage.limit/used/remaining/resetTime and the limits[] array), so no parsing changes were needed.

Changes

File Change
open-sse/services/usage.ts getKimiUsage(accessToken, apiKey?) — pick x-api-key when apiKey is present, else fall back to the OAuth Bearer + X-Msh-* device headers. Add case "kimi-coding-apikey" in getUsageForProvider.
src/lib/usage/providerLimits.ts Add "kimi-coding-apikey" to PROVIDER_LIMITS_APIKEY_PROVIDERS.

Test plan

  • Connect a kimi-coding-apikey provider with a real Kimi API key and open the dashboard Quota page — expect Weekly (limit/used/remaining) and Ratelimit cards.
  • Confirm kimi-coding (OAuth) still shows quota as before (no regression — same code path, useApiKey=false).
  • Confirm a bad/revoked API key falls through to the existing Kimi Coding connected. API Error … message branch instead of crashing.

@janeza2
janeza2 requested a review from diegosouzapw as a code owner June 20, 2026 21:34
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

janeza2 and others added 2 commits June 21, 2026 08:42
Kimi's /coding/v1/usages endpoint accepts the same API key used for
/v1/messages (verified live: responds with authentication.method =
METHOD_API_KEY). Add kimi-coding-apikey to PROVIDER_LIMITS_APIKEY_PROVIDERS
and extend getKimiUsage to use x-api-key header when an apiKey is provided,
falling back to the OAuth Bearer + device-headers shape.

Co-authored-by: Cursor <cursoragent@cursor.com>
… + tests (review)

Register kimi-coding-apikey in USAGE_SUPPORTED_PROVIDERS (dashboard gate)
and USAGE_FETCHER_PROVIDERS (auto-routing preflight) so the new switch case
is reachable end-to-end, and add header-selection + wiring regression tests.

Co-authored-by: diegosouzapw <diego.souza@cdwasolutions.com.br>
@diegosouzapw
diegosouzapw force-pushed the feat/kimi-coding-apikey-quota branch from 65562a8 to 3a9e801 Compare June 21, 2026 11:45
@diegosouzapw
diegosouzapw changed the base branch from main to release/v3.8.32 June 21, 2026 11:45
@diegosouzapw
diegosouzapw merged commit c3fd2b9 into cheaper-inference:release/v3.8.32 Jun 21, 2026
5 checks passed
tkgo11 pushed a commit to tkgo11/OmniRoute that referenced this pull request Sep 23, 2026
…rence#4435)

Thanks @janeza2! Rebased onto release/v3.8.32 and completed the end-to-end wiring on review: kimi-coding-apikey was missing from USAGE_SUPPORTED_PROVIDERS (dashboard 400) and USAGE_FETCHER_PROVIDERS (preflight) — added both + header-selection/wiring tests. Now fully routable.
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