Open History to see the last commit
1/** Both Kimi Coding regions are explicitly documented in the same native page. */
2import { cachedDocs } from './model-facts.ts'
3import { fetchText, sha256Text } from './types.ts'
4import type { ProviderConfig } from './types.ts'
5import { KIMI_CODE_MODELS_URL, parseKimiCodeModels } from './kimi-code-docs.ts'
6
7export function kimiCodeProvider(
8 id: string,
9 displayName: string,
10): ProviderConfig {
11 return {
12 id,
13 displayName,
14 specSourceUrl: KIMI_CODE_MODELS_URL,
15 modelsEndpoint: KIMI_CODE_MODELS_URL,
16 defaultDerivation: 'docs-derived',
17 bindSyncedRoutesOnly: true,
18 async listModels(_env, kv) {
19 const doc = await cachedDocs(kv, KIMI_CODE_MODELS_URL, async () => {
20 const html = await fetchText(KIMI_CODE_MODELS_URL)
21 return { html, hash: await sha256Text(html) }
22 })
23 return {
24 models: parseKimiCodeModels(doc.html, {
25 derivation: 'docs-derived',
26 sourceUrl: KIMI_CODE_MODELS_URL,
27 sourceHash: doc.hash,
28 }).map((model) => ({
29 ...model,
30 absent: { pricing: 'cleared' as const },
31 })),
32 }
33 },
34 async fetchSpec() {
35 const html = await fetchText(KIMI_CODE_MODELS_URL)
36 const hash = await sha256Text(html)
37 parseKimiCodeModels(html, {
38 derivation: 'docs-derived',
39 sourceUrl: KIMI_CODE_MODELS_URL,
40 sourceHash: hash,
41 })
42 return {
43 specs: [],
44 sources: [{ url: KIMI_CODE_MODELS_URL, hash }],
45 outputStrategy: 'post-200' as const,
46 skipped: `${id}: native Coding docs publish model facts, but no sourced request/response schema — skipped`,
47 }
48 },
49 classify: () => null,
50 }
51}