chat-demo: DeepSeek's Chat App With No Server Behind It

DeepSeek open-sourced the frontend behind its assistant as one static page. Making the browser do a backend's job meant writing an SSE parser, an error taxonomy, and abort handling from scratch.

9 min read • View on GitHub • More from deepseek-ai

A wide editorial illustration of an empty data center. Server racks have been removed, leaving only mounting rails and faint dust outlines on a bare concrete floor. A single open laptop sits on a plain table in the center, and every loose network cable that once ran to the racks now loops back and plugs into the laptop's own ports. The image argues that the work a server room used to do has relocated into one small machine, which is exactly what chat-demo does by running its whole backend in the browser.
The server room is present but empty. The work moved to the one small machine in the middle.
Key Takeaways

The App That Is a File

You download a ZIP. You open index.html. You paste an API key. You are chatting with DeepSeek. There is no server anywhere in that sequence.

That is the whole pitch of deepseek-ai/chat-demo, and it is worth sitting with. DeepSeek did not publish a reference client, or a component library, or a starter template. It published the frontend of its own assistant as a static page, MIT-licensed, that runs from a file:// URL.

The announcement framed it as the app's capabilities arriving through the API: web search, deep thinking, files and PDFs, link reading, OCR, speech, and import of existing DeepSeek conversation history. The demo is the front door to all of it, and the door turned out to be a file.

The rest of this article is about what that costs. Not in dollars yet. In engineering.

No Server Means No Safety Net

When the backend disappears, the browser inherits every job it used to do. Conversations and original attachments live in IndexedDB. Settings and the API key live in localStorage. There is no session cookie, no server-side cache, no place to hide a secret.

The app is defensive about this. App.tsx renders four distinct states: store not ready, init failed, session loading, and session load failed. Each has its own retry path. That is more care than most demos take, and it is a tell. The authors knew there was no safety net behind the UI.

The trade is plain. Your data stays on your machine until you send it. Your key sits in the browser, where anyone with access to that machine can read it.

A static chat demo powered by the DeepSeek API. No application backend is required: the browser connects directly to the configured API service.

DeepSeek, Official project README · deepseek-ai/chat-demo README

It Speaks Anthropic

Here is the twist. This is DeepSeek's client, but the message path does not speak DeepSeek's dialect. It speaks Anthropic's.

The app talks to three base paths. ${API_ORIGIN}/anthropic/v1 handles messages and files, authenticated with x-api-key. ${API_ORIGIN}/models verifies the key using an OpenAI-style Bearer token. ${API_ORIGIN}/v1/tools runs speech, also Bearer. One client, three dialects, in one file.

The anthropic-beta: files-api-2025-04-14 header is conditional. It is added only when hasFile(body) finds an image or document block in the request. Plain text chat never opts into the beta. That restraint keeps a demo from breaking the moment the beta moves.

Why does this matter beyond trivia? Because it means the client is portable to any Anthropic-compatible endpoint. A demo that only worked against DeepSeek would be a curiosity. A client that speaks a standard surface is a starting point.

A close-up editorial illustration of two hands holding a short black cable whose far end splits into three distinctly shaped plugs. Each plug is seated in its own wall socket, and a small paper tag hangs from one plug on a loop of string. The image makes chat-demo's protocol mix physical and immediate: one client, three connectors, and one tag added only for certain loads, which is how the conditional Anthropic beta header behaves.
One client, three connectors, one conditional tag. The protocol mix, made physical.

The Parser That Replaces EventSource

EventSource cannot do POST. The browser's built-in SSE client only issues GET requests, and a chat needs to send a JSON body. So chat-demo writes the WHATWG Server-Sent Events interpretation algorithm from scratch on top of fetch and the Web Streams API.

The core is ServerSentEventDecoder, a line-oriented state machine. Chunks arrive, get appended to a buffer, and get scanned for line breaks with /\r\n|\r|\n/g. Fields follow the spec: a leading : marks a comment (used for keep-alives), a single leading space after the colon is stripped, multiple data: lines join with \n, and an id containing a NUL byte is ignored.

The single cleverest detail is one character long. A trailing \r at the end of a chunk is held back, because it might be the first half of a \r\n split across two network reads.

if (match[0] === '\r' && LINE_BREAK.lastIndex === this.buffer.length) {
  break
}

Get that wrong and a CRLF split across chunks reads as two line endings, which produces a spurious empty line, which dispatches an event early. The bug is invisible until the network happens to split a packet in exactly the wrong place.

Two more details earn their keep. TextDecoder runs with { stream: true } so a multi-byte UTF-8 character split across chunks decodes correctly. And on abort, the reader calls reader.cancel(signal.reason) explicitly, because the code refuses to trust the network layer to propagate a stop to the response body.

The SSE decoder holds back a trailing carriage return at a chunk boundary so a split CRLF never fires an event early.

Errors That Know Where They Came From

A static client earns the right to be called production-quality by how it fails. ApiErrorKind is a closed five-way union, and each kind maps to a different recovery path.

The distinction that matters most is interrupted versus stream. The first means the connection dropped before the protocol said it was done, so the right recovery is to continue. The second means the server reported a problem, so the right recovery is to retry. Collapse them and you offer the wrong button.

There is a quieter detail in request(). When a user presses stop, the AbortError is propagated untouched, not reclassified as a network failure.

try {
  response = await fetch(url, init)
} catch (error) {
  if (init.signal?.aborted) {
    throw error // propagate AbortError untouched
  }
  throw new ApiError('network', ...)
}

Without that check, stopping generation would look like the network died. The stop feature depends on the distinction.

What It Costs to Run

A static client does not have a subscription. It has a bill. You pay for tokens, and you pay for tools: search and link reading bill separately. Speech is the expensive line, which is why the loudest community note about this release is about read-aloud cost, not model cost.

Then there is the comparison. chat-demo is not competing with the self-hosted field on breadth. It wins on fidelity to one API, and that is exactly why it is useful.

ProjectBackend requiredScopeDeepSeek app featuresAccounts & quotas
chat-demoNo. Static page, direct to APIDeepSeek API reference clientYes: search, URL reading, files, OCR, speech, citations, history importNo. User-supplied key
Open WebUIYes. Server deploymentBroad, multi-backend interfaceNoYes
LibreChatYes. Self-hosted appMulti-provider chat appNoYes
NextChatNo. Browser client (precursor)Generic multi-provider clientNoNo
ChatboxNo. Desktop clientGeneric multi-provider clientPartialNo

NextChat and Chatbox are the honest architectural precursors, browser and desktop clients that talk to many providers. chat-demo's difference is that it exercises DeepSeek-specific server capabilities a generic client has no reason to implement.

What a Static Client Can't Do

The honest reckoning. A static client cannot do accounts, quotas, or access control. It cannot keep a secret. The browser sends message content, attachments, and speech to the configured service, and local storage does not change that.

The fork xiaohuangbo/chat-demo-unrestricted is evidence the pattern is easy to extend. It adds configurable temperature, Top P, and token limits, custom system prompts, and editable replies. It is also a boundary marker: the fork changes what the browser sends, not what the server does. The API is still DeepSeek's.

That is the shape of the thing. DeepSeek open-sourced the front door, and the front door turned out to be a file. The interesting part was never the door. It was everything the browser had to learn to stand where the server used to.