CodexBar icon indicating copy to clipboard operation
CodexBar copied to clipboard

Add Kimi Code API-key usage support

Open yashiels opened this issue 5 months ago • 0 comments

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 .api source mode to the .kimi provider (auto/api/web), preferring API key when KIMI_API_KEY or config apiKey is set
  • Add KimiCodeAPIFetchStrategy for the GET /coding/v1/usages endpoint
  • Support codexbar config set-api-key --provider kimi mapping to KIMI_API_KEY
  • Support optional KIMI_CODE_BASE_URL override
  • Parse both API response shapes (web: root usages, code API: root usage + 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.

yashiels avatar Jun 11 '26 02:06 yashiels