跪拜 Guibai
← Back to the summary

DeepSeek Puts Its Whole App Stack Behind One API and Open-Sources the Web Client

Really Going Hard: DeepSeek Opens Its Full-Suite API

Hello everyone, I'm Second Brother.

DeepSeek is really going hard. It has opened up all the application-layer capabilities used in the App and web client as official APIs.

This means web search, deep-thinking search, file input, link reading, content safety review, and capabilities like Search, Fetch, OCR, ASR, and TTS are all directly at our disposal.

They even worried we wouldn't know how to use them, so they open-sourced a web version of DeepSeek — fill in your API Key and you can replicate it 1:1.

What open-source spirit!

Oh my god, Saint Liang is great. Aside from TTS and ASR, I've already integrated everything into Pi Congming and tried it out.

Hope DeepSeek releases an Embedding model later, and strengthens video and text capabilities — then it would be truly invincible.

01. What the full-suite API includes

Let's take a closer look at what capabilities the full-suite API includes.

DeepSeek supports three protocols: Anthropic Messages, OpenAI Responses, and OpenAI Chat Completions.

On top of these three protocols, DeepSeek has built in several capabilities that execute directly on the server side. We just declare them in the request, and DeepSeek handles everything else. Let me explain the five most core ones.

Additionally, DeepSeek has made five underlying capabilities available as independent API endpoints that can be easily integrated into your Agent projects.

I've also organized the billing for each tool. The pricing is very reasonable.

02. Web search

Pi Congming is a RAG knowledge base project that previously could only answer based on user-uploaded documents. When users asked about content not in the knowledge base — such as the latest version releases, news, or official documentation — the model couldn't answer.

After integrating search and fetch, that problem was solved. The method is simple: wrap these two endpoints as tools and hand them to the model.

The code looks roughly like this:

public JsonNode search(String query) {
    if (query == null || query.isBlank() || query.codePointCount(0, query.length()) > 128)
        throw new IllegalArgumentException("Search term must be 1 to 128 characters");
    return execute(client().post().uri("/v1/tools/search").contentType(MediaType.APPLICATION_JSON)
            .bodyValue(Map.of("query", query, "count", 5, "need_content", false)).retrieve().bodyToMono(JsonNode.class), properties.getTimeoutSeconds());
}

public JsonNode fetch(String url) {
    validatePublicUrl(url);
    return execute(client().post().uri("/v1/tools/fetch").contentType(MediaType.APPLICATION_JSON)
            .bodyValue(Map.of("url", url)).retrieve().bodyToMono(JsonNode.class), properties.getTimeoutSeconds());
}

When searching, pass need_content = false to only read summaries instead of full page content; the benefit is saving tokens. The model first looks at summaries to judge which pages are useful, then only reads the pages it actually needs, rather than stuffing the full text of a bunch of irrelevant pages into the context.

Why not use the built-in deepseek_web_search from the chat API?

Because DeepSeek stipulates that built-in tools and self-defined tools cannot be mixed in the same request. Pi Congming also needs to call its own knowledge base retrieval tool, so it has to use the independent endpoints. If you're just building a plain chat client, the built-in tool is easier.

The officially open-sourced chat-demo uses the built-in tool. Looking at its conversation handling logic, you can see how it works across multiple turns.

After the built-in link reading tool fetches a page, the content field in the returned result is empty; the page content is encrypted server-side and stored in a signature field (signature).

In the next turn, the frontend deletes all the previous reasoning process and search results, and only passes back the web reading records along with the signature unchanged.

if (
  block.type === 'server_tool_use' &&
  block.kind === 'read_link' &&
  !unsignedReadLinks.has(block.id)
) {
  const { type, id, name, input, kind } = block
  content.push({ type, id, name, input, kind })
} else if (
  block.type === 'web_fetch_tool_result' &&
  block.kind === 'read_link' &&
  !unsignedReadLinks.has(block.tool_use_id)
) {
  content.push(block)
}

After the server receives the signature, it internally decrypts, restores the page content, and splices it back into the context.

Here's the actual result after Pi Congming integrated the web search API.

