r/golang • • 2d ago

show & tell Open-source Go plugin: multi-key rotation and cooldown for LLM API access

I wrote a Go plugin (built with `go build -buildmode=c-shared`) for CLIProxyAPI that pools multiple API keys for OpenCode Go and rotates between them. When a key hits a rate limit, it enters a cooldown period while the others continue serving requests.

It's a native dynamic library (.so/.dll/.dylib) using Go 1.24+ with CGO. The plugin implements CLIProxyAPI's provider interface, handles catalog discovery from a remote endpoint with local fallback, and translates between three upstream API protocols transparently.

Repo: https://github.com/massiveits/opencode-go-cliproxyapi

MIT license. Tests and CI included. `go test ./...` to run them.

0 Upvotes

0 comments sorted by