pi-mono/packages/ai/catalog/providers/siliconflow.ts
Armin Ronacher 63dfe49bfa feat(ai,coding-agent): add DeepInfra, Nebius, Ollama Cloud, Scaleway, SiliconFlow, and StepFun providers
Adds deepinfra, nebius, ollama-cloud, scaleway, siliconflow, siliconflow-cn, stepfun, and stepfun-cn from models.dev. Hosts without verified support for OpenAI-only request features leave out store, developer messages, long cache retention, and max_completion_tokens, and send reasoning_effort only where models.dev lists effort levels. SiliconFlow toggles thinking with enable_thinking; StepFun uses DeepSeek-style reasoning.
2026-10-28 11:06:14 +01:00

28 lines
1.1 KiB
TypeScript

import type { Model } from "../../src/types.ts";
import { defineProvider, modelsDevModels, type ProviderContext } from "../define.ts";
import { catalogedEffortCompat, OPENAI_COMPATIBLE_HOST_COMPAT } from "../openai-compatible.ts";
/**
* SiliconFlow. Reasoning models with a thinking toggle take a top-level
* `enable_thinking` flag (Qwen's thinking format); other reasoning models keep
* the server default unless models.dev lists effort levels.
*/
export function siliconflowModels(ctx: ProviderContext, source: string, baseUrl: string) {
return modelsDevModels(ctx, source, {
api: "openai-completions",
baseUrl,
map: (model, source): Model<"openai-completions"> => ({
...model,
compat: {
...catalogedEffortCompat(source),
...(source.reasoningOptions?.some((option) => option.type === "toggle") ? { thinkingFormat: "qwen" } : {}),
},
}),
});
}
export default defineProvider({
id: "siliconflow",
models: (ctx) => siliconflowModels(ctx, "siliconflow", "https://api.siliconflow.com/v1"),
compat: { "openai-completions": OPENAI_COMPATIBLE_HOST_COMPAT },
});