pi-mono/packages/ai/catalog/providers/xiaomi.ts
Armin Ronacher 2e0f175bd5
feat(ai): refactor provider definitions (#11368)
This builds the model catalog from per-provider definitions and
models.dev v2 data.

It eplacer `generate-models.ts` with one `defineProvider()` file per
built-in provider, shared model-family rules (Claude, GPT, DeepSeek,
Kimi, Google), and source adapters. models.dev is read through its v2
API. Outputs and CLI flags are unchanged.
2026-10-28 11:06:10 +01:00

46 lines
1.4 KiB
TypeScript

import type { Model } from "../../src/types.ts";
import { defineProvider, modelsDevModels, type ProviderContext } from "../define.ts";
/**
* Xiaomi MiMo. The `xiaomi` provider targets the API billing endpoint; the
* `xiaomi-token-plan-*` providers cover prepaid Token Plan endpoints per region.
* MiMo Chat Completions only documents thinking.type enabled/disabled and
* rejects some reasoning_effort values (e.g. "minimal"). Xiaomi documents all
* effort levels as identical, so expose only off and high.
*/
export function xiaomiModels(ctx: ProviderContext, baseUrl: string) {
return modelsDevModels(ctx, ctx.providerId, {
api: "openai-completions",
baseUrl,
skipDeprecated: true,
recordReasoning: false,
compat: {
supportsReasoningEffort: false,
requiresReasoningContentOnAssistantMessages: true,
thinkingFormat: "deepseek",
},
map: (model): Model<"openai-completions"> =>
model.reasoning
? {
...model,
thinkingLevelMap: {
off: "off",
minimal: null,
low: null,
medium: null,
high: "high",
xhigh: null,
max: null,
},
}
: model,
});
}
export const XIAOMI_COMPLETIONS_COMPAT = { supportsStrictMode: true } as const;
export default defineProvider({
id: "xiaomi",
models: (ctx) => xiaomiModels(ctx, "https://api.xiaomimimo.com/v1"),
compat: { "openai-completions": XIAOMI_COMPLETIONS_COMPAT },
});