Skip to content
 
 

Repository files navigation

opencode-go-clpx

A CLIProxyAPI plugin that exposes OpenCode Go as a single opencode-go provider with shared key pooling, multi-protocol translation, and a per-key quota page; a personal fork of massiveits/opencode-go-cliproxyapi with the changes listed below.

Install

Add this repo as a third-party store source in CLIProxyAPI's config.yaml:

plugins:
  enabled: true
  store-sources:
    - "https://raw.githubusercontent.com/tympom/opencode-go-cliproxyapi/main/registry.json"

Then install from the Management Center's Plugin Store page (or POST /v0/management/plugin-store/opencode-go-clpx/install) and restart CLIProxyAPI.

Configuration

In config.yaml under plugins.configs.opencode-go-clpx:

plugins:
  configs:
    opencode-go-clpx:
      # Upstream base URL (default: "https://opencode.ai/zen/go/v1")
      base-url: "https://opencode.ai/zen/go/v1"

      # Optional catalog endpoint override (default: "{base-url}/models")
      # catalog-url: "https://opencode.ai/zen/go/v1/models"

      # Client-facing model ID prefix configuration
      model-prefix:
        enabled: true           # true -> "opencode-go/<model>", false -> bare "<model>" (default: true)
        value: "opencode-go"    # prefix name (default: "opencode-go")

      # OpenCode Go API keys. Supports ${ENV_VAR} expansion. With no keys the plugin still
      # registers (so the Management Center config editor works) but serves no models.
      api-keys:
        - value: "sk-opencode-key-1"
          label: "work"                # optional display name; also names the auth file
        - value: "sk-opencode-key-2"
          label: "personal"
        - "${OPENCODE_GO_API_KEY}"      # a bare string works too (no label)

      # Catalog discovery settings
      catalog:
        refresh-interval: "15m"          # discovery refresh cadence, min "1m" (default: "15m")
        stale-while-unavailable: true    # retain last good catalog snapshot on refresh failure (default: true)

      # Protocol enable/disable switches (all default to true)
      protocols:
        chat-completions: true   # enables models routed to /v1/chat/completions
        messages: true           # enables models routed to /v1/messages
        responses: true          # enables models routed to /v1/responses

      # Explicit route overrides per model (takes priority over built-in prefix routing)
      route-overrides:
        "custom-model":
          protocol: "messages"           # "chat-completions" | "messages" | "responses"
          endpoint: "/v1/messages"       # must start with /

      # Execution settings
      request-timeout: "5m"              # upstream request timeout (default: "5m")
      max-response-bytes: 67108864       # max non-streaming response body size in bytes (default: 64 MiB)
      allow-http: false                  # allow http:// scheme for local mock/testing (default: false)

All fields are also editable through the Management Center's plugin config UI (registration publishes ConfigFields). A fresh store install registers without keys, so you can add api-keys there (Plugins → Edit config) without touching config.yaml by hand, e.g. ["sk-..."] or [{"value": "sk-...", "label": "work"}].

Notes

  • Auth files: each key gets a credential file named after its label (opencode-go-work.json); unlabeled keys fall back to a masked key suffix (opencode-go-key-Xf9a.json). Renaming a key's label creates a new auth file; remove the old one in Auth Files manually (the host plugin ABI has no delete callback).
  • Quota page: Management Center → OpenCode Go Quota. Cards are titled with each key's label; reset times show local date/time plus a countdown, e.g. 09/23, 16:35 · in 4d 23h (same formatting as CPA's native quota UI). Page load never contacts upstream; refresh each card manually or all at once with Refresh All.
  • Built and tested against CLIProxyAPI v8.0.10.

Changes vs upstream (massiveits/opencode-go-cliproxyapi)

  • Plugin ID renamed opencode-go-cliproxyapi → opencode-go-clpx so this fork can coexist with the official store listing instead of colliding on the same name.
  • Per-key labels: api-keys[].label names a key's quota card and its auth file (upstream shows an opaque hash of the key).
  • Readable auth file names: opencode-go-<label>.json instead of upstream's opencode-go-key-<64-hex>.json; same-name keys get a 12-hex disambiguator instead of overwriting each other.
  • Native reset-time formatting on the quota page: 09/23, 16:35 · in 4d 23h style (ported from CPA's Management Center); upstream prints the raw resets_at ISO string.
  • Registers without API keys, so the config editor works right after a Store install; upstream fails registration until a key is configured.
  • Plain-string API keys: api-keys accepts ["sk-..."] as well as {value, label} objects.
  • CI: Linux-only release builds (amd64/arm64), no test job; registry.json published for the plugin store.

Everything else (provider behavior, protocol translation, catalog discovery, scheduling, model prefixing) is unchanged from upstream (merged through upstream v0.1.10, incl. its Codex CLI support); merge upstream/main to pick up its fixes.

About

CLIProxyAPI plugin providing unified access to OpenCode Go plan's models across Chat Completions, Anthropic Messages, and OpenAI Responses protocols.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages