Skip to content

Garry's Opinionated OpenClaw/Hermes Agent Brain

TypeScript

fix(pricing): A-N1 DeepSeek rows at today's peak rates, add deepseek-flash (#5847)

time-attack69c1c66324a6
diff --git a/docs/guides/sub-agent-routing.md b/docs/guides/sub-agent-routing.md
index f8cab6b1a0..fb94783348 100644
--- a/docs/guides/sub-agent-routing.md
+++ b/docs/guides/sub-agent-routing.md
@@ -43,7 +43,7 @@ routing policy; this guide is the cost rationale behind it.
| Task Type | Recommended Model | Why |
|-----------|------------------|-----|
| Main session / complex instructions | Opus-class (default) | Best reasoning and instruction following |
-| Research / synthesis / analysis | DeepSeek V3 or equivalent | 25-40x cheaper, strong on exploratory work |
+| Research / synthesis / analysis | DeepSeek Flash or equivalent | about 7-17x cheaper than Anthropic Sonnet 5.5 to Opus 5.5 at peak rates, strong on exploratory work |
| Structured output / long context | Large context model (Qwen, Gemini) | 200K+ context, reliable JSON output |
| Fast lightweight sub-agents | Fast inference model (Groq) | 500 tok/s, cheap, good for quick tasks |
| Deep reasoning (use sparingly) | Reasoning model (DeepSeek-R1, o3) | Best for hard problems, expensive |
diff --git a/src/commands/providers.ts b/src/commands/providers.ts
index 7b2646aec4..8ed5cc384e 100644
--- a/src/commands/providers.ts
+++ b/src/commands/providers.ts
@@ -445,7 +445,7 @@ function prosFor(r: Recipe, touchpoint: TouchpointFilter): string[] {
if (r.id === 'anthropic') out.push('Default subagent driver', 'Prompt-cache support', 'Strong tool calling');
else if (r.id === 'openai') out.push('Strong tool calling', 'Wide adapter support');
else if (r.id === 'google') out.push('1M context', 'Cheap');
- else if (r.id === 'deepseek') out.push('25-40x cheaper than Anthropic', 'Strong reasoning');
+ else if (r.id === 'deepseek') out.push('About 7-17x cheaper than Anthropic Sonnet 5.5 to Opus 5.5 at peak rates', 'Strong reasoning');
else if (r.id === 'groq') out.push('500 tok/s inference', 'Cheap fallback');
else if (r.id === 'together') out.push('Open-weights house', 'Llama / Qwen / Mixtral');
return out;
diff --git a/src/core/ai/recipes/deepseek.ts b/src/core/ai/recipes/deepseek.ts
index a4b80c0ea6..0999b21d5a 100644
--- a/src/core/ai/recipes/deepseek.ts
+++ b/src/core/ai/recipes/deepseek.ts
@@ -1,7 +1,7 @@
import type { Recipe } from '../types.ts';
/**
- * DeepSeek's thinking mode (default on `deepseek-v4-flash`/`deepseek-v4-pro`;
+ * DeepSeek's thinking mode (default on `deepseek-flash`, `deepseek-v4-flash` and `deepseek-v4-pro`;
* formerly the `deepseek-reasoner` model, retired 2026-07-24) returns its
* answer in a separate `reasoning_content` field and leaves `content`
* empty/whitespace when the whole response was reasoning. The AI SDK's openai-compatible adapter reads only `content`, so
@@ -63,8 +63,8 @@ export const deepseekReasoningContentCompatFetch = (async (
/**
* DeepSeek exposes an OpenAI-compatible /v1/chat/completions endpoint.
* Useful as the second hop in a refusal-fallback chain and for cheap-
- * research delegation: 25-40x cheaper than Anthropic on equivalent
- * reasoning workloads.
+ * research delegation.
+ * Pricing: https://api-docs.deepseek.com/quick_start/pricing
*/
export const deepseek: Recipe = {
id: 'deepseek',
@@ -82,17 +82,20 @@ export const deepseek: Recipe = {
// declaration an explicit `expansion_model: deepseek:...` silently
// yields no expansion (#1135).
// `deepseek-chat` / `deepseek-reasoner` were retired by DeepSeek on
- // 2026-07-24 (#1255); both map to `deepseek-v4-flash` (non-thinking /
- // thinking mode). Do not re-add the old names — the API 404s them.
+ // 2026-07-24 (#1255). Do not re-add the old names — the API 404s them.
+ // `deepseek-flash` (DeepSeek-V4.1-Flash) is the current name; the legacy
+ // `deepseek-v4-flash` is still accepted and served by the same model.
// openai-compat tier means user-configured legacy names still pass
// validation locally; the provider rejects them at call time.
+ // Rates are DeepSeek's PEAK cache-miss rates (an upper bound; off-peak
+ // bills half), matching model-pricing.ts.
expansion: {
- models: ['deepseek-v4-flash'],
- cost_per_1m_tokens_usd: 0.14,
- price_last_verified: '2026-07-27',
+ models: ['deepseek-flash', 'deepseek-v4-flash'],
+ cost_per_1m_tokens_usd: 0.30,
+ price_last_verified: '2026-10-05',
},
chat: {
- models: ['deepseek-v4-flash', 'deepseek-v4-pro'],
+ models: ['deepseek-flash', 'deepseek-v4-flash', 'deepseek-v4-pro'],
supports_tools: true,
supports_subagent_loop: true,
// DeepSeek's context caching is on by default for every account — the
@@ -102,14 +105,14 @@ export const deepseek: Recipe = {
// baseline — i.e. it already assumes a cache exists — and produced advice
// telling operators to move to a more expensive provider "for lower cost".
supports_prompt_cache: true,
- // Thinking mode is DEFAULT ON for both v4 models (see module docstring):
+ // Thinking mode is DEFAULT ON for every listed model (see module docstring):
// reasoning bills as output and counts against max_tokens, so callers
// that size output caps must grant reasoning headroom (gbrain#4172).
thinking_by_default: true,
max_context_tokens: 1_000_000,
- cost_per_1m_input_usd: 0.14, // deepseek-v4-flash cache-miss baseline
- cost_per_1m_output_usd: 0.28,
- price_last_verified: '2026-07-27',
+ cost_per_1m_input_usd: 0.30, // deepseek-flash peak cache-miss baseline
+ cost_per_1m_output_usd: 1.20,
+ price_last_verified: '2026-10-05',
},
},
setup_hint: 'Get an API key at https://platform.deepseek.com/api_keys, then `export DEEPSEEK_API_KEY=...`',
diff --git a/src/core/model-pricing.ts b/src/core/model-pricing.ts
index 4ba6540a54..235f3daaa5 100644
--- a/src/core/model-pricing.ts
+++ b/src/core/model-pricing.ts
@@ -165,9 +165,16 @@ export const CANONICAL_PRICING: Record<string, ModelPricing> = {
// `deepseek-chat` was retired by DeepSeek 2026-07-24 (#1255); kept so
// historical usage/audit rows still price. New calls use the v4 names.
'deepseek:deepseek-chat': { input: 0.14, output: 0.28 },
- // DeepSeek v4 (verified 2026-07-27 at api-docs.deepseek.com): cache-miss rates.
- 'deepseek:deepseek-v4-flash': { input: 0.14, output: 0.28 },
- 'deepseek:deepseek-v4-pro': { input: 0.435, output: 0.87 },
+ // DeepSeek (verified 2026-10-05 at https://api-docs.deepseek.com/quick_start/pricing):
+ // PEAK cache-miss rates, an upper bound. DeepSeek bills half these rates
+ // off-peak (outside 01:00-04:00 and 06:00-10:00 UTC on weekdays); a static
+ // row cannot know the hour and a cap must bound the worst case, so caps
+ // and estimates use peak. `deepseek-flash` (DeepSeek-V4.1-Flash) is the
+ // current name; the legacy `deepseek-v4-flash` is served by the same model
+ // and billed at the Flash price, so the pair stays in lockstep.
+ 'deepseek:deepseek-flash': { input: 0.30, output: 1.20 },
+ 'deepseek:deepseek-v4-flash': { input: 0.30, output: 1.20 },
+ 'deepseek:deepseek-v4-pro': { input: 1.32, output: 3.96 },
// ── Z.ai / GLM (via LiteLLM proxy) ───────────────────────────────────
// GLM-5.2 from Z.ai: $1.40/M input, $4.40/M output (verified 2026-08-16
// against OpenRouter provider listings — z.ai's own direct rates).
@@ -175,7 +182,7 @@ export const CANONICAL_PRICING: Record<string, ModelPricing> = {
// ── OpenRouter (router-prefixed, own catalogue rate) ────────────────────
// Static entries pulled from OpenRouter's published `/api/v1/models`
- // catalogue (verified 2026-08-17), NOT aliased to the inner vendor's
+ // catalogue (verified 2026-08-17; re-checked 2026-10-05), NOT aliased to the inner vendor's
// direct rate — a router bills its own spread, and canonicalLookup's
// nested-id miss (see doc comment below) exists precisely to stop a
// router-prefixed id from silently matching the vendor's key instead.
@@ -189,10 +196,11 @@ export const CANONICAL_PRICING: Record<string, ModelPricing> = {
// live; see PR discussion on gbrain#3848 for why a dynamic fetch/cache
// didn't merge (default-on network behavior, new pricing-source surface).
//
- // deepseek/deepseek-v4-flash-0731 matches deepseek:deepseek-v4-flash
- // above to the cent — OpenRouter passing DeepSeek through at vendor
- // rate, not a coincidence worth losing to an alias shortcut.
- 'openrouter:deepseek/deepseek-v4-flash-0731': { input: 0.14, output: 0.28 },
+ // deepseek/deepseek-v4-flash-0731 re-verified 2026-10-05 against the
+ // catalogue's own rate ($0.0152 in / $1.28 out), which no longer matches
+ // the vendor row above: a router row is read from the router, never
+ // copied from the vendor.
+ 'openrouter:deepseek/deepseek-v4-flash-0731': { input: 0.0152, output: 1.28 },
'openrouter:qwen/qwen3.7-flash': { input: 0.03, output: 0.13 },
'openrouter:qwen/qwen3.6-plus': { input: 0.325, output: 1.95 },
};
diff --git a/test/ai/deepseek-reasoning-content.test.ts b/test/ai/deepseek-reasoning-content.test.ts
index 8796f0351c..ac095e608d 100644
--- a/test/ai/deepseek-reasoning-content.test.ts
+++ b/test/ai/deepseek-reasoning-content.test.ts
@@ -122,8 +122,13 @@ describe('applyOpenAICompatConfig — compat.fetch wiring (gateway seam)', () =>
expect(deepseek.compat?.fetch).toBe(deepseekReasoningContentCompatFetch);
});
- test('recipe lists only v4 model names — deepseek-chat/deepseek-reasoner retired 2026-07-24 (#1255)', () => {
- expect(deepseek.touchpoints.chat?.models).toEqual(['deepseek-v4-flash', 'deepseek-v4-pro']);
- expect(deepseek.touchpoints.expansion?.models).toEqual(['deepseek-v4-flash']);
+ test('recipe lists only current model names — deepseek-chat/deepseek-reasoner retired 2026-07-24 (#1255)', () => {
+ // deepseek-flash (V4.1-Flash) is the current name; deepseek-v4-flash is its accepted legacy alias (A-N1).
+ expect(deepseek.touchpoints.chat?.models).toEqual(['deepseek-flash', 'deepseek-v4-flash', 'deepseek-v4-pro']);
+ expect(deepseek.touchpoints.expansion?.models).toEqual(['deepseek-flash', 'deepseek-v4-flash']);
+ for (const retired of ['deepseek-chat', 'deepseek-reasoner']) {
+ expect(deepseek.touchpoints.chat?.models).not.toContain(retired);
+ expect(deepseek.touchpoints.expansion?.models).not.toContain(retired);
+ }
});
});
diff --git a/test/model-pricing.test.ts b/test/model-pricing.test.ts
index 72b095e611..4580ab04a2 100644
--- a/test/model-pricing.test.ts
+++ b/test/model-pricing.test.ts
@@ -147,14 +147,16 @@ describe('canonicalLookup — id normalization', () => {
});
test('OpenRouter id WITH a declared static entry → hit on its own rate, not the vendor alias', () => {
- // deepseek/deepseek-v4-flash-0731 happens to match deepseek:deepseek-v4-flash
- // to the cent, but this must resolve via its OWN canonical key, not by
- // falling through to the bare vendor tail — that fallthrough is exactly
+ // deepseek/deepseek-v4-flash-0731 resolves via its OWN canonical key, not
+ // by falling through to the bare vendor tail — that fallthrough is exactly
// what canonicalLookup's nested-id miss (case above) exists to prevent.
+ // Its rate is OpenRouter's catalogue rate (re-verified 2026-10-05), which
+ // differs from the vendor's deepseek:deepseek-v4-flash row.
expect(canonicalLookup('openrouter:deepseek/deepseek-v4-flash-0731')).toEqual({
- input: 0.14,
- output: 0.28,
+ input: 0.0152,
+ output: 1.28,
});
+ expect(canonicalLookup('openrouter:deepseek/deepseek-v4-flash-0731')).not.toEqual(canonicalLookup('deepseek:deepseek-v4-flash'));
expect(canonicalLookup('openrouter:qwen/qwen3.7-flash')).toEqual({
input: 0.03,
output: 0.13,
@@ -206,6 +208,25 @@ describe('DRIFT GUARD — derived views stay equal to canonical (re-hardcode tri
expect(openai.touchpoints?.expansion?.cost_per_1m_tokens_usd).toBe(canonical.input);
});
+ test('A-N1: DeepSeek rows carry the vendor PEAK rates; legacy flash id stays in lockstep with deepseek-flash', () => {
+ expect(CANONICAL_PRICING['deepseek:deepseek-flash']).toEqual({ input: 0.30, output: 1.20 });
+ expect(CANONICAL_PRICING['deepseek:deepseek-v4-flash']).toEqual(CANONICAL_PRICING['deepseek:deepseek-flash']);
+ expect(CANONICAL_PRICING['deepseek:deepseek-v4-pro']).toEqual({ input: 1.32, output: 3.96 });
+ });
+
+ test('A-N1: every deepseek recipe chat/expansion model is priced and the touchpoint costs equal canonical deepseek-flash', async () => {
+ const { deepseek } = await import('../src/core/ai/recipes/deepseek.ts');
+ const flash = CANONICAL_PRICING['deepseek:deepseek-flash'];
+ expect(deepseek.touchpoints.chat?.models?.[0]).toBe('deepseek-flash');
+ expect(deepseek.touchpoints.expansion?.models?.[0]).toBe('deepseek-flash');
+ for (const m of [...(deepseek.touchpoints.chat?.models ?? []), ...(deepseek.touchpoints.expansion?.models ?? [])]) {
+ expect({ m, priced: canonicalLookup(`deepseek:${m}`) !== undefined }).toEqual({ m, priced: true });
+ }
+ expect(deepseek.touchpoints.chat?.cost_per_1m_input_usd).toBe(flash.input);
+ expect(deepseek.touchpoints.chat?.cost_per_1m_output_usd).toBe(flash.output);
+ expect(deepseek.touchpoints.expansion?.cost_per_1m_tokens_usd).toBe(flash.input);
+ });
+
test('cross-modal panel models are all priced from canonical', () => {
// The runner now calls canonicalLookup(slot.model) directly, so presence
// here = the runner prices these. Mirrors the panel it used to inline.