Repository navigation
feat: add a Moonshot Kimi chat preset (#240) - #335
Conversation
Selecting MoonShot Kimi fills https://api.moonshot.cn/v1 and keeps live model discovery, so the picker lists the models the entered key reaches. The international endpoint stays a custom OpenAI-compatible service.
6c4557a to
347ad70
Compare
FayeSpica
left a comment
There was a problem hiding this comment.
Could you support both Moonshot Open Platform token billing and Kimi Coding Plan subscription quotas in this PR?
| logoOrganization: "moonshotai", | ||
| name: "月之暗面 Kimi", | ||
| kinds: ["agent"], | ||
| url: "https://api.moonshot.cn/v1", |
There was a problem hiding this comment.
Could you add a separate Kimi Coding Plan preset alongside the pay-per-token Open Platform preset in this PR? Coding Plan uses https://api.kimi.com/coding/v1 with its own API key. Official configuration docs
There was a problem hiding this comment.
GET, I'll make it
…b#240) The Kimi Code subscription uses its own base URL and its own key, so the pay-per-token preset could not serve it: the same key returns 401 against https://api.kimi.com/coding/v1. The open-platform row keeps https://api.moonshot.cn/v1 and the new row points at https://api.kimi.com/coding/v1, and both keep live /models discovery. providerPresetFor matches on the exact base URL, so a saved Kimi Code connection reopens as its own row instead of falling back to the open-platform one. kimi_real.mjs takes KIMI_ROUTE to exercise either route. The Kimi Code row is verified only up to the endpoint: it answers the OpenAI-compatible shape with 401 for a key it does not own, and no subscription key was available to run a real turn.
|
Both routes are now in the PR: What is verified. What is not verified. I do not hold a Kimi Code Plan subscription, so I could not check which model ids the subscription exposes, whether a real turn streams, or whether tool calls work on that route. The model list is left to live If you have a subscription key, Two smaller things I can change on request: give both rows a shared |
FayeSpica
left a comment
There was a problem hiding this comment.
Thanks for adding Coding Plan support. LGTM now.
I verified live model discovery, a completed SSE reply and tool-driven text asset creation with k3 on 20361fe0 using my subscription key.
What
Adds the 月之暗面 Kimi / Moonshot Kimi chat presets requested in #240 (mainland chat row), in both billing forms requested in review.
src/canvas/providerPresets.ts: two rows, because the two billing routes do not share a key or a base URL.kimi— 月之暗面 Kimi 开放平台 / Moonshot Kimi Open Platform,url: https://api.moonshot.cn/v1, pay-per-token on the open platform.kimi-coding— 月之暗面 Kimi Code 订阅 / Moonshot Kimi Code subscription,url: https://api.kimi.com/coding/v1, draws on a Kimi Code Plan subscription quota.kinds: ["agent"],openai+api+bearer,logoOrganization: "moonshotai", placed afterbailian-beijing, beforezhipu.modelsByKindis deliberately omitted on both rows, so Fetch models stays a live/modelscall and the picker lists whatever the entered key can actually reach (same approach asdeepseek). With a mainland open-platform key that iskimi-k3andkimi-k3.1-pro.providerPresetFor()matches on the exact base URL, so a saved Kimi Code connection reopens as its own row instead of collapsing into the open-platform one. No routing code changed.api.moonshot.ai) is a separate row of the [tracking] providers: API integrations #240 matrix and is intentionally not matched — it stays a custom OpenAI-compatible service. The docs paragraph says so.moonshotaialready resolves throughmodelBrands.json→kimi.svg.docs/guides/user-guide.md+user-guide.zh-CN.md: one paragraph per locale covering both routes, that the keys are not interchangeable, live discovery, and international → custom service.tests/providerPresets.test.ts: 2 tests (both rows' shape + discovery-stays-on + localized labels + kind filtering + the two names stay distinct; andproviderPresetFor()re-selectingkimi/kimi-codingfor their saved connections while.ai,api.kimi.com/v1, deeper paths and other kinds fall back tocustom).tests/browser/kimi_real.mjs+manifest.json: an opt-in real-endpoint browser check.KIMI_ROUTE=openusesMOONSHOT_API_KEY,KIMI_ROUTE=codingusesKIMI_CODING_API_KEY;helper, incurs charges, no lane runs it.How tested
Gates on the updated branch:
The updated tests are mutation-checked: renaming the
kimi-codingid fails 2 assertions, restoring passes 20/20.Evidence
Open-platform route, a real turn against the real endpoint, unchanged from the first push:
/modelsdiscovery returnskimi-k3, the streamed reply arrives in the UI, the agent-written asset comes back withprovenance.source == "agent_written"andmodelSnapshot.modelId == "kimi-k3", it appears in the asset list, adds a canvas node, and survives a reload.Kimi Code route, no subscription key available, so this stops at the endpoint and at everything the app does before a key is validated:
api.kimi.comconnection reopens as its own row (zh-CN)What that route does prove:
https://api.kimi.com/coding/v1is live and speaks the OpenAI shape (/modelsand/chat/completionsboth answer JSON), and an open-platform key is rejected there with401 invalid_authentication_error— so the two keys are genuinely not interchangeable and one preset could not serve both. The rows are distinct in both locales, prefill their own URLs, save, and reopen with their own identity.What it does not prove: which model ids the subscription exposes, whether a real turn streams, and whether tool calls work on that route. Those need a Kimi Code Plan key. The full path is exercised end to end against an OpenAI-compatible stub on
127.0.0.1(slow_kimi_stub.pyin the evidence branch): discovery, connection save, and a complete streamed turn withstatus=complete— this checks the app side, not Moonshot's coding endpoint.Notes
kimi-note.txtinside the project. The agent completed it throughopendirector asset write-text, so the whole tool-calling loop works over Kimi.kimi-k3is slow-ish for a full tool round trip (~2 min for 4 calls in my run), which is why the browser check allows long waits; that is the model, not the integration.node_modules/.vitewas cleared. Not part of this PR, no fix included.group/optionLabelpairing if you prefer one dropdown entry with two options, or drop the Kimi Code row until someone with a subscription can verify a real turn.