map deepseek thinking levels to the model studio reasoning_effort ladder
46 unmodified lines474849505152515253545556575859606162636465666768697071727333 unmodified lines46 unmodified linesAt startup the extension still asks `/models` for entitlement only, and hides models thekey cannot call. The list is cached in `~/.prime/agent/alibaba-entitlement.json`, so aslow or failed call reuses the last known list.
Thinking is mapped per family: `qwen` -> top-level `enable_thinking`, `deepseek` ->`thinking` + `reasoning_effort`, `glm` -> Z.ai format.## Thinking
| family | switch | depth | levels offered || --- | --- | --- | --- || deepseek | `thinking: {type}` (verified) or `enable_thinking` (documented) | `reasoning_effort`: low, medium, high, xhigh, max, default high | off, low, medium, high, xhigh, max || qwen | `enable_thinking` | `thinking_budget` (token cap) | off, high || glm | `enable_thinking` | `thinking_budget` | off, high |
DeepSeek on Model Studio takes the full `reasoning_effort` ladder, unlike Prime'sbuilt-in DeepSeek entries, which expose only high and max - so the levels are remappedhere rather than inherited.
Qwen and GLM have no effort parameter. Depth is a token cap (`thinking_budget`), whichPrime's OpenAI-completions path does not send, so every level above off is the samerequest and only off/high are offered.
Sources: [deep thinking](https://help.aliyun.com/en/model-studio/deep-thinking),[DeepSeek API](https://help.aliyun.com/en/model-studio/deepseek-api).
## Prompt caching
Model Studio has two modes, and they are mutually exclusive per request:
33 unmodified lines56 unmodified lines57585960616261626364656667686970717273747576777873 unmodified lines1521531541551441561571581591606 unmodified lines56 unmodified lines zai: { thinkingFormat: "zai", supportsReasoningEffort: false }, other: {},};
/** DeepSeek V4 exposes only high/max, same as Prime's built-in DeepSeek models. */const DEEPSEEK_THINKING_LEVELS = { minimal: null, low: null, medium: null, high: "high", xhigh: "max", max: null };/** * Model Studio's own levels, not the vendors' defaults. * * DeepSeek here takes `reasoning_effort` with low/medium/high/xhigh/max (default high), * so every level maps to itself. Qwen and GLM take only a boolean `enable_thinking`; * depth would need `thinking_budget`, which the OpenAI-completions path cannot send, so * they offer off and high and nothing in between. */const THINKING_LEVELS: Record<Family, Record<string, string | null> | undefined> = { deepseek: { minimal: null, low: "low", medium: "medium", high: "high", xhigh: "xhigh", max: "max" }, qwen: { minimal: null, low: null, medium: null, high: "high" }, zai: { minimal: null, low: null, medium: null, high: "high" }, other: undefined,};
export const baseUrlFromEnv = (): string => (process.env.ALIBABA_BASE_URL || DEFAULT_BASE_URL).replace(/\/+$/, "");
const readFile = (path: string): string | undefined => {73 unmodified lines supportsDeveloperRole: false, maxTokensField: "max_tokens" as const, ...FAMILY_COMPAT[familyOf(m.id)], }, ...(m.reasoning && familyOf(m.id) === "deepseek" ? { thinkingLevelMap: DEEPSEEK_THINKING_LEVELS } : {}), ...(m.reasoning && THINKING_LEVELS[familyOf(m.id)] ? { thinkingLevelMap: THINKING_LEVELS[familyOf(m.id)] } : {}), }));
pi.registerProvider(PROVIDER, { name: "Alibaba Model Studio (token plan)",6 unmodified lines