dsh-plugin-ocr: Replacing Vision-Based Document Reading with DeepSeek OCR

Preface

In DeepSeek Harness (DSH), when dealing with PDFs, scanned documents, or photos, a common approach is to let the conversational model “see” the images directly: multi-page documents consume a large amount of visual tokens and are costly. If the goal is simply to extract the text from the pages for further analysis, a more suitable path is to hand the file over to a dedicated OCR service, allowing the conversational model to process only plain text.

dsh-plugin-ocr (repository 1111210/dsh-plugin-ocr) addresses this need: it adds the model-callable tool ocr_extract and the skill ocr-extract to each agent in the profile. The skill determines “when to read locally and when to call OCR,” avoiding the mistake of sending machine-readable documents into OCR.

What is this

  • Maintainer: GitHub user 1111210
  • Category: Model Inference (Community Directory categorization)
  • License: MIT (package.json version 1.0.0)
  • Positioning: No standalone UI; agents initiate recognition via tools, and skills define call boundaries. Recognition is completed on the DeepSeek OCR API side, so the conversational model does not consume visual tokens for pages.

Core Features

After installation, the bundle is named dsh-plugin-ocr, which inserts a tool-ocr entry into the profile and mounts it to each agent:

  1. Tool ocr_extract: Sends PDF, Word, PowerPoint, or images to POST https://api.deepseek.com/v1/tools/ocr with the request body carrying purpose=text_recognition; it returns the recognized text for each page in page order. By default, it strips layout markers (<|ref|>, <|box|>, etc.), keeping only plain text.
  2. Skill ocr-extract: Instructs the agent to first determine the document type—Markdown, plain text, or Office/PDF with text layers should be processed directly using read, grep, or Office tools; scanned books, manuscripts, pure image PDFs, forms, etc., should go through OCR; content where image semantics are primary, such as architectural drawings, flowcharts, and UI screenshots, should still use the model’s vision, not OCR.

If reading directly results in empty pages, garbled text, or (cid:123) placeholders, the skill will suggest treating the document as a scan and calling ocr_extract.

Installation and Enablement

In DSH, open Plugins, select Add plugin, and enter one of the following Git specs (do not use the bare package name dsh-plugin-ocr, otherwise it will look in npm registry instead of GitHub):

Spec Use Case
https://github.com/1111210/dsh-plugin-ocr Common: Repository HTTPS URL
git+ssh://git@github.com/1111210/dsh-plugin-ocr.git Local machine has GitHub SSH key, or HTTPS is blocked
github:1111210/dsh-plugin-ocr pnpm’s GitHub shorthand

Note: git@github.com:1111210/dsh-plugin-ocr.git will be rejected by pnpm (ERR_PNPM_UNSUPPORTED_PROTOCOL). If you need SSH, please use the git+ssh:// form.

The Git bundle has no Versions panel; the update method is to remove the bundle and reinstall it. Uninstalling is done by using Remove on the bundle in Plugins.

Before installation, the Plugin Manager probes the repository using git ls-remote (default ~5 seconds). It may time out on slow networks or when using a proxy. You can retry after increasing githubConnectionTimeoutMs in plugin-manager in the profile’s cordis.patch.yml, for example:

- id: plugin-manager
  name: "@deepseek-ai/dsh-plugin-manager"
  config:
    githubConnectionTimeoutMs: 20000

In proxy scenarios, Git and pnpm both need to use the proxy (README provides git config and profile .npmrc examples). After changing, restart or wait for HMR to reload the profile.

The plugin runs with the permissions of the current DSH process; it is recommended to browse the repository source code and LICENSE before installation to ensure it meets your security and compliance requirements.

Configuration and Credentials

Fields are optional; the package’s cordis.patch.yml comes with default values for tool-ocr. You can also overwrite the entire config using id: tool-ocr in the profile’s cordis.patch.yml (when overwriting, you must write out all fields you want to keep).

Field Default Value Meaning
credentialMode auto Credential order: auto, account, api-key
apiKeyEnv DEEPSEEK_OCR_API_KEY Reference to the credential for the OCR API Key
harnessApiKeyEnv DEEPSEEK_API_KEY Reference to the Harness’s general DeepSeek API Key
baseURL https://api.deepseek.com/v1/tools API base URL (change this for private deployment or test endpoints)
stripLayoutMarkers true Whether to remove layout markers, keeping only plain text
timeoutMs 210000 Tool invocation cooperation timeout (server-side recognition limit is 180 seconds)

Under auto mode, the credential attempt order is: apiKeyEnv → logged-in DeepSeek account → harnessApiKeyEnv. If an API Key is rejected, it will not silently switch to the next one; if an account token is rejected, it can fall back to the API Key. Do not write keys into the patch in plaintext; they should be placed in a credentials library (e.g., the environment pointed to by $DSH_HOME/.credentials.yaml) or in $DSH_HOME/.env as DEEPSEEK_OCR_API_KEY.

Typical Usage (Behavioral Description)

There is no separate frontend workflow: when the agent needs to handle “scanned PDF / photo invoice / DOCX without text layer” in a conversation, the skill should guide it to call ocr_extract. The tool uploads the file to DeepSeek OCR and returns paginated text, after which the agent can continue summarizing, retrieving, or structuring on the text.

The boundary with “General Document Understanding” is clearly defined in the README: this plugin only performs text recognition and does not use the rich_layout_recognition API; layout, coordinates, and illustration semantics should be left to vision or other tools.

Billing, Limits, and Outbound Data

  • Billed by number of recognized pages: 1.5 CNY per 1000 pages, recorded in the account corresponding to the credential actually used for this call; failed or timeout recognitions are not billed.
  • Single file limit: 100 MiB and 1000 pages; single call max 180 seconds; upload must complete within 120 seconds; max 15 concurrent recognition paths per account.
  • Data destination: Documents are sent to api.deepseek.com (or the configured baseURL), not entering DeepSeek Files API long-term storage; Harness only retains recognized text in tool results; very large results fall into the same result spill storage as other tools.

Known Limitations

  • Default is text-only output, no coordinates or layout; documents significant mainly within images are not suitable to rely solely on this tool.
  • One file per call, one API request; documents of thousands of pages must wait for the entire recognition to finish before returning.
  • When a page’s finish_reason is length, the server will truncate; the tool will indicate which pages were truncated.
  • In auto credential mode, if both a logged-in account and an API Key exist, the billing entity may differ from expectations; you can explicitly set credentialMode.

Conclusion

If your agent workflow is primarily “extracting text from scans and photos,” dsh-plugin-ocr integrates DeepSeek OCR as a standard tool and skill, dividing labor with local reading and model vision, helping to control visual tokens and recognition costs.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye