Skip to Content

Ecosystem

TanStack AI with Vercel Sandbox


Sandbox

Install TanStack AI, the sandbox packages, and the Codex adapter:

TanStack AI

Use a JavaScript or TypeScript project with Node.js 22 or later and a Vercel account with a team and project. This example uses the Codex harness, which requires an OpenAI API key.

Copy page

Run TanStack AI coding agents in Vercel Sandbox using the @tanstack/ai-sandbox-vercel provider. The provider manages the microVM, while a harness adapter selects the coding agent that runs inside it.

npm

Save your credentials in a .env file:


VERCEL_TOKEN=your_access_token_here

bun

Create a Vercel access token scoped to your team and find your team and project IDs using the Sandbox authentication instructions.

VERCEL_TEAM_ID=your_team_id_here

pnpm i @tanstack/ai @tanstack/ai-sandbox @tanstack/ai-sandbox-vercel @tanstack/ai-codex

CODEX_API_KEY=your_openai_api_key_here

yarn

Create an entry file and replace your_org/your_repo with a public GitHub repository. The example clones that repository into the sandbox and asks Codex to list its files:

VERCEL_PROJECT_ID=your_project_id_here

The provider uses the Vercel credentials to manage sandboxes. Pass the agent's CODEX_API_KEY as a workspace secret so the agent can authenticate inside the microVM.

createSecrets,

thrownewError('Set CODEX_API_KEY in your .env file.');

defineSandboxPolicy,

import { vercelSandbox } from'@tanstack/ai-sandbox-vercel';

if (!apiKey) {
import {
defineWorkspace,

conststream=chat({

source:githubRepo({ repo:'your_org/your_repo' }),

defineSandbox,
githubRepo,
TypeScript
id:'vercel-agent',

approvalPolicy:'never',

messages: [{ role:'user', content:'List the project files.' }],

setup: [
withSandbox,
console.log(chunk);
}),

The workspace setup installs the Codex CLI inside the microVM and checks that it runs before starting the agent. --include=optional includes its platform-specific binary. The adapter uses that executable through codexPathOverride. See installing an agent CLI for setup behavior.

The danger-full-access mode uses the Vercel microVM as the isolation boundary. Together with approvalPolicy: 'never' and the default: 'allow' policy, it lets Codex execute commands without approval prompts inside that microVM. See TanStack AI policies for harness-specific enforcement.

Run the TypeScript example with tsx, loading credentials from .env:

pnpm dlxtsx--env-file=.envindex.mts


For JavaScript, run node --env-file=.env index.mjs. Your terminal displays stream events with the agent's command activity and response listing the repository files.

Next steps

Last updated September 15, 2026


Cross-link map: TanStack AI with Vercel Sandbox (/docs/sandbox/ecosystem/tanstack-ai)From the Vercel docs graph (built 2026-09-21T05:26:59.511Z), spanning vercel.com docs + KB, nextjs.org, ai-sdk.dev, and other Vercel documentation sites. Full graph as JSON: https://vercel.com/docs/graph.jsonSemantically closest pagesUsing TanStack AI with Vercel Sandbox — Run coding agents in isolated Vercel Sandbox microVMs with the @tanstack/ai-sandbox-vercel provider, with durable resumeEcosystem — Use Vercel Sandbox with the agent frameworks, model SDKs, and coding agents you already work with.TanStack AI with AI Gateway — Connect TanStack AI to Vercel AI Gateway with the official adapter to authenticate requests and stream responses from AITanStack AI with MCP — Connect TanStack AI to a Model Context Protocol server on Vercel and call its tools with models served through AI GatewaQuickstart — Learn how to run your first code in a Vercel Sandbox.PrerequisitesEcosystem — Use Vercel Sandbox with the agent frameworks, model SDKs, and coding agents you already work with.This page links to (6)Account Management — Learn how to manage your Vercel account and team members.TanStack AI with AI Gateway — Connect TanStack AI to Vercel AI Gateway with the official adapter to authenticate requests and stream responses from AITanStack AI — Connect a TanStack AI app to OAuth-protected MCP servers with Vercel Connect, handle user consent, and manage MCP clientVercel Sandbox — Run untrusted or agent-generated code in isolated Linux microVMs with Vercel Sandbox.Sandbox Authentication — Learn how to authenticate with Vercel Sandbox using OIDC tokens or access tokens.Using TanStack AI with Vercel Sandbox — Run coding agents in isolated Vercel Sandbox microVMs with the @tanstack/ai-sandbox-vercel provider, with durable resumePages that link here (4)By site: vercel-docs (4)TanStack AI — Connect a TanStack AI app to OAuth-protected MCP servers with Vercel Connect, handle user consent, and manage MCP clientTanStack Start on Vercel — Deploy TanStack Start applications to Vercel with Nitro and configure Vercel Functions.TanStack AI with MCP — Connect TanStack AI to a Model Context Protocol server on Vercel and call its tools with models served through AI GatewaEcosystem — Use Vercel Sandbox with the agent frameworks, model SDKs, and coding agents you already work with.

Was this helpful?