diff --git a/.context/DESIGN.md b/.context/DESIGN.md
index c92aabff4..a60f2df1d 100644
--- a/.context/DESIGN.md
+++ b/.context/DESIGN.md
@@ -182,10 +182,11 @@ density="rail"` (the group caption with its chevron) and `DashNavItem density="r
component under the canvas chrome's name. `AvatarStack` (the first `max` people plus a "+N"
disc), `tone="ink"` (the account's own face: initials on an ink disc, no collar), `initials()`
(the one first-and-last-letter rule), `BrandMark` - every third-party logo (``; figma, github,
- canva, photoshop, meta, claude, openai, cursor, gemini, google, apple, microsoft, slack, linear, openrouter);
+ canva, photoshop, meta, claude, openai, cursor, gemini, google, apple, microsoft, slack, linear, openrouter,
+ deepseek, kimi);
`AppIcon` is a model provider, import source or export format as doop.design's "Works with" row draws it:
the brand tile (23% corners, inset edge and soft drop) with its glyph at 56% (`claude`, `claude-code`, `openai`,
- `gemini`, `openrouter`, `seedream`, `codex`, `cursor`, `mcp`, `headless`, `github`, `figma`, `photoshop`, `canva`, `website`, `live-app`, `pdf`, `png`, `svg`,
+ `gemini`, `openrouter`, `deepseek`, `kimi`, `seedream`, `codex`, `cursor`, `mcp`, `headless`, `github`, `figma`, `photoshop`, `canva`, `website`, `live-app`, `pdf`, `png`, `svg`,
`jpg`), 32px in a list row and 40px beside a modal title,
`Wordmark`, `Logo` / `DoopMark` (the bare Disc-D; `animated` hops its dot, as the home greeting
wears it), `icons.tsx` - identity. Feature tiles (`FigmaTile`, `MetaTile`, the integrations'
diff --git a/.context/TECHSTACK.md b/.context/TECHSTACK.md
index 90e52e9d3..8bb2c18cd 100644
--- a/.context/TECHSTACK.md
+++ b/.context/TECHSTACK.md
@@ -81,8 +81,15 @@
catalog, `CHATGPT_MODELS_URL`, asked with the account's token as Codex CLI
`CHATGPT_CODEX_CLIENT_VERSION`; the route refreshes the token first) have loaders, each with a
family filter for reasoning chat models with tools, images and a 16k output window; a picked id
- only has to be shaped like the provider's, and the run is the final check. OpenRouter stays on
- its curated roster (the run-time vision check knows only the roster's flags).
+ only has to be shaped like the provider's, and the run is the final check. OpenRouter, DeepSeek,
+ Kimi and Kimi Code stay on their curated rosters (the run-time vision check knows only the roster's flags).
+- DeepSeek and Kimi keys (`deepseek-key`, `kimi-key`) and the Kimi Code plan (`kimi-code`, a
+ Kimi membership's key, sent with a `Doop/` User-Agent as Kimi Code's terms require)
+ run on the Chat Completions transport (`server/chatCompletionsAgent.ts`) against fixed URLs
+ (`DEEPSEEK_CHAT_URL`, `KIMI_CHAT_URL`, `KIMI_CODE_CHAT_URL`, an operator's override only). Both refuse a tool-calling conversation that drops an earlier turn's
+ `reasoning_content`, so the transport keeps it as a `thinking` block in the run's history and
+ sends it back where the config sets `echoReasoning`. Tests: the `reasoning_content` cases in
+ `chatCompletionsAgent.test.ts`, `rosterRouting.test.ts`, `providerKeyAccounts.test.ts`.
- Reasoning effort on a user's OpenAI account (ChatGPT subscription or OpenAI key): the pick lives
in `model_accounts.reasoning_effort` (`REASONING_EFFORTS` in `shared/modelMenu.ts`: low / medium /
high / xhigh), set through `PATCH /api/model-account/:kind { effort }`, read by `effortFor` in
diff --git a/.env.example b/.env.example
index 02b4a5c63..c77c14805 100644
--- a/.env.example
+++ b/.env.example
@@ -185,12 +185,15 @@
# user starts on; they pick low / medium / high / xhigh for themselves in
# Settings or the composer, on a ChatGPT subscription or an OpenAI key.
#DOOP_AGENT_OPENAI_EFFORT=medium
-# Default models for the two wide-roster BYO keys (users pick another in
-# Settings). OpenRouter ids come from the curated roster in
-# shared/modelMenu.ts; an off-roster override runs but is treated as
+# Default models for the Chat Completions BYO keys (users pick another in
+# Settings). OpenRouter, DeepSeek and Kimi ids come from the curated rosters
+# in shared/modelMenu.ts; an off-roster override runs but is treated as
# text-only (no visual review) to be safe.
#DOOP_AGENT_OPENROUTER_MODEL=moonshotai/kimi-k2.6
#DOOP_AGENT_GEMINI_MODEL=gemini-3.7-flash
+#DOOP_AGENT_DEEPSEEK_MODEL=deepseek-flash
+#DOOP_AGENT_KIMI_MODEL=kimi-k3.1-pro
+#DOOP_AGENT_KIMI_CODE_MODEL=k3.1-pro
# Experimental subscription-backed Gemini cloud workers. Operator-managed pilot;
# one isolated worker and credential volume per user. Disabled when unset.
@@ -413,6 +416,12 @@
#OPENROUTER_CHAT_URL=https://openrouter.ai/api/v1/chat/completions
#GEMINI_OPENAI_CHAT_URL=https://generativelanguage.googleapis.com/v1beta/openai/chat/completions
#GEMINI_MODELS_URL=https://generativelanguage.googleapis.com/v1beta/models
+#DEEPSEEK_CHAT_URL=https://api.deepseek.com/chat/completions
+# Moonshot's international platform; keys from platform.moonshot.cn need
+# https://api.moonshot.cn/v1/chat/completions instead.
+#KIMI_CHAT_URL=https://api.moonshot.ai/v1/chat/completions
+# Kimi Code (a Kimi membership's quota); China: https://api.kimi.com/coding/v1/chat/completions
+#KIMI_CODE_CHAT_URL=https://api.kimi.ai/coding/v1/chat/completions
# Read by the Anthropic SDK itself: every Claude API call, including the
# connected-key model catalog behind the picker, goes to this origin.
#ANTHROPIC_BASE_URL=https://api.anthropic.com
diff --git a/README.md b/README.md
index fa3ab2ac3..728393a47 100644
--- a/README.md
+++ b/README.md
@@ -30,7 +30,7 @@ runs on **GPT, Claude, Gemini, DeepSeek, Kimi or Qwen** models
then watch it sketch, stream and self-review designs on your canvas, next to your cursor.
- **A built-in Doop Agent** — queue a card or @mention a role and it designs on its own, no client
to connect. Runs on the model account each user connects (a **ChatGPT subscription**, or an
- OpenAI, Claude, Gemini or OpenRouter key), or on the server's `ANTHROPIC_API_KEY` for as many
+ OpenAI, Claude, Gemini, DeepSeek, Kimi or OpenRouter key), or on the server's `ANTHROPIC_API_KEY` for as many
free tasks as `RESIDENT_TASK_LIMIT` grants (none by default) ([setup](#the-doop-agent)); the
first-canvas welcome performance is scripted and runs without any of it.
- **Pages within a canvas** — organize frames into named pages from the Layers panel. Add, rename,
@@ -79,8 +79,8 @@ tasks. **Connect AI** in the top bar walks you through each one.
| Headless agents (n8n, Mastra, CI) | An agent key as a bearer header ([setup](#headless-agents-agent-keys)) |
No agent of your own? The built-in [Doop Agent](#the-doop-agent) runs on the model account you
-connect: a ChatGPT subscription, or an OpenAI, Claude, Gemini or OpenRouter key. OpenRouter brings
-DeepSeek, Kimi, Qwen, GLM and MiniMax ([details](#past-the-free-tasks-connect-your-own-chatgpt)).
+connect: a ChatGPT subscription, or an OpenAI, Claude, Gemini, DeepSeek, Kimi or OpenRouter key.
+OpenRouter brings Qwen, GLM, MiniMax and more ([details](#past-the-free-tasks-connect-your-own-chatgpt)).
## Quickstart
@@ -396,7 +396,7 @@ from the very next task: the free tier is a trial that gets people here, not a b
first, and connecting stops costing the server anything from that moment. The connection is
account-level, so it lives at **/settings** (Home → Settings); the free-tier wall links there rather
than carrying its own copy, and "Connect an AI agent" on a canvas stays about MCP clients only. A
-user can connect five kinds of account; the Gemini cloud pilot and Claude Plan appear only where
+user can connect eight kinds of account; the Gemini cloud pilot and Claude Plan appear only where
the operator or the desktop app provides them:
- **ChatGPT subscription** — OAuth against `auth.openai.com`, then inference through the Codex
@@ -410,6 +410,15 @@ the operator or the desktop app provides them:
the picker labels them "no visual review".
- **Gemini API key** — Google's Gemini models through their OpenAI-compatible endpoint, plus Nano
Banana image generation.
+- **DeepSeek API key** — DeepSeek V4.1 Flash (with vision) and V4 Pro (text-only for now) on the
+ user's own platform.deepseek.com account.
+- **Kimi API key** — Moonshot's Kimi K3 models, all with vision, on the user's own
+ platform.moonshot.ai account. A key from Moonshot's China platform needs an operator to point
+ `KIMI_CHAT_URL` at `https://api.moonshot.cn/v1/chat/completions`.
+- **Kimi Code plan** — a Kimi membership (Plus and up) through a key from the Kimi Code console,
+ billed to the membership rather than per token. Its own endpoint (`KIMI_CODE_CHAT_URL`,
+ `api.kimi.ai/coding/v1` overseas) and ids (`k3.1-pro`, `k3.1-pro-highspeed`, `k3`); requests
+ name Doop in their `User-Agent`, as Kimi Code's terms ask of every third-party tool.
- **Gemini cloud pilot** — an operator-managed prototype running the official Gemini CLI in an
isolated worker using Google sign-in. Disabled by default; see the
[pilot setup and verification guide](docs/gemini-cloud-pilot.md).
@@ -425,19 +434,21 @@ same list the Codex CLI reads, asked as `CHATGPT_CODEX_CLIENT_VERSION`), OpenAI'
Anthropic's `/v1/models`, Gemini's `/v1beta/models`. A newly released model is on the menu
without an upgrade; the curated entries above sit on top as recommendations, a curated tier the
account cannot run is left off, and the curated menu alone is served if the provider cannot be
-reached. OpenRouter stays on its curated roster, whose hand-checked vision flags are what the
-run relies on.
+reached. OpenRouter, DeepSeek, Kimi and Kimi Code stay on their curated rosters, whose hand-checked vision
+flags are what the run relies on. DeepSeek and Kimi return their reasoning as `reasoning_content`
+and refuse a tool-calling conversation that leaves it out, so the transport keeps it in the run's
+history and sends it back on every turn.
-Azure OpenAI is deliberately _not_ a connectable account kind, and the OpenRouter/Gemini endpoints
-are fixed constants: a user-supplied endpoint would be a URL the server fetches with the run's full
+Azure OpenAI is deliberately _not_ a connectable account kind, and the OpenRouter/Gemini/DeepSeek/Kimi
+endpoints are fixed constants: a user-supplied endpoint would be a URL the server fetches with the run's full
context — an SSRF vector — so custom endpoints stay server-level configuration only.
Either way the user picks their **model tier** in Settings from that provider's curated menu — on
OpenAI, `gpt-6-astra` (the newest flagship; on a ChatGPT subscription it needs Plus or better and
OpenAI is still rolling it out per account), `gpt-5.6-sol` (flagship), `gpt-5.6-terra` (the default
workhorse) or `gpt-5.6-luna` (cheap and fast). They are paying for it, so the choice is theirs;
-`DOOP_AGENT_OPENAI_MODEL`, `DOOP_AGENT_OPENROUTER_MODEL` and `DOOP_AGENT_GEMINI_MODEL` only set the
-default they start on. Note that
+`DOOP_AGENT_OPENAI_MODEL`, `DOOP_AGENT_OPENROUTER_MODEL`, `DOOP_AGENT_GEMINI_MODEL`,
+`DOOP_AGENT_DEEPSEEK_MODEL`, `DOOP_AGENT_KIMI_MODEL` and `DOOP_AGENT_KIMI_CODE_MODEL` only set the default they start on. Note that
`gpt-5.4` and `gpt-5.4-mini` retire from ChatGPT-authenticated Codex on **31 August 2026**, so
pinning a 5.4 id via that env var will break the subscription path after that date.
@@ -490,6 +501,9 @@ own agent over MCP.
| `DOOP_AGENT_OPENAI_EFFORT` | `medium` | Default reasoning effort on a user's OpenAI account; each user can pick low–xhigh |
| `DOOP_AGENT_OPENROUTER_MODEL` | `moonshotai/kimi-k2.6` | Default model on a connected OpenRouter key |
| `DOOP_AGENT_GEMINI_MODEL` | `gemini-3.7-flash` | Default model on a connected Gemini key |
+| `DOOP_AGENT_DEEPSEEK_MODEL` | `deepseek-flash` | Default model on a connected DeepSeek key |
+| `DOOP_AGENT_KIMI_MODEL` | `kimi-k3.1-pro` | Default model on a connected Kimi key |
+| `DOOP_AGENT_KIMI_CODE_MODEL` | `k3.1-pro` | Default model on a connected Kimi Code plan |
| `CHATGPT_CONNECT_DISABLED` | _unset_ | `1` hides the ChatGPT flow, leaving the API-key path |
| `DOOP_DISTILL_MODEL` | `claude-haiku-4-5-20251001` | Model for the guideline distiller |
diff --git a/server/agentModel.ts b/server/agentModel.ts
index d9c3e53d1..c3cfbd906 100644
--- a/server/agentModel.ts
+++ b/server/agentModel.ts
@@ -9,7 +9,15 @@ import { withFreshToken, accountModelFor, accountVisionFor, accountWithPick } fr
import type { AccountKind, ModelAccount } from './modelAccounts.ts'
import { ModelAuthError, ModelUnavailableError, effortFor, runAzureTurn, runOpenAiTurn } from './openaiAgent.ts'
import type { StopReason, TurnBlock } from './openaiAgent.ts'
-import { geminiConfig, openrouterConfig, runChatCompletionsTurn } from './chatCompletionsAgent.ts'
+import {
+ deepseekConfig,
+ geminiConfig,
+ kimiCodeConfig,
+ kimiConfig,
+ openrouterConfig,
+ runChatCompletionsTurn,
+ type ChatCompletionsConfig,
+} from './chatCompletionsAgent.ts'
/**
* Which model runs a Doop Agent turn, and on whose bill.
@@ -203,6 +211,20 @@ const BYO_LABELS: Record = {
'anthropic-key': 'Claude API',
'openrouter-key': 'OpenRouter',
'gemini-key': 'Gemini',
+ 'deepseek-key': 'DeepSeek',
+ 'kimi-key': 'Kimi',
+ 'kimi-code': 'Kimi Code',
+}
+
+/* the account kinds that run on the Chat Completions transport */
+const CHAT_COMPLETIONS_CONFIGS: Partial<
+ Record ChatCompletionsConfig>
+> = {
+ 'openrouter-key': openrouterConfig,
+ 'gemini-key': geminiConfig,
+ 'deepseek-key': deepseekConfig,
+ 'kimi-key': kimiConfig,
+ 'kimi-code': kimiCodeConfig,
}
/* the OpenAI-shaped transports take one system string; cache breakpoints are
@@ -241,14 +263,12 @@ function byoModel(account: ModelAccount): AgentModel {
},
}
}
- if (account.kind === 'openrouter-key' || account.kind === 'gemini-key') {
+ const chatCompletionsConfig = CHAT_COMPLETIONS_CONFIGS[account.kind]
+ if (chatCompletionsConfig) {
if (!account.apiKey) throw new ModelAuthError(`Reconnect your ${BYO_LABELS[account.kind]} key in Settings.`)
const model = accountModelFor(account)
const vision = accountVisionFor(account)
- const config =
- account.kind === 'openrouter-key'
- ? openrouterConfig(account.apiKey, model, vision)
- : geminiConfig(account.apiKey, model, vision)
+ const config = chatCompletionsConfig(account.apiKey, model, vision)
return {
provider: account.kind,
label: `${BYO_LABELS[account.kind]} (${model})`,
diff --git a/server/agentRunners.ts b/server/agentRunners.ts
index e3d0d546e..b1c5dee37 100644
--- a/server/agentRunners.ts
+++ b/server/agentRunners.ts
@@ -18,7 +18,15 @@ import {
type AccountStatus,
} from './modelAccounts.ts'
import { CLAUDE_EFFORT_OPTIONS, CLAUDE_MODELS } from '../shared/localAgent.ts'
-import { ANTHROPIC_MODELS, GEMINI_MODELS, OPENROUTER_MODELS, reasoningEffortOptions } from '../shared/modelMenu.ts'
+import {
+ ANTHROPIC_MODELS,
+ DEEPSEEK_MODELS,
+ GEMINI_MODELS,
+ KIMI_CODE_MODELS,
+ KIMI_MODELS,
+ OPENROUTER_MODELS,
+ reasoningEffortOptions,
+} from '../shared/modelMenu.ts'
import type { ModelOption } from '../shared/modelMenu.ts'
import { RUNNER_NAMES, type AgentRunner, type AgentRunners, type RunnerProvider } from '../shared/agentRunner.ts'
@@ -29,6 +37,9 @@ export const MODEL_MENUS: Record = {
'anthropic-key': ANTHROPIC_MODELS,
'openrouter-key': OPENROUTER_MODELS,
'gemini-key': GEMINI_MODELS,
+ 'deepseek-key': DEEPSEEK_MODELS,
+ 'kimi-key': KIMI_MODELS,
+ 'kimi-code': KIMI_CODE_MODELS,
}
export async function listRunners(userId: string): Promise {
diff --git a/server/chatCompletionsAgent.ts b/server/chatCompletionsAgent.ts
index d4c2beb52..68a845cf4 100644
--- a/server/chatCompletionsAgent.ts
+++ b/server/chatCompletionsAgent.ts
@@ -1,4 +1,5 @@
import { env } from './env.ts'
+import packageJson from '../package.json' with { type: 'json' }
import { randomUUID } from 'node:crypto'
import type Anthropic from '@anthropic-ai/sdk'
import {
@@ -18,9 +19,11 @@ import type { StopReason, TurnBlock, TurnRequest, TurnResult } from './openaiAge
*
* - OpenRouter (a user's `sk-or-` key) — one key, many vendors' models;
* - Google Gemini (a user's AI Studio key), through Google's own
- * OpenAI-compatibility endpoint.
+ * OpenAI-compatibility endpoint;
+ * - DeepSeek and Kimi (Moonshot), whose own APIs speak Chat Completions,
+ * and Kimi Code, a Kimi membership's coding quota.
*
- * Both URLs are fixed constants. Like the Azure transport, this module never
+ * Every URL is a fixed constant. Like the Azure transport, this module never
* takes a user-supplied endpoint: a configurable base URL would be a
* server-side fetch target, i.e. an SSRF into whatever network Doop runs on.
*
@@ -32,10 +35,18 @@ import type { StopReason, TurnBlock, TurnRequest, TurnResult } from './openaiAge
* result or user block — is replaced by a text note here, at the one choke
* point all seven image-producing tools pass through, so no request can 400
* on a modality the model lacks.
+ *
+ * DeepSeek and Kimi think out loud in `reasoning_content` and refuse (400) a
+ * tool-calling conversation that drops it from an earlier assistant turn.
+ * The reasoning rides the run's history as a `thinking` block and goes back
+ * out where the config asks for it (`echoReasoning`).
*/
export const OPENROUTER_URL = env.OPENROUTER_CHAT_URL
export const GEMINI_OPENAI_URL = env.GEMINI_OPENAI_CHAT_URL
+export const DEEPSEEK_URL = env.DEEPSEEK_CHAT_URL
+export const KIMI_URL = env.KIMI_CHAT_URL
+export const KIMI_CODE_URL = env.KIMI_CODE_CHAT_URL
export const IMAGE_OMITTED_NOTE = '[image omitted — the selected model cannot view images]'
@@ -50,6 +61,8 @@ export interface ChatCompletionsConfig {
label: string
/** false = strip every image into a text note before sending */
vision: boolean
+ /** true = send earlier turns' reasoning back as `reasoning_content` */
+ echoReasoning?: boolean
}
export function openrouterConfig(apiKey: string, model: string, vision: boolean): ChatCompletionsConfig {
@@ -73,6 +86,41 @@ export function geminiConfig(apiKey: string, model: string, vision: boolean): Ch
}
}
+export function deepseekConfig(apiKey: string, model: string, vision: boolean): ChatCompletionsConfig {
+ return {
+ url: DEEPSEEK_URL,
+ headers: { Authorization: `Bearer ${apiKey}` },
+ model,
+ label: 'DeepSeek',
+ vision,
+ echoReasoning: true,
+ }
+}
+
+export function kimiConfig(apiKey: string, model: string, vision: boolean): ChatCompletionsConfig {
+ return {
+ url: KIMI_URL,
+ headers: { Authorization: `Bearer ${apiKey}` },
+ model,
+ label: 'Kimi',
+ vision,
+ echoReasoning: true,
+ }
+}
+
+export function kimiCodeConfig(apiKey: string, model: string, vision: boolean): ChatCompletionsConfig {
+ return {
+ url: KIMI_CODE_URL,
+ /* Kimi Code's terms ask every tool to name itself truthfully; a disguised
+ client can cost the member their plan */
+ headers: { Authorization: `Bearer ${apiKey}`, 'User-Agent': `Doop/${packageJson.version}` },
+ model,
+ label: 'Kimi Code',
+ vision,
+ echoReasoning: true,
+ }
+}
+
/* ---------------------------------------------------------------- */
/* Anthropic messages -> Chat Completions messages */
/* ---------------------------------------------------------------- */
@@ -81,7 +129,7 @@ type ChatPart = { type: 'text'; text: string } | { type: 'image_url'; image_url:
type ChatMessage =
| { role: 'system' | 'user'; content: string | ChatPart[] }
- | { role: 'assistant'; content: string | null; tool_calls?: ChatToolCall[] }
+ | { role: 'assistant'; content: string | null; tool_calls?: ChatToolCall[]; reasoning_content?: string }
| { role: 'tool'; tool_call_id: string; content: string }
interface ChatToolCall {
@@ -90,7 +138,12 @@ interface ChatToolCall {
function: { name: string; arguments: string }
}
-function toMessages(system: string, messages: Anthropic.MessageParam[], vision: boolean): ChatMessage[] {
+function toMessages(
+ system: string,
+ messages: Anthropic.MessageParam[],
+ vision: boolean,
+ echoReasoning = false,
+): ChatMessage[] {
const out: ChatMessage[] = [{ role: 'system', content: system }]
for (const message of messages) {
if (typeof message.content === 'string') {
@@ -103,9 +156,11 @@ function toMessages(system: string, messages: Anthropic.MessageParam[], vision:
}
if (message.role === 'assistant') {
const texts: string[] = []
+ const thoughts: string[] = []
const calls: ChatToolCall[] = []
for (const block of message.content) {
if (block.type === 'text') texts.push(block.text)
+ else if (block.type === 'thinking') thoughts.push(block.thinking)
else if (block.type === 'tool_use') {
calls.push({
id: block.id,
@@ -118,6 +173,7 @@ function toMessages(system: string, messages: Anthropic.MessageParam[], vision:
role: 'assistant',
content: texts.length > 0 ? texts.join('\n') : null,
...(calls.length > 0 ? { tool_calls: calls } : {}),
+ ...(echoReasoning && thoughts.length > 0 ? { reasoning_content: thoughts.join('\n') } : {}),
})
continue
}
@@ -189,6 +245,7 @@ interface CompletionBody {
finish_reason?: string
message?: {
content?: string | null
+ reasoning_content?: string | null
refusal?: string | null
tool_calls?: { id?: string; function?: { name?: string; arguments?: string } }[]
}
@@ -204,6 +261,11 @@ function fromCompletion(body: CompletionBody, label: string): TurnResult {
const choice = body.choices?.[0]
if (!choice?.message) throw new Error(`${label} returned an empty response`)
const content: TurnBlock[] = []
+ /* kept for the next request, never shown: the signature is Anthropic's and
+ this block never reaches the Messages API */
+ if (choice.message.reasoning_content) {
+ content.push({ type: 'thinking', thinking: choice.message.reasoning_content, signature: '' })
+ }
if (choice.message.content) content.push({ type: 'text', text: choice.message.content })
const refused = Boolean(choice.message.refusal)
let toolCalls = 0
@@ -228,7 +290,8 @@ function fromCompletion(body: CompletionBody, label: string): TurnResult {
const stop: StopReason = refused ? 'refusal' : toolCalls > 0 ? 'tool_use' : truncated ? 'max_tokens' : 'end_turn'
/* a response with nothing in it would end the loop silently; make it a
visible failure instead */
- if (content.length === 0 && !refused) throw new Error(`${label} returned an empty response`)
+ if (!content.some((block) => block.type !== 'thinking') && !refused)
+ throw new Error(`${label} returned an empty response`)
return { content, stop_reason: stop }
}
@@ -242,7 +305,7 @@ export async function runChatCompletionsTurn(config: ChatCompletionsConfig, req:
headers: { ...config.headers, 'Content-Type': 'application/json' },
body: JSON.stringify({
model: config.model,
- messages: toMessages(req.system, req.messages, config.vision),
+ messages: toMessages(req.system, req.messages, config.vision, config.echoReasoning),
tools: toTools(req.tools),
tool_choice: 'auto',
max_tokens: req.maxTokens,
diff --git a/server/db/schema.ts b/server/db/schema.ts
index 0512f5567..3090228a8 100644
--- a/server/db/schema.ts
+++ b/server/db/schema.ts
@@ -625,7 +625,7 @@ export const modelAccounts = pgTable(
'model_accounts',
{
userId: text('user_id').notNull(),
- /** 'chatgpt' (subscription, OAuth) | 'openai-key' | 'anthropic-key' | 'openrouter-key' | 'gemini-key' */
+ /** 'chatgpt' (subscription, OAuth) | 'openai-key' | 'anthropic-key' | 'openrouter-key' | 'gemini-key' | 'deepseek-key' | 'kimi-key' | 'kimi-code' */
kind: text('kind').notNull(),
/** off keeps the credential but takes the account out of the composer and the default */
enabled: boolean('enabled').notNull().default(true),
diff --git a/server/env.ts b/server/env.ts
index 715fe491d..0946bd662 100644
--- a/server/env.ts
+++ b/server/env.ts
@@ -1,7 +1,13 @@
import { bool, cleanEnv, EnvMissingError, makeExactValidator, port, str } from 'envalid'
import type { ReporterOptions } from 'envalid'
import { createHash } from 'node:crypto'
-import { DEFAULT_GEMINI_MODEL, DEFAULT_OPENROUTER_MODEL } from '../shared/modelMenu.ts'
+import {
+ DEFAULT_DEEPSEEK_MODEL,
+ DEFAULT_GEMINI_MODEL,
+ DEFAULT_KIMI_CODE_MODEL,
+ DEFAULT_KIMI_MODEL,
+ DEFAULT_OPENROUTER_MODEL,
+} from '../shared/modelMenu.ts'
import { FALLBACK_LOCALE, LOCALES } from '../shared/locales.ts'
/**
@@ -160,6 +166,9 @@ const schema = {
DOOP_AGENT_OPENAI_EFFORT: str({ default: 'medium' }),
DOOP_AGENT_OPENROUTER_MODEL: str({ default: DEFAULT_OPENROUTER_MODEL }),
DOOP_AGENT_GEMINI_MODEL: str({ default: DEFAULT_GEMINI_MODEL }),
+ DOOP_AGENT_DEEPSEEK_MODEL: str({ default: DEFAULT_DEEPSEEK_MODEL }),
+ DOOP_AGENT_KIMI_MODEL: str({ default: DEFAULT_KIMI_MODEL }),
+ DOOP_AGENT_KIMI_CODE_MODEL: str({ default: DEFAULT_KIMI_CODE_MODEL }),
/* JSON; parsed and shape-checked where it is used so a parse error never
echoes the worker secrets it contains */
DOOP_GEMINI_CLOUD_WORKERS: str({ default: undefined }),
@@ -182,6 +191,13 @@ const schema = {
GEMINI_OPENAI_CHAT_URL: str({
default: 'https://generativelanguage.googleapis.com/v1beta/openai/chat/completions',
}),
+ DEEPSEEK_CHAT_URL: str({ default: 'https://api.deepseek.com/chat/completions' }),
+ /* Moonshot's international platform; keys from platform.moonshot.cn need
+ https://api.moonshot.cn/v1/chat/completions */
+ KIMI_CHAT_URL: str({ default: 'https://api.moonshot.ai/v1/chat/completions' }),
+ /* Kimi Code, a membership's coding quota; China's is
+ https://api.kimi.com/coding/v1/chat/completions */
+ KIMI_CODE_CHAT_URL: str({ default: 'https://api.kimi.ai/coding/v1/chat/completions' }),
/* ------------------------------------------------ image generation */
OPENAI_API_KEY: str({ default: undefined }),
diff --git a/server/index.ts b/server/index.ts
index 274d08e27..f10f8bd46 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -1093,6 +1093,9 @@ const KEY_CONNECTS = {
'anthropic-key': modelAccounts.connectAnthropicKey,
'openrouter-key': modelAccounts.connectOpenRouterKey,
'gemini-key': modelAccounts.connectGeminiKey,
+ 'deepseek-key': modelAccounts.connectDeepSeekKey,
+ 'kimi-key': modelAccounts.connectKimiKey,
+ 'kimi-code': modelAccounts.connectKimiCodeKey,
} as const
for (const [kind, connect] of Object.entries(KEY_CONNECTS)) {
app.post(`/api/model-account/${kind}`, async (req, res) => {
diff --git a/server/modelAccounts.ts b/server/modelAccounts.ts
index de45eaca7..369e74576 100644
--- a/server/modelAccounts.ts
+++ b/server/modelAccounts.ts
@@ -6,10 +6,14 @@ import { and, asc, eq } from 'drizzle-orm'
import { db } from './db/index.ts'
import { modelAccounts } from './db/schema.ts'
import {
+ DEEPSEEK_MODELS,
DEFAULT_ANTHROPIC_MODEL,
GEMINI_MODELS,
+ KIMI_CODE_MODELS,
+ KIMI_MODELS,
OPENROUTER_MODELS,
isReasoningEffort,
+ type ModelOption,
type ReasoningEffort,
} from '../shared/modelMenu.ts'
import { CLAUDE_API_MODEL, GEMINI_API_MODEL, OPENAI_API_MODEL } from './modelCatalog.ts'
@@ -57,7 +61,15 @@ const REDIRECT_URI = env.CHATGPT_OAUTH_REDIRECT_URI
fetch — an ordinary product User-Agent passes where no header at all does */
const AUTH_USER_AGENT = env.CHATGPT_AUTH_USER_AGENT
-export type AccountKind = 'chatgpt' | 'openai-key' | 'anthropic-key' | 'openrouter-key' | 'gemini-key'
+export type AccountKind =
+ | 'chatgpt'
+ | 'openai-key'
+ | 'anthropic-key'
+ | 'openrouter-key'
+ | 'gemini-key'
+ | 'deepseek-key'
+ | 'kimi-key'
+ | 'kimi-code'
const ACCOUNT_KINDS: readonly string[] = [
'chatgpt',
@@ -65,6 +77,9 @@ const ACCOUNT_KINDS: readonly string[] = [
'anthropic-key',
'openrouter-key',
'gemini-key',
+ 'deepseek-key',
+ 'kimi-key',
+ 'kimi-code',
] satisfies AccountKind[]
export interface ModelAccount {
@@ -175,6 +190,25 @@ export function statusOf(account: ModelAccount): AccountStatus {
const DEFAULT_OPENROUTER = env.DOOP_AGENT_OPENROUTER_MODEL
const DEFAULT_GEMINI = env.DOOP_AGENT_GEMINI_MODEL
+const DEFAULT_DEEPSEEK = env.DOOP_AGENT_DEEPSEEK_MODEL
+const DEFAULT_KIMI = env.DOOP_AGENT_KIMI_MODEL
+const DEFAULT_KIMI_CODE = env.DOOP_AGENT_KIMI_CODE_MODEL
+
+/* the kinds whose menu is a hand-checked roster and nothing else: the roster's
+ vision flags are all the run-time check knows about their models */
+const ROSTERS: Partial> = {
+ 'openrouter-key': OPENROUTER_MODELS,
+ 'deepseek-key': DEEPSEEK_MODELS,
+ 'kimi-key': KIMI_MODELS,
+ 'kimi-code': KIMI_CODE_MODELS,
+}
+
+function rosterPolicy(roster: ModelOption[], fallback: string) {
+ return {
+ resolve: (model?: string) => model || fallback,
+ isKnown: (model: string) => roster.some((option) => option.id === model),
+ }
+}
/* per-kind model policy: how a stored (possibly unset or stale) model id
resolves to the one that will run, and which ids the picker may set */
@@ -193,14 +227,15 @@ const MODEL_POLICY: Record model || DEFAULT_OPENROUTER,
- isKnown: (model) => OPENROUTER_MODELS.some((option) => option.id === model),
- },
+ 'openrouter-key': rosterPolicy(OPENROUTER_MODELS, DEFAULT_OPENROUTER),
'gemini-key': {
resolve: (model) => model || DEFAULT_GEMINI,
isKnown: (model) => GEMINI_API_MODEL.test(model),
},
+ /* DeepSeek and Kimi too: their catalogs list ids without saying which see images */
+ 'deepseek-key': rosterPolicy(DEEPSEEK_MODELS, DEFAULT_DEEPSEEK),
+ 'kimi-key': rosterPolicy(KIMI_MODELS, DEFAULT_KIMI),
+ 'kimi-code': rosterPolicy(KIMI_CODE_MODELS, DEFAULT_KIMI_CODE),
}
export function accountModelFor(account: Pick): string {
@@ -226,16 +261,17 @@ export function accountWithPick(account: ModelAccount, pick: RunnerPick | undefi
/** Whether the model this account resolves to can see images. An id off the
* curated menu (a server env override) is trusted to have vision except on
- * OpenRouter, whose roster mixes text-only models — there the conservative
- * answer is a degraded run rather than a 400 on the first screenshot. */
+ * the roster kinds, whose rosters mix text-only models — there the
+ * conservative answer is a degraded run rather than a 400 on the first
+ * screenshot. */
export function accountVisionFor(account: Pick): boolean {
const model = accountModelFor(account)
- const menu =
- account.kind === 'openrouter-key' ? OPENROUTER_MODELS : account.kind === 'gemini-key' ? GEMINI_MODELS : null
+ const roster = ROSTERS[account.kind]
+ const menu = roster ?? (account.kind === 'gemini-key' ? GEMINI_MODELS : null)
if (!menu) return true
const option = menu.find((entry) => entry.id === model)
if (option) return option.vision
- return account.kind !== 'openrouter-key'
+ return !roster
}
/** Change which model tier one account runs on. */
@@ -827,6 +863,19 @@ const KEY_SHAPES: Partial key.length >= 30 && !/\s/.test(key),
hint: 'That does not look like a Gemini API key (a long single token, usually starting with "AIza")',
},
+ 'deepseek-key': {
+ test: (key) => key.startsWith('sk-') && key.length >= 20 && !/\s/.test(key),
+ hint: 'That does not look like a DeepSeek API key (they start with "sk-")',
+ },
+ 'kimi-key': {
+ test: (key) => key.startsWith('sk-') && key.length >= 20 && !/\s/.test(key),
+ hint: 'That does not look like a Kimi API key (they start with "sk-")',
+ },
+ 'kimi-code': {
+ /* the Kimi Code console's format is not documented: one long token */
+ test: (key) => key.length >= 20 && !/\s/.test(key),
+ hint: 'That does not look like a Kimi Code key (copy it from the Kimi Code console)',
+ },
}
async function connectKey(userId: string, kind: AccountKind, apiKey: string): Promise {
@@ -860,6 +909,18 @@ export function connectGeminiKey(userId: string, apiKey: string): Promise
return connectKey(userId, 'gemini-key', apiKey)
}
+export function connectDeepSeekKey(userId: string, apiKey: string): Promise {
+ return connectKey(userId, 'deepseek-key', apiKey)
+}
+
+export function connectKimiKey(userId: string, apiKey: string): Promise {
+ return connectKey(userId, 'kimi-key', apiKey)
+}
+
+export function connectKimiCodeKey(userId: string, apiKey: string): Promise {
+ return connectKey(userId, 'kimi-code', apiKey)
+}
+
/* refreshes are per-user serialized: two runs starting together must not both
spend the single-use refresh token */
const refreshing = new Map>()
diff --git a/server/openaiAgent.ts b/server/openaiAgent.ts
index 29c2faef3..d4f0401f6 100644
--- a/server/openaiAgent.ts
+++ b/server/openaiAgent.ts
@@ -71,7 +71,9 @@ export function effortFor(account: Pick): string {
admits other originators. */
export const ORIGINATOR = env.CHATGPT_ORIGINATOR
-export type TurnBlock = Anthropic.TextBlockParam | Anthropic.ToolUseBlockParam
+/* thinking blocks carry a Chat Completions model's `reasoning_content`, which
+ DeepSeek and Kimi need sent back on every later turn of a run */
+export type TurnBlock = Anthropic.TextBlockParam | Anthropic.ToolUseBlockParam | Anthropic.ThinkingBlockParam
export type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'refusal'
export interface TurnRequest {
@@ -445,7 +447,7 @@ export async function runAzureTurn(config: AzureConfig, req: TurnRequest): Promi
}
const transports: Record<
- Exclude,
+ Extract,
(account: ModelAccount, req: TurnRequest) => Promise
> = {
chatgpt: runChatgpt,
@@ -453,7 +455,7 @@ const transports: Record<
}
export function runOpenAiTurn(account: ModelAccount, req: TurnRequest): Promise {
- if (account.kind === 'anthropic-key' || account.kind === 'openrouter-key' || account.kind === 'gemini-key') {
+ if (account.kind !== 'chatgpt' && account.kind !== 'openai-key') {
throw new Error(`${account.kind} accounts do not use the OpenAI transport`)
}
return transports[account.kind](account, req)
diff --git a/server/resident.ts b/server/resident.ts
index b1a359a8c..da825c32e 100644
--- a/server/resident.ts
+++ b/server/resident.ts
@@ -394,7 +394,7 @@ async function runAgent(canvasId: string, agentName: string, stalled: Set Promise>> = {
+ 'openai-key': api.connectOpenAiKey,
+ 'anthropic-key': api.connectAnthropicKey,
+ 'openrouter-key': api.connectOpenRouterKey,
+ 'gemini-key': api.connectGeminiKey,
+ 'deepseek-key': api.connectDeepSeekKey,
+ 'kimi-key': api.connectKimiKey,
+ 'kimi-code': api.connectKimiCodeKey,
+}
+
const PLAN_NAMES: Record = {
free: 'Free',
go: 'Go',
@@ -320,14 +331,7 @@ export function ModelAccountPanel({ onChange }: { onChange?: () => void }) {
const saveKey = () => {
const kind = showKey || 'openai-key'
- const connect =
- kind === 'anthropic-key'
- ? api.connectAnthropicKey
- : kind === 'openrouter-key'
- ? api.connectOpenRouterKey
- : kind === 'gemini-key'
- ? api.connectGeminiKey
- : api.connectOpenAiKey
+ const connect = KEY_CONNECTS[kind] ?? api.connectOpenAiKey
return act(
kind,
() => connect(apiKey),
@@ -729,6 +733,27 @@ export function ModelAccountPanel({ onChange }: { onChange?: () => void }) {
mark: ,
placeholder: 'AIza…',
}),
+ keyRow({
+ kind: 'deepseek-key',
+ title: t('models.deepseekKeyTitle'),
+ short: t('models.deepseekKeyShort'),
+ mark: ,
+ placeholder: 'sk-…',
+ }),
+ keyRow({
+ kind: 'kimi-key',
+ title: t('models.kimiKeyTitle'),
+ short: t('models.kimiKeyShort'),
+ mark: ,
+ placeholder: 'sk-…',
+ }),
+ keyRow({
+ kind: 'kimi-code',
+ title: t('models.kimiCodeTitle'),
+ short: t('models.kimiCodeShort'),
+ mark: ,
+ placeholder: t('models.kimiCodePlaceholder'),
+ }),
/* the Plan's row decides for itself whether it is a row or a card; the
pane only needs to know which part it belongs in */
{ connected: planConnected, node: },
diff --git a/src/components/ModelPicker.tsx b/src/components/ModelPicker.tsx
index 897e5b4c0..5436a7a1a 100644
--- a/src/components/ModelPicker.tsx
+++ b/src/components/ModelPicker.tsx
@@ -29,6 +29,9 @@ const PROVIDER_MARK: Partial> = {
'openai-key': 'openai',
'gemini-key': 'gemini',
'openrouter-key': 'openrouter',
+ 'deepseek-key': 'deepseek',
+ 'kimi-key': 'kimi',
+ 'kimi-code': 'kimi',
}
/* the effort ids stay as sent to the server; only their names are translated */
diff --git a/src/components/ui/brand-mark.tsx b/src/components/ui/brand-mark.tsx
index bcb73dab4..b64ac8547 100644
--- a/src/components/ui/brand-mark.tsx
+++ b/src/components/ui/brand-mark.tsx
@@ -11,10 +11,13 @@ import slackLogo from './brand/slack.svg'
* brand's own colours where it has them (Figma, Google, Gemini, Meta,
* Photoshop, Canva, Slack, Linear, Microsoft) and in `currentColor` where the brand
* itself asks for the text colour (GitHub, OpenAI, Cursor, OpenRouter, Apple).
+ * DeepSeek wears its whale blue; Kimi's K takes the text colour beside its
+ * blue dot.
* Claude's default is Anthropic's terracotta; `color` overrides any of the
* single-colour marks.
*
- * Paths: Simple Icons (CC0) for Claude, OpenAI, Cursor and GitHub; the
+ * Paths: Simple Icons (CC0) for Claude, OpenAI, Cursor and GitHub; Lobe Icons
+ * (MIT) for DeepSeek and Kimi; the
* providers' own sign-in branding assets for Google, Apple and Microsoft;
* each company's brand page for the rest. Wordmarks and tiles that belong to
* a feature (the automation chain's clock, the integration tiles) stay with
@@ -31,6 +34,8 @@ export type Brand =
| 'cursor'
| 'gemini'
| 'openrouter'
+ | 'deepseek'
+ | 'kimi'
| 'google'
| 'apple'
| 'microsoft'
@@ -59,6 +64,22 @@ const OPENAI_PATH =
const OPENROUTER_PATH =
'M198.973 0c29.97 0 54.265 24.296 54.265 54.265s-24.294 54.266-54.265 54.266l53.826 53.826c6.838 6.837 1.995 18.528-7.673 18.528H90.442C40.492 180.885 0 140.392 0 90.442S40.492 0 90.442 0zM90.443 36.177c-29.97 0-54.266 24.295-54.266 54.265s24.295 54.265 54.265 54.265s54.265-24.295 54.265-54.265s-24.295-54.265-54.265-54.265'
+/** DeepSeek's whale (Lobe Icons, MIT). */
+const DEEPSEEK_PATH =
+ 'M23.748 4.482c-.254-.124-.364.113-.512.234-.051.039-.094.09-.137.136-.372.397-.806.657-1.373.626-.829-.046-1.537.214-2.163.848-.133-.782-.575-1.248-1.247-1.548-.352-.156-.708-.311-.955-.65-.172-.241-.219-.51-.305-.774-.055-.16-.11-.323-.293-.35-.2-.031-.278.136-.356.276-.313.572-.434 1.202-.422 1.84.027 1.436.633 2.58 1.838 3.393.137.093.172.187.129.323-.082.28-.18.552-.266.833-.055.179-.137.217-.329.14a5.526 5.526 0 01-1.736-1.18c-.857-.828-1.631-1.742-2.597-2.458a11.365 11.365 0 00-.689-.471c-.985-.957.13-1.743.388-1.836.27-.098.093-.432-.779-.428-.872.004-1.67.295-2.687.684a3.055 3.055 0 01-.465.137 9.597 9.597 0 00-2.883-.102c-1.885.21-3.39 1.102-4.497 2.623C.082 8.606-.231 10.684.152 12.85c.403 2.284 1.569 4.175 3.36 5.653 1.858 1.533 3.997 2.284 6.438 2.14 1.482-.085 3.133-.284 4.994-1.86.47.234.962.327 1.78.397.63.059 1.236-.03 1.705-.128.735-.156.684-.837.419-.961-2.155-1.004-1.682-.595-2.113-.926 1.096-1.296 2.746-2.642 3.392-7.003.05-.347.007-.565 0-.845-.004-.17.035-.237.23-.256a4.173 4.173 0 001.545-.475c1.396-.763 1.96-2.015 2.093-3.517.02-.23-.004-.467-.247-.588zM11.581 18c-2.089-1.642-3.102-2.183-3.52-2.16-.392.024-.321.471-.235.763.09.288.207.486.371.739.114.167.192.416-.113.603-.673.416-1.842-.14-1.897-.167-1.361-.802-2.5-1.86-3.301-3.307-.774-1.393-1.224-2.887-1.298-4.482-.02-.386.093-.522.477-.592a4.696 4.696 0 011.529-.039c2.132.312 3.946 1.265 5.468 2.774.868.86 1.525 1.887 2.202 2.891.72 1.066 1.494 2.082 2.48 2.914.348.292.625.514.891.677-.802.09-2.14.11-3.054-.614zm1-6.44a.306.306 0 01.415-.287.302.302 0 01.2.288.306.306 0 01-.31.307.303.303 0 01-.304-.308zm3.11 1.596c-.2.081-.399.151-.59.16a1.245 1.245 0 01-.798-.254c-.274-.23-.47-.358-.552-.758a1.73 1.73 0 01.016-.588c.07-.327-.008-.537-.239-.727-.187-.156-.426-.199-.688-.199a.559.559 0 01-.254-.078c-.11-.054-.2-.19-.114-.358.028-.054.16-.186.192-.21.356-.202.767-.136 1.146.016.352.144.618.408 1.001.782.391.451.462.576.685.914.176.265.336.537.445.848.067.195-.019.354-.25.452z'
+
+/** DeepSeek's whale blue. */
+const DEEPSEEK_COLOR = '#4D6BFE'
+
+/** Kimi's K and the dot over it (Lobe Icons, MIT). */
+const KIMI_K_PATH =
+ 'M11.065 11.199l7.257-7.2c.137-.136.06-.41-.116-.41H14.3a.164.164 0 00-.117.051l-7.82 7.756c-.122.12-.302.013-.302-.179V3.82c0-.127-.083-.23-.185-.23H3.186c-.103 0-.186.103-.186.23V19.77c0 .128.083.23.186.23h2.69c.103 0 .186-.102.186-.23v-3.25c0-.069.025-.135.069-.178l2.424-2.406a.158.158 0 01.205-.023l6.484 4.772a7.677 7.677 0 003.453 1.283c.108.012.2-.095.2-.23v-3.06c0-.117-.07-.212-.164-.227a5.028 5.028 0 01-2.027-.807l-5.613-4.064c-.117-.078-.132-.279-.028-.381z'
+const KIMI_DOT_PATH =
+ 'M21.846 0a1.923 1.923 0 110 3.846H20.15a.226.226 0 01-.227-.226V1.923C19.923.861 20.784 0 21.846 0z'
+
+/** The blue of Kimi's dot. */
+const KIMI_COLOR = '#1783FF'
+
/** ByteDance's four bars, which its Seed lab (Seedream) wears in a blue-teal blend. */
const BYTEDANCE_PATH =
'M19.877 1.469L24 2.532v18.942l-4.123 1.056zM6.53 10.897l4.115 1.064v8.978L6.53 22.003zM0 2.572l4.115 1.064v16.736L0 21.428zm17.455 5.62V19.3l-4.122-1.065V9.257z'
@@ -215,6 +236,16 @@ function OpenRouter({ size, color = 'currentColor', className }: GlyphProps) {
)
}
+/** Kimi's K in the text colour under its blue dot. */
+function Kimi({ size, color = 'currentColor', className }: GlyphProps) {
+ return (
+
+ )
+}
+
/** Adobe's Ps app mark (the 2025 icon from adobe.com): the dark tile with
* the two letters as a vector. */
function Photoshop({ size, className }: GlyphProps) {
@@ -238,6 +269,8 @@ const MARKS: Record JSX.Element> = {
cursor: path(CURSOR_PATH),
gemini: Gemini,
openrouter: OpenRouter,
+ deepseek: path(DEEPSEEK_PATH, DEEPSEEK_COLOR),
+ kimi: Kimi,
google: Google,
apple: path(APPLE_PATH),
microsoft: Microsoft,
@@ -260,6 +293,8 @@ export type AppIconBrand =
| 'openai'
| 'gemini'
| 'openrouter'
+ | 'deepseek'
+ | 'kimi'
| 'seedream'
| 'codex'
| 'cursor'
@@ -323,6 +358,17 @@ const APP_TILES: Record = {
tile: '#111',
glyph: () => ,
},
+ deepseek: { tile: DEEPSEEK_COLOR, glyph: () => },
+ /* Kimi's app icon: the white K and its blue dot on black */
+ kimi: {
+ tile: '#111',
+ glyph: () => (
+ <>
+
+
+ >
+ ),
+ },
/* the knot reversed out of black, beside ChatGPT's black on white */
codex: { tile: '#111', glyph: () => },
cursor: { tile: '#14120b', glyph: () => },
diff --git a/src/lib/api.ts b/src/lib/api.ts
index a1007929b..d5645a596 100644
--- a/src/lib/api.ts
+++ b/src/lib/api.ts
@@ -149,7 +149,15 @@ export interface Allowance {
onOwnAccount: boolean
}
-export type ModelAccountKind = 'chatgpt' | 'openai-key' | 'anthropic-key' | 'openrouter-key' | 'gemini-key'
+export type ModelAccountKind =
+ | 'chatgpt'
+ | 'openai-key'
+ | 'anthropic-key'
+ | 'openrouter-key'
+ | 'gemini-key'
+ | 'deepseek-key'
+ | 'kimi-key'
+ | 'kimi-code'
/** An in-flight device sign-in: the user types `userCode` at `verificationUrl`
* and the server polls OpenAI until they approve. */
@@ -575,6 +583,12 @@ export const api = {
req('/api/model-account/openrouter-key', { method: 'POST', body: JSON.stringify({ apiKey }) }),
connectGeminiKey: (apiKey: string) =>
req('/api/model-account/gemini-key', { method: 'POST', body: JSON.stringify({ apiKey }) }),
+ connectDeepSeekKey: (apiKey: string) =>
+ req('/api/model-account/deepseek-key', { method: 'POST', body: JSON.stringify({ apiKey }) }),
+ connectKimiKey: (apiKey: string) =>
+ req('/api/model-account/kimi-key', { method: 'POST', body: JSON.stringify({ apiKey }) }),
+ connectKimiCodeKey: (apiKey: string) =>
+ req('/api/model-account/kimi-code', { method: 'POST', body: JSON.stringify({ apiKey }) }),
disconnectModelAccount: (kind: ModelAccountKind) =>
req(`/api/model-account/${kind}`, { method: 'DELETE' }),
setAgentModel: (kind: ModelAccountKind, model: string) =>
diff --git a/src/lib/i18n/en/models.ts b/src/lib/i18n/en/models.ts
index 6a035ac9b..4fd46d568 100644
--- a/src/lib/i18n/en/models.ts
+++ b/src/lib/i18n/en/models.ts
@@ -19,6 +19,9 @@ export const models = {
openaiKeyShort: 'Pay per token',
openrouterKeyShort: 'Kimi, Qwen, GLM, DeepSeek and more',
geminiKeyShort: 'Gemini, plus Nano Banana images',
+ deepseekKeyShort: 'DeepSeek V4, with your own key',
+ kimiKeyShort: 'Kimi K3, with your own key',
+ kimiCodeShort: 'Your Kimi membership, through a Kimi Code key',
claudeKeyShort: 'Pay per token, runs on Doop’s server',
claudePlanShort: 'Your Claude subscription, on this Mac',
downloadShort: 'Get the app',
@@ -81,6 +84,10 @@ export const models = {
openaiKeyTitle: 'OpenAI API key',
openrouterKeyTitle: 'OpenRouter API key',
geminiKeyTitle: 'Gemini API key',
+ deepseekKeyTitle: 'DeepSeek API key',
+ kimiKeyTitle: 'Kimi API key',
+ kimiCodeTitle: 'Kimi Code plan',
+ kimiCodePlaceholder: 'Key from the Kimi Code console',
claudeKeyTitle: 'Claude API key',
/* LocalClaude */
diff --git a/src/lib/i18n/pt-BR/models.ts b/src/lib/i18n/pt-BR/models.ts
index 6d3ce6ea9..e59bdbf04 100644
--- a/src/lib/i18n/pt-BR/models.ts
+++ b/src/lib/i18n/pt-BR/models.ts
@@ -19,6 +19,9 @@ export const models: Catalog['models'] = {
openaiKeyShort: 'Pague por token',
openrouterKeyShort: 'Kimi, Qwen, GLM, DeepSeek e mais',
geminiKeyShort: 'Gemini, mais imagens com Nano Banana',
+ deepseekKeyShort: 'DeepSeek V4, com a sua própria chave',
+ kimiKeyShort: 'Kimi K3, com a sua própria chave',
+ kimiCodeShort: 'Sua assinatura do Kimi, com uma chave do Kimi Code',
claudeKeyShort: 'Pague por token, roda no servidor do Doop',
claudePlanShort: 'Sua assinatura do Claude, neste Mac',
downloadShort: 'Baixar o app',
@@ -83,6 +86,10 @@ export const models: Catalog['models'] = {
openaiKeyTitle: 'Chave de API da OpenAI',
openrouterKeyTitle: 'Chave de API do OpenRouter',
geminiKeyTitle: 'Chave de API do Gemini',
+ deepseekKeyTitle: 'Chave de API do DeepSeek',
+ kimiKeyTitle: 'Chave de API do Kimi',
+ kimiCodeTitle: 'Plano Kimi Code',
+ kimiCodePlaceholder: 'Chave do console do Kimi Code',
claudeKeyTitle: 'Chave de API do Claude',
/* LocalClaude */
diff --git a/tests/chatCompletionsAgent.test.ts b/tests/chatCompletionsAgent.test.ts
index 3bb8bb733..773b85cbd 100644
--- a/tests/chatCompletionsAgent.test.ts
+++ b/tests/chatCompletionsAgent.test.ts
@@ -3,7 +3,9 @@ import type Anthropic from '@anthropic-ai/sdk'
import {
_internal,
IMAGE_OMITTED_NOTE,
+ deepseekConfig,
geminiConfig,
+ kimiConfig,
openrouterConfig,
runChatCompletionsTurn,
} from '../server/chatCompletionsAgent.ts'
@@ -13,7 +15,8 @@ import { IMAGE_NOTE, ModelAuthError, ModelUnavailableError } from '../server/ope
* The Chat Completions transport speaks the same Anthropic message shape the
* agent loop is written in. These tests pin the mapping in both directions,
* the degraded no-vision path (images become text notes), and the fixed
- * request/headers — without ever calling OpenRouter or Google.
+ * request/headers — without ever calling OpenRouter, Google, DeepSeek or
+ * Moonshot.
*/
const { toMessages, toTools, fromCompletion } = _internal
@@ -206,6 +209,24 @@ describe('the request', () => {
expect((init!.headers as Record).Authorization).toBe('Bearer AIzaKey')
})
+ it('sends DeepSeek and Kimi turns to their own fixed endpoints', async () => {
+ const fetchSpy = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementation(async () => new Response(JSON.stringify({ choices: [{ message: { content: 'ok' } }] })))
+ await runChatCompletionsTurn(deepseekConfig('sk-deep', 'deepseek-flash', true), req)
+ await runChatCompletionsTurn(kimiConfig('sk-kimi', 'kimi-k3.1-pro', true), req)
+ const [[deepUrl, deepInit], [kimiUrl, kimiInit]] = fetchSpy.mock.calls as [
+ [string, RequestInit],
+ [string, RequestInit],
+ ]
+ expect(String(deepUrl)).toBe('https://api.deepseek.com/chat/completions')
+ expect((deepInit.headers as Record).Authorization).toBe('Bearer sk-deep')
+ expect(String(kimiUrl)).toBe('https://api.moonshot.ai/v1/chat/completions')
+ expect((kimiInit.headers as Record).Authorization).toBe('Bearer sk-kimi')
+ /* Kimi refuses a temperature other than its own; the transport sends none */
+ expect(JSON.parse(String(kimiInit.body))).not.toHaveProperty('temperature')
+ })
+
it('classifies a 401 as a dead credential and a missing model as unavailable', async () => {
vi.spyOn(globalThis, 'fetch').mockResolvedValue(new Response('nope', { status: 401 }))
await expect(runChatCompletionsTurn(openrouterConfig('sk-or-x', 'm', true), req)).rejects.toThrow(ModelAuthError)
@@ -218,3 +239,61 @@ describe('the request', () => {
)
})
})
+
+describe('reasoning_content', () => {
+ const reasoned = {
+ choices: [
+ {
+ finish_reason: 'tool_calls',
+ message: {
+ content: null,
+ reasoning_content: 'A hero needs a headline first.',
+ tool_calls: [{ id: 'call_1', function: { name: 'create_frame', arguments: '{"name":"Hero"}' } }],
+ },
+ },
+ ],
+ }
+
+ it('keeps the reasoning as a thinking block ahead of the call', () => {
+ const result = fromCompletion(reasoned, 'DeepSeek')
+ expect(result.stop_reason).toBe('tool_use')
+ expect(result.content[0]).toEqual({ type: 'thinking', thinking: 'A hero needs a headline first.', signature: '' })
+ expect(result.content[1]).toMatchObject({ type: 'tool_use', id: 'call_1' })
+ })
+
+ it('sends it back only where the provider asks for it', () => {
+ const history: Anthropic.MessageParam[] = [
+ { role: 'user', content: 'make a hero' },
+ { role: 'assistant', content: fromCompletion(reasoned, 'Kimi').content },
+ { role: 'user', content: [{ type: 'tool_result', tool_use_id: 'call_1', content: 'created' }] },
+ ]
+ expect(toMessages('sys', history, true, true)[2]).toMatchObject({
+ role: 'assistant',
+ content: null,
+ reasoning_content: 'A hero needs a headline first.',
+ tool_calls: [{ id: 'call_1' }],
+ })
+ expect(toMessages('sys', history, true)[2]).not.toHaveProperty('reasoning_content')
+ })
+
+ it('round-trips the reasoning through a DeepSeek run', async () => {
+ const fetchSpy = vi
+ .spyOn(globalThis, 'fetch')
+ .mockImplementationOnce(async () => new Response(JSON.stringify(reasoned)))
+ .mockImplementationOnce(async () => new Response(JSON.stringify({ choices: [{ message: { content: 'Done' } }] })))
+ const config = deepseekConfig('sk-deep', 'deepseek-flash', true)
+ const messages: Anthropic.MessageParam[] = [{ role: 'user', content: 'make a hero' }]
+ const first = await runChatCompletionsTurn(config, { system: 'sys', tools: [TOOL], messages, maxTokens: 16000 })
+ messages.push({ role: 'assistant', content: first.content })
+ messages.push({ role: 'user', content: [{ type: 'tool_result', tool_use_id: 'call_1', content: 'created' }] })
+ await runChatCompletionsTurn(config, { system: 'sys', tools: [TOOL], messages, maxTokens: 16000 })
+ const second = JSON.parse(String(fetchSpy.mock.calls[1]![1]!.body)) as { messages: Record[] }
+ expect(second.messages[2]).toMatchObject({ role: 'assistant', reasoning_content: 'A hero needs a headline first.' })
+ })
+
+ it('still fails a response that only thought', () => {
+ expect(() => fromCompletion({ choices: [{ message: { reasoning_content: 'hmm' } }] }, 'Kimi')).toThrow(
+ /empty response/,
+ )
+ })
+})
diff --git a/tests/chatgptProviderSwitch.test.tsx b/tests/chatgptProviderSwitch.test.tsx
index f6dd8fe28..5c63d80a8 100644
--- a/tests/chatgptProviderSwitch.test.tsx
+++ b/tests/chatgptProviderSwitch.test.tsx
@@ -39,7 +39,16 @@ const view = (accounts: { kind: string; enabled: boolean; plan?: string }[]) =>
accounts: accounts.map((a) => ({ connectedAt: 1, ...a })),
default: 'claude-local',
chatgptEnabled: true,
- menus: { chatgpt: [], 'openai-key': [], 'anthropic-key': [], 'openrouter-key': [], 'gemini-key': [] },
+ menus: {
+ chatgpt: [],
+ 'openai-key': [],
+ 'anthropic-key': [],
+ 'openrouter-key': [],
+ 'gemini-key': [],
+ 'deepseek-key': [],
+ 'kimi-key': [],
+ 'kimi-code': [],
+ },
})
const keyOnly = view([{ kind: 'openai-key', enabled: true }])
const withChatgpt = view([
diff --git a/tests/keyRotation.test.tsx b/tests/keyRotation.test.tsx
index 138c53c2e..3a8782b21 100644
--- a/tests/keyRotation.test.tsx
+++ b/tests/keyRotation.test.tsx
@@ -12,7 +12,16 @@ const claudeView = {
accounts: [{ kind: 'anthropic-key', enabled: true, model: 'claude-opus-5', connectedAt: 1 }],
default: 'anthropic-key',
chatgptEnabled: true,
- menus: { chatgpt: [], 'openai-key': [], 'anthropic-key': [], 'openrouter-key': [], 'gemini-key': [] },
+ menus: {
+ chatgpt: [],
+ 'openai-key': [],
+ 'anthropic-key': [],
+ 'openrouter-key': [],
+ 'gemini-key': [],
+ 'deepseek-key': [],
+ 'kimi-key': [],
+ 'kimi-code': [],
+ },
}
vi.mock('../src/lib/auth', () => ({ authClient: { useSession: () => ({ data: { user: { id: 'alice' } } }) } }))
vi.mock('../src/lib/api', () => ({
diff --git a/tests/providerKeyAccounts.test.ts b/tests/providerKeyAccounts.test.ts
index 3871f8de3..c342d3ad9 100644
--- a/tests/providerKeyAccounts.test.ts
+++ b/tests/providerKeyAccounts.test.ts
@@ -61,6 +61,30 @@ it('stores a Gemini key beside the OpenRouter one, each with its own model', asy
expect(accountIn(await (await alice.get('/api/model-account')).json(), 'openrouter-key')).toBeTruthy()
})
+it('stores DeepSeek and Kimi keys, each held to its own roster', async () => {
+ for (const [kind, key, model, other] of [
+ ['deepseek-key', 'sk-deepseekTestKeyLongEnough01', 'deepseek-flash', 'deepseek-v4-pro'],
+ ['kimi-key', 'sk-kimiTestKeyLongEnoughToPass01', 'kimi-k3.1-pro', 'kimi-k3'],
+ ['kimi-code', 'sk-kimiCodeTestKeyLongEnough0001', 'k3.1-pro', 'k3'],
+ ] as const) {
+ expect((await alice.post(`/api/model-account/${kind}`, { apiKey: 'has spaces in it, long enough' })).status).toBe(
+ 400,
+ )
+ expect((await alice.post(`/api/model-account/${kind}`, { apiKey: 'sk-short' })).status).toBe(400)
+ const response = await alice.post(`/api/model-account/${kind}`, { apiKey: key })
+ expect(response.status).toBe(200)
+ const view = (await response.json()) as View
+ expect(accountIn(view, kind)).toMatchObject({ enabled: true, model })
+ expect(JSON.stringify(view)).not.toContain(key)
+ expect((await alice.patch(`/api/model-account/${kind}`, { model: 'moonshotai/kimi-k3' })).status).toBe(400)
+ expect((await alice.patch(`/api/model-account/${kind}`, { model: other })).status).toBe(200)
+ expect((await alice.delete(`/api/model-account/${kind}`)).status).toBe(200)
+ }
+ const { menus } = await (await alice.get('/api/model-account')).json()
+ expect(menus['deepseek-key'].map((m: { id: string }) => m.id)).toContain('deepseek-flash')
+ expect(menus['kimi-key'].every((m: { vision: boolean }) => m.vision)).toBe(true)
+})
+
it('validates image-model picks against the registry and this user’s credentials', async () => {
/* nothing connected, no server keys in this harness: every entry is
visible but unavailable, and picking one is refused */
diff --git a/tests/rosterRouting.test.ts b/tests/rosterRouting.test.ts
index db59e532b..dcbe6719d 100644
--- a/tests/rosterRouting.test.ts
+++ b/tests/rosterRouting.test.ts
@@ -72,3 +72,44 @@ it('routes a Gemini account with its default model and vision intact', async ()
expect(await model!.run(request)).toMatchObject({ stop_reason: 'end_turn' })
expect(String(fetchSpy.mock.calls[0]![0])).toContain('generativelanguage.googleapis.com')
})
+
+it('routes a DeepSeek account to DeepSeek, Pro as text-only', async () => {
+ mocks.account.mockResolvedValue({ kind: 'deepseek-key', userId: 'c', apiKey: 'sk-deepseek-test-key-0123' })
+ const fetchSpy = vi
+ .spyOn(globalThis, 'fetch')
+ .mockResolvedValue(new Response(JSON.stringify({ choices: [{ message: { content: 'Done' } }] }), { status: 200 }))
+ const model = await pickModel('c')
+ expect(model).toMatchObject({ provider: 'deepseek-key', vision: true, label: 'DeepSeek (deepseek-flash)' })
+ expect(await model!.run(request)).toMatchObject({ stop_reason: 'end_turn' })
+ expect(String(fetchSpy.mock.calls[0]![0])).toContain('api.deepseek.com')
+
+ mocks.account.mockResolvedValue({ kind: 'deepseek-key', userId: 'c', apiKey: 'sk-d', model: 'deepseek-v4-pro' })
+ expect(await pickModel('c')).toMatchObject({ vision: false })
+ mocks.account.mockResolvedValue({ kind: 'deepseek-key', userId: 'c', apiKey: 'sk-d', model: 'deepseek-v9' })
+ expect(await pickModel('c')).toMatchObject({ vision: false })
+})
+
+it('routes a Kimi account to Moonshot with vision', async () => {
+ mocks.account.mockResolvedValue({ kind: 'kimi-key', userId: 'd', apiKey: 'sk-kimi-test-key-0123456' })
+ const fetchSpy = vi
+ .spyOn(globalThis, 'fetch')
+ .mockResolvedValue(new Response(JSON.stringify({ choices: [{ message: { content: 'Done' } }] }), { status: 200 }))
+ const model = await pickModel('d')
+ expect(model).toMatchObject({ provider: 'kimi-key', vision: true, label: 'Kimi (kimi-k3.1-pro)' })
+ expect(await model!.run(request)).toMatchObject({ stop_reason: 'end_turn' })
+ expect(String(fetchSpy.mock.calls[0]![0])).toContain('api.moonshot.ai')
+})
+
+it('routes a Kimi Code plan to the membership endpoint, naming Doop as the client', async () => {
+ mocks.account.mockResolvedValue({ kind: 'kimi-code', userId: 'e', apiKey: 'kimi-code-test-key-01234' })
+ const fetchSpy = vi
+ .spyOn(globalThis, 'fetch')
+ .mockResolvedValue(new Response(JSON.stringify({ choices: [{ message: { content: 'Done' } }] }), { status: 200 }))
+ const model = await pickModel('e')
+ expect(model).toMatchObject({ provider: 'kimi-code', vision: true, label: 'Kimi Code (k3.1-pro)' })
+ expect(await model!.run(request)).toMatchObject({ stop_reason: 'end_turn' })
+ const [url, init] = fetchSpy.mock.calls[0]!
+ expect(String(url)).toBe('https://api.kimi.ai/coding/v1/chat/completions')
+ expect((init!.headers as Record)['User-Agent']).toMatch(/^Doop\/\d+\.\d+\.\d+/)
+ expect(JSON.parse(String(init!.body))).toMatchObject({ model: 'k3.1-pro' })
+})