How It Works
Every workspace can reach the proxy athttp://172.16.0.1:9090 from inside the VM. When managed mode is active, AI SDK requests are routed through that bridge-local proxy, which fronts an OpenRouter gateway. The proxy:
- Intercepts the request from your workspace VM
- Resolves the workspace from the VM’s source IP on the compute bridge
- Injects Rigbox’s managed OpenRouter key (your VM never sees it)
- Forwards the request to OpenRouter, which routes to the appropriate upstream provider for the requested model
- Logs token usage and deducts from your credit balance
- Returns the response to your code
anthropic/claude-sonnet-4, openai/gpt-4o, google/gemini-2.5-pro).
Endpoints
The proxy speaks two HTTP shapes — OpenAI-compatible (used by most SDKs and tools) and an Anthropic-shaped passthrough for Claude Code. Both terminate on the same OpenRouter gateway behind the scenes.A small set of free-tier models is also exposed through a
free alias when Rigbox has the matching managed key. They consume credits at zero rate but otherwise behave identically.Credit Tiers
Every Rigbox account comes with AI credits that reset monthly.
Credits map roughly to API cost - one credit equals approximately $0.01 of upstream provider spend. The exact mapping depends on the model and token count.
Activate Managed Mode
With the CLI
Set a workspace to managed mode withrig workspace ai mode:
rig ai defaults:
Inside a Workspace VM
Managed workspaces already injectOPENROUTER_BASE_URL and OPENROUTER_API_KEY into every login shell, so most tools work without any setup step. The rig proxy on helper is a convenience for scripts or CI where you want the exports printed explicitly:
- Prints shell
exportstatements forOPENROUTER_BASE_URLandOPENROUTER_API_KEY(plus a small set of compatibility variables for SDKs that prefer provider-native names) - Uses
managed-by-rigboxplaceholder API keys where SDKs require a non-empty key and don’t readOPENROUTER_API_KEY - Routes subsequent AI SDK calls in that shell through the Rigbox proxy
Check Your Credit Balance
The fastest path is the CLI:rig status prints your remaining credits, monthly total, current mode, and active workspaces. For programmatic access, see the Credits API reference.
View Usage Breakdown
Get a daily breakdown of credit consumption across your workspaces.Per-subject cost and budgets
If your app fronts many end-users through a single workspace — a multi-tenant SaaS, an agent platform, a shared chatbot — you can attribute managed-AI cost to each end-user (“subject”), read their spend, and cap it. The proxy is the mechanism (accurate cost, attribution, enforcement); your app owns the policy (which tiers exist, the amounts, the windows) and asserts the subject id over the already-IP-attested channel. This covers the OpenAI-shape endpoints (/v1/chat/completions, /v1/completions, /v1/responses, /v1/embeddings).
Read the settled cost of a call
The settled rigbox-credit cost rides on the response — no second lookup. 1 credit ≈ $0.01; 1,000,000 microcredits = 1 credit.cost_micro is the exact integer; cost_credits is the convenience float. The fields are best-effort: present only when the upstream model reports a cost, so don’t treat their absence as zero.
"stream": true), the same cost_micro / cost_credits are spliced into the final usage chunk:
Attribute a call to a subject
Tag any call withX-Rigbox-Subject (it wins) or the OpenAI user body field. Trimmed; empty = unattributed; capped at 256 characters.
Read a subject’s rolling spend
window accepts 30s / 15m / 5h / 7d or a bare number of seconds (default 86400). It’s a rolling window scoped to your workspace — you can only read your own subjects, and they’re isolated from each other. Attribution is forward-only. This read alone is enough to enforce policy yourself (read spend → decide whether to call); the next section is for letting the proxy do it. See the Get Subject Usage API reference.
Enforce budgets and rate limits
Declare the policy inline on each request and the proxy checks it against the subject’s recorded spend before the call runs:- Amount — a bare number is credits (
5= 5 credits); areqsuffix is a request count (100req). - Window —
5h/30m/3600/7d. - Enforcement requires
X-Rigbox-Subject; with no subject, the limit headers are ignored.
Retry-After header and a structured body. OpenAI SDKs still read error.message / error.code; error.details is the rich payload for your UX:
subject_over_budget, a rate breach 429 subject_rate_limited (budget is evaluated first if several trip), and a malformed limit header 400 subject_limit_malformed. The full schema is in the Chat Completion API reference.
/v1/messages (Anthropic) and the audio endpoints are not yet covered by per-subject attribution or enforcement.What Happens When Credits Run Out
When your credit balance reaches zero:- API requests return HTTP 402 - the proxy rejects new managed AI calls until credits are available
- The UI shows an upgrade prompt - you can upgrade to Pro or switch to BYOK mode
- Existing services keep running - only new AI API calls are blocked; your workspace and non-AI services are unaffected
End-to-End Example
Here is a complete flow: activate managed mode, make an AI call from inside the workspace, then check remaining credits. Step 1 - Activate managed mode for a workspace:rig status prints your balance directly. For the raw payload, query the endpoint with rig api:
Credit deduction happens synchronously - the balance is updated before the proxy returns the response to your code, so the credits endpoint always reflects the latest usage.
Switching Providers and Models
Because the managed gateway is OpenRouter, you can switch the upstream provider and model at any time by changing themodel field on your request — there’s no environment change, no proxy restart, and no separate “configure provider” step:
rig ai defaults) define the default provider and model used by tools that don’t ask for one explicitly, and are also surfaced by rig proxy status.
Next Steps
- AI Coding Tools - use Rigbox credits with Claude Code, Codex, OpenCode, and Kilocode
- App Catalog - one-click install of the four CLI-shape agent recipes
- Bring Your Own Keys - use your own API keys for unlimited usage
- Setup Scripts - automate SDK installation in new workspaces
- Service Specs - run AI-powered services as background daemons