Managed mode routes traffic through Rigbox’s OpenRouter gateway and meters it against your credit balance. In BYOK mode, configure your SDK or agent with your provider key and endpoint. The selected tool and endpoint determine the route; changing the workspace mode does not intercept or rewrite every outgoing SDK request.
Before you begin
Use the v0.13 CLI and authenticate. Run workspace-management and recipe commands from your local terminal. Commands identified as running inside a workspace require its console terminal or SSH session. Replace example resource IDs with the values returned for your account. Start the target workspace first and verify its identity withrig workspace ls. AI calls require managed credits or an appropriately configured provider account.
When to Use BYOK
BYOK is the right choice when:- You already have API keys from Anthropic, OpenAI, Google, or another provider
- You want provider-billed usage instead of managed credits
- You need a specific model not available in managed mode
- Your organization requires that API keys stay under your own provider account for billing, audit, or compliance reasons
Set BYOK Mode
BYOK is two steps: flip the workspace’s AI mode tobyok, then set your provider key as a workspace environment variable using the standard name your SDK expects (ANTHROPIC_API_KEY, OPENAI_API_KEY, GOOGLE_API_KEY, …).
The API stores workspace environment changes and pushes configuration files to a running workspace. Existing processes retain their current environment; restart the affected tool or service and open a fresh login shell. Stopped workspaces receive the configuration on their next start.
How Keys Are Stored and Injected
When you set a BYOK key:- Stored with the workspace - the value is saved as one of the workspace’s environment variables
- Masked by default -
rig workspace env getshows secret-shaped values (like*_API_KEY) as<masked>; pass--revealto print the real value - Injected at runtime - the key is exported into the workspace environment, so SDKs pick it up with no extra setup
- Scoped to the workspace - each workspace has its own environment; changing one does not affect others
/home/developer/.rigbox/.env. Masking CLI output does not encrypt the values or prevent workspace code from reading them. Do not treat this mechanism as a dedicated secret vault.
The consuming process must load the configured provider environment variable, such as OPENAI_API_KEY, ANTHROPIC_API_KEY, or GOOGLE_API_KEY.
Clear a Key
To remove a provider key from a workspace, unset the environment variable:Switch Back to Managed Mode
You can switch from BYOK to managed mode at any time. This starts routing through Rigbox-managed credits again:Mode updates refresh the workspace’s routing profile for new shells. An existing shell or process can retain old values until restarted.
Set Defaults for New Workspaces
If you use BYOK across most of your workspaces, set an account default so new workspaces start in BYOK mode with your preferred provider and model:rig ai defaults with no flags to see the current defaults. Account defaults cover mode, provider, and model only — the provider key is always set per workspace (with rig workspace env set), so it is never stored account-wide. See the AI Defaults API reference for the full schema.
Managed vs. BYOK Comparison
Provider-Specific Examples
Anthropic (Claude)
OpenAI (GPT)
Google (Gemini)
Security Best Practices
- Rotate keys regularly - update the key with
rig workspace env set, then restart the workspace - Use scoped keys - if your provider supports project-scoped or restricted keys, prefer those over organization-wide keys
- Audit usage - monitor your provider dashboard for unexpected usage patterns
- One key per workspace - avoid sharing the same key across many workspaces; this makes it easier to revoke access to a single workspace
Verify and troubleshoot
Inside the workspace, inspectrig proxy status, then make one small request with your chosen tool. Verify the configured endpoint and check the corresponding Rigbox or provider usage. After changing keys or mode, start a fresh shell and restart processes that retained their old configuration. Never print a provider key to verify it.
For failures, start with runtime logs, health checks, or resource exhaustion.
Next Steps
- Managed AI Proxy - use Rigbox-provided credits instead
- Setup Scripts - automate SDK installation in every workspace
- Service Specs - run AI-powered backend services automatically