Skip to main content
Your code starts a Vercel Sandbox sandbox and makes a OneCLI agent for it, on one vault. The sandbox can reach only OneCLI. Its HTTPS calls go through the gateway, which adds the vault’s key on the way out, so no key is ever in the sandbox.

Before you start

  • A OneCLI managing key in ONECLI_API_KEY. Make one in the dashboard under Settings > API keys. It stays with your code: never put it in the sandbox.
  • Vercel credentials: VERCEL_OIDC_TOKEN (run vercel env pull in a linked project), or an access token. In TypeScript, pass the token to Sandbox.create as token, with teamId and projectId. In Python, set VERCEL_TOKEN, VERCEL_TEAM_ID, and VERCEL_PROJECT_ID.
  • Node.js 22 or later, or Python 3.11 or later.
  • The example uses your Personal vault and its Test key for httpbin.org, which every account starts with. Use any vault, and any host it has an item for.

Install

Example

Save the TypeScript as sandbox.mts and run npx tsx sandbox.mts, or the Python as sandbox.py and run python sandbox.py. It prints 200.

What goes where

The Sandboxes overview explains each value.

Good to know

  • Lifetime. timeout in TypeScript, or execution_time_limit in seconds in Python, is how long the sandbox runs: at most 45 minutes on Vercel’s Hobby plan and 24 hours on Pro. Keep the agent’s lifetime at least as long.
  • Plain allow rules only. For an allowed domain with no rules, Vercel’s firewall passes the connection without decrypting it, which is what the gateway needs. Don’t add transform rules for OneCLI’s hosts.
  • Node clients. Behind an allow list, Node’s http and https modules and axios fail, because they send no host name to the gateway. Give them agent.baseUrl(host) instead, or agent.base_url(host) in Python. See the SDK reference for TypeScript or Python.
  • Vercel Sandbox’s own key injection. Vercel Sandbox can also add a key to a sandbox’s calls itself, with credentials brokering in its network policy. See how OneCLI compares.

From a terminal

To connect one Vercel Sandbox sandbox that is already running, make a connect token as in From a terminal, then run its install_command in the sandbox, as it is, in place of <install_command>:

Versions

Written in December 2026 for @onecli-sh/sdk 4.1 and @vercel/sandbox 5.1 in TypeScript, and for onecli-sdk 0.1 and vercel-sandbox 1.3 in Python.

Next steps