DeepSeek Harness SDK: Python, HTTP API and gateway
DeepSeek Harness has three developer entry points: Python SDK, Typert gateway, and CLI calls. They target different callers; choosing wrong means writing code where a command would do, or assembling commands where structured results are needed.
Who each entry serves
Decide by the caller and the result you need.
| Entry | For | Solves | Stability |
|---|---|---|---|
| Python SDK | External programs | Drive sessions, structured results | Official |
| Typert gateway | Plugin front and back ends | Expose host capabilities to client | Internal mechanism |
| CLI | Scripts, CI | Trigger commands, exit codes | Official |
The SDK is for programmatic use, the gateway is for plugin internals, and the CLI is for one-off actions. Create sessions, send messages, and read results from Python (source). The gateway exposes host methods to client code and is not a public HTTP API; you meet it when writing plugin UI. The CLI handles install, start, plugin management, and commands, so scripts depend on it least.
Python SDK: minimal working example
The SDK's value is structure, not replacing the CLI.
- Install the SDK: pip install deepseek-harness-sdk.
- Prepare the environment and a writable DSH_HOME.
- Start the sdk-minimal profile with the DeepSeekHarness context manager.
- Create a session and send one test message.
- Read the result and confirm JSONL logs under DSH_HOME/sessions.
sdk-minimal is deliberately small. It reduces plugin and tool dependencies for scripted calls; switch to a fuller profile when needed.
Logs are the first diagnostic entry. If a request does not return or the result is incomplete, read the JSONL before adding prints.
Typert gateway: plugin communication
The gateway is an internal bridge, not a public interface.
- Add @Remote or @RemoteScope to host service methods to select exposure.
- Declare object and wire-identity relationships with TypertLookupMap.
- Call through the generated client entry; do not hand-write the protocol.
- Expose only necessary methods; a wider surface increases permission and security risk.
- Use logs to confirm whether a call reached the host.
@Remote controls whether a method can be called; @RemoteScope controls where it is visible (source).
Do not treat it as REST. It has no public HTTP paths or status-code semantics; understanding it as a plugin mechanism avoids fragile code.
CLI: scripts and CI
The most stable script pattern is command plus exit code.
- Confirm the environment with dsh --version.
- Confirm plugin state with dsh plugin --profile web list.
- Call the target command and capture the exit code.
- Parse standard output or switch to the SDK when structure is needed.
- Pin versions in CI to avoid pulling a different build each run.
Avoid interactive prompts in CI. Add non-interactive flags; otherwise the pipeline waits for input.
The exit code is the contract. Zero and non-zero mean success and failure; do not match output text, which changes between versions.
Authentication and timeouts
Each entry authenticates differently and needs its own timeout policy.
- SDK: provide model keys through environment variables or configuration, never hard-coded.
- Gateway: uses host permissions; no extra token, but limit exposed methods.
- CLI: reuses local configuration and login state; inject env vars in CI.
- Timeouts: request-level for SDK, process-level for CLI, call-level for the gateway.
- Retries: only for retryable errors, with a cap.
Keys do not belong in code; timeouts must be layered. Environment variables, secret managers, and CI secrets beat plaintext. Set request, task, and process limits separately; one layer alone kills long tasks.
Errors and logs
The three entries fail differently, but diagnosis starts with logs.
| Entry | Failure shape | Look at |
|---|---|---|
| SDK | Exception type and message | SDK exception and session JSONL |
| Gateway | Rejected call or timeout | Host logs and exposure scope |
| CLI | Exit code and stderr | Terminal output and system logs |
Separate "not called" from "call failed." The first checks entry configuration, the second checks the error; mixing them changes the wrong place.
Logs need context. Session ID, profile, and version make reproduction possible; "it failed" does not.
Selection table
Choose by caller, result, and dependency tolerance.
| Scenario | Entry | Reason |
|---|---|---|
| External system integration | Python SDK | Structured results, session control |
| Plugin UI calling host | Typert gateway | Internal, permission-scoped |
| Scheduled jobs, CI | CLI | Few dependencies, clear exit codes |
| One-off troubleshooting | CLI | Fastest, no code |
| Complex output parsing | SDK | Avoid text parsing |
If the CLI solves it, do not add the SDK. More code means more maintenance; use the SDK for structure and reuse.
Write plugins only with the gateway. It is not an external integration entry; treating internal mechanisms as public APIs creates fragile integrations.
Next steps
Pick the entry, then write the minimal example. For Python SDK configuration, read How to call DeepSeek Harness from Python. For @Remote, read What the DeepSeek Harness API gateway is. To write a first plugin, read Write your first DSH plugin.
Sources: DeepSeek Harness docs, dsh CLI README, deepseek-harness repository
FAQ
DeepSeek Harness exposes a Python SDK and a CLI as stable external entries; plugin front and back ends use the Typert gateway internally. Prefer the SDK rather than undocumented HTTP paths.
Install deepseek-harness-sdk and use the DeepSeekHarness context manager with the sdk-minimal profile, then send one message. Session logs are written as JSONL under DSH_HOME/sessions.
In the Typert gateway, @Remote is not an HTTP route: @Remote and @RemoteScope select which host methods are exposed to the client. TypertLookupMap declares object and wire-identity relationships.
In scripts and CI, use the DeepSeek Harness SDK when you need structured results and session control, and the CLI when you only trigger a command and read the exit code. CI prefers the CLI.
Related Terms
- Python SDK
- The Python SDK is the official programmatic entry for DeepSeek Harness, using the DeepSeekHarness context manager to drive profiles and sessions.— DeepSeek Harness docs
- Typert gateway
- The Typert gateway is the internal service-exposure mechanism between host and client, using @Remote and @RemoteScope to control visible methods.— DeepSeek Harness docs
- sdk-minimal
- sdk-minimal is a minimal profile for SDK use, reducing plugin and tool dependencies for scripted calls.— DeepSeek Harness docs
- JSONL
- JSONL is a log format with one JSON object per line; DeepSeek Harness writes session logs in this format under DSH_HOME/sessions.— DeepSeek Harness docs
Sources
- DeepSeek Harness docs· deepseek-harness
- dsh CLI README· deepseek-ai
- deepseek-harness repository· deepseek-ai