← Về thư mục
📄 / / root / .hermes / skills / autonomous-ai-agents / claude-bridge-orchestration / SKILL.md

name: claude-bridge-orchestration description: Configuration and orchestration patterns for running Claude Code CLI via a local translation bridge to OpenAI-backed providers (like 9router).


Claude Code to 9router bridge

When Claude Code must run on a host VPS but needs to route via a local 9router (using OpenAI backend):

  1. Host-side setup: npm install -g @anthropic-ai/claude-code.
  2. Bridge setup: Use a Python bridge script (e.g., claude_openai_bridge.py) that implements a basic Anthropic Messages API -> OpenAI API converter. The bridge must handle HEAD (connectivity check), GET /v1/models (model listing), and POST /v1/messages (chat).
  3. Claude Code URL handling: Claude Code appends /v1 to the base URL automatically. Set ANTHROPIC_BASE_URL to http://127.0.0.1:<port> (without a trailing path). The bridge should listen on /v1/messages directly.
  4. Configuration:
  5. ~/.claude/settings.json points to the bridge URL (e.g., http://127.0.0.1:20131).
  6. The bridge points upstream to 9router at http://127.0.0.1:20128/v1.
  7. Model in settings: use claude-3-5-sonnet-20241022 or any Anthropic model ID — the bridge does not actually call it.
  8. systemd deployment: Install the bridge as a systemd service for auto-restart (/etc/systemd/system/claude-bridge.service). Use BRIDGE_HOST, BRIDGE_PORT, BRIDGE_UPSTREAM_BASE, BRIDGE_UPSTREAM_KEY env vars.
  9. Pitfalls:
  10. Claude Code --model flag with full model names may fail resolution. Use aliases like sonnet instead of full IDs.
  11. The 9router cc provider does not map claude-sonnet-5 to an OpenAI model. The bridge must bypass the cc provider entirely and call the OpenAI-compatible endpoint of 9router.
  12. HEAD /v1 is required for Claude Code's connectivity test — the bridge must respond 200, not 501.
  13. Invocation guardrail: Only call claude CLI when the user explicitly requests code, repo, file, test, bug, terminal, or system review/fix. Always prefer chat for normal text or planning.

Helper Script

See scripts/claude_openai_bridge.py for a functional ThreadingHTTPServer bridge example.