A credential profile is a named set of AI provider keys and custom APIs, with several accounts per provider. With the AI proxy on (off by default), sandboxes get placeholder keys; the real keys stay encrypted on froog, which forwards requests.
$ echo "$ANTHROPIC_API_KEY" | soulsand ai key-add anthropic # into the default profile
$ echo "$ANTHROPIC_KEY_2" | soulsand ai key-add anthropic # second account, used when the first runs out
$ soulsand ai proxy on # sandboxes started from now on get placeholders
$ soulsand ai usage # requests, tokens, estimated cost per sandbox
$ soulsand ai block my-box # refuse its AI requests at once
Credential profiles
Each account has a profile named default. A sandbox uses the profile its environment names (soulsand ai env ci ci-bots), else the default. soulsand ai use my-box ci-bots overrides one sandbox (proxied requests switch at once, variables at next start). The API never returns a key, only its provider, last four characters and id.
$ soulsand ai profile-new ci-bots --copy-from default
$ echo "$OPENAI_API_KEY" | soulsand ai key-add openai --profile ci-bots
$ echo "$STRIPE_KEY" | soulsand ai key-add STRIPE_KEY --base-url https://api.stripe.com --profile ci-bots
$ echo "$ACME_KEY" | soulsand ai key-add ACME_KEY --base-url https://api.acme.dev --secret-header X-Api-Key
$ soulsand ai profiles
$ soulsand ai key-rm cred_0123456789abcdef --profile ci-bots
$ soulsand ai profile-set ci-bots --default
| Provider | The sandbox gets |
|---|---|
anthropic | ANTHROPIC_API_KEY, ANTHROPIC_BASE_URL |
openai | OPENAI_API_KEY, OPENAI_BASE_URL |
gemini | GEMINI_API_KEY, GOOGLE_GEMINI_BASE_URL |
deepseek, mistral, openrouter, xai | NAME_API_KEY, NAME_BASE_URL |
bedrock | AWS_BEARER_TOKEN_BEDROCK, ANTHROPIC_BEDROCK_BASE_URL, AWS_REGION (+ CLAUDE_CODE_USE_BEDROCK=1 without an Anthropic key) |
| a custom API | NAME, NAME_BASE_URL |
- The CLI reads the key from stdin if omitted. One token, up to 8192 printable characters.
- Bedrock takes a Bedrock API key or
ACCESS_KEY_ID:SECRET_ACCESS_KEY[:SESSION_TOKEN], plus--region(defaultus-east-1). - A custom API: name of A-Z, 0-9,
_(provider prefixes and*_BASE_URLare400 reserved_name); publichttps://base URL. Its secret goes only where you say:Authorization: Bearerby default, or--secret-header,--secret-prefix,--secret-query. - Up to 20 profiles, 50 keys each. A default or in-use profile can't be deleted (
409 is_default,409 in_use). - Provider keys set with
soulsand envcount as the last account in every profile, so the proxy hides them too (unless you also set their base URL). A sandbox's own-evariables are never proxied.--no-environmentgets no AI credentials. - Without the proxy, a sandbox gets the real key of the account in use.
Several accounts per provider
The proxy uses the first account that isn't resting. On a limit it rests that account and retries the next at once: 429 for its Retry-After (default 60 s); 402 or a quota error code (insufficient_quota, credit_balance_too_low, …) for an hour. Error message text is ignored. soulsand ai profiles shows which accounts rest and why; soulsand ai switch cred_… puts one first. Switching needs the proxy.
The proxy
sandbox froog provider
ANTHROPIC_API_KEY=froog-ph-…
ANTHROPIC_BASE_URL=https://ai.froog.tech/anthropic
agent ── request + placeholder ──▶ placeholder of a running sandbox?
blocked? swap in the real key ── request ──▶ api.anthropic.com
◀────── answer, streamed ──── count the tokens ◀──────────── answer ──────
soulsand ai proxy on (needs account.admin) applies at each sandbox's next start; soulsand ai proxy shows state and URL.
- Placeholders are per sandbox, worthless outside froog, and renewed at each start. A process holding an old one gets
401 ai_placeholder_invalid. - Each key goes only to its own provider, in its key header. A placeholder elsewhere in a request is stripped; in the path it's
400 ai_placeholder_in_path. A custom API's base URL sees its secret: pick one you trust. - Built-in providers accept only model endpoints (messages, chat/completions, responses, embeddings, models, Gemini
generateContentetc., Bedrockinvoke/converse); others are403 ai_path_not_allowed. Custom APIs take any path. - Answers stream unbuffered. Limits: 16 MiB per request, body within 60 s, 16 concurrent requests per sandbox and 64 per account.
- Answers are sandboxed against browsers (minimal headers, strict CSP); browser requests are
403 ai_browser_refused. - froog never logs prompts, answers or keys: only provider, status and sandbox.
- Subscription credentials pass through unproxied.
soulsand ai proxy on --withhold-subscriptions truekeeps them out of proxied sandboxes.
Proxy errors are JSON {"error": {"code", "message"}}: 400 ai_placeholder_in_path, 401 ai_placeholder_missing / ai_placeholder_invalid, 403 ai_blocked / ai_path_not_allowed / ai_browser_refused, 404 ai_no_credential / ai_unknown_provider, 408 request_timeout, 413 request_too_large, 429 ai_too_many_requests / ip_rate_limited / account_rate_limited, 502 ai_upstream_unreachable. Anything else is the provider's answer.
Usage
froog counts requests, errors and tokens (input, output, cache reads and writes) per proxied sandbox, day and model. cost_usd is an estimate at list prices, not a froog charge. Kept 400 days.
$ soulsand ai usage --days 7 # every sandbox, most expensive first
$ soulsand ai usage my-box # per day and model
Block a sandbox
soulsand ai block my-box refuses its AI requests at once (403 ai_blocked); --all blocks every proxied sandbox. Anyone who may update the sandbox can block it, including its in-sandbox key. Unblocking or changing its profile needs an unrestricted environment.write or account.admin key (and owner/admin in an org), so a sandbox can't unblock itself. There is no automatic AI spend cap: poll GET /v1/sandboxes/{name}/ai and block past your limit.
API: /v1/ai/proxy, /v1/ai/profiles[/{profile}[/credentials[/{id}[/active]]]], PUT /v1/ai/environments/{env}, GET /v1/ai/usage, GET/PUT /v1/sandboxes/{name}/ai. Changes appear in the audit log, never with a key.