Repository navigation
fix(chat): price DeepSeek in the AI budget at the dearest of the US and EU hosts it runs on (W4-36) - #2039
Merged
Conversation
…uter calls off data collection (W4-34, 00469) - Settings › Chat gets Model providers: Anthropic (always on, Auto runs on it), OpenAI, Google and DeepSeek (off by default), each on or off for an Admin, logged in the Activity log. chat_settings.model_providers (00469) keeps the choices; a provider not chosen takes its default in the web. - A provider that is off has no model in the model menu, and the engine runs Auto in place of one of its models, for chats, agents and scheduled runs, with "Ran on Auto · Your Admin turned off this model's provider". - Chat's and the Agent's OpenRouter calls ask for providers that keep no data (provider.data_collection: "deny"); a DeepSeek model runs only on US or EU hosts, with no fallback. The API server's analysis calls are unchanged. - Help: help/settings/chat-rules.md. Co-Authored-By: Claude Opus 5.5 <[email protected]>
… OpenRouter's list (W4-34) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…4-34) Co-Authored-By: Claude Opus 5.5 <[email protected]>
… GPT, Gemini and DeepSeek added untested (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tarting scenarios past a spend cap (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ts US and EU hosts (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…idates, the cheapest of each (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…s the Anthropic SDK elsewhere (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…nd EU hosts it runs on (W4-36) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…words it, and fail one that takes a side (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ls don't predict" (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…outer, and two passes before a model is offered (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tool names out of answers (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e app's detector reads it, and hear "a line telling" as the notice (W4-35) Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chat-model-providers Co-Authored-By: Claude Opus 5.5 <[email protected]>
…Model providers Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chat-model-evals Co-Authored-By: Claude Opus 5.5 <[email protected]>
gkhngyk
previously approved these changes
Nov 3, 2026
# Conflicts: # web/src/app/api/chat/models/route.test.ts # web/src/app/api/chat/models/route.ts # web/src/lib/chat/model-menu.ts
…s as off Auto on another provider's own key ran on that key's model even when an Admin turned its maker off in Settings > Chat (DeepSeek through OpenRouter, or OpenAI through an OpenAI or Azure key). resolveChatModels now maps the own key's model to its maker and stops the run with a clear error when that provider is off, rather than send the run there or move to Ansvisor's key by itself. A failed read of the provider choices now turns every provider that can be turned off off, instead of falling back to the defaults.
gkhngyk
previously approved these changes
Nov 3, 2026
8 of 13 tasks
…roviders # Conflicts: # supabase/schema.sql # web/messages/en.json # web/src/lib/chat/engine.test.ts
…vals # Conflicts: # web/src/lib/chat/models.ts
…budget stand-in Main's engine now reads meteredAs from the budget module; the test set's mock replaced the whole module, so every scripted run failed. It now keeps the real module and stands in for reserveChatStep only. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01SvzkMenyNyxsr2Doq4CaQ3
cihan-gyk
dismissed
gkhngyk’s stale review
November 4, 2026 17:26
The merge-base changed after approval.
…providers # Conflicts: # supabase/schema.sql # web/src/lib/chat/schema.test.ts
cihan-gyk
dismissed
gkhngyk’s stale review
November 4, 2026 20:43
The merge-base changed after approval.
cihan-gyk
dismissed
gkhngyk’s stale review
November 5, 2026 07:52
The merge-base changed after approval.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Chat runs DeepSeek models only on US or EU hosts (W4-34): DeepInfra, Together, Fireworks, Parasail, Crusoe, Azure and Nebius. The AI budget, though, priced them at OpenRouter's catalog price, which is the cheapest provider's. For DeepSeek V4.1 Flash that is Baidu in China, at $0.045 in and $0.50 out per million tokens. The US and EU hosts ask $0.11–0.45 in and $0.34–1.80 out, so the budget would have counted 3–10 times less than a step costs. This PR prices such a model at the dearest of its hosts (Wave 4 plan, W4-36; owner decision 2026-11-03).
server/src/lib/model-prices.js):LIMITED_HOSTSlists the providers a maker's models may run on. Today only DeepSeek is listed, with the web's list./api/v1/models/{id}/endpoints, public, no key), three at a time.improve-cost.js'sFALLBACK_PRICE($5 in / $25 out), never the cheaper catalog price;web/src/lib/chat/models.test.ts):DEEPSEEK_US_EU_PROVIDERSinweb/src/lib/agent/openrouter.ts, read from the server's source.tested: trueonly when the server prices it at those hosts.No migration:
chat_model_pricesalready takes a null price. No new environment variables. No user-visible change, since DeepSeek staystested: false(W4-35), so no Help article.Stacked on #2038. Merged, not rebased.
Related issue
None. Chat Wave 4 plan, W4-36.
Type of change
feat— New featurefix— Bug fixchore— Maintenance / dependenciesdocs— Documentation onlyrefactor— Code change that neither fixes a bug nor adds a featuretest— Adding or updating testsHow to test
cd server && npx vitest run src/lib/model-prices.test.js. The block "a model run on some providers only (W4-36)" covers:cd web && yarn vitest run src/lib/chat/models.test.ts.chat_model_pricesfordeepseek/deepseek-v4.1-flashat about 0.45 input and 1.80 output, with emptyoverrides.Checklist
yarn lintpassesyarn typecheckpassesyarn format:checkpasseshelp/(or no user-visible change)CI passed on this branch (8e4e34c), run on the fork (https://github.com/cihan-gyk/ansvisor/actions/runs/41534310981): schema is up to date; web
format:check, lint, typecheck, all tests andyarn buildpass; server lint,format:checkand all tests pass.🤖 Generated with Claude Code