Skip to content

feat(kimi): add Kimi Code provider and list-price costing - #64

Open
ipo wants to merge 1 commit into
snipeship:mainfrom
ipo:pr-kimi-29324b8
Open

feat(kimi): add Kimi Code provider and list-price costing#64
ipo wants to merge 1 commit into
snipeship:mainfrom
ipo:pr-kimi-29324b8

Conversation

@ipo

@ipo ipo commented Jul 25, 2026

Copy link
Copy Markdown

Kimi added support for kimi-code via oauth, if you want to merge.

Commit-message
Adds kimi as a native passthrough provider and gives its traffic a meaningful cost in the dashboard.

Provider:

  • OAuth device authorization grant (RFC 8628), a first for this repo, so the shared OAuth flow, the API handler, the TUI and the dashboard form now branch on beginDeviceAuthorization instead of assuming a PKCE redirect with a pasted code.
  • KimiProvider extends OpenAIProvider: the upstream at https://api.kimi.com/coding/v1 is OpenAI-compatible chat-completions, so only auth differs. Access tokens live 900s and the refresh token rotates on every refresh.
  • Requests route through /v1/kimi/*.

Costing:

ccflare's only price source is the models.dev catalogue, and that catalogue lists Kimi's plan model ids under a kimi-for-coding block at zero cost because the plan is flat-rate. Every Kimi request was therefore recorded at $0 and could not be compared against Claude Code or Codex, which pick up real Anthropic and OpenAI list prices from the same catalogue.

packages/types/src/pricing-catalogue.ts now maps each provider to the catalogue blocks to read and, where the ids differ, their metered equivalents (kimi-for-coding -> kimi-k2.7-code, k3 and k3-256k -> kimi-k3, and so on). No rates are hardcoded; only where to look, so prices stay live.

Naming the catalogue block also fixes an existing ambiguity that affected every provider: the lookup scanned all blocks and took the first id match in JSON key order, so gpt-5.3-codex could be priced off a reseller's markup rather than OpenAI's own entry. First-party blocks are now consulted first, with the old catalogue-wide scan kept as a fallback for callers with no provider hint.

Costs remain list-price equivalents rather than billed amounts, which is already how subscription accounts were treated. docs/providers.md gains a "Request Cost" section saying so.

Quota fetching is still unimplemented for Kimi.

Adds `kimi` as a native passthrough provider and gives its traffic a
meaningful cost in the dashboard.

Provider:

- OAuth device authorization grant (RFC 8628), a first for this repo, so
  the shared OAuth flow, the API handler, the TUI and the dashboard form
  now branch on `beginDeviceAuthorization` instead of assuming a PKCE
  redirect with a pasted code.
- `KimiProvider` extends `OpenAIProvider`: the upstream at
  `https://api.kimi.com/coding/v1` is OpenAI-compatible chat-completions,
  so only auth differs. Access tokens live 900s and the refresh token
  rotates on every refresh.
- Requests route through `/v1/kimi/*`.

Costing:

ccflare's only price source is the models.dev catalogue, and that
catalogue lists Kimi's plan model ids under a `kimi-for-coding` block at
zero cost because the plan is flat-rate. Every Kimi request was therefore
recorded at $0 and could not be compared against Claude Code or Codex,
which pick up real Anthropic and OpenAI list prices from the same
catalogue.

`packages/types/src/pricing-catalogue.ts` now maps each provider to the
catalogue blocks to read and, where the ids differ, their metered
equivalents (`kimi-for-coding` -> `kimi-k2.7-code`, `k3` and `k3-256k` ->
`kimi-k3`, and so on). No rates are hardcoded; only where to look, so
prices stay live.

Naming the catalogue block also fixes an existing ambiguity that affected
every provider: the lookup scanned all blocks and took the first id match
in JSON key order, so `gpt-5.3-codex` could be priced off a reseller's
markup rather than OpenAI's own entry. First-party blocks are now
consulted first, with the old catalogue-wide scan kept as a fallback for
callers with no provider hint.

Costs remain list-price equivalents rather than billed amounts, which is
already how subscription accounts were treated. `docs/providers.md` gains
a "Request Cost" section saying so.

Quota fetching is still unimplemented for Kimi.
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.

1 participant