From 809ad83580677ebdb6c7ba9c4d86a366dbe05e4d Mon Sep 17 00:00:00 2001 From: damngamerz <13048113+damngamerz@users.noreply.github.com> Date: Tue, 4 Aug 2026 15:53:49 +0200 Subject: [PATCH] fix: expose max thinking level for reasoning models Advertise the extended `max` thinking level in pi for every reasoning-capable Requesty model via thinkingLevelMap, and persist it so /requesty-models-sync keeps it. `max` is a global Requesty effort value normalized per backend (OpenAI -> high, Anthropic/Gemini -> token budget), so it is safe across all models. Fixes #8 --- requesty.js | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/requesty.js b/requesty.js index 5ab8906..4e1e982 100644 --- a/requesty.js +++ b/requesty.js @@ -71,20 +71,29 @@ async function discoverModels(provider) { return payload.data .filter((model) => model && typeof model.id === "string" && model.id.length > 0) - .map((model) => ({ - id: model.id, - name: typeof model.name === "string" && model.name.length > 0 ? model.name : model.id, - reasoning: model.supports_reasoning === true, - input: model.supports_vision === true ? ["text", "image"] : ["text"], - cost: { - input: pricePerMillionTokens(model.input_price), - output: pricePerMillionTokens(model.output_price), - cacheRead: pricePerMillionTokens(model.cached_price), - cacheWrite: pricePerMillionTokens(model.caching_price), - }, - contextWindow: model.context_window || DEFAULT_CONTEXT_WINDOW, - maxTokens: model.max_output_tokens || DEFAULT_MAX_TOKENS, - })); + .map((model) => { + const reasoning = model.supports_reasoning === true; + return { + id: model.id, + name: typeof model.name === "string" && model.name.length > 0 ? model.name : model.id, + reasoning, + // pi exposes the extended `max` thinking level only when a model declares it in + // `thinkingLevelMap`; standard levels (`minimal`..`high`) are implicit via pi's + // provider default mapping. `max` is a global Requesty effort value normalized + // per backend (OpenAI -> high, Anthropic/Gemini -> token budget), so it is safe + // to advertise `max` for every reasoning-capable model. + thinkingLevelMap: reasoning ? { max: "max" } : undefined, + input: model.supports_vision === true ? ["text", "image"] : ["text"], + cost: { + input: pricePerMillionTokens(model.input_price), + output: pricePerMillionTokens(model.output_price), + cacheRead: pricePerMillionTokens(model.cached_price), + cacheWrite: pricePerMillionTokens(model.caching_price), + }, + contextWindow: model.context_window || DEFAULT_CONTEXT_WINDOW, + maxTokens: model.max_output_tokens || DEFAULT_MAX_TOKENS, + }; + }); } function pricePerMillionTokens(value) { @@ -105,6 +114,7 @@ function updateModelsJson(data, models) { id: model.id, name: model.name, reasoning: model.reasoning, + thinkingLevelMap: model.thinkingLevelMap, input: model.input, cost: model.cost, contextWindow: model.contextWindow,