dsh-zen-proxy

by yee-h

模型与账号接入github收录于 08-23

进程内 OpenAI 兼容代理:在上游请求注入官方 OpenCode Zen 客户端头,让 dsh 用上 Zen 免费模型

A DeepSeek Harness (dsh) plugin: an in-process, OpenAI-compatible proxy that injects the official OpenCode Zen client headers on upstream requests, enabling Zen free models in…

安装

dsh plugin --profile web add github:yee-h/dsh-zen-proxy

GitHub 源码安装:首次需按提示配置 allowBuilds 构建授权后重试

安装与环境配置指引、插件开发教程见 DSH 中文社区文档 ↗

安装即在你的机器上以你的权限运行第三方代码——它可读写文件、使用凭据、访问网络,DSH 的工具审批不会为插件代码加沙箱。「检测到 manifest」仅代表发现 dsh.bundle / dsh.plugin 清单,不构成兼容性或安全审查;安装前请审阅源码,不熟悉的插件先在不含密钥的环境试用。

README

目录

A DeepSeek Harness (dsh) plugin: an in-process, OpenAI-compatible proxy that injects the official OpenCode Zen client headers on upstream requests, enabling Zen free models in dsh without the 429 FreeUsageLimitError.

Why

OpenCode Zen's free-tier gateway rate-limits third-party clients by fingerprinting HTTP identity headers. Requests that look like the official opencode CLI get the normal free quota; anonymous or third-party clients are pinned to a very low fallback bucket and immediately rejected with:

{"type":"FreeUsageLimitError","message":"Rate limit exceeded. Please try again later."}

dsh's LLM adapters (e.g. dsh-llm-pi-ai) are designed to always send their own attribution User-Agent (deepseek-harness/<version> ...) and filter any configured user-agent out — so no dsh configuration can make the gateway see the official client. This plugin closes that gap with a tiny local proxy that lives inside the dsh process (started/stopped with the profile) and rewrites the identity headers before forwarding to https://opencode.ai/zen/v1.

Verified behavior

Smoke-tested against https://opencode.ai/zen/v1/chat/completions:

Headers sent Result
no official headers 429 FreeUsageLimitError
x-opencode-* only 429 ❌
x-opencode-* + official User-Agent 200 ✅
x-opencode-* + dsh's own UA 429 ❌

The gateway validates the User-Agent content, not just its presence. The x-opencode-* headers alone are not enough.

Install

dsh plugin --profile web add "https://github.com/Yee-h/dsh-zen-proxy.git"

Or from a local checkout:

dsh plugin --profile web add "file:C:/path/to/dsh-zen-proxy"

Configure

1. Register the plugin (profile patch)

Add to $DSH_HOME/profiles/<profile>/cordis.patch.yml:

- insert:
    - id: zen-proxy
      name: 'dsh-zen-proxy'
      config:
        host: 127.0.0.1
        port: 4097
        upstreamHost: opencode.ai
        upstreamBasePath: /zen/v1

2. Point the opencode provider at the proxy

In $DSH_HOME/settings.yaml:

llm-pi-ai:
  providers:
    opencode:
      apiKeyEnv: OPENCODE_API_KEY
      baseURL: http://127.0.0.1:4097/v1

Keep your sk-zen-* key in $DSH_HOME/.credentials.yaml (or the environment variable named by apiKeyEnv).

Restart dsh. The proxy listens on http://127.0.0.1:4097/v1 for as long as the profile runs and closes automatically on shutdown — no external process, no startup scripts.

How it works

dsh (dsh-llm-pi-ai)
   │  POST http://127.0.0.1:4097/v1/chat/completions
   ▼
dsh-zen-proxy (in-process)
   │  rewrites identity headers, forwards to https://opencode.ai/zen/v1
   ▼
OpenCode Zen gateway → official-client quota → 200

Headers injected on every upstream request:

Header Value
User-Agent opencode/1.15.5 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14
x-opencode-client cli
x-opencode-project global
x-opencode-session ses_ + random (per request)
x-opencode-request msg_ + random (per request)

