import type { ExtensionAPI, ProviderModelConfig, } from "@earendil-works/pi-coding-agent"; const anthropicUrl = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/apps/anthropic"; const openaiUrl = "https://token-plan.ap-southeast-1.maas.aliyuncs.com/compatible-mode/v1"; const cost = { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 }; type ModelConfig = Omit; const anthropicModel = { api: "anthropic-messages" as const, baseUrl: anthropicUrl, reasoning: true, input: ["text"] as ProviderModelConfig["input"], cost, maxTokens: 65_536, thinkingLevelMap: { off: null }, compat: { thinkingFormat: "qwen" as const }, }; const deepseekModel = { ...anthropicModel, api: "openai-completions" as const, baseUrl: openaiUrl, maxTokens: 393_216, compat: { supportsStore: false, supportsDeveloperRole: false, supportsReasoningEffort: false, maxTokensField: "max_tokens" as const, thinkingFormat: "qwen" as const, }, }; // Coding Plan does not expose a model-catalog API. const MODELS = new Map([ [ "qwen3.7-max", { ...anthropicModel, name: "Qwen 3.7 Max", contextWindow: 1_000_000 }, ], [ "qwen3.7-plus", { ...anthropicModel, name: "Qwen 3.7 Plus", input: ["text", "image"], contextWindow: 1_000_000, }, ], [ "qwen3.6-flash", { ...anthropicModel, name: "Qwen 3.6 Flash", contextWindow: 1_000_000 }, ], [ "glm-5.2", { ...anthropicModel, name: "GLM 5.2", contextWindow: 1_048_576, maxTokens: 131_072, }, ], [ "deepseek-v4-pro", { ...deepseekModel, name: "DeepSeek V4 Pro", contextWindow: 1_000_000, }, ], [ "deepseek-v4-flash-0731", { ...deepseekModel, name: "DeepSeek V4 Flash 0731", contextWindow: 1_048_576, }, ], [ "qwen3.8-max", { ...anthropicModel, name: "Qwen 3.8 Max", input: ["text", "image"], contextWindow: 1_000_000, maxTokens: 131_072, }, ], [ "qwen3.8-flash", { ...anthropicModel, name: "Qwen 3.8 Flash", contextWindow: 1_000_000 }, ], [ "deepseek-v4-pro-0813", { ...deepseekModel, name: "DeepSeek V4 Pro 0813", contextWindow: 1_048_576, }, ], ]); export default function (pi: ExtensionAPI) { pi.registerProvider("alibaba-plan", { name: "Alibaba Model Studio Plan", baseUrl: anthropicUrl, api: "anthropic-messages", apiKey: "$ALIBABA_API_KEY", authHeader: true, models: [...MODELS].map(([id, model]) => ({ id, ...model })), }); }