Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

feat(providers): add a dedicated DeepSeek provider module

xianhongtao9dd607ab2646
diff --git a/docs/fr/providers-and-models.md b/docs/fr/providers-and-models.md
index bc362a2aa..309537310 100644
--- a/docs/fr/providers-and-models.md
+++ b/docs/fr/providers-and-models.md
@@ -54,7 +54,7 @@ class BaseLLMProvider {
| `gemini` | `openai` | cloud | `gemini-3.1-flash` | Regex nom de modèle |
| `cloudflare` | `openai` | routeur | `@cf/zai-org/glm-5.2` | Regex nom de modèle |
| `mistral` | `openai` | cloud | `mistral-large-latest` | Regex nom de modèle |
-| `deepseek` | `openai` | cloud | `deepseek-v4-flash` | Regex nom de modèle |
+| `deepseek` | `openai` | cloud | `deepseek-flash` | Regex nom de modèle |
| `xai` (Grok) | `openai` | cloud | `grok-4.3` | Regex nom de modèle |
| `nvidia` (NIM) | `openai` | routeur | `meta/llama-3.1-8b-instruct` | Regex nom de modèle |
| `groq` | `openai` | routeur | `llama-3.3-70b-versatile` | Regex nom de modèle |
@@ -225,6 +225,7 @@ Le mode Ask ignore le niveau du fournisseur et reste en lecture seule. Le mode A
| Fournisseur | Mécanisme |
|---|---|
| Compatible OpenAI | Regex sur le nom du modèle (`gpt-4o`, `gpt-5`, `claude-3`, `claude-sonnet-4`, `gemini-2.0-flash`, etc.) |
+| DeepSeek | La famille `deepseek-flash` (y compris les alias retirés `deepseek-v4-flash`) est multimodale ; `deepseek-v4-pro` et les identifiants de la génération V3 sont textuels |
| Anthropic | Patterns `claude-(3\|sonnet-4\|opus-4)` |
| Ollama | `POST /api/show` `capabilities`, avec replis historiques `projector_info` / `.vision.` |
| llama.cpp | `GET /props` → `modalities.vision`, avec Automatique / Forcer / Désactivé |
@@ -248,6 +249,33 @@ Lorsque le fournisseur actif est Anthropic, l'agent convertit les messages au fo
| Rôle `tool` | Blocs de contenu `user` + `tool_result` |
| `image_url` (URL de données) | Bloc source `image` |
+### DeepSeek
+
+Le modèle livré est `deepseek-flash` (DeepSeek-V4.1-Flash). Les identifiants retirés
+`deepseek-v4-flash` et `deepseek-v4-flash-vision-exp` sont toujours servis par le même
+modèle et facturés comme Flash : ils conservent donc le support complet (contexte 1M,
+sortie 384K, entrée d'images). Tous les autres identifiants DeepSeek — y compris
+`deepseek-v4-pro`, retiré — restent sur un profil prudent (contexte 64K, sortie 8K,
+texte uniquement) au lieu d'hériter de capacités qu'ils n'ont peut-être pas.
+
+| Aspect | Comportement |
+|---|---|
+| Format de transport | Chat Completions par défaut (`apiFormat: 'auto'`) ; l'API Responses s'active explicitement depuis le panneau Avancé |
+| Mode réflexion | Objet `thinking` au niveau supérieur plus `reasoning_effort` ; désactiver la réflexion omet complètement `reasoning_effort`. L'échelle partagée associe `minimal`→`low` et `medium`/`xhigh`→`high` |
+| Rejeu du raisonnement | `reasoning_content` est rejoué d'un tour à l'autre, car DeepSeek renvoie 400 si une requête avec `tools` l'omet |
+| Streaming | `stream_options.include_usage` à chaque requête ; l'analyseur ignore les commentaires SSE `: keep-alive` de DeepSeek |
+| Sortie structurée | Chat Completions utilise le mode JSON Object ; l'API Responses utilise un schéma JSON `text.format` pour le planificateur |
+| Images | `deepseek-flash` accepte les `image_url` (URL de données ou URL publique) dans les messages `user` |
+| Coût | Tarif hors pointe converti à 1 USD = 7,1 CNY (entrée 1, entrée en cache 0,02, sortie 4 ; pointe 2 / 0,04 / 8). Les hits de cache arrivent via le compteur de premier niveau `prompt_cache_hit_tokens` et sont facturés au tarif de lecture du cache |
+| Point de terminaison Anthropic | `https://api.deepseek.com/anthropic` fonctionne avec la carte `anthropic` intégrée en remplaçant son URL de base |
+
+Le contrat réside dans `providers/deepseek-config.js` (helpers purs et constantes) et
+`providers/deepseek.js` (`DeepSeekProvider`). Les modules partagés `openai.js` et
+`provider-compatibility.js` ne contiennent aucune connaissance DeepSeek, et
+`ProviderManager#_createProvider()` aiguille la carte `deepseek` — ou toute carte
+pointant vers `api.deepseek.com`, ou sélectionnant explicitement le preset `deepseek` —
+vers la classe dédiée.
+
---
## ProviderManager (`providers/manager.js`)
@@ -339,4 +367,4 @@ myprovider: {
},
```
-La vision est auto-détectée via une regex sur le nom du modèle. Si le fournisseur a un ensemble connu de modèles de vision, ajoutez-les à la regex dans `openai.js`. Définissez `supportsStreamUsageOptions: true` uniquement pour les fournisseurs qui acceptent `stream_options.include_usage` de style OpenAI ; laissez-le à false lorsqu'un fournisseur retourne l'utilisation sans accepter ce champ de requête.
+La vision est auto-détectée via une regex sur le nom du modèle. Si le fournisseur a un ensemble connu de modèles de vision, étendez `_modelNameSniffedVision()` dans `openai.js`, ou ajoutez une sous-classe dédiée comme le fait `providers/deepseek.js`. Définissez `supportsStreamUsageOptions: true` uniquement pour les fournisseurs qui acceptent `stream_options.include_usage` de style OpenAI ; laissez-le à false lorsqu'un fournisseur retourne l'utilisation sans accepter ce champ de requête.
diff --git a/docs/providers-and-models.md b/docs/providers-and-models.md
index 0b76f41f5..05075c888 100644
--- a/docs/providers-and-models.md
+++ b/docs/providers-and-models.md
@@ -55,7 +55,7 @@ class BaseLLMProvider {
| `gemini` | `openai` | cloud | `gemini-3.1-flash` | Model-name regex |
| `cloudflare` | `openai` | router | `@cf/zai-org/glm-5.2` | Model-name regex |
| `mistral` | `openai` | cloud | `mistral-large-latest` | Model-name regex |
-| `deepseek` | `openai` | cloud | `deepseek-v4-flash` | Model-name regex |
+| `deepseek` | `openai` | cloud | `deepseek-flash` | Model-name regex |
| `xai` (Grok) | `openai` | cloud | `grok-4.3` | Model-name regex |
| `nvidia` (NIM) | `openai` | router | `meta/llama-3.1-8b-instruct` | Model-name regex |
| `groq` | `openai` | router | `llama-3.3-70b-versatile` | Model-name regex |
@@ -299,6 +299,7 @@ Ask mode ignores provider tier and stays read-only. Act mode uses the selected t
| Provider | Mechanism |
|---|---|
| OpenAI-compatible | Regex against model name (`gpt-4o`, `gpt-5`, `claude-3`, `claude-sonnet-4`, `gemini-2.0-flash`, etc.) |
+| DeepSeek | The `deepseek-flash` family (including the retired `deepseek-v4-flash` aliases) is multimodal; `deepseek-v4-pro` and the V3-era ids are text-only |
| Anthropic | `claude-(3\|sonnet-4\|opus-4)` patterns |
| Ollama | `POST /api/show` `capabilities`, with legacy projector / `.vision.` metadata fallbacks; Auto / Force on / Off |
| llama.cpp | `GET /props` → `modalities.vision`, with Auto / Force on / Off |
@@ -322,6 +323,33 @@ When the active provider is Anthropic, the agent converts OpenAI-format messages
| `tool` role | `user` + `tool_result` content blocks |
| `image_url` (data URL) | `image` source block |
+### DeepSeek
+
+`deepseek-flash` (DeepSeek-V4.1-Flash) is the shipped model. The retired
+`deepseek-v4-flash` and `deepseek-v4-flash-vision-exp` ids still serve the same
+model and are billed as Flash, so they keep full support (1M context, 384K
+output, image input). Every other DeepSeek id — including the retired
+`deepseek-v4-pro` — stays on a conservative profile (64K context, 8K output,
+text-only) rather than inheriting capacities it may not have.
+
+| Aspect | Behaviour |
+|---|---|
+| Wire format | Chat Completions by default (`apiFormat: 'auto'`); the Responses API is an opt-in from the Advanced panel |
+| Thinking | Top-level `thinking` object plus `reasoning_effort`; disabling thinking omits `reasoning_effort` entirely. The shared UI ladder maps `minimal`→`low` and `medium`/`xhigh`→`high` |
+| Reasoning replay | `reasoning_content` is replayed across turns because DeepSeek returns 400 when a tool-carrying follow-up drops it |
+| Streaming | `stream_options.include_usage` on every request; the parser ignores DeepSeek's SSE `: keep-alive` comments |
+| Structured output | Chat Completions uses JSON Object mode; the Responses API uses `text.format` JSON Schema for the planner |
+| Images | `deepseek-flash` accepts `image_url` data URLs and public URLs in `user` messages |
+| Cost | Off-peak list price converted at 1 USD = 7.1 CNY (1 input, 0.02 cached input, 4 output; peak 2 / 0.04 / 8). Cache hits arrive as the top-level `prompt_cache_hit_tokens` counter and are priced at the cache-read rate |
+| Anthropic endpoint | `https://api.deepseek.com/anthropic` works with the built-in `anthropic` card by overriding its base URL |
+
+The contract lives in `providers/deepseek-config.js` (pure helpers and
+constants) and `providers/deepseek.js` (`DeepSeekProvider`). The shared
+`openai.js` and `provider-compatibility.js` modules carry no DeepSeek
+knowledge, and `ProviderManager#_createProvider()` dispatches the `deepseek`
+card — or any card pointed at `api.deepseek.com`, or one that explicitly selects
+the `deepseek` compatibility preset — to the dedicated class.
+
---
## ProviderManager (`providers/manager.js`)
@@ -475,4 +503,4 @@ myprovider: {
},
```
-Vision is auto-detected via model-name regex. If the provider has a known set of vision models, add them to the regex in `openai.js`. Set `supportsStreamUsageOptions: true` only for providers that accept OpenAI-style `stream_options.include_usage`; leave it false when a provider returns usage without accepting that request field.
+Vision is auto-detected via model-name regex. If the provider has a known set of vision models, extend `_modelNameSniffedVision()` in `openai.js`, or add a vendor subclass the way `providers/deepseek.js` does. Set `supportsStreamUsageOptions: true` only for providers that accept OpenAI-style `stream_options.include_usage`; leave it false when a provider returns usage without accepting that request field.
diff --git a/docs/zh-CN/providers-and-models.md b/docs/zh-CN/providers-and-models.md
index 06ef29525..aae03f0ae 100644
--- a/docs/zh-CN/providers-and-models.md
+++ b/docs/zh-CN/providers-and-models.md
@@ -54,7 +54,7 @@ class BaseLLMProvider {
| `gemini` | `openai` | 云端 | `gemini-3.1-flash` | 模型名正则 |
| `cloudflare` | `openai` | 路由器 | `@cf/zai-org/glm-5.2` | 模型名正则 |
| `mistral` | `openai` | 云端 | `mistral-large-latest` | 模型名正则 |
-| `deepseek` | `openai` | 云端 | `deepseek-v4-flash` | 模型名正则 |
+| `deepseek` | `openai` | 云端 | `deepseek-flash` | 模型名正则 |
| `xai`(Grok) | `openai` | 云端 | `grok-4.3` | 模型名正则 |
| `nvidia`(NIM) | `openai` | 路由器 | `meta/llama-3.1-8b-instruct` | 模型名正则 |
| `groq` | `openai` | 路由器 | `llama-3.3-70b-versatile` | 模型名正则 |
@@ -201,6 +201,7 @@ Ask 模式忽略提供商层级,保持只读。Act 模式使用所选层级的
| 提供商 | 机制 |
|---|---|
| OpenAI 兼容 | 根据模型名称进行正则匹配(`gpt-4o`、`gpt-5`、`claude-3`、`claude-sonnet-4`、`gemini-2.0-flash` 等) |
+| DeepSeek | `deepseek-flash` 系列(含已退役的 `deepseek-v4-flash` 别名)支持多模态;`deepseek-v4-pro` 与 V3 时代标识为纯文本 |
| Anthropic | `claude-(3\|sonnet-4\|opus-4)` 模式 |
| Ollama | `POST /api/show` 的 `capabilities`,并兼容旧版 `projector_info` / `.vision.` 元数据 |
| llama.cpp | `GET /props` → `modalities.vision`,支持自动 / 强制开启 / 关闭 |
@@ -222,6 +223,30 @@ Ask 模式忽略提供商层级,保持只读。Act 模式使用所选层级的
| `tool` 角色 | `user` + `tool_result` 内容块 |
| `image_url`(data URL) | `image` 源块 |
+### DeepSeek
+
+出厂模型是 `deepseek-flash`(DeepSeek-V4.1-Flash)。已退役的 `deepseek-v4-flash` 与
+`deepseek-v4-flash-vision-exp` 仍由同一模型承接并按 Flash 计费,因此保留完整支持
+(1M 上下文、384K 输出、图片输入)。其他 DeepSeek 标识(包括已退役的
+`deepseek-v4-pro`)保持保守配置(64K 上下文、8K 输出、纯文本),不会继承它未必具备
+的更大容量。
+
+| 方面 | 行为 |
+|---|---|
+| 线路格式 | 默认 Chat Completions(`apiFormat: 'auto'`);Responses API 需在「高级」面板显式选择 |
+| 思考模式 | 顶层 `thinking` 对象 + `reasoning_effort`;关闭思考时完全省略 `reasoning_effort`。共享 UI 档位把 `minimal` 映射为 `low`、`medium`/`xhigh` 映射为 `high` |
+| 思维链回传 | 跨轮回传 `reasoning_content`,因为带 `tools` 的后续请求丢弃它会返回 400 |
+| 流式 | 每次请求都带 `stream_options.include_usage`;解析器忽略 DeepSeek 的 SSE `: keep-alive` 注释 |
+| 结构化输出 | Chat Completions 使用 JSON Object 模式;Responses API 为规划器使用 `text.format` JSON Schema |
+| 图片 | `deepseek-flash` 接受 `user` 消息中的 `image_url`(data URL 或公网 URL) |
+| 计费 | 空闲时段单价按 1 USD = 7.1 CNY 折算(输入 1、缓存命中 0.02、输出 4;高峰 2 / 0.04 / 8)。缓存命中以顶层 `prompt_cache_hit_tokens` 返回,按缓存读取价计费 |
+| Anthropic 端点 | `https://api.deepseek.com/anthropic` 可通过覆盖内置 `anthropic` 卡片的 base URL 使用 |
+
+契约位于 `providers/deepseek-config.js`(纯函数与常量)与 `providers/deepseek.js`
+(`DeepSeekProvider`)。共享的 `openai.js` 与 `provider-compatibility.js` 不含任何
+DeepSeek 知识;`ProviderManager#_createProvider()` 会把 `deepseek` 卡片、任何指向
+`api.deepseek.com` 的卡片,或显式选择 `deepseek` 兼容性预设的卡片分派给该专用类。
+
---
## ProviderManager(`providers/manager.js`)
@@ -306,4 +331,4 @@ myprovider: {
},
```
-视觉能力通过模型名称正则自动检测。如果提供商有已知的视觉模型集,请将它们添加到 `openai.js` 的正则表达式中。仅对接受 OpenAI 风格 `stream_options.include_usage` 的提供商设置 `supportsStreamUsageOptions: true`;当提供商在不接受该请求字段的情况下返回使用量时,请将其保持为 false。
+视觉能力通过模型名称正则自动检测。如果提供商有已知的视觉模型集,请在 `openai.js` 的 `_modelNameSniffedVision()` 中扩展,或像 DeepSeek 那样新增厂商子类(`providers/deepseek.js`)。仅对接受 OpenAI 风格 `stream_options.include_usage` 的提供商设置 `supportsStreamUsageOptions: true`;当提供商在不接受该请求字段的情况下返回使用量时,请将其保持为 false。
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 7f8d1843c..3e9db3074 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -6551,11 +6551,16 @@ export class Agent extends LoopDetector {
);
// OpenAI includes cache reads and writes in its input total. Anthropic and
// Bedrock report cache reads and writes separately from regular input.
+ // DeepSeek also reports its prompt-cache hits inside the input total, but as
+ // top-level counters (`prompt_tokens = prompt_cache_hit_tokens + miss`)
+ // instead of OpenAI's nested `cached_tokens`.
let includedCacheReadTokens = positiveNumber(
usage?.prompt_tokens_details?.cached_tokens ??
usage?.input_tokens_details?.cached_tokens ??
usage?.promptTokensDetails?.cachedTokens ??
usage?.inputTokensDetails?.cachedTokens ??
+ usage?.prompt_cache_hit_tokens ??
+ usage?.promptCacheHitTokens ??
0
);
let includedCacheWriteTokens = positiveNumber(
diff --git a/src/chrome/src/providers/context-windows.js b/src/chrome/src/providers/context-windows.js
index 8a8d2b3be..1599ce99f 100644
--- a/src/chrome/src/providers/context-windows.js
+++ b/src/chrome/src/providers/context-windows.js
@@ -1,3 +1,5 @@
+import { deepSeekModelCapabilities } from './deepseek-config.js';
+
export const DEFAULT_LOCAL_CONTEXT_WINDOW = 16384;
export const DEFAULT_CLOUD_CONTEXT_WINDOW = 128000;
export const MIN_CONTEXT_WINDOW = 4096;
@@ -294,8 +296,11 @@ export function inferContextWindow(config = {}) {
// Mistral
if (/mistral-medium-(?:3\.5|2604)/.test(model)) return K256;
- // DeepSeek
- if (model.includes('deepseek-v4')) return M1;
+ // DeepSeek: 1M for the V4.1-Flash family (including the retired
+ // `deepseek-v4-flash` aliases), a conservative 64K for retired and unknown
+ // DeepSeek ids. Numbers live in deepseek-config.js.
+ const deepSeek = deepSeekModelCapabilities(model);
+ if (deepSeek) return deepSeek.contextWindow;
// xAI
if (/grok-4\.[56](?:$|[^0-9])/.test(model)) return 500000;
@@ -363,9 +368,10 @@ export function inferMaxOutputTokens(config = {}) {
if (/claude-3/.test(model)) return 4096;
if (model.includes('claude-')) return 64000;
- // DeepSeek
- if (model.includes('deepseek-v4')) return 384000;
- if (model.includes('deepseek')) return 8192;
+ // DeepSeek: 384K for the V4.1-Flash family, 8K for the retired ids (and the
+ // unsupported V4 Pro id). Numbers live in deepseek-config.js.
+ const deepSeek = deepSeekModelCapabilities(model);
+ if (deepSeek) return deepSeek.maxOutputTokens;
return null;
}
diff --git a/src/chrome/src/providers/deepseek-config.js b/src/chrome/src/providers/deepseek-config.js
new file mode 100644
index 000000000..a48996f04
--- /dev/null
+++ b/src/chrome/src/providers/deepseek-config.js
@@ -0,0 +1,209 @@
+/**
+ * DeepSeek API contract.
+ *
+ * Single owner of everything DeepSeek-specific, so the generic OpenAI-compatible
+ * provider (`openai.js`) and the shared compatibility presets
+ * (`provider-compatibility.js`) stay vendor-agnostic and only delegate here.
+ *
+ * Source of truth: https://api-docs.deepseek.com/zh-cn/ (模型 & 价格 / 思考模式 /
+ * 图像理解 / 上下文硬盘缓存 / 使用 Responses API / 限速与隔离).
+ *
+ * Deliberately dependency-free: `provider-compatibility.js` imports this module
+ * and `deepseek.js` (the provider class) imports both, so importing back would
+ * create a cycle.
+ */
+
+// Endpoints. The OpenAI-compatible API is rooted at the origin (no /v1) and the
+// Anthropic-compatible API lives under /anthropic.
+export const DEEPSEEK_BASE_URL = 'https://api.deepseek.com';
+export const DEEPSEEK_LEGACY_DEFAULT_BASE_URL = 'https://api.deepseek.com/v1';
+export const DEEPSEEK_ANTHROPIC_BASE_URL = 'https://api.deepseek.com/anthropic';
+
+// `deepseek-flash` (DeepSeek-V4.1-Flash) is the current model id. The retired
+// `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp` ids still call the same
+// model and are billed as Flash, so they keep first-class handling.
+export const DEEPSEEK_DEFAULT_MODEL = 'deepseek-flash';
+export const DEEPSEEK_LEGACY_DEFAULT_MODEL = 'deepseek-v4-flash';
+
+// 1M context, up to 384K output. The server defaults (8K non-thinking, 64K
+// thinking, 128K at `max`) only apply when no budget is sent, and WebBrain
+// always sends one, so the ceiling is the number that matters.
+export const DEEPSEEK_FLASH_CONTEXT_WINDOW = 1000000;
+export const DEEPSEEK_FLASH_MAX_OUTPUT_TOKENS = 384000;
+
+// Retired ids (`deepseek-chat`, `deepseek-reasoner`), the unsupported V4 Pro id,
+// and unknown third-party DeepSeek slugs stay on the conservative generation:
+// never over-claim capacity or vision for a model we cannot verify.
+export const DEEPSEEK_LEGACY_CONTEXT_WINDOW = 65536;
+export const DEEPSEEK_LEGACY_MAX_OUTPUT_TOKENS = 8192;
+
+function clean(value) {
+ return String(value || '').trim().toLowerCase();
+}
+
+/** Any DeepSeek model id, including router slugs such as `deepseek/deepseek-v4`. */
+export function isDeepSeekModel(model) {
+ return clean(model).includes('deepseek');
+}
+
+/**
+ * V4.1-Flash family: the current id plus every retired alias that resolves to
+ * it. Only this family is multimodal — `deepseek-v4-pro` (DeepSeek-V4-Pro-0813)
+ * and the V3-era chat/reasoner ids are text-only.
+ */
+export function isDeepSeekV41FlashModel(model) {
+ const m = clean(model);
+ return m.includes('deepseek-flash') || m.includes('deepseek-v4-flash');
+}
+
+/**
+ * Context window, output ceiling, and image input support for a DeepSeek model
+ * id. Returns null for non-DeepSeek ids so callers keep their generic fallback.
+ */
+export function deepSeekModelCapabilities(model = '') {
+ if (!isDeepSeekModel(model)) return null;
+ if (isDeepSeekV41FlashModel(model)) {
+ return {
+ contextWindow: DEEPSEEK_FLASH_CONTEXT_WINDOW,
+ maxOutputTokens: DEEPSEEK_FLASH_MAX_OUTPUT_TOKENS,
+ vision: true,
+ };
+ }
+ return {
+ contextWindow: DEEPSEEK_LEGACY_CONTEXT_WINDOW,
+ maxOutputTokens: DEEPSEEK_LEGACY_MAX_OUTPUT_TOKENS,
+ vision: false,
+ };
+}
+
+/**
+ * Whether a config targets DeepSeek's own API: the `deepseek` provider card, or
+ * any card pointed at api.deepseek.com (a proxy or a hand-made entry that opts
+ * into the native contract). Local OpenAI-compatible servers that merely serve a
+ * DeepSeek model are intentionally excluded by the caller.
+ */
+export function isDeepSeekEndpoint(config = {}) {
+ if (clean(config.providerName) === 'deepseek') return true;
+ try {
+ const url = new URL(config.baseUrl || '');
+ return (url.protocol === 'http:' || url.protocol === 'https:')
+ && url.hostname.toLowerCase() === 'api.deepseek.com';
+ } catch {
+ return false;
+ }
+}
+
+/**
+ * DeepSeek's OpenAI-compatible API is rooted at the origin, unlike most
+ * OpenAI-compatible servers whose API lives below /v1.
+ */
+export function isDeepSeekRootUrl(url) {
+ return !!url
+ && (url.protocol === 'http:' || url.protocol === 'https:')
+ && url.hostname.toLowerCase() === 'api.deepseek.com'
+ && url.pathname === '/'
+ && !url.search
+ && !url.hash;
+}
+
+/**
+ * DeepSeek's documented effort ladder is low/high/max, with compatibility
+ * aliases mapped by the server. WebBrain keeps its shared, more expressive UI
+ * ladder and translates the values DeepSeek only accepts for compatibility.
+ * (`ultra` maps to `max` upstream; the UI ladder has no `ultra`.)
+ */
+export function mappedDeepSeekReasoningEffort(effort) {
+ if (effort === 'minimal') return 'low';
+ if (effort === 'medium' || effort === 'xhigh') return 'high';
+ return effort;
+}
+
+/**
+ * Thinking-mode controls for one request.
+ *
+ * Chat Completions switches thinking with a top-level `thinking` object and
+ * controls its strength with top-level `reasoning_effort`; a disabled-thinking
+ * request must omit `reasoning_effort` entirely. The Responses API instead uses
+ * `reasoning.effort`, where `none` disables thinking.
+ *
+ * `direct` is false for local/hosted OpenAI-compatible servers that merely serve
+ * a DeepSeek model — those keep the Qwen-style chat-template switch.
+ */
+export function deepSeekThinkingExtras({
+ direct = false,
+ enabled = true,
+ effort = 'auto',
+ responses = false,
+} = {}) {
+ if (!direct) return { chat_template_kwargs: { thinking: enabled } };
+ if (responses) {
+ return { reasoning: { effort: enabled ? mappedDeepSeekReasoningEffort(effort) : 'none' } };
+ }
+ if (!enabled) return { thinking: { type: 'disabled' } };
+ return {
+ thinking: { type: 'enabled' },
+ reasoning_effort: mappedDeepSeekReasoningEffort(effort),
+ };
+}
+
+/**
+ * Per-request controls for classifier/planner calls, which need short
+ * machine-readable JSON instead of hidden reasoning. The native Chat Completions
+ * contract supports JSON Object mode only (no JSON Schema); the Responses API
+ * supports full `text.format` schemas, which the shared Responses body builder
+ * derives from `response_format.type === 'json_schema'`.
+ */
+export function deepSeekPlannerExtras({
+ direct = false,
+ responses = false,
+ includeResponseFormat = true,
+ disableThinking = true,
+ schema = null,
+ schemaName = 'webbrain_planner',
+} = {}) {
+ const body = {};
+ if (direct && disableThinking) {
+ if (responses) body.reasoning = { effort: 'none' };
+ else body.thinking = { type: 'disabled' };
+ }
+ if (!includeResponseFormat) return body;
+ if (direct && !responses) {
+ body.response_format = { type: 'json_object' };
+ return body;
+ }
+ if (direct && responses && schema) {
+ body.response_format = {
+ type: 'json_schema',
+ json_schema: {
+ name: String(schemaName || 'webbrain_planner').replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 64),
+ strict: true,
+ schema,
+ },
+ };
+ }
+ return body;
+}
+
+/**
+ * Vision probe controls. DeepSeek ignores `temperature` while thinking, and a
+ * visible reasoning channel would spend the whole caption budget, so thinking is
+ * switched off natively before the probe runs.
+ */
+export function deepSeekVisionExtras(maxTokens = 800, { responses = false } = {}) {
+ return {
+ maxTokens,
+ temperature: 0,
+ extraBody: responses ? { reasoning: { effort: 'none' } } : { thinking: { type: 'disabled' } },
+ };
+}
+
+/**
+ * DeepSeek's disabled-thinking contract omits `reasoning_effort` entirely, so a
+ * per-call planner/vision override must clear an effort inherited from the
+ * configured compatibility preset.
+ */
+export function stripDisabledDeepSeekReasoningEffort(body) {
+ if (!body || typeof body !== 'object' || Array.isArray(body)) return body;
+ if (body.thinking?.type === 'disabled') delete body.reasoning_effort;
+ return body;
+}
diff --git a/src/chrome/src/providers/deepseek.js b/src/chrome/src/providers/deepseek.js
new file mode 100644
index 000000000..45e859977
--- /dev/null
+++ b/src/chrome/src/providers/deepseek.js
@@ -0,0 +1,47 @@
+import { OpenAICompatibleProvider } from './openai.js';
+import { isDirectDeepSeekConfig } from './provider-compatibility.js';
+import {
+ deepSeekModelCapabilities,
+ isDeepSeekEndpoint,
+} from './deepseek-config.js';
+
+/**
+ * DeepSeek provider (`type: 'openai'`, dispatched by `providers/manager.js`).
+ *
+ * Owns the DeepSeek-specific protocol behaviour so the generic
+ * OpenAI-compatible provider stays vendor-agnostic:
+ * - vision capability for the V4.1-Flash family (and its retired aliases),
+ * - `stream_options.include_usage` on every request,
+ * - cross-turn `reasoning_content` replay, which DeepSeek requires whenever a
+ * request carries `tools` (omitting it returns 400).
+ *
+ * The request-body contract (native `thinking` / `reasoning_effort`, the
+ * Responses-API shape, planner and vision overrides) lives in
+ * `deepseek-config.js`, because it is also consumed by call sites that only have
+ * a plain provider config (the planner and the connection tests).
+ */
+export class DeepSeekProvider extends OpenAICompatibleProvider {
+ /** True when this card speaks DeepSeek's own API, not a local lookalike. */
+ _isDirectDeepSeek() {
+ return isDirectDeepSeekConfig({
+ ...this.config,
+ providerName: this.config.providerName || this.name,
+ baseUrl: this.baseUrl,
+ model: this.model,
+ });
+ }
+
+ _modelNameSniffedVision(model) {
+ const capabilities = deepSeekModelCapabilities(model);
+ return capabilities ? capabilities.vision : super._modelNameSniffedVision(model);
+ }
+
+ _shouldRequestStreamUsage() {
+ if (isDeepSeekEndpoint(this.config)) return true;
+ return super._shouldRequestStreamUsage();
+ }
+
+ _supportsReasoningContentReplay(_options = {}) {
+ return this._isDirectDeepSeek();
+ }
+}
diff --git a/src/chrome/src/providers/manager.js b/src/chrome/src/providers/manager.js
index 0e3760685..d27251020 100644
--- a/src/chrome/src/providers/manager.js
+++ b/src/chrome/src/providers/manager.js
@@ -1,5 +1,6 @@
import { LlamaCppProvider } from './llamacpp.js';
import { OpenAICompatibleProvider } from './openai.js';
+import { DeepSeekProvider } from './deepseek.js';
import { AzureOpenAIProvider } from './azure-openai.js';
import { AnthropicProvider, AnthropicOAuthProvider } from './anthropic.js';
import { VertexAnthropicProvider } from './vertex-anthropic.js';
@@ -24,6 +25,12 @@ import {
webgpuModelRuntime,
} from './webgpu.js';
import { ADDITIONAL_PROVIDER_DEFAULTS } from './provider-catalog.js';
+import {
+ DEEPSEEK_BASE_URL,
+ DEEPSEEK_DEFAULT_MODEL,
+ DEEPSEEK_LEGACY_DEFAULT_BASE_URL,
+ DEEPSEEK_LEGACY_DEFAULT_MODEL,
+} from './deepseek-config.js';
// Static, NOT dynamic: this module runs in the MV3 service worker, where
// `await import()` throws "import() is disallowed on ServiceWorkerGlobalScope".
// The provider modules above already import this statically, so it's in the SW
@@ -54,6 +61,7 @@ import {
shouldApplyDetectedContextWindow,
} from './context-windows.js';
import {
+ isDirectDeepSeekConfig,
normalizeOpenAICompatibleBaseUrl,
openAiCompatiblePayloadError,
unsupportedVisionGenerationControl,
@@ -76,9 +84,6 @@ const OPENROUTER_DEFAULT_MODEL = 'openrouter/free';
const OPENROUTER_LEGACY_DEFAULT_MODEL = 'stepfun/step-3.7-flash';
const OPENAI_DEFAULT_MODEL = 'gpt-5.6-terra';
const OPENAI_LEGACY_DEFAULT_MODEL = 'gpt-5.5';
-const DEEPSEEK_DEFAULT_BASE_URL = 'https://api.deepseek.com';
-const DEEPSEEK_LEGACY_DEFAULT_BASE_URL = 'https://api.deepseek.com/v1';
-const DEEPSEEK_DEFAULT_MODEL = 'deepseek-v4-flash';
const OPENCODE_LEGACY_DEFAULT_MODEL = 'ring-2.6-1t-free';
const SUPPORTED_PROVIDER_TYPES = new Set(['llamacpp', 'webgpu', 'openai', 'azure_openai', 'aws_bedrock', 'anthropic', 'anthropic_oauth', 'vertex_anthropic']);
const SAFE_PROVIDER_ID_RE = /^[A-Za-z0-9_-]+$/;
@@ -767,12 +772,17 @@ export class ProviderManager {
category: 'cloud',
label: 'DeepSeek',
providerName: 'deepseek',
- baseUrl: DEEPSEEK_DEFAULT_BASE_URL,
+ baseUrl: DEEPSEEK_BASE_URL,
model: DEEPSEEK_DEFAULT_MODEL,
contextWindow: 1000000,
maxOutputTokens: 384000,
- inputCostPerMillionUsd: 0.27,
- outputCostPerMillionUsd: 1.1,
+ // `deepseek-flash` off-peak list price, CNY per 1M tokens: 1 input,
+ // 0.02 cache-hit input, 4 output (peak is 2 / 0.04 / 8), converted at
+ // 1 USD = 7.1 CNY.
+ // https://api-docs.deepseek.com/zh-cn/quick_start/pricing
+ inputCostPerMillionUsd: 0.14,
+ cacheReadCostPerMillionUsd: 0.0028,
+ outputCostPerMillionUsd: 0.56,
supportsStreamUsageOptions: true,
supportsAskStreaming: true,
apiKey: '',
@@ -957,18 +967,26 @@ export class ProviderManager {
model: OPENROUTER_DEFAULT_MODEL,
};
}
+ // DeepSeek renamed its shipped default model to `deepseek-flash`. The
+ // retired `deepseek-v4-flash` id (plus the old /v1 base path and the
+ // pre-V4.1 prices) identifies a card the user never touched, so the rename
+ // and the new price sheet can be applied without overriding a real choice.
const storedDeepSeek = migrated.deepseek;
const deepSeekBaseUrl = String(storedDeepSeek?.baseUrl || '').replace(/\/+$/, '');
- const untouchedDeepSeekDefault = storedDeepSeek?.model === DEEPSEEK_DEFAULT_MODEL
+ const untouchedDeepSeekDefault = storedDeepSeek?.model === DEEPSEEK_LEGACY_DEFAULT_MODEL
&& storedDeepSeek?.configured !== true
&& !String(storedDeepSeek?.apiKey || '').trim()
- && deepSeekBaseUrl === DEEPSEEK_LEGACY_DEFAULT_BASE_URL
+ && (deepSeekBaseUrl === DEEPSEEK_LEGACY_DEFAULT_BASE_URL || deepSeekBaseUrl === DEEPSEEK_BASE_URL)
&& (storedDeepSeek?.inputCostPerMillionUsd == null || Number(storedDeepSeek.inputCostPerMillionUsd) === 0.27)
&& (storedDeepSeek?.outputCostPerMillionUsd == null || Number(storedDeepSeek.outputCostPerMillionUsd) === 1.1);
if (untouchedDeepSeekDefault) {
migrated.deepseek = {
...storedDeepSeek,
- baseUrl: DEEPSEEK_DEFAULT_BASE_URL,
+ baseUrl: DEEPSEEK_BASE_URL,
+ model: DEEPSEEK_DEFAULT_MODEL,
+ inputCostPerMillionUsd: 0.14,
+ cacheReadCostPerMillionUsd: 0.0028,
+ outputCostPerMillionUsd: 0.56,
};
}
this._migrateUntouchedShippedDefaults(migrated);
@@ -1240,7 +1258,12 @@ export class ProviderManager {
case 'webgpu':
return new WebGPUProvider(normalizedConfig);
case 'openai':
- return new OpenAICompatibleProvider(normalizedConfig);
+ // The DeepSeek card (and any card pointed at DeepSeek's own API, or one
+ // that explicitly opts into the `deepseek` preset) gets the dedicated
+ // provider; every other OpenAI-compatible endpoint stays generic.
+ return isDirectDeepSeekConfig(normalizedConfig)
+ ? new DeepSeekProvider(normalizedConfig)
+ : new OpenAICompatibleProvider(normalizedConfig);
case 'azure_openai':
return new AzureOpenAIProvider(normalizedConfig);
case 'aws_bedrock':
diff --git a/src/chrome/src/providers/openai.js b/src/chrome/src/providers/openai.js
index ed0e31bb0..de2c2dcdd 100644
--- a/src/chrome/src/providers/openai.js
+++ b/src/chrome/src/providers/openai.js
@@ -1,7 +1,6 @@
import { BaseLLMProvider } from './base.js';
import { fetchWithFallback } from './fetch-with-fallback.js';
import {
- isDirectDeepSeekConfig,
isNewOpenAIContractConfig,
isOfficialOpenAIConfig,
isOpenCodeZenConfig,
@@ -136,9 +135,21 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
// Otherwise sniff the model name for known vision-capable identifiers.
// Qwen went natively multimodal starting at 3.5 (no separate -VL
// checkpoint needed), so qwen3\.[5-9] catches those alongside the
- // older qwen*vl-suffixed lines.
+ // older qwen*vl-suffixed lines. Vendor-specific families extend
+ // `_modelNameSniffedVision` (see the vendor subclass in this folder)
+ // rather than widening this shared regex.
const m = (this.config.model || '').toLowerCase();
- return /gpt-4o|gpt-4\.1|gpt-4-turbo|gpt-5|claude|gemini|grok|minimax-m3|kimi-k(?:-?3|2\.[5-9])|llava|qwen.*vl|qwen2.*vl|qwen3.*vl|qwen3\.[5-9]|qwen3p8-27b|pixtral|llama.*vision|gemma.*vision|gemma-?[34]|step-3|deepseek-v4-flash-vision-exp/.test(m);
+ return this._modelNameSniffedVision(m);
+ }
+
+ /**
+ * Shared model-name vision sniffing. Subclasses override this hook so a
+ * vendor-specific allow/deny list never has to duplicate the explicit
+ * user-override and auto-detection precedence handled by the
+ * `supportsVision` getter above.
+ */
+ _modelNameSniffedVision(model) {
+ return /gpt-4o|gpt-4\.1|gpt-4-turbo|gpt-5|claude|gemini|grok|minimax-m3|kimi-k(?:-?3|2\.[5-9])|llava|qwen.*vl|qwen2.*vl|qwen3.*vl|qwen3\.[5-9]|qwen3p8-27b|pixtral|llama.*vision|gemma.*vision|gemma-?[34]|step-3/.test(String(model || ''));
}
get useCompactPrompt() {
@@ -321,7 +332,6 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
if (!providerName && this.baseUrl === 'https://api.openai.com/v1') return true;
return providerName === 'openai'
|| providerName === 'openrouter'
- || providerName === 'deepseek'
|| providerName === 'gemini';
}
@@ -395,12 +405,6 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
}
_supportsReasoningContentReplay(options = {}) {
- if (isDirectDeepSeekConfig({
- ...this.config,
- providerName: this.config.providerName || this.name,
- baseUrl: this.baseUrl,
- model: this.model,
- })) return true;
if (String(this.config.providerName || '').trim().toLowerCase() !== 'kimi') return false;
const model = String(this.model || '').trim().toLowerCase();
if (KIMI_PRESERVED_THINKING_MODELS.has(model)) return true;
diff --git a/src/chrome/src/providers/provider-compatibility.js b/src/chrome/src/providers/provider-compatibility.js
index f599a3550..cf2fcd874 100644
--- a/src/chrome/src/providers/provider-compatibility.js
+++ b/src/chrome/src/providers/provider-compatibility.js
@@ -1,3 +1,12 @@
+import {
+ deepSeekPlannerExtras,
+ deepSeekThinkingExtras,
+ deepSeekVisionExtras,
+ isDeepSeekEndpoint,
+ isDeepSeekRootUrl,
+ stripDisabledDeepSeekReasoningEffort,
+} from './deepseek-config.js';
+
const COMPATIBILITY_PRESETS = new Set(['auto', 'openai', 'qwen', 'deepseek', 'openrouter', 'custom']);
const REASONING_EFFORTS = new Set(['auto', 'off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
const SYSTEM_PROMPT_ROLES = new Set(['auto', 'system', 'developer']);
@@ -96,11 +105,7 @@ export function normalizeOpenAICompatibleBaseUrl(value) {
const url = new URL(trimmed);
// DeepSeek's OpenAI-compatible endpoint is rooted at the origin, unlike
// most OpenAI-compatible servers whose API lives below /v1.
- if (url.hostname.toLowerCase() === 'api.deepseek.com' &&
- (url.protocol === 'http:' || url.protocol === 'https:') &&
- url.pathname === '/' && !url.search && !url.hash) {
- return trimmed;
- }
+ if (isDeepSeekRootUrl(url)) return trimmed;
if ((url.protocol === 'http:' || url.protocol === 'https:')
&& url.pathname === '/'
&& !url.search
@@ -128,10 +133,11 @@ export function visionGenerationOptions(maxTokens = 800, {
const extraBody = {};
if (reasoningControl) {
if (isDirectDeepSeekConfig(providerConfig || {})) {
- // DeepSeek does not use the local Qwen/LM Studio template controls. Its
- // native Chat Completions switch is a top-level `thinking` object.
- extraBody.thinking = { type: 'disabled' };
- return { maxTokens, temperature: 0, extraBody };
+ // DeepSeek does not use the local Qwen/LM Studio template controls; its
+ // native thinking switch is owned by the DeepSeek contract module.
+ return deepSeekVisionExtras(maxTokens, {
+ responses: shouldUseOpenAIResponsesApi(providerConfig || {}),
+ });
}
// LM Studio 0.4.8+ honors these fields for Chat Completions. They prevent
// Qwen vision models from spending the entire output budget in a hidden
@@ -148,15 +154,19 @@ export function unsupportedVisionGenerationControl(error) {
return /reasoning_effort|reasoning_tokens|chat_template_kwargs|enable_thinking/i.test(message);
}
+/**
+ * Whether a config speaks DeepSeek's own API contract rather than a
+ * DeepSeek-flavoured OpenAI-compatible server. Local servers and the local
+ * runtime provider names are always excluded; an explicit `deepseek` preset in
+ * the Advanced panel opts a custom endpoint in. The DeepSeek-specific endpoint
+ * knowledge lives in `deepseek-config.js`.
+ */
export function isDirectDeepSeekConfig(config = {}) {
const providerName = clean(config.providerName);
if (clean(config.category) === 'local' || LOCAL_OPENAI_COMPAT_PROVIDER_NAMES.has(providerName)) {
return false;
}
- if (providerName === 'deepseek') return true;
- try {
- if (new URL(config.baseUrl || '').hostname.toLowerCase() === 'api.deepseek.com') return true;
- } catch {}
+ if (isDeepSeekEndpoint(config)) return true;
return normalizeProviderCompatibility(config).preset === 'deepseek';
}
@@ -363,15 +373,6 @@ function mappedReasoningEffort(effort, preset) {
return effort;
}
-function mappedDeepSeekReasoningEffort(effort) {
- // DeepSeek's public ladder is low/high/max. Keep the shared UI ladder
- // expressive while translating values that DeepSeek only accepts for
- // compatibility (medium and xhigh both mean high in its API).
- if (effort === 'minimal') return 'low';
- if (effort === 'medium' || effort === 'xhigh') return 'high';
- return effort;
-}
-
export function compatibilityRequestBody(config = {}) {
const compat = normalizeProviderCompatibility(config);
if (compat.reasoningEffort === 'auto') return {};
@@ -386,14 +387,14 @@ export function compatibilityRequestBody(config = {}) {
};
}
if (preset === 'deepseek') {
- if (!isDirectDeepSeekConfig(config)) {
- return { chat_template_kwargs: { thinking: enabled } };
- }
- if (!enabled) return { thinking: { type: 'disabled' } };
- return {
- thinking: { type: 'enabled' },
- reasoning_effort: mappedDeepSeekReasoningEffort(compat.reasoningEffort),
- };
+ // The native contract (thinking object, effort ladder, Responses shape) and
+ // the hosted/local template fallback are both owned by deepseek-config.js.
+ return deepSeekThinkingExtras({
+ direct: isDirectDeepSeekConfig(config),
+ enabled,
+ effort: compat.reasoningEffort,
+ responses: shouldUseOpenAIResponsesApi(config),
+ });
}
if (preset === 'openrouter') {
return enabled
@@ -432,11 +433,22 @@ export function plannerRequestBody(config = {}, {
const isDirectDeepSeek = isDirectDeepSeekConfig(config) && !isLocalOpenAICompat;
const body = {};
+ if (isDirectDeepSeek) {
+ // DeepSeek owns its classifier controls: the native thinking switch on Chat
+ // Completions (JSON Object mode only) and `reasoning.effort` on Responses.
+ return deepSeekPlannerExtras({
+ direct: true,
+ responses: shouldUseOpenAIResponsesApi(config),
+ includeResponseFormat,
+ disableThinking,
+ schema,
+ schemaName,
+ });
+ }
+
if (disableThinking) {
if (preset === 'openrouter') {
body.reasoning = { enabled: false };
- } else if (isDirectDeepSeek) {
- body.thinking = { type: 'disabled' };
} else if ((preset === 'qwen' && isLocalOpenAICompat) || providerName === 'vllm' || providerName === 'sglang') {
body.chat_template_kwargs = { enable_thinking: false };
} else if (preset === 'openai' && shouldUseOpenAIResponsesApi(config)) {
@@ -447,11 +459,6 @@ export function plannerRequestBody(config = {}, {
}
if (!includeResponseFormat) return body;
- if (isDirectDeepSeek) {
- // The direct DeepSeek API supports JSON Object mode, not JSON Schema.
- body.response_format = { type: 'json_object' };
- return body;
- }
if (schema && STRUCTURED_OUTPUT_PROVIDER_NAMES.has(providerName)) {
body.response_format = {
type: 'json_schema',
@@ -485,12 +492,10 @@ export function mergeProviderRequestBody(body, config = {}, perRequestExtraBody
result[key] = isPlainObject(value) || Array.isArray(value) ? safeClone(value) : value;
}
}
- // DeepSeek's disabled-thinking contract omits reasoning_effort entirely.
- // Per-call planner and vision overrides must clear an effort inherited from
- // the configured compatibility preset.
- if (isDirectDeepSeekConfig(config) && result.thinking?.type === 'disabled') {
- delete result.reasoning_effort;
- }
+ // DeepSeek's disabled-thinking contract omits reasoning_effort entirely, so a
+ // per-call planner/vision override must clear an effort inherited from the
+ // configured compatibility preset (see deepseek-config.js).
+ if (isDirectDeepSeekConfig(config)) stripDisabledDeepSeekReasoningEffort(result);
return result;
}
diff --git a/src/chrome/src/trace/privacy.js b/src/chrome/src/trace/privacy.js
index 4c39ae0dd..a78434f16 100644
--- a/src/chrome/src/trace/privacy.js
+++ b/src/chrome/src/trace/privacy.js
@@ -51,7 +51,7 @@ function pick(source, fields) {
function projectUsage(usage) {
return pick(usage, [
'prompt_tokens', 'completion_tokens', 'input_tokens', 'output_tokens',
- 'cached_tokens', 'cost',
+ 'cached_tokens', 'prompt_cache_hit_tokens', 'cost',
]);
}
diff --git a/src/chrome/src/ui/locales/ar.js b/src/chrome/src/ui/locales/ar.js
index 473c7beb7..c77139b78 100644
--- a/src/chrome/src/ui/locales/ar.js
+++ b/src/chrome/src/ui/locales/ar.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'عنوان الخادم',
'st.provider.field.api_base_url': 'عنوان API الأساسي',
+ 'st.provider.field.api_format': 'تنسيق API',
'st.provider.field.api_key': 'مفتاح API',
'st.provider.field.model': 'النموذج',
'st.provider.field.model_optional': 'النموذج (اختياري)',
diff --git a/src/chrome/src/ui/locales/bn.js b/src/chrome/src/ui/locales/bn.js
index b3fa4bc94..d69ff52b7 100644
--- a/src/chrome/src/ui/locales/bn.js
+++ b/src/chrome/src/ui/locales/bn.js
@@ -789,6 +789,7 @@ export default {
'st.provider.field.server_url': "সার্ভার URL",
'st.provider.field.api_base_url': "API বেস URL",
+ 'st.provider.field.api_format': "API ফরম্যাট",
'st.provider.field.api_key': "API কী",
'st.provider.field.model': "মডেল",
'st.provider.field.model_optional': "মডেল (ঐচ্ছিক)",
diff --git a/src/chrome/src/ui/locales/de.js b/src/chrome/src/ui/locales/de.js
index 83c4255cd..90b773849 100644
--- a/src/chrome/src/ui/locales/de.js
+++ b/src/chrome/src/ui/locales/de.js
@@ -726,6 +726,7 @@ export default {
'st.providers.compat.value.developer': 'Entwickler',
'st.provider.field.server_url': 'Server-URL',
'st.provider.field.api_base_url': 'API-Basis-URL',
+ 'st.provider.field.api_format': 'API-Format',
'st.provider.field.api_key': 'API-Schlüssel',
'st.provider.field.model': 'Modell',
'st.provider.field.model_optional': 'Modell (optional)',
diff --git a/src/chrome/src/ui/locales/en.js b/src/chrome/src/ui/locales/en.js
index 21621ada4..4f0886dff 100644
--- a/src/chrome/src/ui/locales/en.js
+++ b/src/chrome/src/ui/locales/en.js
@@ -790,6 +790,7 @@ export default {
'st.provider.field.server_url': 'Server URL',
'st.provider.field.api_base_url': 'API Base URL',
+ 'st.provider.field.api_format': 'API format',
'st.provider.field.api_key': 'API Key',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (optional)',
diff --git a/src/chrome/src/ui/locales/es.js b/src/chrome/src/ui/locales/es.js
index 4624af64b..0ce0005b6 100644
--- a/src/chrome/src/ui/locales/es.js
+++ b/src/chrome/src/ui/locales/es.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL del servidor',
'st.provider.field.api_base_url': 'URL base de la API',
+ 'st.provider.field.api_format': 'Formato de API',
'st.provider.field.api_key': 'Clave de API',
'st.provider.field.model': 'Modelo',
'st.provider.field.model_optional': 'Modelo (opcional)',
diff --git a/src/chrome/src/ui/locales/fa.js b/src/chrome/src/ui/locales/fa.js
index 5c72adbae..08e77ce61 100644
--- a/src/chrome/src/ui/locales/fa.js
+++ b/src/chrome/src/ui/locales/fa.js
@@ -789,6 +789,7 @@ export default {
'st.provider.field.server_url': "آدرس سرور",
'st.provider.field.api_base_url': "URL پایه API",
+ 'st.provider.field.api_format': "قالب API",
'st.provider.field.api_key': "کلید API",
'st.provider.field.model': "مدل",
'st.provider.field.model_optional': "مدل (اختیاری)",
diff --git a/src/chrome/src/ui/locales/fr.js b/src/chrome/src/ui/locales/fr.js
index b1ef815ce..abf1cbf5b 100644
--- a/src/chrome/src/ui/locales/fr.js
+++ b/src/chrome/src/ui/locales/fr.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL du serveur',
'st.provider.field.api_base_url': 'URL de base de l\'API',
+ 'st.provider.field.api_format': 'Format de l\'API',
'st.provider.field.api_key': 'Clé d\'API',
'st.provider.field.model': 'Modèle',
'st.provider.field.model_optional': 'Modèle (facultatif)',
diff --git a/src/chrome/src/ui/locales/he.js b/src/chrome/src/ui/locales/he.js
index 9641b00fb..3c1282cde 100644
--- a/src/chrome/src/ui/locales/he.js
+++ b/src/chrome/src/ui/locales/he.js
@@ -701,6 +701,7 @@ export default {
"st.skills.error.add_failed": "לא ניתן להוסיף מיומנות.",
"st.provider.field.server_url": "שרת URL",
"st.provider.field.api_base_url": "API בָּסִיס URL",
+ "st.provider.field.api_format": "פורמט API",
"st.provider.field.api_key": "מפתח API",
"st.provider.field.model": "מודל",
"st.provider.field.model_optional": "מודל (אופציונלי)",
diff --git a/src/chrome/src/ui/locales/hi.js b/src/chrome/src/ui/locales/hi.js
index 6b3975f10..3e5272f48 100644
--- a/src/chrome/src/ui/locales/hi.js
+++ b/src/chrome/src/ui/locales/hi.js
@@ -789,6 +789,7 @@ export default {
'st.provider.field.server_url': "सर्वर यूआरएल",
'st.provider.field.api_base_url': "एपीआई बेस यूआरएल",
+ 'st.provider.field.api_format': "एपीआई प्रारूप",
'st.provider.field.api_key': "एपीआई कुंजी",
'st.provider.field.model': "मॉडल",
'st.provider.field.model_optional': "मॉडल (वैकल्पिक)",
diff --git a/src/chrome/src/ui/locales/id.js b/src/chrome/src/ui/locales/id.js
index 9b435e6c7..1f57ac12a 100644
--- a/src/chrome/src/ui/locales/id.js
+++ b/src/chrome/src/ui/locales/id.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL server',
'st.provider.field.api_base_url': 'URL dasar API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Kunci API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (opsional)',
diff --git a/src/chrome/src/ui/locales/ja.js b/src/chrome/src/ui/locales/ja.js
index 783c6eb22..1f4df5975 100644
--- a/src/chrome/src/ui/locales/ja.js
+++ b/src/chrome/src/ui/locales/ja.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'サーバー URL',
'st.provider.field.api_base_url': 'API ベース URL',
+ 'st.provider.field.api_format': 'API 形式',
'st.provider.field.api_key': 'API キー',
'st.provider.field.model': 'モデル',
'st.provider.field.model_optional': 'モデル(任意)',
diff --git a/src/chrome/src/ui/locales/ko.js b/src/chrome/src/ui/locales/ko.js
index 24ecab22e..562f0d5d4 100644
--- a/src/chrome/src/ui/locales/ko.js
+++ b/src/chrome/src/ui/locales/ko.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': '서버 URL',
'st.provider.field.api_base_url': 'API 기본 URL',
+ 'st.provider.field.api_format': 'API 형식',
'st.provider.field.api_key': 'API 키',
'st.provider.field.model': '모델',
'st.provider.field.model_optional': '모델 (선택)',
diff --git a/src/chrome/src/ui/locales/ms.js b/src/chrome/src/ui/locales/ms.js
index d480ab8c8..276b63fce 100644
--- a/src/chrome/src/ui/locales/ms.js
+++ b/src/chrome/src/ui/locales/ms.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL pelayan',
'st.provider.field.api_base_url': 'URL asas API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Kunci API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (pilihan)',
diff --git a/src/chrome/src/ui/locales/nl.js b/src/chrome/src/ui/locales/nl.js
index ab64f5421..e28a4b1f2 100644
--- a/src/chrome/src/ui/locales/nl.js
+++ b/src/chrome/src/ui/locales/nl.js
@@ -702,6 +702,7 @@ export default {
'st.skills.error.add_failed': 'Vaardigheid kon niet worden toegevoegd.',
'st.provider.field.server_url': 'Server-URL',
'st.provider.field.api_base_url': 'API-basis-URL',
+ 'st.provider.field.api_format': 'API-formaat',
'st.provider.field.api_key': 'API-sleutel',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (optioneel)',
diff --git a/src/chrome/src/ui/locales/pl.js b/src/chrome/src/ui/locales/pl.js
index a880ee370..2ff2a8566 100644
--- a/src/chrome/src/ui/locales/pl.js
+++ b/src/chrome/src/ui/locales/pl.js
@@ -540,6 +540,7 @@ export default {
'st.providers.webbrain_note.privacy_link': 'Polityka prywatności',
'st.provider.field.server_url': 'Adres URL serwera',
'st.provider.field.api_base_url': 'Bazowy adres URL API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Klucz API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (opcjonalnie)',
diff --git a/src/chrome/src/ui/locales/pt.js b/src/chrome/src/ui/locales/pt.js
index 20d85947d..541c71e3e 100644
--- a/src/chrome/src/ui/locales/pt.js
+++ b/src/chrome/src/ui/locales/pt.js
@@ -789,6 +789,7 @@ export default {
'st.provider.field.server_url': "URL do servidor",
'st.provider.field.api_base_url': "URL base da API",
+ 'st.provider.field.api_format': "Formato da API",
'st.provider.field.api_key': "Chave de API",
'st.provider.field.model': "Modelo",
'st.provider.field.model_optional': "Modelo (opcional)",
diff --git a/src/chrome/src/ui/locales/ru.js b/src/chrome/src/ui/locales/ru.js
index 285b7b2db..38a40c32e 100644
--- a/src/chrome/src/ui/locales/ru.js
+++ b/src/chrome/src/ui/locales/ru.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL сервера',
'st.provider.field.api_base_url': 'Базовый URL API',
+ 'st.provider.field.api_format': 'Формат API',
'st.provider.field.api_key': 'API-ключ',
'st.provider.field.model': 'Модель',
'st.provider.field.model_optional': 'Модель (необязательно)',
diff --git a/src/chrome/src/ui/locales/th.js b/src/chrome/src/ui/locales/th.js
index e6e4830a8..0774b57f8 100644
--- a/src/chrome/src/ui/locales/th.js
+++ b/src/chrome/src/ui/locales/th.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL เซิร์ฟเวอร์',
'st.provider.field.api_base_url': 'URL ฐานของ API',
+ 'st.provider.field.api_format': 'รูปแบบ API',
'st.provider.field.api_key': 'คีย์ API',
'st.provider.field.model': 'โมเดล',
'st.provider.field.model_optional': 'โมเดล (ไม่บังคับ)',
diff --git a/src/chrome/src/ui/locales/tl.js b/src/chrome/src/ui/locales/tl.js
index 0a9aa1ba4..7bcfc74c0 100644
--- a/src/chrome/src/ui/locales/tl.js
+++ b/src/chrome/src/ui/locales/tl.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'Server URL',
'st.provider.field.api_base_url': 'API Base URL',
+ 'st.provider.field.api_format': 'Format ng API',
'st.provider.field.api_key': 'API Key',
'st.provider.field.model': 'Modelo',
'st.provider.field.model_optional': 'Modelo (opsyonal)',
diff --git a/src/chrome/src/ui/locales/tr.js b/src/chrome/src/ui/locales/tr.js
index 90dc4ffe0..bd2b26dfa 100644
--- a/src/chrome/src/ui/locales/tr.js
+++ b/src/chrome/src/ui/locales/tr.js
@@ -370,6 +370,7 @@ export default {
'st.provider.field.server_url': 'Sunucu URL\'si',
'st.provider.field.api_base_url': 'API temel URL\'si',
+ 'st.provider.field.api_format': 'API biçimi',
'st.provider.field.api_key': 'API anahtarı',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (isteğe bağlı)',
diff --git a/src/chrome/src/ui/locales/uk.js b/src/chrome/src/ui/locales/uk.js
index f0b7ac2db..0bd2eccfe 100644
--- a/src/chrome/src/ui/locales/uk.js
+++ b/src/chrome/src/ui/locales/uk.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': 'URL сервера',
'st.provider.field.api_base_url': 'Базовий URL API',
+ 'st.provider.field.api_format': 'Формат API',
'st.provider.field.api_key': 'API-ключ',
'st.provider.field.model': 'Модель',
'st.provider.field.model_optional': 'Модель (необов\'язково)',
diff --git a/src/chrome/src/ui/locales/vi.js b/src/chrome/src/ui/locales/vi.js
index 2dcbe53d8..004cdfdea 100644
--- a/src/chrome/src/ui/locales/vi.js
+++ b/src/chrome/src/ui/locales/vi.js
@@ -789,6 +789,7 @@ export default {
'st.provider.field.server_url': "URL máy chủ",
'st.provider.field.api_base_url': "URL cơ sở API",
+ 'st.provider.field.api_format': "Định dạng API",
'st.provider.field.api_key': "Khóa API",
'st.provider.field.model': "người mẫu",
'st.provider.field.model_optional': "Mô hình (tùy chọn)",
diff --git a/src/chrome/src/ui/locales/zh.js b/src/chrome/src/ui/locales/zh.js
index 22d593ab2..49a0cb410 100644
--- a/src/chrome/src/ui/locales/zh.js
+++ b/src/chrome/src/ui/locales/zh.js
@@ -331,6 +331,7 @@ export default {
'st.provider.field.server_url': '服务器 URL',
'st.provider.field.api_base_url': 'API 基础 URL',
+ 'st.provider.field.api_format': 'API 格式',
'st.provider.field.api_key': 'API 密钥',
'st.provider.field.model': '模型',
'st.provider.field.model_optional': '模型(可选)',
diff --git a/src/chrome/src/ui/settings.js b/src/chrome/src/ui/settings.js
index fb237a7ea..f4ee43c4e 100644
--- a/src/chrome/src/ui/settings.js
+++ b/src/chrome/src/ui/settings.js
@@ -2927,9 +2927,17 @@ function renderProviders() {
deepseek: {
fields: [
{ key: 'apiKey', labelKey: 'st.provider.field.api_key', type: 'password', placeholder: 'sk-...' },
- { key: 'model', labelKey: 'st.provider.field.model', type: 'text', placeholder: 'deepseek-v4-flash',
- suggestions: ['deepseek-v4-flash', 'deepseek-v4-pro', 'deepseek-v4-flash-vision-exp'] },
+ { key: 'model', labelKey: 'st.provider.field.model', type: 'text', placeholder: 'deepseek-flash',
+ suggestions: ['deepseek-flash', 'deepseek-v4-flash'] },
{ key: 'baseUrl', labelKey: 'st.provider.field.api_base_url', type: 'text', placeholder: 'https://api.deepseek.com' },
+ // Chat Completions is the default wire format; DeepSeek's Responses API
+ // is an opt-in that mainly adds JSON-schema structured output.
+ { key: 'apiFormat', labelKey: 'st.provider.field.api_format', type: 'select', collapsed: true,
+ options: [
+ { value: 'auto', label: 'Chat Completions (default)' },
+ { value: 'chat', label: 'Chat Completions' },
+ { value: 'responses', label: 'Responses API' },
+ ] },
...COST_ESTIMATE_FIELDS,
],
},
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 73c1e0e97..3d5ea8a84 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -6332,11 +6332,16 @@ export class Agent extends LoopDetector {
);
// OpenAI includes cache reads and writes in its input total. Anthropic and
// Bedrock report cache reads and writes separately from regular input.
+ // DeepSeek also reports its prompt-cache hits inside the input total, but as
+ // top-level counters (`prompt_tokens = prompt_cache_hit_tokens + miss`)
+ // instead of OpenAI's nested `cached_tokens`.
let includedCacheReadTokens = positiveNumber(
usage?.prompt_tokens_details?.cached_tokens ??
usage?.input_tokens_details?.cached_tokens ??
usage?.promptTokensDetails?.cachedTokens ??
usage?.inputTokensDetails?.cachedTokens ??
+ usage?.prompt_cache_hit_tokens ??
+ usage?.promptCacheHitTokens ??
0
);
let includedCacheWriteTokens = positiveNumber(
diff --git a/src/firefox/src/providers/context-windows.js b/src/firefox/src/providers/context-windows.js
index 8a8d2b3be..1599ce99f 100644
--- a/src/firefox/src/providers/context-windows.js
+++ b/src/firefox/src/providers/context-windows.js
@@ -1,3 +1,5 @@
+import { deepSeekModelCapabilities } from './deepseek-config.js';
+
export const DEFAULT_LOCAL_CONTEXT_WINDOW = 16384;
export const DEFAULT_CLOUD_CONTEXT_WINDOW = 128000;
export const MIN_CONTEXT_WINDOW = 4096;
@@ -294,8 +296,11 @@ export function inferContextWindow(config = {}) {
// Mistral
if (/mistral-medium-(?:3\.5|2604)/.test(model)) return K256;
- // DeepSeek
- if (model.includes('deepseek-v4')) return M1;
+ // DeepSeek: 1M for the V4.1-Flash family (including the retired
+ // `deepseek-v4-flash` aliases), a conservative 64K for retired and unknown
+ // DeepSeek ids. Numbers live in deepseek-config.js.
+ const deepSeek = deepSeekModelCapabilities(model);
+ if (deepSeek) return deepSeek.contextWindow;
// xAI
if (/grok-4\.[56](?:$|[^0-9])/.test(model)) return 500000;
@@ -363,9 +368,10 @@ export function inferMaxOutputTokens(config = {}) {
if (/claude-3/.test(model)) return 4096;
if (model.includes('claude-')) return 64000;
- // DeepSeek
- if (model.includes('deepseek-v4')) return 384000;
- if (model.includes('deepseek')) return 8192;
+ // DeepSeek: 384K for the V4.1-Flash family, 8K for the retired ids (and the
+ // unsupported V4 Pro id). Numbers live in deepseek-config.js.
+ const deepSeek = deepSeekModelCapabilities(model);
+ if (deepSeek) return deepSeek.maxOutputTokens;
return null;
}
diff --git a/src/firefox/src/providers/deepseek-config.js b/src/firefox/src/providers/deepseek-config.js
new file mode 100644
index 000000000..a48996f04
--- /dev/null
+++ b/src/firefox/src/providers/deepseek-config.js
@@ -0,0 +1,209 @@
+/**
+ * DeepSeek API contract.
+ *
+ * Single owner of everything DeepSeek-specific, so the generic OpenAI-compatible
+ * provider (`openai.js`) and the shared compatibility presets
+ * (`provider-compatibility.js`) stay vendor-agnostic and only delegate here.
+ *
+ * Source of truth: https://api-docs.deepseek.com/zh-cn/ (模型 & 价格 / 思考模式 /
+ * 图像理解 / 上下文硬盘缓存 / 使用 Responses API / 限速与隔离).
+ *
+ * Deliberately dependency-free: `provider-compatibility.js` imports this module
+ * and `deepseek.js` (the provider class) imports both, so importing back would
+ * create a cycle.
+ */
+
+// Endpoints. The OpenAI-compatible API is rooted at the origin (no /v1) and the
+// Anthropic-compatible API lives under /anthropic.
+export const DEEPSEEK_BASE_URL = 'https://api.deepseek.com';
+export const DEEPSEEK_LEGACY_DEFAULT_BASE_URL = 'https://api.deepseek.com/v1';
+export const DEEPSEEK_ANTHROPIC_BASE_URL = 'https://api.deepseek.com/anthropic';
+
+// `deepseek-flash` (DeepSeek-V4.1-Flash) is the current model id. The retired
+// `deepseek-v4-flash` / `deepseek-v4-flash-vision-exp` ids still call the same
+// model and are billed as Flash, so they keep first-class handling.
+export const DEEPSEEK_DEFAULT_MODEL = 'deepseek-flash';
+export const DEEPSEEK_LEGACY_DEFAULT_MODEL = 'deepseek-v4-flash';
+
+// 1M context, up to 384K output. The server defaults (8K non-thinking, 64K
+// thinking, 128K at `max`) only apply when no budget is sent, and WebBrain
+// always sends one, so the ceiling is the number that matters.
+export const DEEPSEEK_FLASH_CONTEXT_WINDOW = 1000000;
+export const DEEPSEEK_FLASH_MAX_OUTPUT_TOKENS = 384000;
+
+// Retired ids (`deepseek-chat`, `deepseek-reasoner`), the unsupported V4 Pro id,
+// and unknown third-party DeepSeek slugs stay on the conservative generation:
+// never over-claim capacity or vision for a model we cannot verify.
+export const DEEPSEEK_LEGACY_CONTEXT_WINDOW = 65536;
+export const DEEPSEEK_LEGACY_MAX_OUTPUT_TOKENS = 8192;
+
+function clean(value) {
+ return String(value || '').trim().toLowerCase();
+}
+
+/** Any DeepSeek model id, including router slugs such as `deepseek/deepseek-v4`. */
+export function isDeepSeekModel(model) {
+ return clean(model).includes('deepseek');
+}
+
+/**
+ * V4.1-Flash family: the current id plus every retired alias that resolves to
+ * it. Only this family is multimodal — `deepseek-v4-pro` (DeepSeek-V4-Pro-0813)
+ * and the V3-era chat/reasoner ids are text-only.
+ */
+export function isDeepSeekV41FlashModel(model) {
+ const m = clean(model);
+ return m.includes('deepseek-flash') || m.includes('deepseek-v4-flash');
+}
+
+/**
+ * Context window, output ceiling, and image input support for a DeepSeek model
+ * id. Returns null for non-DeepSeek ids so callers keep their generic fallback.
+ */
+export function deepSeekModelCapabilities(model = '') {
+ if (!isDeepSeekModel(model)) return null;
+ if (isDeepSeekV41FlashModel(model)) {
+ return {
+ contextWindow: DEEPSEEK_FLASH_CONTEXT_WINDOW,
+ maxOutputTokens: DEEPSEEK_FLASH_MAX_OUTPUT_TOKENS,
+ vision: true,
+ };
+ }
+ return {
+ contextWindow: DEEPSEEK_LEGACY_CONTEXT_WINDOW,
+ maxOutputTokens: DEEPSEEK_LEGACY_MAX_OUTPUT_TOKENS,
+ vision: false,
+ };
+}
+
+/**
+ * Whether a config targets DeepSeek's own API: the `deepseek` provider card, or
+ * any card pointed at api.deepseek.com (a proxy or a hand-made entry that opts
+ * into the native contract). Local OpenAI-compatible servers that merely serve a
+ * DeepSeek model are intentionally excluded by the caller.
+ */
+export function isDeepSeekEndpoint(config = {}) {
+ if (clean(config.providerName) === 'deepseek') return true;
+ try {
+ const url = new URL(config.baseUrl || '');
+ return (url.protocol === 'http:' || url.protocol === 'https:')
+ && url.hostname.toLowerCase() === 'api.deepseek.com';
+ } catch {
+ return false;
+ }
+}
+
+/**
+ * DeepSeek's OpenAI-compatible API is rooted at the origin, unlike most
+ * OpenAI-compatible servers whose API lives below /v1.
+ */
+export function isDeepSeekRootUrl(url) {
+ return !!url
+ && (url.protocol === 'http:' || url.protocol === 'https:')
+ && url.hostname.toLowerCase() === 'api.deepseek.com'
+ && url.pathname === '/'
+ && !url.search
+ && !url.hash;
+}
+
+/**
+ * DeepSeek's documented effort ladder is low/high/max, with compatibility
+ * aliases mapped by the server. WebBrain keeps its shared, more expressive UI
+ * ladder and translates the values DeepSeek only accepts for compatibility.
+ * (`ultra` maps to `max` upstream; the UI ladder has no `ultra`.)
+ */
+export function mappedDeepSeekReasoningEffort(effort) {
+ if (effort === 'minimal') return 'low';
+ if (effort === 'medium' || effort === 'xhigh') return 'high';
+ return effort;
+}
+
+/**
+ * Thinking-mode controls for one request.
+ *
+ * Chat Completions switches thinking with a top-level `thinking` object and
+ * controls its strength with top-level `reasoning_effort`; a disabled-thinking
+ * request must omit `reasoning_effort` entirely. The Responses API instead uses
+ * `reasoning.effort`, where `none` disables thinking.
+ *
+ * `direct` is false for local/hosted OpenAI-compatible servers that merely serve
+ * a DeepSeek model — those keep the Qwen-style chat-template switch.
+ */
+export function deepSeekThinkingExtras({
+ direct = false,
+ enabled = true,
+ effort = 'auto',
+ responses = false,
+} = {}) {
+ if (!direct) return { chat_template_kwargs: { thinking: enabled } };
+ if (responses) {
+ return { reasoning: { effort: enabled ? mappedDeepSeekReasoningEffort(effort) : 'none' } };
+ }
+ if (!enabled) return { thinking: { type: 'disabled' } };
+ return {
+ thinking: { type: 'enabled' },
+ reasoning_effort: mappedDeepSeekReasoningEffort(effort),
+ };
+}
+
+/**
+ * Per-request controls for classifier/planner calls, which need short
+ * machine-readable JSON instead of hidden reasoning. The native Chat Completions
+ * contract supports JSON Object mode only (no JSON Schema); the Responses API
+ * supports full `text.format` schemas, which the shared Responses body builder
+ * derives from `response_format.type === 'json_schema'`.
+ */
+export function deepSeekPlannerExtras({
+ direct = false,
+ responses = false,
+ includeResponseFormat = true,
+ disableThinking = true,
+ schema = null,
+ schemaName = 'webbrain_planner',
+} = {}) {
+ const body = {};
+ if (direct && disableThinking) {
+ if (responses) body.reasoning = { effort: 'none' };
+ else body.thinking = { type: 'disabled' };
+ }
+ if (!includeResponseFormat) return body;
+ if (direct && !responses) {
+ body.response_format = { type: 'json_object' };
+ return body;
+ }
+ if (direct && responses && schema) {
+ body.response_format = {
+ type: 'json_schema',
+ json_schema: {
+ name: String(schemaName || 'webbrain_planner').replace(/[^a-zA-Z0-9_-]/g, '_').slice(0, 64),
+ strict: true,
+ schema,
+ },
+ };
+ }
+ return body;
+}
+
+/**
+ * Vision probe controls. DeepSeek ignores `temperature` while thinking, and a
+ * visible reasoning channel would spend the whole caption budget, so thinking is
+ * switched off natively before the probe runs.
+ */
+export function deepSeekVisionExtras(maxTokens = 800, { responses = false } = {}) {
+ return {
+ maxTokens,
+ temperature: 0,
+ extraBody: responses ? { reasoning: { effort: 'none' } } : { thinking: { type: 'disabled' } },
+ };
+}
+
+/**
+ * DeepSeek's disabled-thinking contract omits `reasoning_effort` entirely, so a
+ * per-call planner/vision override must clear an effort inherited from the
+ * configured compatibility preset.
+ */
+export function stripDisabledDeepSeekReasoningEffort(body) {
+ if (!body || typeof body !== 'object' || Array.isArray(body)) return body;
+ if (body.thinking?.type === 'disabled') delete body.reasoning_effort;
+ return body;
+}
diff --git a/src/firefox/src/providers/deepseek.js b/src/firefox/src/providers/deepseek.js
new file mode 100644
index 000000000..45e859977
--- /dev/null
+++ b/src/firefox/src/providers/deepseek.js
@@ -0,0 +1,47 @@
+import { OpenAICompatibleProvider } from './openai.js';
+import { isDirectDeepSeekConfig } from './provider-compatibility.js';
+import {
+ deepSeekModelCapabilities,
+ isDeepSeekEndpoint,
+} from './deepseek-config.js';
+
+/**
+ * DeepSeek provider (`type: 'openai'`, dispatched by `providers/manager.js`).
+ *
+ * Owns the DeepSeek-specific protocol behaviour so the generic
+ * OpenAI-compatible provider stays vendor-agnostic:
+ * - vision capability for the V4.1-Flash family (and its retired aliases),
+ * - `stream_options.include_usage` on every request,
+ * - cross-turn `reasoning_content` replay, which DeepSeek requires whenever a
+ * request carries `tools` (omitting it returns 400).
+ *
+ * The request-body contract (native `thinking` / `reasoning_effort`, the
+ * Responses-API shape, planner and vision overrides) lives in
+ * `deepseek-config.js`, because it is also consumed by call sites that only have
+ * a plain provider config (the planner and the connection tests).
+ */
+export class DeepSeekProvider extends OpenAICompatibleProvider {
+ /** True when this card speaks DeepSeek's own API, not a local lookalike. */
+ _isDirectDeepSeek() {
+ return isDirectDeepSeekConfig({
+ ...this.config,
+ providerName: this.config.providerName || this.name,
+ baseUrl: this.baseUrl,
+ model: this.model,
+ });
+ }
+
+ _modelNameSniffedVision(model) {
+ const capabilities = deepSeekModelCapabilities(model);
+ return capabilities ? capabilities.vision : super._modelNameSniffedVision(model);
+ }
+
+ _shouldRequestStreamUsage() {
+ if (isDeepSeekEndpoint(this.config)) return true;
+ return super._shouldRequestStreamUsage();
+ }
+
+ _supportsReasoningContentReplay(_options = {}) {
+ return this._isDirectDeepSeek();
+ }
+}
diff --git a/src/firefox/src/providers/manager.js b/src/firefox/src/providers/manager.js
index 13525e493..ae558118b 100644
--- a/src/firefox/src/providers/manager.js
+++ b/src/firefox/src/providers/manager.js
@@ -1,11 +1,18 @@
import { LlamaCppProvider } from './llamacpp.js';
import { OpenAICompatibleProvider } from './openai.js';
+import { DeepSeekProvider } from './deepseek.js';
import { AzureOpenAIProvider } from './azure-openai.js';
import { AnthropicProvider, AnthropicOAuthProvider } from './anthropic.js';
import { VertexAnthropicProvider } from './vertex-anthropic.js';
import { signOutClaude } from './oauth-claude.js';
import { AwsBedrockProvider } from './aws-bedrock.js';
import { ADDITIONAL_PROVIDER_DEFAULTS } from './provider-catalog.js';
+import {
+ DEEPSEEK_BASE_URL,
+ DEEPSEEK_DEFAULT_MODEL,
+ DEEPSEEK_LEGACY_DEFAULT_BASE_URL,
+ DEEPSEEK_LEGACY_DEFAULT_MODEL,
+} from './deepseek-config.js';
import { fetchWithTimeout } from './fetch-timeout.js';
import {
VISION_MODES,
@@ -30,6 +37,7 @@ import {
shouldApplyDetectedContextWindow,
} from './context-windows.js';
import {
+ isDirectDeepSeekConfig,
normalizeOpenAICompatibleBaseUrl,
openAiCompatiblePayloadError,
unsupportedVisionGenerationControl,
@@ -52,9 +60,6 @@ const OPENROUTER_DEFAULT_MODEL = 'openrouter/free';
const OPENROUTER_LEGACY_DEFAULT_MODEL = 'stepfun/step-3.7-flash';
const OPENAI_DEFAULT_MODEL = 'gpt-5.6-terra';
const OPENAI_LEGACY_DEFAULT_MODEL = 'gpt-5.5';
-const DEEPSEEK_DEFAULT_BASE_URL = 'https://api.deepseek.com';
-const DEEPSEEK_LEGACY_DEFAULT_BASE_URL = 'https://api.deepseek.com/v1';
-const DEEPSEEK_DEFAULT_MODEL = 'deepseek-v4-flash';
const OPENCODE_LEGACY_DEFAULT_MODEL = 'ring-2.6-1t-free';
const SUPPORTED_PROVIDER_TYPES = new Set(['llamacpp', 'openai', 'azure_openai', 'aws_bedrock', 'anthropic', 'anthropic_oauth', 'vertex_anthropic']);
const SAFE_PROVIDER_ID_RE = /^[A-Za-z0-9_-]+$/;
@@ -665,12 +670,17 @@ export class ProviderManager {
category: 'cloud',
label: 'DeepSeek',
providerName: 'deepseek',
- baseUrl: DEEPSEEK_DEFAULT_BASE_URL,
+ baseUrl: DEEPSEEK_BASE_URL,
model: DEEPSEEK_DEFAULT_MODEL,
contextWindow: 1000000,
maxOutputTokens: 384000,
- inputCostPerMillionUsd: 0.27,
- outputCostPerMillionUsd: 1.1,
+ // `deepseek-flash` off-peak list price, CNY per 1M tokens: 1 input,
+ // 0.02 cache-hit input, 4 output (peak is 2 / 0.04 / 8), converted at
+ // 1 USD = 7.1 CNY.
+ // https://api-docs.deepseek.com/zh-cn/quick_start/pricing
+ inputCostPerMillionUsd: 0.14,
+ cacheReadCostPerMillionUsd: 0.0028,
+ outputCostPerMillionUsd: 0.56,
supportsStreamUsageOptions: true,
supportsAskStreaming: true,
apiKey: '',
@@ -854,18 +864,26 @@ export class ProviderManager {
model: OPENROUTER_DEFAULT_MODEL,
};
}
+ // DeepSeek renamed its shipped default model to `deepseek-flash`. The
+ // retired `deepseek-v4-flash` id (plus the old /v1 base path and the
+ // pre-V4.1 prices) identifies a card the user never touched, so the rename
+ // and the new price sheet can be applied without overriding a real choice.
const storedDeepSeek = migrated.deepseek;
const deepSeekBaseUrl = String(storedDeepSeek?.baseUrl || '').replace(/\/+$/, '');
- const untouchedDeepSeekDefault = storedDeepSeek?.model === DEEPSEEK_DEFAULT_MODEL
+ const untouchedDeepSeekDefault = storedDeepSeek?.model === DEEPSEEK_LEGACY_DEFAULT_MODEL
&& storedDeepSeek?.configured !== true
&& !String(storedDeepSeek?.apiKey || '').trim()
- && deepSeekBaseUrl === DEEPSEEK_LEGACY_DEFAULT_BASE_URL
+ && (deepSeekBaseUrl === DEEPSEEK_LEGACY_DEFAULT_BASE_URL || deepSeekBaseUrl === DEEPSEEK_BASE_URL)
&& (storedDeepSeek?.inputCostPerMillionUsd == null || Number(storedDeepSeek.inputCostPerMillionUsd) === 0.27)
&& (storedDeepSeek?.outputCostPerMillionUsd == null || Number(storedDeepSeek.outputCostPerMillionUsd) === 1.1);
if (untouchedDeepSeekDefault) {
migrated.deepseek = {
...storedDeepSeek,
- baseUrl: DEEPSEEK_DEFAULT_BASE_URL,
+ baseUrl: DEEPSEEK_BASE_URL,
+ model: DEEPSEEK_DEFAULT_MODEL,
+ inputCostPerMillionUsd: 0.14,
+ cacheReadCostPerMillionUsd: 0.0028,
+ outputCostPerMillionUsd: 0.56,
};
}
this._migrateUntouchedShippedDefaults(migrated);
@@ -1131,7 +1149,12 @@ export class ProviderManager {
case 'llamacpp':
return new LlamaCppProvider(normalizedConfig);
case 'openai':
- return new OpenAICompatibleProvider(normalizedConfig);
+ // The DeepSeek card (and any card pointed at DeepSeek's own API, or one
+ // that explicitly opts into the `deepseek` preset) gets the dedicated
+ // provider; every other OpenAI-compatible endpoint stays generic.
+ return isDirectDeepSeekConfig(normalizedConfig)
+ ? new DeepSeekProvider(normalizedConfig)
+ : new OpenAICompatibleProvider(normalizedConfig);
case 'azure_openai':
return new AzureOpenAIProvider(normalizedConfig);
case 'aws_bedrock':
diff --git a/src/firefox/src/providers/openai.js b/src/firefox/src/providers/openai.js
index 0b0cdbea6..dfd6e08f9 100644
--- a/src/firefox/src/providers/openai.js
+++ b/src/firefox/src/providers/openai.js
@@ -1,7 +1,6 @@
import { BaseLLMProvider } from './base.js';
import { fetchWithTimeout } from './fetch-timeout.js';
import {
- isDirectDeepSeekConfig,
isNewOpenAIContractConfig,
isOfficialOpenAIConfig,
isOpenCodeZenConfig,
@@ -136,9 +135,21 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
// Otherwise sniff the model name for known vision-capable identifiers.
// Qwen went natively multimodal starting at 3.5 (no separate -VL
// checkpoint needed), so qwen3\.[5-9] catches those alongside the
- // older qwen*vl-suffixed lines.
+ // older qwen*vl-suffixed lines. Vendor-specific families extend
+ // `_modelNameSniffedVision` (see the vendor subclass in this folder)
+ // rather than widening this shared regex.
const m = (this.config.model || '').toLowerCase();
- return /gpt-4o|gpt-4\.1|gpt-4-turbo|gpt-5|claude|gemini|grok|minimax-m3|kimi-k(?:-?3|2\.[5-9])|llava|qwen.*vl|qwen2.*vl|qwen3.*vl|qwen3\.[5-9]|qwen3p8-27b|pixtral|llama.*vision|gemma.*vision|gemma-?[34]|step-3|deepseek-v4-flash-vision-exp/.test(m);
+ return this._modelNameSniffedVision(m);
+ }
+
+ /**
+ * Shared model-name vision sniffing. Subclasses override this hook so a
+ * vendor-specific allow/deny list never has to duplicate the explicit
+ * user-override and auto-detection precedence handled by the
+ * `supportsVision` getter above.
+ */
+ _modelNameSniffedVision(model) {
+ return /gpt-4o|gpt-4\.1|gpt-4-turbo|gpt-5|claude|gemini|grok|minimax-m3|kimi-k(?:-?3|2\.[5-9])|llava|qwen.*vl|qwen2.*vl|qwen3.*vl|qwen3\.[5-9]|qwen3p8-27b|pixtral|llama.*vision|gemma.*vision|gemma-?[34]|step-3/.test(String(model || ''));
}
get useCompactPrompt() {
@@ -321,7 +332,6 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
if (!providerName && this.baseUrl === 'https://api.openai.com/v1') return true;
return providerName === 'openai'
|| providerName === 'openrouter'
- || providerName === 'deepseek'
|| providerName === 'gemini';
}
@@ -395,12 +405,6 @@ export class OpenAICompatibleProvider extends BaseLLMProvider {
}
_supportsReasoningContentReplay(options = {}) {
- if (isDirectDeepSeekConfig({
- ...this.config,
- providerName: this.config.providerName || this.name,
- baseUrl: this.baseUrl,
- model: this.model,
- })) return true;
if (String(this.config.providerName || '').trim().toLowerCase() !== 'kimi') return false;
const model = String(this.model || '').trim().toLowerCase();
if (KIMI_PRESERVED_THINKING_MODELS.has(model)) return true;
diff --git a/src/firefox/src/providers/provider-compatibility.js b/src/firefox/src/providers/provider-compatibility.js
index f599a3550..cf2fcd874 100644
--- a/src/firefox/src/providers/provider-compatibility.js
+++ b/src/firefox/src/providers/provider-compatibility.js
@@ -1,3 +1,12 @@
+import {
+ deepSeekPlannerExtras,
+ deepSeekThinkingExtras,
+ deepSeekVisionExtras,
+ isDeepSeekEndpoint,
+ isDeepSeekRootUrl,
+ stripDisabledDeepSeekReasoningEffort,
+} from './deepseek-config.js';
+
const COMPATIBILITY_PRESETS = new Set(['auto', 'openai', 'qwen', 'deepseek', 'openrouter', 'custom']);
const REASONING_EFFORTS = new Set(['auto', 'off', 'minimal', 'low', 'medium', 'high', 'xhigh', 'max']);
const SYSTEM_PROMPT_ROLES = new Set(['auto', 'system', 'developer']);
@@ -96,11 +105,7 @@ export function normalizeOpenAICompatibleBaseUrl(value) {
const url = new URL(trimmed);
// DeepSeek's OpenAI-compatible endpoint is rooted at the origin, unlike
// most OpenAI-compatible servers whose API lives below /v1.
- if (url.hostname.toLowerCase() === 'api.deepseek.com' &&
- (url.protocol === 'http:' || url.protocol === 'https:') &&
- url.pathname === '/' && !url.search && !url.hash) {
- return trimmed;
- }
+ if (isDeepSeekRootUrl(url)) return trimmed;
if ((url.protocol === 'http:' || url.protocol === 'https:')
&& url.pathname === '/'
&& !url.search
@@ -128,10 +133,11 @@ export function visionGenerationOptions(maxTokens = 800, {
const extraBody = {};
if (reasoningControl) {
if (isDirectDeepSeekConfig(providerConfig || {})) {
- // DeepSeek does not use the local Qwen/LM Studio template controls. Its
- // native Chat Completions switch is a top-level `thinking` object.
- extraBody.thinking = { type: 'disabled' };
- return { maxTokens, temperature: 0, extraBody };
+ // DeepSeek does not use the local Qwen/LM Studio template controls; its
+ // native thinking switch is owned by the DeepSeek contract module.
+ return deepSeekVisionExtras(maxTokens, {
+ responses: shouldUseOpenAIResponsesApi(providerConfig || {}),
+ });
}
// LM Studio 0.4.8+ honors these fields for Chat Completions. They prevent
// Qwen vision models from spending the entire output budget in a hidden
@@ -148,15 +154,19 @@ export function unsupportedVisionGenerationControl(error) {
return /reasoning_effort|reasoning_tokens|chat_template_kwargs|enable_thinking/i.test(message);
}
+/**
+ * Whether a config speaks DeepSeek's own API contract rather than a
+ * DeepSeek-flavoured OpenAI-compatible server. Local servers and the local
+ * runtime provider names are always excluded; an explicit `deepseek` preset in
+ * the Advanced panel opts a custom endpoint in. The DeepSeek-specific endpoint
+ * knowledge lives in `deepseek-config.js`.
+ */
export function isDirectDeepSeekConfig(config = {}) {
const providerName = clean(config.providerName);
if (clean(config.category) === 'local' || LOCAL_OPENAI_COMPAT_PROVIDER_NAMES.has(providerName)) {
return false;
}
- if (providerName === 'deepseek') return true;
- try {
- if (new URL(config.baseUrl || '').hostname.toLowerCase() === 'api.deepseek.com') return true;
- } catch {}
+ if (isDeepSeekEndpoint(config)) return true;
return normalizeProviderCompatibility(config).preset === 'deepseek';
}
@@ -363,15 +373,6 @@ function mappedReasoningEffort(effort, preset) {
return effort;
}
-function mappedDeepSeekReasoningEffort(effort) {
- // DeepSeek's public ladder is low/high/max. Keep the shared UI ladder
- // expressive while translating values that DeepSeek only accepts for
- // compatibility (medium and xhigh both mean high in its API).
- if (effort === 'minimal') return 'low';
- if (effort === 'medium' || effort === 'xhigh') return 'high';
- return effort;
-}
-
export function compatibilityRequestBody(config = {}) {
const compat = normalizeProviderCompatibility(config);
if (compat.reasoningEffort === 'auto') return {};
@@ -386,14 +387,14 @@ export function compatibilityRequestBody(config = {}) {
};
}
if (preset === 'deepseek') {
- if (!isDirectDeepSeekConfig(config)) {
- return { chat_template_kwargs: { thinking: enabled } };
- }
- if (!enabled) return { thinking: { type: 'disabled' } };
- return {
- thinking: { type: 'enabled' },
- reasoning_effort: mappedDeepSeekReasoningEffort(compat.reasoningEffort),
- };
+ // The native contract (thinking object, effort ladder, Responses shape) and
+ // the hosted/local template fallback are both owned by deepseek-config.js.
+ return deepSeekThinkingExtras({
+ direct: isDirectDeepSeekConfig(config),
+ enabled,
+ effort: compat.reasoningEffort,
+ responses: shouldUseOpenAIResponsesApi(config),
+ });
}
if (preset === 'openrouter') {
return enabled
@@ -432,11 +433,22 @@ export function plannerRequestBody(config = {}, {
const isDirectDeepSeek = isDirectDeepSeekConfig(config) && !isLocalOpenAICompat;
const body = {};
+ if (isDirectDeepSeek) {
+ // DeepSeek owns its classifier controls: the native thinking switch on Chat
+ // Completions (JSON Object mode only) and `reasoning.effort` on Responses.
+ return deepSeekPlannerExtras({
+ direct: true,
+ responses: shouldUseOpenAIResponsesApi(config),
+ includeResponseFormat,
+ disableThinking,
+ schema,
+ schemaName,
+ });
+ }
+
if (disableThinking) {
if (preset === 'openrouter') {
body.reasoning = { enabled: false };
- } else if (isDirectDeepSeek) {
- body.thinking = { type: 'disabled' };
} else if ((preset === 'qwen' && isLocalOpenAICompat) || providerName === 'vllm' || providerName === 'sglang') {
body.chat_template_kwargs = { enable_thinking: false };
} else if (preset === 'openai' && shouldUseOpenAIResponsesApi(config)) {
@@ -447,11 +459,6 @@ export function plannerRequestBody(config = {}, {
}
if (!includeResponseFormat) return body;
- if (isDirectDeepSeek) {
- // The direct DeepSeek API supports JSON Object mode, not JSON Schema.
- body.response_format = { type: 'json_object' };
- return body;
- }
if (schema && STRUCTURED_OUTPUT_PROVIDER_NAMES.has(providerName)) {
body.response_format = {
type: 'json_schema',
@@ -485,12 +492,10 @@ export function mergeProviderRequestBody(body, config = {}, perRequestExtraBody
result[key] = isPlainObject(value) || Array.isArray(value) ? safeClone(value) : value;
}
}
- // DeepSeek's disabled-thinking contract omits reasoning_effort entirely.
- // Per-call planner and vision overrides must clear an effort inherited from
- // the configured compatibility preset.
- if (isDirectDeepSeekConfig(config) && result.thinking?.type === 'disabled') {
- delete result.reasoning_effort;
- }
+ // DeepSeek's disabled-thinking contract omits reasoning_effort entirely, so a
+ // per-call planner/vision override must clear an effort inherited from the
+ // configured compatibility preset (see deepseek-config.js).
+ if (isDirectDeepSeekConfig(config)) stripDisabledDeepSeekReasoningEffort(result);
return result;
}
diff --git a/src/firefox/src/trace/privacy.js b/src/firefox/src/trace/privacy.js
index 4c39ae0dd..a78434f16 100644
--- a/src/firefox/src/trace/privacy.js
+++ b/src/firefox/src/trace/privacy.js
@@ -51,7 +51,7 @@ function pick(source, fields) {
function projectUsage(usage) {
return pick(usage, [
'prompt_tokens', 'completion_tokens', 'input_tokens', 'output_tokens',
- 'cached_tokens', 'cost',
+ 'cached_tokens', 'prompt_cache_hit_tokens', 'cost',
]);
}
diff --git a/src/firefox/src/ui/locales/ar.js b/src/firefox/src/ui/locales/ar.js
index f616b5211..2499bdd7a 100644
--- a/src/firefox/src/ui/locales/ar.js
+++ b/src/firefox/src/ui/locales/ar.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'عنوان الخادم',
'st.provider.field.api_base_url': 'عنوان API الأساسي',
+ 'st.provider.field.api_format': 'تنسيق API',
'st.provider.field.api_key': 'مفتاح API',
'st.provider.field.model': 'النموذج',
'st.provider.field.model_optional': 'النموذج (اختياري)',
diff --git a/src/firefox/src/ui/locales/bn.js b/src/firefox/src/ui/locales/bn.js
index 5e4e8bd89..71eeaa924 100644
--- a/src/firefox/src/ui/locales/bn.js
+++ b/src/firefox/src/ui/locales/bn.js
@@ -775,6 +775,7 @@ export default {
'st.provider.field.server_url': "সার্ভার URL",
'st.provider.field.api_base_url': "API বেস URL",
+ 'st.provider.field.api_format': "API ফরম্যাট",
'st.provider.field.api_key': "API কী",
'st.provider.field.model': "মডেল",
'st.provider.field.model_optional': "মডেল (ঐচ্ছিক)",
diff --git a/src/firefox/src/ui/locales/de.js b/src/firefox/src/ui/locales/de.js
index 93de36a6a..732306c78 100644
--- a/src/firefox/src/ui/locales/de.js
+++ b/src/firefox/src/ui/locales/de.js
@@ -712,6 +712,7 @@ export default {
'st.providers.compat.value.developer': 'Entwickler',
'st.provider.field.server_url': 'Server-URL',
'st.provider.field.api_base_url': 'API-Basis-URL',
+ 'st.provider.field.api_format': 'API-Format',
'st.provider.field.api_key': 'API-Schlüssel',
'st.provider.field.model': 'Modell',
'st.provider.field.model_optional': 'Modell (optional)',
diff --git a/src/firefox/src/ui/locales/en.js b/src/firefox/src/ui/locales/en.js
index d22fa235e..e6b29dbac 100644
--- a/src/firefox/src/ui/locales/en.js
+++ b/src/firefox/src/ui/locales/en.js
@@ -776,6 +776,7 @@ export default {
'st.provider.field.server_url': 'Server URL',
'st.provider.field.api_base_url': 'API Base URL',
+ 'st.provider.field.api_format': 'API format',
'st.provider.field.api_key': 'API Key',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (optional)',
diff --git a/src/firefox/src/ui/locales/es.js b/src/firefox/src/ui/locales/es.js
index c54fa70a7..a51c89a9b 100644
--- a/src/firefox/src/ui/locales/es.js
+++ b/src/firefox/src/ui/locales/es.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL del servidor',
'st.provider.field.api_base_url': 'URL base de la API',
+ 'st.provider.field.api_format': 'Formato de API',
'st.provider.field.api_key': 'Clave de API',
'st.provider.field.model': 'Modelo',
'st.provider.field.model_optional': 'Modelo (opcional)',
diff --git a/src/firefox/src/ui/locales/fa.js b/src/firefox/src/ui/locales/fa.js
index d5fedea9b..4b1204858 100644
--- a/src/firefox/src/ui/locales/fa.js
+++ b/src/firefox/src/ui/locales/fa.js
@@ -775,6 +775,7 @@ export default {
'st.provider.field.server_url': "آدرس سرور",
'st.provider.field.api_base_url': "URL پایه API",
+ 'st.provider.field.api_format': "قالب API",
'st.provider.field.api_key': "کلید API",
'st.provider.field.model': "مدل",
'st.provider.field.model_optional': "مدل (اختیاری)",
diff --git a/src/firefox/src/ui/locales/fr.js b/src/firefox/src/ui/locales/fr.js
index 1e1d1a984..9c9b396dd 100644
--- a/src/firefox/src/ui/locales/fr.js
+++ b/src/firefox/src/ui/locales/fr.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL du serveur',
'st.provider.field.api_base_url': 'URL de base de l\'API',
+ 'st.provider.field.api_format': 'Format de l\'API',
'st.provider.field.api_key': 'Clé d\'API',
'st.provider.field.model': 'Modèle',
'st.provider.field.model_optional': 'Modèle (facultatif)',
diff --git a/src/firefox/src/ui/locales/he.js b/src/firefox/src/ui/locales/he.js
index 59128312c..921783025 100644
--- a/src/firefox/src/ui/locales/he.js
+++ b/src/firefox/src/ui/locales/he.js
@@ -680,6 +680,7 @@ export default {
"st.skills.error.add_failed": "לא ניתן להוסיף מיומנות.",
"st.provider.field.server_url": "שרת URL",
"st.provider.field.api_base_url": "API בָּסִיס URL",
+ "st.provider.field.api_format": "פורמט API",
"st.provider.field.api_key": "מפתח API",
"st.provider.field.model": "מודל",
"st.provider.field.model_optional": "מודל (אופציונלי)",
diff --git a/src/firefox/src/ui/locales/hi.js b/src/firefox/src/ui/locales/hi.js
index 1352131d4..c19cd8b41 100644
--- a/src/firefox/src/ui/locales/hi.js
+++ b/src/firefox/src/ui/locales/hi.js
@@ -775,6 +775,7 @@ export default {
'st.provider.field.server_url': "सर्वर यूआरएल",
'st.provider.field.api_base_url': "एपीआई बेस यूआरएल",
+ 'st.provider.field.api_format': "एपीआई प्रारूप",
'st.provider.field.api_key': "एपीआई कुंजी",
'st.provider.field.model': "मॉडल",
'st.provider.field.model_optional': "मॉडल (वैकल्पिक)",
diff --git a/src/firefox/src/ui/locales/id.js b/src/firefox/src/ui/locales/id.js
index 003ea936b..2d3e65bab 100644
--- a/src/firefox/src/ui/locales/id.js
+++ b/src/firefox/src/ui/locales/id.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL server',
'st.provider.field.api_base_url': 'URL dasar API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Kunci API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (opsional)',
diff --git a/src/firefox/src/ui/locales/ja.js b/src/firefox/src/ui/locales/ja.js
index 2c36ee8fa..ae9f008e3 100644
--- a/src/firefox/src/ui/locales/ja.js
+++ b/src/firefox/src/ui/locales/ja.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'サーバー URL',
'st.provider.field.api_base_url': 'API ベース URL',
+ 'st.provider.field.api_format': 'API 形式',
'st.provider.field.api_key': 'API キー',
'st.provider.field.model': 'モデル',
'st.provider.field.model_optional': 'モデル(任意)',
diff --git a/src/firefox/src/ui/locales/ko.js b/src/firefox/src/ui/locales/ko.js
index 46dfa6ac8..842bc26d9 100644
--- a/src/firefox/src/ui/locales/ko.js
+++ b/src/firefox/src/ui/locales/ko.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': '서버 URL',
'st.provider.field.api_base_url': 'API 기본 URL',
+ 'st.provider.field.api_format': 'API 형식',
'st.provider.field.api_key': 'API 키',
'st.provider.field.model': '모델',
'st.provider.field.model_optional': '모델 (선택)',
diff --git a/src/firefox/src/ui/locales/ms.js b/src/firefox/src/ui/locales/ms.js
index bd38b2457..9e9755db1 100644
--- a/src/firefox/src/ui/locales/ms.js
+++ b/src/firefox/src/ui/locales/ms.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL pelayan',
'st.provider.field.api_base_url': 'URL asas API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Kunci API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (pilihan)',
diff --git a/src/firefox/src/ui/locales/nl.js b/src/firefox/src/ui/locales/nl.js
index eed02760c..23551b031 100644
--- a/src/firefox/src/ui/locales/nl.js
+++ b/src/firefox/src/ui/locales/nl.js
@@ -688,6 +688,7 @@ export default {
'st.skills.error.add_failed': 'Vaardigheid kon niet worden toegevoegd.',
'st.provider.field.server_url': 'Server-URL',
'st.provider.field.api_base_url': 'API-basis-URL',
+ 'st.provider.field.api_format': 'API-formaat',
'st.provider.field.api_key': 'API-sleutel',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (optioneel)',
diff --git a/src/firefox/src/ui/locales/pl.js b/src/firefox/src/ui/locales/pl.js
index 0ee3eb594..d34b9dbb5 100644
--- a/src/firefox/src/ui/locales/pl.js
+++ b/src/firefox/src/ui/locales/pl.js
@@ -531,6 +531,7 @@ export default {
'st.providers.webbrain_note.privacy_link': 'Polityka prywatności',
'st.provider.field.server_url': 'Adres URL serwera',
'st.provider.field.api_base_url': 'Bazowy adres URL API',
+ 'st.provider.field.api_format': 'Format API',
'st.provider.field.api_key': 'Klucz API',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (opcjonalnie)',
diff --git a/src/firefox/src/ui/locales/pt.js b/src/firefox/src/ui/locales/pt.js
index b12e85c47..8dc7e6b47 100644
--- a/src/firefox/src/ui/locales/pt.js
+++ b/src/firefox/src/ui/locales/pt.js
@@ -775,6 +775,7 @@ export default {
'st.provider.field.server_url': "URL do servidor",
'st.provider.field.api_base_url': "URL base da API",
+ 'st.provider.field.api_format': "Formato da API",
'st.provider.field.api_key': "Chave de API",
'st.provider.field.model': "Modelo",
'st.provider.field.model_optional': "Modelo (opcional)",
diff --git a/src/firefox/src/ui/locales/ru.js b/src/firefox/src/ui/locales/ru.js
index 8cf882342..8e9e5284c 100644
--- a/src/firefox/src/ui/locales/ru.js
+++ b/src/firefox/src/ui/locales/ru.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL сервера',
'st.provider.field.api_base_url': 'Базовый URL API',
+ 'st.provider.field.api_format': 'Формат API',
'st.provider.field.api_key': 'API-ключ',
'st.provider.field.model': 'Модель',
'st.provider.field.model_optional': 'Модель (необязательно)',
diff --git a/src/firefox/src/ui/locales/th.js b/src/firefox/src/ui/locales/th.js
index 3411a54c7..34205e292 100644
--- a/src/firefox/src/ui/locales/th.js
+++ b/src/firefox/src/ui/locales/th.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL เซิร์ฟเวอร์',
'st.provider.field.api_base_url': 'URL ฐานของ API',
+ 'st.provider.field.api_format': 'รูปแบบ API',
'st.provider.field.api_key': 'คีย์ API',
'st.provider.field.model': 'โมเดล',
'st.provider.field.model_optional': 'โมเดล (ไม่บังคับ)',
diff --git a/src/firefox/src/ui/locales/tl.js b/src/firefox/src/ui/locales/tl.js
index 928724d20..7b197c43a 100644
--- a/src/firefox/src/ui/locales/tl.js
+++ b/src/firefox/src/ui/locales/tl.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'Server URL',
'st.provider.field.api_base_url': 'API Base URL',
+ 'st.provider.field.api_format': 'Format ng API',
'st.provider.field.api_key': 'API Key',
'st.provider.field.model': 'Modelo',
'st.provider.field.model_optional': 'Modelo (opsyonal)',
diff --git a/src/firefox/src/ui/locales/tr.js b/src/firefox/src/ui/locales/tr.js
index 65dbac6ca..8084d7af3 100644
--- a/src/firefox/src/ui/locales/tr.js
+++ b/src/firefox/src/ui/locales/tr.js
@@ -362,6 +362,7 @@ export default {
'st.provider.field.server_url': 'Sunucu URL\'si',
'st.provider.field.api_base_url': 'API temel URL\'si',
+ 'st.provider.field.api_format': 'API biçimi',
'st.provider.field.api_key': 'API anahtarı',
'st.provider.field.model': 'Model',
'st.provider.field.model_optional': 'Model (isteğe bağlı)',
diff --git a/src/firefox/src/ui/locales/uk.js b/src/firefox/src/ui/locales/uk.js
index 9c20855c5..9d667b4cd 100644
--- a/src/firefox/src/ui/locales/uk.js
+++ b/src/firefox/src/ui/locales/uk.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': 'URL сервера',
'st.provider.field.api_base_url': 'Базовий URL API',
+ 'st.provider.field.api_format': 'Формат API',
'st.provider.field.api_key': 'API-ключ',
'st.provider.field.model': 'Модель',
'st.provider.field.model_optional': 'Модель (необов\'язково)',
diff --git a/src/firefox/src/ui/locales/vi.js b/src/firefox/src/ui/locales/vi.js
index 934053098..5f9e8c701 100644
--- a/src/firefox/src/ui/locales/vi.js
+++ b/src/firefox/src/ui/locales/vi.js
@@ -775,6 +775,7 @@ export default {
'st.provider.field.server_url': "URL máy chủ",
'st.provider.field.api_base_url': "URL cơ sở API",
+ 'st.provider.field.api_format': "Định dạng API",
'st.provider.field.api_key': "Khóa API",
'st.provider.field.model': "người mẫu",
'st.provider.field.model_optional': "Mô hình (tùy chọn)",
diff --git a/src/firefox/src/ui/locales/zh.js b/src/firefox/src/ui/locales/zh.js
index 041f60143..ced27e93b 100644
--- a/src/firefox/src/ui/locales/zh.js
+++ b/src/firefox/src/ui/locales/zh.js
@@ -323,6 +323,7 @@ export default {
'st.provider.field.server_url': '服务器 URL',
'st.provider.field.api_base_url': 'API 基础 URL',
+ 'st.provider.field.api_format': 'API 格式',
'st.provider.field.api_key': 'API 密钥',
'st.provider.field.model': '模型',
'st.provider.field.model_optional': '模型(可选)',
diff --git a/src/firefox/src/ui/settings.js b/src/firefox/src/ui/settings.js
index 5e0743c2d..d97740ea6 100644
--- a/src/firefox/src/ui/settings.js
+++ b/src/firefox/src/ui/settings.js
@@ -2527,9 +2527,17 @@ function renderProviders() {
deepseek: {
fields: [
{ key: 'apiKey', labelKey: 'st.provider.field.api_key', type: 'password', placeholder: 'sk-...' },
- { key: 'model', labelKey: 'st.provider.field.model', type: 'text', placeholder: 'deepseek-v4-flash',
- suggestions: ['deepseek-v4-flash', 'deepseek-v4-pro', 'deepseek-v4-flash-vision-exp'] },
+ { key: 'model', labelKey: 'st.provider.field.model', type: 'text', placeholder: 'deepseek-flash',
+ suggestions: ['deepseek-flash', 'deepseek-v4-flash'] },
{ key: 'baseUrl', labelKey: 'st.provider.field.api_base_url', type: 'text', placeholder: 'https://api.deepseek.com' },
+ // Chat Completions is the default wire format; DeepSeek's Responses API
+ // is an opt-in that mainly adds JSON-schema structured output.
+ { key: 'apiFormat', labelKey: 'st.provider.field.api_format', type: 'select', collapsed: true,
+ options: [
+ { value: 'auto', label: 'Chat Completions (default)' },
+ { value: 'chat', label: 'Chat Completions' },
+ { value: 'responses', label: 'Responses API' },
+ ] },
...COST_ESTIMATE_FIELDS,
],
},
diff --git a/test/provider-model-limits.mjs b/test/provider-model-limits.mjs
index 547df76de..ac844a703 100644
--- a/test/provider-model-limits.mjs
+++ b/test/provider-model-limits.mjs
@@ -21,6 +21,8 @@ for (const browser of ['chrome', 'firefox']) {
assert.equal(inferMaxOutputTokens({ model: 'gpt-5.6-terra' }), 128000, `${browser}: GPT-5.6 output ceiling`);
assert.equal(inferMaxOutputTokens({ model: 'gpt-4o' }), 16384, `${browser}: GPT-4o output ceiling`);
assert.equal(inferMaxOutputTokens({ model: 'deepseek-v4-flash' }), 384000, `${browser}: DeepSeek V4 output ceiling`);
+ assert.equal(inferMaxOutputTokens({ model: 'deepseek-flash' }), 384000, `${browser}: current DeepSeek output ceiling`);
+ assert.equal(inferMaxOutputTokens({ model: 'deepseek-v4-pro' }), 8192, `${browser}: retired DeepSeek Pro stays conservative`);
assert.equal(inferMaxOutputTokens({ model: 'deepseek-chat' }), 8192, `${browser}: legacy DeepSeek chat output ceiling`);
assert.equal(
resolveMaxOutputTokens({ model: 'claude-haiku-4-5', maxOutputTokens: 128000 }),
diff --git a/test/run.js b/test/run.js
index 3878de884..32527bb5a 100644
--- a/test/run.js
+++ b/test/run.js
@@ -1039,6 +1039,18 @@ const { OpenAICompatibleProvider: OpenAIProviderCh } = await import(
const { OpenAICompatibleProvider: OpenAIProviderFx } = await import(
'file://' + path.join(ROOT, 'src/firefox/src/providers/openai.js').replace(/\\/g, '/')
);
+const { DeepSeekProvider: DeepSeekProviderCh } = await import(
+ 'file://' + path.join(ROOT, 'src/chrome/src/providers/deepseek.js').replace(/\\/g, '/')
+);
+const { DeepSeekProvider: DeepSeekProviderFx } = await import(
+ 'file://' + path.join(ROOT, 'src/firefox/src/providers/deepseek.js').replace(/\\/g, '/')
+);
+const DeepSeekConfigCh = await import(
+ 'file://' + path.join(ROOT, 'src/chrome/src/providers/deepseek-config.js').replace(/\\/g, '/')
+);
+const DeepSeekConfigFx = await import(
+ 'file://' + path.join(ROOT, 'src/firefox/src/providers/deepseek-config.js').replace(/\\/g, '/')
+);
const { LlamaCppProvider: LlamaCppProviderCh } = await import(
'file://' + path.join(ROOT, 'src/chrome/src/providers/llamacpp.js').replace(/\\/g, '/')
);
@@ -71037,7 +71049,6 @@ test('OpenAI-compatible streams request usage metadata only for supporting provi
for (const Provider of [OpenAIProviderCh, OpenAIProviderFx]) {
for (const config of [
{ category: 'cloud', providerName: 'gemini' },
- { category: 'cloud', providerName: 'deepseek' },
{ category: 'cloud', providerName: 'mistral', supportsStreamUsageOptions: false },
{ category: 'router', providerName: 'openrouter' },
{ providerName: 'openai' },
@@ -71061,6 +71072,20 @@ test('OpenAI-compatible streams request usage metadata only for supporting provi
assert.equal(body.stream_options, undefined);
}
}
+
+ // DeepSeek always requests usage; the behaviour moved to its dedicated
+ // provider (see deepseek.js) instead of living in the shared class.
+ for (const Provider of [DeepSeekProviderCh, DeepSeekProviderFx]) {
+ const provider = new Provider({
+ category: 'cloud',
+ providerName: 'deepseek',
+ baseUrl: 'https://api.deepseek.com',
+ model: 'deepseek-flash',
+ });
+ const body = { stream: true, stream_options: { custom: 'keep' } };
+ provider._addStreamUsageOptions(body);
+ assert.deepEqual(body.stream_options, { custom: 'keep', include_usage: true });
+ }
});
test('OpenAI-compatible streams emit only the final cumulative usage snapshot', async () => {
@@ -71731,10 +71756,35 @@ test('DeepSeek Chat Completions uses native thinking, vision, streaming, and rep
},
}];
try {
- for (const [label, compatibility] of [
- ['chrome', ProviderCompatibilityCh],
- ['firefox', ProviderCompatibilityFx],
+ for (const [label, compatibility, deepSeekConfig] of [
+ ['chrome', ProviderCompatibilityCh, DeepSeekConfigCh],
+ ['firefox', ProviderCompatibilityFx, DeepSeekConfigFx],
]) {
+ assert.deepEqual(
+ deepSeekConfig.deepSeekModelCapabilities('deepseek-flash'),
+ { contextWindow: 1000000, maxOutputTokens: 384000, vision: true },
+ `${label}: the current DeepSeek model is 1M / 384K / multimodal`,
+ );
+ assert.deepEqual(
+ deepSeekConfig.deepSeekModelCapabilities('deepseek-v4-flash-vision-exp'),
+ { contextWindow: 1000000, maxOutputTokens: 384000, vision: true },
+ `${label}: retired flash aliases keep the V4.1-Flash capacities`,
+ );
+ assert.deepEqual(
+ deepSeekConfig.deepSeekModelCapabilities('deepseek-v4-pro'),
+ { contextWindow: 65536, maxOutputTokens: 8192, vision: false },
+ `${label}: retired and unknown DeepSeek ids stay conservative`,
+ );
+ assert.equal(
+ deepSeekConfig.deepSeekModelCapabilities('gpt-5.6-terra'),
+ null,
+ `${label}: non-DeepSeek ids keep the generic fallback`,
+ );
+ assert.equal(
+ deepSeekConfig.isDeepSeekRootUrl(new URL('https://api.deepseek.com')),
+ true,
+ `${label}: the DeepSeek origin is a root endpoint`,
+ );
assert.equal(
compatibility.normalizeOpenAICompatibleBaseUrl('https://api.deepseek.com'),
'https://api.deepseek.com',
@@ -71819,14 +71869,56 @@ test('DeepSeek Chat Completions uses native thinking, vision, streaming, and rep
{ thinking: { type: 'disabled' } },
`${label}: disabling DeepSeek vision thinking must clear configured reasoning effort`,
);
+ const plannerSchema = { type: 'object', properties: {}, additionalProperties: false };
+ assert.deepEqual(
+ compatibility.plannerRequestBody({ ...deepSeekVisionConfig, apiFormat: 'responses' }, { schema: plannerSchema }),
+ {
+ reasoning: { effort: 'none' },
+ response_format: {
+ type: 'json_schema',
+ json_schema: { name: 'webbrain_planner', strict: true, schema: plannerSchema },
+ },
+ },
+ `${label}: DeepSeek Responses planners disable thinking and keep a strict JSON schema`,
+ );
+ assert.deepEqual(
+ compatibility.visionGenerationOptions(160, {
+ providerConfig: { ...deepSeekVisionConfig, apiFormat: 'responses' },
+ }),
+ { maxTokens: 160, temperature: 0, extraBody: { reasoning: { effort: 'none' } } },
+ `${label}: DeepSeek Responses vision probes disable thinking via reasoning.effort`,
+ );
}
for (const PM of [ProviderManagerCh, ProviderManagerFx]) {
const manager = new PM();
const defaults = manager._defaultConfigs();
assert.equal(defaults.deepseek.baseUrl, 'https://api.deepseek.com', `${PM.name}: official DeepSeek base URL`);
- assert.equal(defaults.deepseek.model, 'deepseek-v4-flash', `${PM.name}: current DeepSeek default model`);
+ assert.equal(defaults.deepseek.model, 'deepseek-flash', `${PM.name}: current DeepSeek default model`);
assert.equal(defaults.deepseek.contextWindow, 1000000, `${PM.name}: DeepSeek context window`);
+ assert.equal(defaults.deepseek.maxOutputTokens, 384000, `${PM.name}: DeepSeek output ceiling`);
+ assert.equal(defaults.deepseek.cacheReadCostPerMillionUsd, 0.0028, `${PM.name}: DeepSeek cache-hit rate`);
+ assert.equal(
+ manager._createProvider('deepseek', defaults.deepseek).constructor.name,
+ 'DeepSeekProvider',
+ `${PM.name}: the DeepSeek card must use the dedicated provider`,
+ );
+ assert.equal(
+ manager._createProvider('deepseek__duplicate', { ...defaults.deepseek, duplicateOf: 'deepseek' }).constructor.name,
+ 'DeepSeekProvider',
+ `${PM.name}: a duplicated DeepSeek card keeps the dedicated provider`,
+ );
+ assert.equal(
+ manager._createProvider('openrouter', {
+ type: 'openai',
+ category: 'router',
+ providerName: 'openrouter',
+ baseUrl: 'https://openrouter.ai/api/v1',
+ model: 'deepseek/deepseek-v4',
+ }).constructor.name,
+ 'OpenAICompatibleProvider',
+ `${PM.name}: a router-hosted DeepSeek model stays on the generic provider`,
+ );
const migrated = manager._migrateStoredProviderConfigs({
deepseek: {
model: 'deepseek-v4-flash',
@@ -71836,23 +71928,51 @@ test('DeepSeek Chat Completions uses native thinking, vision, streaming, and rep
},
});
assert.equal(migrated.deepseek.baseUrl, 'https://api.deepseek.com', `${PM.name}: untouched legacy DeepSeek defaults should migrate`);
+ assert.equal(migrated.deepseek.model, 'deepseek-flash', `${PM.name}: untouched legacy DeepSeek model should be renamed`);
+ assert.equal(migrated.deepseek.inputCostPerMillionUsd, 0.14, `${PM.name}: untouched legacy DeepSeek prices should migrate`);
+ assert.equal(migrated.deepseek.cacheReadCostPerMillionUsd, 0.0028, `${PM.name}: untouched legacy DeepSeek cache-hit price should migrate`);
+ const configured = manager._migrateStoredProviderConfigs({
+ deepseek: {
+ model: 'deepseek-v4-flash',
+ baseUrl: 'https://api.deepseek.com/v1',
+ apiKey: 'sk-live',
+ configured: true,
+ },
+ });
+ assert.equal(configured.deepseek.model, 'deepseek-v4-flash', `${PM.name}: a saved DeepSeek card must not be rewritten`);
+ assert.equal(configured.deepseek.baseUrl, 'https://api.deepseek.com/v1', `${PM.name}: a saved DeepSeek base URL must not be rewritten`);
}
for (const [label, Provider, AgentClass] of [
- ['chrome', OpenAIProviderCh, AgentCh],
- ['firefox', OpenAIProviderFx, AgentFx],
+ ['chrome', DeepSeekProviderCh, AgentCh],
+ ['firefox', DeepSeekProviderFx, AgentFx],
]) {
const provider = new Provider({
category: 'cloud',
providerName: 'deepseek',
baseUrl: 'https://api.deepseek.com',
- model: 'deepseek-v4-flash',
+ model: 'deepseek-flash',
compat: { reasoningEffort: 'high' },
supportsStreamUsageOptions: true,
});
- assert.equal(provider.supportsVision, false, `${label}: the text-only DeepSeek model must not advertise vision`);
+ assert.equal(provider.supportsVision, true, `${label}: the V4.1-Flash model must advertise vision`);
const vision = new Provider({ ...provider.config, model: 'deepseek-v4-flash-vision-exp' });
- assert.equal(vision.supportsVision, true, `${label}: the official DeepSeek vision model must advertise vision`);
+ assert.equal(vision.supportsVision, true, `${label}: the retired vision alias must advertise vision`);
+ assert.equal(
+ new Provider({ ...provider.config, model: 'deepseek-v4-flash' }).supportsVision,
+ true,
+ `${label}: retired flash ids resolve to the multimodal V4.1-Flash model`,
+ );
+ assert.equal(
+ new Provider({ ...provider.config, model: 'deepseek-v4-pro' }).supportsVision,
+ false,
+ `${label}: the retired V4 Pro id is text-only`,
+ );
+ assert.equal(
+ new Provider({ ...provider.config, model: 'deepseek-chat' }).supportsVision,
+ false,
+ `${label}: V3-era DeepSeek ids are text-only`,
+ );
const body = provider._buildChatCompletionsBody(
[{ role: 'user', content: 'Read the page' }],
@@ -71867,6 +71987,20 @@ test('DeepSeek Chat Completions uses native thinking, vision, streaming, and rep
assert.deepEqual(body.stream_options, { include_usage: true }, `${label}: DeepSeek streaming should request usage`);
assert.equal(body.tools.length, 1, `${label}: function tools must be sent`);
+ // Chat Completions is the default wire format; the Responses API is an
+ // explicit opt-in through `apiFormat: 'responses'`.
+ assert.equal(provider._usesResponsesApi(), false, `${label}: DeepSeek must default to Chat Completions`);
+ const responsesProvider = new Provider({ ...provider.config, apiFormat: 'responses' });
+ assert.equal(responsesProvider._usesResponsesApi(), true, `${label}: apiFormat=responses must opt into the Responses API`);
+ const responsesBody = responsesProvider._buildResponsesBody(
+ [{ role: 'user', content: 'Read the page' }],
+ { maxTokens: 321, temperature: 0.2 },
+ true,
+ );
+ assert.deepEqual(responsesBody.reasoning, { effort: 'high' }, `${label}: Responses must carry reasoning.effort`);
+ assert.equal(responsesBody.thinking, undefined, `${label}: Responses must not carry the Chat Completions thinking object`);
+ assert.equal(responsesBody.reasoning_effort, undefined, `${label}: Responses must not carry top-level reasoning_effort`);
+
const agent = new AgentClass({});
const assistant = {
role: 'assistant',
@@ -71930,6 +72064,32 @@ test('DeepSeek Chat Completions uses native thinking, vision, streaming, and rep
}
});
+test('DeepSeek knowledge stays inside the dedicated provider modules', () => {
+ for (const [label, browser] of [['chrome', 'src/chrome'], ['firefox', 'src/firefox']]) {
+ const providersDir = path.join(ROOT, browser, 'src', 'providers');
+ const openai = fs.readFileSync(path.join(providersDir, 'openai.js'), 'utf8');
+ assert.doesNotMatch(
+ openai,
+ /deepseek/i,
+ `${label}: the shared OpenAI-compatible provider must stay vendor-agnostic`,
+ );
+ const compatibility = fs.readFileSync(path.join(providersDir, 'provider-compatibility.js'), 'utf8');
+ for (const pattern of [/api\.deepseek\.com/, /deepseek-flash/, /mappedDeepSeekReasoningEffort/]) {
+ assert.doesNotMatch(
+ compatibility,
+ pattern,
+ `${label}: DeepSeek wire knowledge belongs to deepseek-config.js (${pattern})`,
+ );
+ }
+ for (const module of ['deepseek.js', 'deepseek-config.js']) {
+ assert.ok(
+ fs.existsSync(path.join(providersDir, module)),
+ `${label}: ${module} must own the DeepSeek contract`,
+ );
+ }
+ }
+});
+
test('official GPT-5.6 uses Responses while older and custom OpenAI-compatible endpoints stay on Chat Completions', () => {
const tools = [{
type: 'function',
@@ -72498,6 +72658,32 @@ test('Agent cost estimation discounts OpenAI cached input included in the input
}
});
+test('Agent cost estimation prices DeepSeek prompt-cache hits at the cache-read rate', () => {
+ for (const AgentClass of [AgentCh, AgentFx]) {
+ const agent = new AgentClass({});
+ const provider = {
+ config: {
+ inputCostPerMillionUsd: 0.14,
+ cacheReadCostPerMillionUsd: 0.0028,
+ outputCostPerMillionUsd: 0.56,
+ },
+ };
+ // DeepSeek reports `prompt_tokens` as hit + miss, so the hit counter is a
+ // subset of the input total: 200 uncached @0.14 + 800 cached @0.0028
+ // + 100 output @0.56.
+ const usage = {
+ prompt_tokens: 1000,
+ completion_tokens: 100,
+ prompt_cache_hit_tokens: 800,
+ prompt_cache_miss_tokens: 200,
+ };
+ assert.equal(
+ agent._estimateUsageCostUsd(provider, usage),
+ (200 * 0.14 + 800 * 0.0028 + 100 * 0.56) / 1000000,
+ );
+ }
+});
+
test('Agent cost estimation prices OpenAI included cache writes from nested usage details', () => {
for (const AgentClass of [AgentCh, AgentFx]) {
const agent = new AgentClass({});