The Authorization header and the request body (model, messages, stream: true, etc.) pass through unchanged; SSE streaming responses are relayed as-is.

Configuration reference

Field Default Description
host 127.0.0.1 Bind address
port 4097 Listen port
upstreamHost opencode.ai Zen upstream host
upstreamBasePath /zen/v1 Zen upstream base path
userAgent opencode/1.15.5 ai-sdk/provider-utils/4.0.23 runtime/bun/1.3.14 Official CLI user-agent
clientHeader cli x-opencode-client value
projectHeader global x-opencode-project value

Smoke test

$body = '{"model":"deepseek-v4-flash-free","messages":[{"role":"user","content":"hi"}],"max_tokens":16}'
Invoke-RestMethod -Uri "http://127.0.0.1:4097/v1/chat/completions" -Method Post `
  -Headers @{ "Authorization" = "Bearer sk-zen-你的密钥" } `
  -ContentType "application/json" -Body $body

Expect HTTP 200 with a real completion.

Notes & limitations

  • Free-tier quota still applies: the free allowance is shared per IP + client fingerprint (community reports ~200 requests/day) and is managed dynamically by OpenCode. Headers only restore the official-client tier; they cannot create quota.
  • Occasional 429s can still happen when the server is overloaded even with correct headers — retry or switch to another free model.
  • Recharging does NOT unlock free models (known issue): it only unlocks paid models.
  • Only the tool-calling HTTP surface (/v1/chat/completions and GET /v1/models) is proxied; resources and prompts are out of scope.
  • This plugin deliberately keeps dsh's own attribution mechanism intact: dsh still sends its real identity to the local proxy; the identity rewrite happens at the network boundary.

License

MIT

原始 README: https://github.com/Yee-h/dsh-zen-proxy/blob/main/README.md ↗

同类插件

查看全部 →
模型与账号接入Anionex

agent-vision-toolkit

为纯文本模型"看图“设计更好的视觉工具箱和技能,支持多图理解,图片问答,前端UI还原、GUI 自动化等,并可选无缝接入多个主流agent,直接识别粘贴图片| A vision toolkit and skill designed for text-only llms — image Q&A, long-screenshot OCR, frontend UI restoration, and GUI automation, with optional seamless integration for Codex, Claude Code, Pi, Oh My Pi, and OpenCode

查看详情
928github+08-16
模型与账号接入toby-bridges

api-relay-audit

从 DeepSeek Harness 对 AI API 中转站和 LLM 代理运行本地安全审计,生成 Markdown 报告,覆盖提示词注入、模型替换信号、工具调用改写、错误泄漏、流完整性和按 profile 启用的 Web3 风险。

查看详情
791github+08-21
模型与账号接入ZJU-LLMs

OpenStory

✨ OpenStory 现已支持 DeepSeek Harness 插件! 现在可以通过 dsh-openstory 将 OpenStory 多智能体推演接入 DeepSeek Harness,让 agent 直接启动模拟、查看角色、下达指令并逐回合推进故事。查看 DSH 插件配置与使用指南。

查看详情
377github+08-17
模型与账号接入pulseaiclub

phi

pi的编码代理 ∞ 提供者、子代理、hashline编辑和权限门

查看详情
89github+08-16
模型与账号接入anysearch-team

anysearch-dsh

DeepSeek Harness(DSH)的 AnySearch 网络搜索提供方与高级搜索工具。

查看详情
79github+08-17
模型与账号接入kuangre123

codex-switch

Codex Switch 是一个 macOS 工具,一键配置 Codex 的自定义 API,同时保留官方 OpenAI 登录。保存后 Codex 的模型选择器里只会出现你选的那个 provider 的模型。也支持 Claude Code 的官方 / 自定义 API 切换。Codex Switch is a lightweight helper for configuring multiple coding-agent API routes. For Codex, it keeps Official OpenAI and a custom API provider configured in parallel, registers the custom model in Codex's mod

查看详情
67github+08-16