← Back to docs
Docs / Reference

Providers & agents

TokenBeaver sits in front of any OpenAI-compatible tool. Point your agent's base URL at the local gateway, keep your own key, and every request is slimmed before it reaches your provider — same requests, same answers, fewer tokens.

How the gateway sits in front of your tool

The gateway is local-first. Its base URL is always http://127.0.0.1:4505/v1 (port 4505 by default). Point any OpenAI-compatible agent at that URL and pass your own key — it flows straight through (BYOK) and is never stored. Both surfaces below drive the same gateway.

CLI

Start it, then confirm the URL

tokenbeaver-gateway # confirm it's up and on which port tokenbeaver-gateway --status

Then set your agent's base URL to http://127.0.0.1:4505/v1. Change the port with TOKENBEAVER_GATEWAY_PORT if 4505 is taken.

VS Code extension

Copy the base URL from the palette

Command Palette → TokenBeaver: Copy Gateway Base URL, then paste it into your agent's settings. TokenBeaver: Agent Setup Instructions shows the per-agent steps, and TokenBeaver: Gateway Status confirms it's running.

Supported providers

The gateway forwards to one upstream provider. Precedence is env > config.json > default, and the default is openrouter. Provider changes are restart-required.

ProviderDefault upstreamKeyNotes
openrouterhttps://openrouter.ai/api/v1BYOK, header pass-throughDefault
openaihttps://api.openai.com/v1BYOKAlso the internal fallback
anthropichttps://api.anthropic.com/v1BYOK (x-api-key)Native Messages API (/v1/messages)
customnone — must set an upstreamDepends on endpointRejected / falls back if set without an upstream
copilotdynamic; https://api.individual.githubcopilot.com fallbackGitHub token, no API keyOpenAI-wire only — see Copilot

Choosing a provider

The provider lives on the gateway, shared across surfaces via config.json. It is not a VS Code setting — there is no provider dropdown in VS Code settings. State it once and restart.

CLI

Environment variable or Settings page

TOKENBEAVER_PROVIDER=anthropic tokenbeaver-gateway # or set it on the localhost Settings page: tokenbeaver-gateway --settings

Dropdown order on the Settings page: openrouter, openai, anthropic, custom, copilot. Restart after changing.

VS Code extension

Open the Settings page

Command Palette → TokenBeaver: Settings opens the same localhost Settings page and provider dropdown. There is no separate VS Code provider setting — engine settings live here so both surfaces stay in sync.

Custom endpoint

To point the gateway at any other OpenAI-compatible endpoint, set the provider to custom and give it an upstream base URL. A custom provider without an upstream is rejected or falls back — the upstream is required.

TOKENBEAVER_PROVIDER=custom \ TOKENBEAVER_UPSTREAM_BASE_URL=https://your-endpoint.example/v1 \ tokenbeaver-gateway

In VS Code, set the same two fields on the Settings page (TokenBeaver: Settings): provider custom + the upstream base URL. Restart to apply.

Dual upstream — one port, two agents

One gateway can serve an OpenAI-compatible agent and Claude Code at the same time. Set an Anthropic upstream alongside your main one: TOKENBEAVER_ANTHROPIC_UPSTREAM_BASE_URL routes /v1/messages to Anthropic, while /v1/chat/completions goes to your OpenAI-compatible provider.

# OpenAI-compatible traffic -> OpenRouter TOKENBEAVER_UPSTREAM_BASE_URL=https://openrouter.ai/api/v1 \ # Anthropic /v1/messages -> Anthropic TOKENBEAVER_ANTHROPIC_UPSTREAM_BASE_URL=https://api.anthropic.com/v1 \ tokenbeaver-gateway

The same two fields exist on the Settings page (upstreamBaseUrl and anthropicUpstreamBaseUrl). Now Cursor (or any OpenAI-wire tool) and Claude Code both point at http://127.0.0.1:4505/v1 and each reaches the right upstream.

Per-tool setup

Every tool below takes a base URL and an API key. Set the base URL to http://127.0.0.1:4505/v1 and paste your own provider key. For the full agent list see Integrations.

Cursor

Settings → Models → enable a custom OpenAI base URL, set it to the gateway URL, and paste your key. Cursor then talks to your provider through TokenBeaver.

Cline

Set the API provider to "OpenAI Compatible", base URL to the gateway URL, and your key. Pick a model your upstream serves.

Kilo / Roo Code

Choose the OpenAI-compatible provider, point the base URL at the gateway, and enter your key. Same wiring as Cline.

Copilot BYOK

In Copilot's model settings, add an OpenAI-compatible endpoint with the gateway URL and your key. Full steps and the flat-rate caveat are on the Copilot page.

Good to know
We only sit where you point us
  • TokenBeaver optimizes only the paths you explicitly route through it — a base URL you set, or Claude Code's hook file. It does not intercept or MITM any traffic you didn't point at it. A tool with no custom base-URL setting and no redirect file simply can't be routed through the gateway, by design.
  • The gateway is local. Run from the CLI it lives as long as that process runs; started from VS Code it runs in-process and stops when you close the editor. An always-on background service is the future desktop app, not shipped yet.
  • Same requests, same answers, fewer tokens — we never spoof, evade, or intercept anything. Trimmed content is restorable on demand.

Troubleshooting

Connection refused / can't reach the gateway
The gateway isn't running, or your agent is using the wrong port. Start it (tokenbeaver-gateway, or TokenBeaver: Start Gateway) and confirm with --status / TokenBeaver: Gateway Status. The base URL is http://127.0.0.1:4505/v1 unless you changed TOKENBEAVER_GATEWAY_PORT.
401 / auth error from the upstream
A 401 comes from your provider, not TokenBeaver. Your key is passed straight through (BYOK) and never stored, so check the key your agent sends and that it's valid for the selected provider.
Custom provider isn't working
A custom provider must also set an upstream base URL (TOKENBEAVER_UPSTREAM_BASE_URL or the Settings field). Custom without an upstream is rejected or falls back.
Wrong tool is hitting the wrong upstream
With dual upstream, /v1/messages goes to the Anthropic upstream and /v1/chat/completions to your OpenAI-compatible one. If a tool lands on the wrong side, check which wire protocol it uses and which upstream URLs you set.
My provider change didn't take effect
Provider changes are restart-required — restart the gateway. If it still looks unchanged, an environment variable may be overriding your Settings edit: precedence is env > config.json > default. The Settings page marks a value with an env: badge when an environment variable is winning.
Found a bug or have a feature request?

Open a GitHub issue →  ·  Questions? Support

Stuck on setup?

Email [email protected] or visit the support page — a real developer will get back to you.