Repository navigation
feat(usage): support quota fetch for kimi-coding-apikey - #4435
Merged
diegosouzapw merged 2 commits intoJun 21, 2026
Merged
diegosouzapw merged 2 commits into
diegosouzapw merged 2 commits into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
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
force-pushed
the
feat/kimi-coding-apikey-quota
branch
from
June 21, 2026 11:45
65562a8 to
3a9e801
Compare
diegosouzapw
merged commit Jun 21, 2026
c3fd2b9
into
cheaper-inference:release/v3.8.32
5 checks passed
2 of 3 tasks
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
kimi-coding-apikeytoPROVIDER_LIMITS_APIKEY_PROVIDERSso its usage/quota can be fetched on the dashboard Quota page (parity with the OAuth-onlykimi-codingprovider).getKimiUsageto accept an optionalapiKeyand switch the auth header accordingly:x-api-keyfor API-key connections,Authorization: Bearer+ device headers for the existing OAuth path.Why
The
kimi-coding-apikeyprovider (added in #463) currently shows no quota in the dashboard, while its OAuth counterpartkimi-codingdoes. Kimi's/coding/v1/usagesendpoint already accepts the same API key used for/v1/messages— a live request returnsauthentication.method: METHOD_API_KEYand 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.comwith 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
getKimiUsagealready handles this shape (it readsusage.limit/used/remaining/resetTimeand thelimits[]array), so no parsing changes were needed.Changes
open-sse/services/usage.tsgetKimiUsage(accessToken, apiKey?)— pickx-api-keywhenapiKeyis present, else fall back to the OAuth Bearer +X-Msh-*device headers. Addcase "kimi-coding-apikey"ingetUsageForProvider.src/lib/usage/providerLimits.ts"kimi-coding-apikey"toPROVIDER_LIMITS_APIKEY_PROVIDERS.Test plan
kimi-coding-apikeyprovider with a real Kimi API key and open the dashboard Quota page — expectWeekly(limit/used/remaining) andRatelimitcards.kimi-coding(OAuth) still shows quota as before (no regression — same code path,useApiKey=false).Kimi Coding connected. API Error …message branch instead of crashing.