Skip to content
English

Proxies

How AnyPick translates between protocols, and how to inspect or control the local processes.

Updated View as Markdown

When a client and an account do not speak the same protocol, AnyPick runs a local proxy between them. It starts on demand as part of activation and stops with the supervisor, so in normal use there is nothing to manage. Everything on this page is for inspection and debugging.

What the proxy does

Each provider proxy accepts more than one wire format and forwards to the provider’s real API:

  • grok — an OpenAI-compatible and an Anthropic-compatible route, forwarding the authenticated upstream /v1/models catalog and requested model ids unchanged
  • opencode — Zen and Go catalogs, choosing between the Messages, Chat Completions, Responses, and Google protocols based on what the model supports
  • gemini — Gemini API by key, or Code Assist by OAuth, including the modern /v1/responses request and SSE lifecycle current Codex CLI releases expect
  • kiro — delegated to an external kirolink / kiro-proxy binary if you have one installed
  • workbuddy — OpenAI Chat Completions (and Anthropic translation) to the CodeBuddy subscription. Some reasoning models can ramble (OK. / Let me write.); stop the turn and pick a non-router slug such as hy3 if that happens.
  • cline — OpenAI Chat Completions to the Cline gateway
  • compatible provider plugins — native Anthropic Messages when the vendor exposes it, OpenAI Chat Completions otherwise, plus the Responses lifecycle used by Codex; API and coding-subscription keys use the same local boundary

Model discovery prefers the live upstream and uses a provider-owned fallback only when /models is missing or unavailable: Gemini reads models.list for API-key accounts and Code Assist fetchAvailableModels for OAuth accounts; OpenCode intersects the live catalogs with provider metadata. New models show up without a AnyPick release.

Reasoning intent survives translation. Codex and OpenAI reasoning_effort, Responses reasoning.effort, Claude output_config.effort, adaptive thinking, explicit budget_tokens, and visible thinking summaries are all preserved; Google routes map the same intent onto Gemini’s thinkingConfig and keep thought summaries separate from the final answer. Native Anthropic and OpenAI routes are pass-through.

Default ports

A proxy uses its configured pool port when one is set; otherwise the provider’s advertised DefaultProxyPort when the provider declares one, otherwise the shared 8080 fallback (plannedPoolPort in src/go/internal/activation/planner.go, defaultPoolPort in src/go/internal/proxy/service_pool.go). Declared today: Ark 4155, TokenHub 4156, GroqCloud 4148, Fireworks 4151, Cerebras 4152, NVIDIA NIM 4154 (all in src/go/internal/provider/compatible.go). A proxy that has no configured port and no provider default takes the first free one.

Manual lifecycle

anypick proxy status <provider> <account>
anypick proxy start <provider> <account>
anypick proxy stop <provider> <account>
anypick proxy enable <provider> <account> [--port N]
anypick proxy disable <provider> <account>
anypick proxy config <provider> <account> [--port N]
anypick proxy restart <provider> <account>
anypick proxy logs <provider> <account> [--lines N] [--follow]

enable configures a proxy and starts it; config changes the port and restarts the proxy; restart stops and starts the same account. status, start, stop and logs each take the exact <provider> <account> pair — there is no “all proxies” form.

Gemini auth sources

Gemini accepts two sign-ins. Which one an account stores is decided when the account is saved, not per proxy:

anypick add account gemini --current --source gemini-cli --name work
anypick add account gemini --current --source antigravity --name work

Omit --source and AnyPick infers it from the files the apps left behind (gemini-cli first). The proxy serves from the saved snapshot, so switching the pinned source means saving a new account, and catalog aliases stay within one source — an Antigravity rollout id is never sent through the Gemini CLI by mistake.

OpenCode auth mode

The Go engine resolves one OpenCode catalog per account, from the credential that is actually logged in: a Go subscription row targets https://opencode.ai/zen/go/v1, any other Zen/Go key targets https://opencode.ai/zen/v1. The TypeScript --auth-mode auto|public|api flag, per-model catalog routing, and the OPENCODE_PROXY_UPSTREAM override are not ported; save the account from the credential you want served.

The key is looked up in this order, first hit wins:

  1. the live CLI credential store (opencode.db under OPENCODE_DATA_DIR);
  2. the opencode.db saved beside the account’s auth.json;
  3. auth.json in the saved snapshot.

The live store is checked first because the beta CLI no longer rewrites auth.json on login — a snapshot saved before you switched accounts would otherwise keep serving the previous account’s key.

An account whose saved login holds no Zen/Go key — an OAuth-only auth.json, for example a ChatGPT or Anthropic sign-in — cannot drive this proxy. Those logins are applied to native clients by anypick use instead; the proxy fails with NO_LIVE_AUTH:

  • no saved auth.json at all: No OpenCode auth available. with the opencode auth login / anypick add opencode --name <name> suggestions;
  • auth.json present but unreadable: Unreadable OpenCode auth: <path>.;
  • auth.json readable but holds only OAuth rows: OpenCode proxy needs a Zen/Go API key in auth.json or the CLI credential store ….

Multi-account pools

The default is one proxy process per account. A pool puts several accounts of one provider behind a single port, so a client sees one endpoint and AnyPick handles rotation.

anypick proxy pool enable gemini -p 4150
anypick proxy pool member gemini work on
anypick proxy pool member gemini alt off      # keep it configured but paused
anypick proxy pool status gemini

anypick use claude --with pool:gemini

anypick proxy pool disable gemini             # back to one process per account

In the terminal UI’s proxy board, p toggles the pool and space pauses or re-enables the member under the cursor. On a multi-account pool row, f toggles the safe quota-driven failover guard.

Failover, rotation, and the quota guard

--strategy failover (the default) keeps serving from the account that last answered and only moves on when that account is rejected. --strategy round-robin instead starts each request at the next member of the ring, so successive requests spread across accounts:

anypick proxy pool enable kiro --strategy round-robin

--strategy soonest-reset starts each request at the account whose unused quota resets soonest. Quota left in a window when it resets is lost, so that account’s quota is the one to spend first:

anypick proxy pool enable codex --strategy soonest-reset

The pool reads each member’s quota windows from its saved login every five minutes and keeps them in a cache next to the pool’s runtime files. Requests only read that cache; they never wait on a usage lookup. Codex and Claude accounts report their windows. An account with no reading, whose reading is more than thirty minutes old, or whose saved login has expired, goes after the accounts that have one, so a pool where nothing is known behaves like failover. The Proxy Hub accepts the same strategy, with anypick proxy hub enable <name> --strategy soonest-reset or the hub’s Strategy picker in the apps.

Every strategy walks the eligible members only: an account the quota guard has put on cooldown is skipped. The difference is where an attempt starts, not whether it fails over — a member that answers with a quota-class error still hands the request to the next one.

When every member is cooling down, the pool keeps serving: it attempts the account that will recover soonest and passes the vendor’s answer back to the caller, rather than refusing locally. One attempt only, so a fully throttled provider is not hammered by a ring walk. An exhausted subscription therefore surfaces exactly what the vendor said (429, 402, or a reset time), which is what a client can act on:

// ~/.anypick/config.json — set false to restore the local refusal
{
  "ui": {
    "quotaGuard": {
      "enabled": true,
      "cooldownMinutes": 60,
      "serveWhenAllCooling": true
    }
  }
}

The guard itself is toggled per pool: f on the pool row in the terminal UI, or enabled in the config above.

Proxy Hub (opt-in)

Pools keep one provider. The unified Proxy Hub is a separate opt-in surface that can expose several saved accounts behind one local endpoint and route by model. Enable it without rewriting existing bindings, add sources, then bind:

anypick proxy hub enable default -p 4140 --start
anypick proxy hub source default grok work
anypick proxy hub status default
anypick use claude --with hub:default

Rotation: one global mode for the hub

Every account in the hub has its own on/off switch, and the hub has one global mode for how requests pick among the accounts you switched on. By default (failover) each model goes to the account that owns it — or the first source, when nothing claims the model. Rotate across accounts spreads each model over every enabled account that can serve it, so three saved Gemini logins share the work instead of one taking every request:

anypick proxy hub enable default --strategy round-robin

“Can serve” comes from the provider catalogs, so two providers advertising the same model id (a compatibility proxy and the vendor, for example) both take turns; accounts that cannot serve the requested model are never chosen. When the catalogs know nothing about a model, rotation stays inside the provider the model resolves to, and a recorded model owner still decides which provider answers — rotation only changes which account of it does.

Per-account switches are the whole membership rule: an account switched off is never a candidate, and switching every account of a provider off simply removes that provider from the hub. The mode is global — not one switch per provider — because the hub resolves a source per request and then spreads it.

The hub also keeps a quota guard of its own (the same ui.quotaGuard settings): when a vendor refuses a request because the key or account is out of quota, that account cools down and the request moves on to the next enabled account that can serve the same model. A vendor refusal that does not blame the credential (a real 500, a per-minute rate limit) is handed to you verbatim — the hub does not spend another account’s quota on it. When every candidate is cooling it still serves the one that recovers soonest and passes its verdict through, unless serveWhenAllCooling is false. Pool proxies keep their own guard; this one applies to the hub only.

The Proxy board lists the Hub as its own row when configured; enter or m opens the Hub editor. Prefer ordinary per-account proxies unless you specifically need one shared endpoint across providers.

Combos: model ids the hub defines

A combo is a name you choose for an ordered fallback chain. Each step is a source already in the hub and the model to send it:

anypick proxy hub combo add default smart \
  claude/work=claude-opus-4 claude/work=claude-sonnet-4 zai/plan=glm-4.6
anypick proxy hub combo list default
anypick proxy hub combo remove default smart

A client that asks the hub for model smart gets the first step. When that step is refused for quota, the request moves to the next step, sent under that step’s own model id. Any other answer, including a rejected request, is the client’s answer. A step can be a pool source (codex/pool:codex=gpt-5), and a pool that is out of quota hands the request on like an account does.

A combo name is a model id the hub owns, so pick one no vendor uses; the hub refuses a name that is already a pinned model. Saving or removing a combo restarts a running hub so it serves the change.

The hub answers GET /v1/models itself: its pinned models, every model only one of its providers publishes, and its combos. A model two providers publish stays out of the list until you pick its owner with anypick proxy hub owner. Apps bound to the hub offer the combos in their model pickers.

Process ownership

In the native macOS architecture, AnyPick.app owns its bundled Go service and the Go service owns local proxy processes. Closing the main window keeps the app running; explicit app Quit gracefully stops the helper and its services. The menu-bar item is a view of that same app, not a standalone supervisor.

The Go engine owns the same supervisor directly (cmdTray / runSuperviseChild in src/go/cmd/anypick/lifecycle.go):

anypick tray          # app surface (same core as `anypick app`)
anypick tray start
anypick tray status
anypick tray stop     # stop that supervisor and the proxies it owns

From this repository, run those forms with make run ARGS="…". Closing the TUI with q leaves background supervisor state unchanged. Its Shift+D and t actions do not manage a separately launched native app.

Orphans are cleaned up rather than accumulating: on startup, AnyPick releases leases whose owning process has exited and stops their proxies.

The Linux and Windows Tauri installers are published from the same release workflow as the macOS app. See the release page for the current assets; there is no separate tray-only installer.

Navigation

Type to search…

↑↓ navigate↵ selectEsc close