With the "web search" toggle in the bottom left of the conversation input box on, the model queries both the knowledge base and the external web simultaneously, with citations numbered uniformly. External pages display as source cards showing the fetch time and the quoted original fragments for easy verification.

There's also a "Save to knowledge base" button in the top right of the card. Spot a valuable page, click it, and it's stored in your knowledge base for direct retrieval next time.

03. Attachment Q&A

A user has a PDF and wants to ask a few questions on the fly, without putting it into the knowledge base. In that case, use the Files API — the effect is exactly the same as "upload attachment then ask" on the DeepSeek web client.

Usage is three steps:

  1. Upload the file, using the purpose field to specify the parsing method.
  2. Get the returned file ID.
  3. When asking, put the file ID and the question in the same user message sent to the model.

There are three parsing methods; pick the most appropriate one by file type.

Note that when uploading, the purpose field must come before the file field, otherwise the API reports an error.

Pi Congming added a paperclip button at the bottom right of the conversation input box for uploading temporary attachments. When asking, put the question and file ID into the content array of the same user message:

if (!attachments.isEmpty()) {
    List<Map<String, Object>> content = new ArrayList<>();
    content.add(Map.of("type", "text", "text", userMessage + "\nTemporary attachments this turn: " + attachments.stream().map(a -> a.getFileName()).toList()
            + ". Mention the attachment name in the answer; do not fabricate page numbers not provided."));
    attachments.forEach(a -> content.add(Map.of("type", "file", "file_id", a.getRemoteFileId())));
    messages.get(messages.size() - 1).put("content", content);
}

There are two engineering details to handle in practice.

First, the Files API charges once based on the number of document pages, but the JSON returned by the endpoint only contains the file ID and byte count, not the page count. If a user uploads a password-protected PDF or a very large several-hundred-page file, sending it as-is to the upstream would error, and overlong documents would waste a lot of tokens. So Pi Congming adds a preprocessing step before uploading, using PDFBox and headless LibreOffice locally to compute the actual page count and block encrypted files; only after confirming compliance does it call the /files endpoint.

Second, files are parsed synchronously within the upload request; the response returns only after parsing is complete. If a user closes the webpage mid-upload, the connection is broken, but DeepSeek's server still parses the file and charges as usual. For this reason, Pi Congming generates a unique task filename during upload; if it times out and disconnects mid-way, the background recovery task calls GET /files to look up that filename, and if the file is found to have been created, it claims the file_id back, avoiding token waste on re-upload.

04. OCR

Content parsed by the Files API cannot be downloaded, so it can't be chunked and stored into the knowledge base. For ingestion, OCR is needed.

This time, I replaced Alibaba Cloud OCR with DeepSeek OCR. Previously I ran a week of Alibaba's OCR and burned through 500+ yuan — it was genuinely expensive. This time I also wanted to observe how well DeepSeek performs.

For scanned PDFs, after upload, the text on every page is recognized, then chunked and stored into the knowledge base.

DeepSeek OCR returns more than plain text; it wraps each segment of text in <ref> and <box> tags, for example <ref>Title<ref><box>[[52, 40, 948, 96]]<box>.

Pi Congming extracts these tags with regex, then computes the image's real width and height to restore the precise position of each line on the page, preserving the layout.

for (JsonNode page : ocr.recognize(bytes).path("pages")) {
    String raw = page.path("text").asText("");
    var matcher = BLOCK.matcher(raw);
    while (matcher.find()) {
        String text = matcher.group(6).trim();
        if (text.isEmpty()) text = matcher.group(1).trim();
        if (text.isEmpty()) continue;
        List<Double> bbox = List.of(coordinate(matcher.group(2), image.getWidth()),
                coordinate(matcher.group(3), image.getHeight()), coordinate(matcher.group(4), image.getWidth()),
                coordinate(matcher.group(5), image.getHeight()));
        results.add(Map.of("text", text, "bbox", bbox, "confidence", 1.0));
    }
}

But OCR alone isn't enough.

Technical documents and financial reports often contain architecture diagrams, line charts, and flow charts. OCR can only recognize text; it can't understand where arrows point or how curves change.

If every page were screenshotted and fed to a vision model, the cost would be too high. During document parsing, Pi Congming uses PDFBox first to scan the underlying drawing instructions on each page; only when embedded images or line drawing are detected does it render that page to PNG and hand it to deepseek-flash to generate a text description, which gets stored in the knowledge base alongside the main text.

The model-generated descriptions may miss some details, so Pi Congming added another step: when answering, if retrieved content contains images, it converts the original image to Base64 and includes it in the context, letting the model verify against the original image before answering.

byte[] png = visualEvidence.image(userId, result.getUserId(), result.getFileMd5(), result.getChunkId());
blocks.add(Map.of("type", "text", "text", "Below is the original image evidence for source #" + number + " (" + result.getFileName() + "). "
        + "Verify the visual description against the original image; clearly state any details that cannot be read."));
blocks.add(Map.of("type", "image_url", "image_url", Map.of("url", "data:image/png;base64,"
        + java.util.Base64.getEncoder().encodeToString(png))));

There's also a "View original image" button below the answer that users can click to verify themselves.

05. Speech

Voice input format matters. DeepSeek's speech recognition endpoint only accepts 16-bit PCM WAV or Ogg Opus audio. The browser's built-in MediaRecorder mostly records WebM format; sending that as-is returns a 400 error.

The chat-demo recording module bypasses MediaRecorder and instead uses the Web Audio API to capture mono audio at 16000 Hz, then prepends a 44-byte WAV file header in the frontend to produce compliant WAV audio.

For reading aloud, synthesis is streamed: the server starts returning 24000 Hz 16-bit PCM byte streams as soon as the first audio segment is generated, and the browser plays each segment as it arrives, so users don't have to wait for the entire synthesis to finish before listening.

There's a byte alignment issue when processing the audio stream.

A 16-bit audio sample takes 2 bytes, but network transmission chunk lengths are not fixed. If a packet happens to end on an odd byte count, subsequent bytes will be misaligned, producing harsh electrical noise. Here's how DeepSeek's speech reading module handles it.

const bytes = new Uint8Array(rest.length + value.length)
bytes.set(rest)
bytes.set(value, rest.length)
const samples = toFloat32(bytes)
rest = bytes.slice(samples.length * 2)
if (samples.length === 0) {
  continue
}
const buffer = context.createBuffer(1, samples.length, TTS_SAMPLE_RATE)
buffer.copyToChannel(samples, 0)
const source = context.createBufferSource()
source.buffer = buffer
source.connect(context.destination)
nextTime = Math.max(nextTime, context.currentTime + (lastSource ? 0 : START_DELAY))
source.start(nextTime)
nextTime += buffer.duration
lastSource = source

It temporarily stores the leftover 1 odd byte at the end of the current packet, prepends it to the next packet before converting to audio samples, and plays segments in sequence on the playback timeline, so it sounds like a complete audio track.

Ending

After integrating DeepSeek's full-suite API into Pi Congming, my biggest feeling is how worry-free it is.

Previously, OCR was on Alibaba Cloud, web search on Zhipu, and TTS on Volcano Engine. Different features meant going to different platforms to open accounts, configure permissions, and pull in third-party SDKs — while also ensuring authentication and exception retries.

Now, one DeepSeek handles everything.

The key thing is that DeepSeek's reputation is well established both at home and abroad; it's genuinely unmatched in open source.

Give DeepSeek a round of applause and some encouragement. Go!

See you next time.

Comments

Top 2 from juejin.cn, machine-translated. The original thread is authoritative.

用户573468752399

After DeepSeek opens up the whole family bucket, everyone's first reaction is to grab a few more models, but the real trouble on the integration side is the metrics: the same prompt, different providers' token counts can differ by 20-30%; cache hits are sometimes listed separately, sometimes counted into input; 429 retries still get billed by the upstream. If these aren't aligned first, the costs calculated from selection are all wrong. Our approach is one gateway, one Key to call all domestic providers, with details exported by business line, and it reconciles at month-end. Details via private message.

用户55568270537

This wave is indeed practical. Previously OCR, search, speech had to integrate several providers, now one API can string them together, which saves a lot of effort for small tools. The detail that OCR returns coordinates is quite useful, and can avoid many pitfalls in document parsing.