DeepSeek Template

Updated at:

Pre-built DeepSeek Harness image addresses are listed by region. Build a template from an image, and then create sandboxes and run tasks.

Overview

DeepSeek Harness is an open-source agent harness from DeepSeek AI (npm package @deepseek-ai/dsh, CLI name dsh). It supports headless single tasks, a Web UI, and programmatic access through the SDK or Agent Client Protocol (ACP).

DeepSeek Harness images are pre-built in Container Registry (ACR) in each region, so manual image pushes and ACR EE configuration are not required. Select an image address below, and then build a template by using from_image + Template.build.

Besides the image addresses and the end-to-end steps, note the prerequisites, the custom domain requirement for browser access, and the profile capability notes.

Prerequisites

  • If you use FC Agent Sandbox for the first time, complete the preliminary preparation, API Key creation, and SDK configuration (E2B API Key, api_url, domain) described in Use FC Agent Sandbox with the SDK.

  • Dependencies installed: pip install e2b==2.31.0. This template does not use Code Interpreter, so e2b-code-interpreter is not required.

  • A model API Key is prepared and injected through envs when you create the sandbox. The image does not include a pre-configured key.

    • Obtain DEEPSEEK_API_KEY from the DeepSeek Open Platform.

    • Optional: DEEPSEEK_BASE_URL specifies a relay endpoint (read natively by dsh). If you leave it empty, requests go directly to the official DeepSeek endpoint.

Image addresses

Select FROM_IMAGE by region:

Region

Image

cn-beijing

fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

cn-shenzhen

fc-e2b-registry.cn-shenzhen.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

ap-southeast-1

fc-e2b-registry.ap-southeast-1.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

cn-hongkong

fc-e2b-registry.cn-hongkong.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

cn-shanghai

fc-e2b-registry.cn-shanghai.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

cn-hangzhou

fc-e2b-registry.cn-hangzhou.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

us-east-1

fc-e2b-registry.us-east-1.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

us-west-1

fc-e2b-registry.us-west-1.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52

Recommended build specifications: cpu_count=2, memory_mb=4096.

The image includes the /opt/deepseek-harness/start.sh one-click startup script for the Web UI.

Build a template

A custom template must be built from the image before it can be used. You need to perform this step only once. After the build completes, save the template name and reuse it when you create sandboxes.

The following example uses the Beijing region:

import time

from e2b import Template, default_build_logger

FROM_IMAGE = "fc-e2b-registry.cn-beijing.cr.aliyuncs.com/runtime/deepseek-harness:v0.0.52"
TEMPLATE_NAME = f"deepseek-harness-{int(time.time())}"

OPTS = {
    "api_key": "<YOUR-E2B-API-KEY>",
    "api_url": "https://api.cn-beijing.e2b.fc.aliyuncs.com",
    "domain": "cn-beijing.e2b.fc.aliyuncs.com",
}

build = Template.build(
    Template().from_image(FROM_IMAGE),
    name=TEMPLATE_NAME,
    cpu_count=2,
    memory_mb=4096,
    on_build_logs=default_build_logger(),
    **OPTS,
)

print(f"template: {build.name}")   # Save the name for later reuse

After the build completes, the template status in the console should be ready. The same template name can be used to create sandboxes multiple times without rebuilding the template.

Create a sandbox

Inject the DeepSeek API Key through envs when you create the sandbox:

from e2b import Sandbox

sandbox = Sandbox.create(
    template=TEMPLATE_NAME,
    envs={"DEEPSEEK_API_KEY": "<YOUR-DEEPSEEK-API-KEY>"},
    timeout=600,
    **OPTS,
)

Run DeepSeek Harness

Headless single task

--profile headless runs one task, prints the final answer, and then exits:

result = sandbox.commands.run(
    'dsh --profile headless "Introduce DeepSeek Harness in one sentence" 2>&1',
    timeout=0,
)
print(result.stdout)

If the model API Key is not injected or is invalid, dsh exits with a non-zero code and reports a clear error. The error is written to stderr, and the following table shows the error text merged into stdout by 2>&1:

Scenario

Output

No API key provided

dsh: MISSING_CREDENTIAL: llm-deepseek: no API key for provider route "deepseek-official"; store DEEPSEEK_API_KEY through the credentials service (the web Models page writes it), or export DEEPSEEK_API_KEY in the launching environment

Invalid API key

dsh: AUTH: Authentication Fails, Your api key: ****3000 is invalid (3000 is the last four characters of the invalid key and varies with the actual key)

Web UI

The image includes a one-click startup script, so the Web UI starts with a single command in the sandbox. The script starts dsh web in the background (it listens only on 127.0.0.1:8080 and uses token authentication), and then prints DSH_WEB_TOKEN and DSH_WEB_LAUNCH_URL to stdout after the service is ready. The script is idempotent: if the Web UI is already running, it returns the existing token instead of starting another instance:

import re

r = sandbox.commands.run("/opt/deepseek-harness/start.sh", timeout=180)
print(r.stdout)
# Output similar to:
# DSH_WEB_TOKEN=<TOKEN>
# DSH_WEB_LAUNCH_URL=http://127.0.0.1:8080/?token=<TOKEN>

token = re.search(r"DSH_WEB_TOKEN=(\S+)", r.stdout).group(1)

Use the SDK port proxy to map port 8080 in the sandbox to a public address. On the default platform domain (*.e2b.fc.aliyuncs.com), the address is suitable only for testing with curl or an SDK, and the Web UI cannot be used in a browser. To use the Web UI in a browser, you must bind a custom domain first. For more information, see Browser access:

host = sandbox.get_host(8080)
print(f"https://{host}/?token={token}")
Warning

The output URL contains ?token= and is equivalent to an access credential. Do not share or store a URL that contains the token, because browser history, terminal output, and proxy logs may all retain it. After the first visit establishes a session, use the URL without ?token=.

If DEEPSEEK_API_KEY is not injected, start.sh exits with a non-zero code and prompts you to inject the key through envs.

Browser access (custom domain + --trusted-host)

The Web UI does not work in a browser on the default platform domain (*.e2b.fc.aliyuncs.com) for two reasons:

  1. The platform forcibly adds Content-Disposition: attachment to HTTP responses on the default domain, so the browser downloads an HTML file instead of rendering the page.

  2. dsh applies a browser trust barrier to /api requests and trusts only loopback hostnames by default. When you access the service through the platform domain proxy, the Host value is not trusted, all /api requests return 403, and the page renders as an empty shell.

The default domain is suitable only for testing with curl or an SDK:

  • A request without a token returns 401 (the native authentication prompt of dsh).

  • A request with a token returns 303 and issues a session cookie.

  • A subsequent request that carries the cookie returns 200.

To use the Web UI in a browser, you must bind a custom domain first, and then add the public hostname to the trust list with --trusted-host at startup:

  1. Bind a custom domain: For the complete steps of adding a domain in the console, DNS resolution, and HTTPS certificates, see Custom Domains. Key points: configure the control-plane domain api.<YOUR-CUSTOM-DOMAIN> and the data-plane wildcard domain *.<YOUR-CUSTOM-DOMAIN>. The certificate must cover the wildcard domain, and the domain must complete ICP filing as required by the region.

  2. Point the SDK to the custom domain: Replace OPTS with a configuration that is consistent with the console settings (the api_key must belong to the same account that bound the domain). All subsequent calls, such as Template.build(...) and Sandbox.create(...), use the new OPTS. After you replace OPTS, run Sandbox.create(...) again to create the sandbox. Only then does sandbox.get_host(8080) return a hostname under the custom domain:

    OPTS = {
        "api_key": "<YOUR-E2B-API-KEY>",
        "api_url": "https://api.<YOUR-CUSTOM-DOMAIN>",
        "domain": "<YOUR-CUSTOM-DOMAIN>",
    }
  3. Start the service with --trusted-host and access the page: start.sh passes extra arguments to dsh web without modification. Pass the public hostname returned by sandbox.get_host(8080):

    host = sandbox.get_host(8080)   # 8080-<SANDBOX-ID>.<YOUR-CUSTOM-DOMAIN>
    
    r = sandbox.commands.run(
        f"/opt/deepseek-harness/start.sh --trusted-host {host}",
        timeout=180,
    )
    token = re.search(r"DSH_WEB_TOKEN=(\S+)", r.stdout).group(1)
    
    print(f"https://{host}/?token={token}")

Open the output URL in a browser to use the Web UI. On the first visit, the Internal Testing Notice dialog appears because DeepSeek Harness 0.1 is in the internal testing phase. Click Continue to close it. You must select a workspace before you can start a conversation (click Choose workspace and select a directory). The model then responds in streaming mode, and the interface provides collapsible reasoning steps and per-turn token usage statistics. This URL also contains the token, so treat it as a credential. After the first visit establishes a session, use the URL without ?token=.

Notes on --trusted-host and authentication:

  • Adding a hostname to the trust list only affects the trust barrier. Authentication is unchanged: a request without a token still returns 401, and after the first visit the session cookie takes over (valid for 30 days).

  • Multiple hostnames can be passed by repeating the option. An entry that includes a port number is matched exactly, and an entry without a port number matches any port.

  • After dsh restarts, the token changes, but browser session cookies that are already issued remain valid.

Troubleshooting: If the request returns a 403 from the proxy layer with a JSON error body, retry the request with the X-Access-Token: <sandbox._envd_access_token> header. _envd_access_token is an internal property of the Python SDK (verified in e2b==2.31.0, and it may be renamed or removed in later versions). It corresponds to the sandbox access token, which becomes invalid when the sandbox is destroyed.

Destroy the sandbox

Release resources after the task is complete. This also terminates the dsh web process in the sandbox:

sandbox.kill()

Environment overview

Item

Specification

Operating system

Debian 13

dsh path

/home/user/.dsh/bin/dsh (0.1.5-rc.1, an rc release whose behavior may change with upstream)

Bundled Node.js

v22.22.3 (/home/user/.dsh/tools/node/bin/node. dsh does not depend on the system Node.js)

System Node.js

v20.x

Default user / working directory

user / /home/user

Profile capability notes

Profile

Usage

Description

headless

dsh --profile headless "<TASK>"

Runs a single task, prints the final answer, and then exits

web

/opt/deepseek-harness/start.sh (or dsh web --no-open directly)

Web UI with token authentication. The script always listens on 127.0.0.1:8080, whereas dsh web listens on 127.0.0.1:3080 by default

sdk

dsh --profile sdk

JSON-RPC over stdio, for SDK clients

sdk-minimal

dsh --profile sdk-minimal

A separate minimal agent configuration tree

acp

dsh --profile acp

ACP over stdio, for automated clients

headless and web are the profiles used in the procedures on this page. The descriptions of sdk, sdk-minimal, and acp come from the dsh README in the image (/home/user/.dsh/lib/node_modules/@deepseek-ai/dsh/README.zh.md). Built-in profiles are initialized automatically on first use. Other profiles are managed by dsh plugin --profile <NAME> <PNPM-ARGS>. The directory in which you run the command is the default workspace root.