AI Skill Hub 强烈推荐:开源AI工作流 是一款优质的Agent工作流。AI 综合评分 8.0 分,在同类工具中表现稳健。如果你正在寻找可靠的Agent工作流解决方案,这是一个值得深入了解的选择。
利用OpenCode Go订阅在Codex应用中实现本地响应到聊天补全
开源AI工作流 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
利用OpenCode Go订阅在Codex应用中实现本地响应到聊天补全
开源AI工作流 是一套完整的 AI Agent 自动化工作流方案。通过可视化的节点编排,将复杂的多步骤任务拆解为清晰的自动化流程,实现全程无人值守的智能处理。支持与数百种外部服务和 API 无缝集成,适合构建数据处理管线、业务自动化和 AI 辅助决策系统。
# 方式一:pip 安装(推荐)
pip install opencode-go-proxy
# 方式二:虚拟环境安装(推荐生产环境)
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install opencode-go-proxy
# 方式三:从源码安装(获取最新功能)
git clone https://github.com/kartikkabadi/opencode-go-proxy
cd opencode-go-proxy
pip install -e .
# 验证安装
python -c "import opencode_go_proxy; print('安装成功')"
# 命令行使用
opencode-go-proxy --help
# 基本用法
opencode-go-proxy input_file -o output_file
# Python 代码中调用
import opencode_go_proxy
# 示例
result = opencode_go_proxy.process("input")
print(result)
# opencode-go-proxy 配置文件示例(config.yml) app: name: "opencode-go-proxy" debug: false log_level: "INFO" # 运行时指定配置文件 opencode-go-proxy --config config.yml # 或通过环境变量配置 export OPENCODE_GO_PROXY_API_KEY="your-key" export OPENCODE_GO_PROXY_OUTPUT_DIR="./output"
Use your own OpenCode Go and OpenCode Zen credentials in Codex through a local protocol adapter.
Codex expects a Responses API (/v1/responses). OpenCode Go's documented models span Responses, Chat Completions, and Anthropic Messages, while OpenCode Zen also includes Gemini-family routes. This proxy selects the documented wire protocol for each model in one local process:
Codex app
│
│ POST /v1/responses (Responses API)
▼
opencode-go-proxy ←── localhost:8787, one runtime dep (zstandard)
│
│ POST per family: chat/completions · responses · messages · models/<id>
▼
OpenCode Go / OpenCode Zen ── 28 documented Go models · optional Zen models
- OpenCode Zen support: auto-discovered zen/<id> catalog merged with models.dev metadata, per-family wire translation (Anthropic Messages / Gemini / Responses / chat-completions) with per-family auth header mapping, free models, and provider="zen" metering - Responses input to chat messages translation - instructions and developer roles mapped to system messages - Function tool schema passthrough - Custom/freeform tool adaptation (Codex apply_patch works) - Reasoning content replay across tool-call turns - Real-time SSE streaming (not synthesized) - Cached image captioning when tools are present: cheapest catalog vision engine (or a probed local runtime) by default, detail: low input, 30s no-retry budget, MiMo V2.5 fallback, reads metered with kind=vision - SSRF protection on image URLs (data:image/ and https:// only) - Configurable body cap, peer-address guard, authenticated remote mode, keychain credential resolution - Local health and model-list endpoints - Prefix caching: byte-stable request prefixes plus include_usage, with per-model hit ratio on /cache - Honest usage meter: append-only usage-events.jsonl in the state dir (truncated or empty responses never count as success) - Upstream retry with bounded exponential backoff on transient failures (429/5xx/network/timeout) - Ops CLI: doctor (reference-style checks with --fix for safe repairs), smoke-test (marker prompt through the local proxy), support-bundle (JSON schema v1, mode 0600), install (points at the macOS menu bar app; no launchd agent), install-skills, refresh-runtime, and status - Spawned threads inherit the parent session's model (create_thread; chatgptWorkCloud targets are skipped) - Correctness contract: empty upstream completions are retried once (a second empty stream answers an empty_completion error), zero-input-token reports are estimated for compaction (OPENCODE_GO_PROXY_ESTIMATE_ZERO_INPUT=0 disables), and keepalive comments run until the stream truly ends without interleaving into data frames - Auth transport guard (zero config): the default listener and accepted peers are loopback-only, forged Host: localhost does not admit a remote peer, browser-originated requests answer 403, non-JSON POSTs answer 415, and OPTIONS preflight stays blocked - Family-aware Go routing for Responses, Chat Completions, and Anthropic Messages, including streaming and non-streaming requests with the family-specific authentication header - Rate-limit harvesting (plan 011): upstream x-ratelimit-* and anthropic-ratelimit-* headers are parsed into per-provider quota snapshots, the latest snapshot per provider is kept, and GET /quota exposes quota-state.json - Menu bar state contract (plan 013): GET /state returns one JSON document (status, port, upstream, latest quota snapshot, today's turns/tokens, last-7-day token bars, current model) computed from the meter file and quota state - WebSocket upgrade requests answered with 426 Upgrade Required (desktop app falls back to HTTP streaming) - zstd-compressed request bodies decompressed (Content-Encoding: zstd; the desktop app sends them) - Single-port guard in the menu bar app: refuses Start when 8787 is already owned
Install the official Codex CLI using OpenAI's current Codex CLI instructions. The standalone macOS/Linux installer is:
curl -fsSL https://chatgpt.com/codex/install.sh | sh
Then run codex app to open the installed Codex desktop app or start OpenAI's official desktop installer. Run opencode-go-proxy config enable once, start the loopback proxy, fully quit and reopen Codex, and select an opencode-go/<model-id> entry.
The config command edits only its marker-delimited block in Codex's existing configuration. It preserves unrelated settings, native ChatGPT authorization, sessions, and desktop state. Run opencode-go-proxy config disable to remove only that managed block.
If you installed the proxy as a tool, check and apply updates with the CLI:
opencode-go-proxy update # check for a newer release
opencode-go-proxy update --apply # install the newer release
update prints the installed version and the latest release (exit code 3 when an update is available). --apply re-installs from the new tag with uv tool install --force; when the proxy was not installed as a tool it prints the exact one-liner to run instead.
```bash
uvx --from git+https://github.com/kartikkabadi/opencode-go-proxy \ opencode-go-proxy config enable
export OPENCODE_GO_API_KEY="your-key-here"
security add-generic-password -a "$USER" -s opencode-go-api-key -w ```
The key is used only for Go or Zen upstream requests. It is never substituted for Codex's native OpenAI authorization, and the separate remote caller token is never forwarded upstream.
All flags have environment variable defaults:
| Flag | Env var | Default |
|---|---|---|
--bind | OPENCODE_GO_PROXY_BIND | 127.0.0.1 |
--port | OPENCODE_GO_PROXY_PORT | 8787 |
--chat-base-url | OPENCODE_GO_BASE_URL then OPENCODE_ZEN_BASE_URL then CHAT_COMPLETIONS_BASE_URL | https://opencode.ai/zen/go/v1 |
--api-key-env | OPENCODE_GO_PROXY_API_KEY_ENV | OPENCODE_GO_API_KEY |
--timeout-sec | OPENCODE_GO_PROXY_TIMEOUT_SEC | 180 |
--max-body-mb | OPENCODE_GO_PROXY_MAX_BODY_MB | 20 |
The proxy accepts both /responses and /v1/responses.
The upstream base URL resolves in this order: the --chat-base-url flag, then OPENCODE_GO_BASE_URL, then OPENCODE_ZEN_BASE_URL, then the legacy CHAT_COMPLETIONS_BASE_URL, then the built-in default.
The one listener accepts all three documented client formats, with or without the /v1 prefix:
| Client request | Supported Go models | Upstream behavior |
|---|---|---|
POST /v1/responses | all 28 documented models | translated to each model's certified Responses, Chat Completions, or Messages family |
POST /v1/chat/completions | the 16 Chat Completions models | relayed in Chat Completions format |
POST /v1/messages | the 8 Anthropic Messages models | relayed in Messages format |
Streaming and non-streaming requests are supported on every row. The Responses aliases /responses/compact and /v1/responses/compact are also available for compaction. A model sent to an incompatible direct-format endpoint is rejected before any upstream request rather than silently translated to a different client response shape.
1. Sign in to OpenCode Zen, subscribe to OpenCode Go, and copy your API key. OpenCode currently permits one Go subscriber per workspace. 2. Optionally verify the key in OpenCode itself: run /connect, select OpenCode Go, paste the key, then run /models. 3. Make the same user-owned key available to this proxy using one of the methods below.
The proxy resolves your OpenCode Go API key in this order:
$OPENCODE_GO_API_KEY environment variableopencode-go-api-key (override with CODEX_KEYCHAIN_SERVICE; macOS only)```bash
uvx --from git+https://github.com/kartikkabadi/opencode-go-proxy opencode-go-proxy --help
Model metadata warning every turn Set model_catalog_json in Codex config and copy the rendered catalog: cp ~/.codex/opencode-go-proxy/opencode-go-catalog.json ~/.codex/model-catalogs/opencode-go.json
Connection refused on localhost:8787 Proxy isn't running. Start it: opencode-go-proxy or check launchctl list | grep opencode.
Port already in use Only one proxy instance can bind 8787. Confirm what is listening: lsof -nP -iTCP:8787 -sTCP:LISTEN. If a stale instance holds the port, stop it before starting another.
API key not found Set OPENCODE_GO_API_KEY env var or add to macOS keychain: security add-generic-password -a "$USER" -s opencode-go-api-key -w
Upstream rate limited (429) OpenCode Go has 5-hour/weekly/monthly usage limits. Switch to a cheaper model (DeepSeek V4 Flash or MiMo V2.5) to stretch your quota. See usage limits.
Streaming not working Codex sends stream: true — the proxy handles this. If you see no SSE events, check stderr trace for upstream.error or upstream.network_error.
Codex says "model is not supported when using ChatGPT account" Run opencode-go-proxy config enable, fully restart Codex, and confirm openai_base_url points at the local proxy. The managed setup uses Codex's documented proxy configuration so native and routed catalog models can coexist.
OpenCode Go Proxy 是一个专为 OpenCode Go 设计的代理工具。它能够作为中间层,将特定的 API 请求进行转换与转发,旨在为开发者提供更灵活的模型调用体验,确保与各类客户端工具的无缝对接。
本项目具备强大的协议转换能力:支持将 chat messages 中的 input 自动翻译为标准格式,并将 instructions 和 developer 角色映射为 system 消息;支持 Function tool schema 透传及自定义工具适配(如 Codex 的 apply_patch);支持跨 tool-call 轮次的 Reasoning content 重放;提供原生的实时 SSE streaming 流式输出;并在启用工具时通过 MiMo V2.5 实现图像描述功能(可通过 CODEX_IMAGE_MODEL 覆盖)。
您可以使用 uvx 工具直接从 GitHub 仓库运行该代理,无需手动安装依赖。请使用以下命令启动服务,并可以通过 --bind 和 --port 参数自定义监听地址与端口: `uvx --from git+https://github.com/kartikkabadi/opencode-go-proxy opencode-go-proxy --bind 127.0.0.1 --port 8787`
快速上手指南:首先,您需要配置 Codex 的配置文件 (~/.codex/config.toml),将 model_provider 指向本地代理地址。随后,您可以通过设置环境变量 OPENCODE_GO_API_KEY 或在 macOS 上使用 keychain 来管理您的 API Key。请确保从 OpenCode Zen 获取有效的订阅 Key。
配置说明:通过修改 Codex 的 config.toml 文件,您可以定义自定义的 model_provider(如 opencode-go)并指定 base_url 为代理运行的地址。对于 API Key 的验证,程序会遵循优先级顺序:首先检查 $OPENCODE_GO_API_KEY 环境变量,其次检查 macOS keychain 中的 opencode-go-api-key 条目。
API Key ��理机制:代理程序会自动解析您的 OpenCode Go API key。解析优先级如下:1. 环境变量 $OPENCODE_GO_API_KEY;2. macOS keychain 中的 opencode-go-api-key 条目(可通过 CODEX_KEYCHAIN_SERVICE 进行覆盖)。请确保您的 Key 已通过 OpenCode Zen 订阅。
源码与工作流:如果您希望不使用包管理器直接从源码运行或查看帮助信息,可以使用 uvx 命令配合 --help 参数来探索代理的可选指令与工作流配置。
常见问题排查:若在运行中遇到 Model metadata warning 警告,请将 contrib/opencode-go-catalog.json 复制到 Codex 的模型目录中;若遇到 Connection refused 错误,请检查 opencode-go-proxy 进程是否已正常启动并监听正确的端口。
高质量的开源AI工作流项目,实现了本地响应到聊天补全
AI Skill Hub 为第三方内容聚合平台,本页面信息基于公开数据整理,不对工具功能和质量作任何法律背书。
建议在沙箱或测试环境中充分验证后,再部署至生产环境,并做好必要的安全评估。
✅ MIT 协议 — 最宽松的开源协议之一,可自由商用、修改、分发,仅需保留版权声明。
总体来看,开源AI工作流 是一款质量优秀的Agent工作流,在同类工具中具备一定竞争力。AI Skill Hub 将持续追踪其更新动态,建议收藏备用,结合自身场景选择合适时机引入使用。
| 原始名称 | opencode-go-proxy |
| 原始描述 | 开源AI工作流:Use your OpenCode Go subscription in the Codex app. Local Responses-to-Chat-Comp。⭐15 · Python |
| Topics | ai-agentchat-completionscodexllmpython |
| GitHub | https://github.com/kartikkabadi/opencode-go-proxy |
| License | MIT |
| 语言 | Python |
收录时间:2026-06-24 · 更新时间:2026-06-26 · License:MIT · AI Skill Hub 不对第三方内容的准确性作法律背书。
选择 Agent 类型,复制安装指令后粘贴到对应客户端