CodexBar
CodexBar copied to clipboard
Add Kimi Code API-key usage support
Summary
Add support for querying Kimi Code usage via the official Kimi Code API key flow (KIMI_API_KEY + https://api.kimi.com/coding/v1/usages), alongside the existing Kimi web cookie auth.
Motivation
The existing .kimi provider uses the Kimi web auth cookie flow (kimi-auth / KIMI_AUTH_TOKEN), which requires browser cookie extraction. The official Kimi Code CLI uses a proper API key that can be obtained via kimi login and supports a dedicated usage endpoint.
Proposed Changes
- Add an
.apisource mode to the.kimiprovider (auto/api/web), preferring API key whenKIMI_API_KEYor configapiKeyis set - Add
KimiCodeAPIFetchStrategyfor theGET /coding/v1/usagesendpoint - Support
codexbar config set-api-key --provider kimimapping toKIMI_API_KEY - Support optional
KIMI_CODE_BASE_URLoverride - Parse both API response shapes (web: root
usages, code API: rootusage+limits) - Preserve existing Kimi web cookie auth as fallback
Usage Endpoint
GET https://api.kimi.com/coding/v1/usages
Authorization: Bearer <KIMI_API_KEY>
Returns weekly and rolling 300-minute window quota information.