feat(kimi): add Kimi Code provider and list-price costing - #64
Open
ipo wants to merge 1 commit into
Open
Conversation
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.
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.
Kimi added support for kimi-code via oauth, if you want to merge.
Commit-message
Adds
kimias a native passthrough provider and gives its traffic a meaningful cost in the dashboard.Provider:
beginDeviceAuthorizationinstead of assuming a PKCE redirect with a pasted code.KimiProviderextendsOpenAIProvider: the upstream athttps://api.kimi.com/coding/v1is OpenAI-compatible chat-completions, so only auth differs. Access tokens live 900s and the refresh token rotates on every refresh./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-codingblock 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.tsnow maps each provider to the catalogue blocks to read and, where the ids differ, their metered equivalents (kimi-for-coding->kimi-k2.7-code,k3andk3-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-codexcould 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.mdgains a "Request Cost" section saying so.Quota fetching is still unimplemented for Kimi.