VercelSandbox
Executes commands as Vercel serverless functions. Provides globally-distributed, zero-infrastructure execution with automatic scaling.
info
For interface details, see WorkspaceSandbox interface.
warning
VercelSandbox is stateless. There is no persistent filesystem, no interactive shell, and no support for long-running or background processes. Only /tmp is writable and is ephemeral between invocations.
InstallationDirect link to Installation
- npm
- pnpm
- Yarn
- Bun
npm install @mastra/vercel
pnpm add @mastra/vercel
yarn add @mastra/vercel
bun add @mastra/vercel
UsageDirect link to Usage
Add a VercelSandbox to a workspace and assign it to an agent:
import { Agent } from '@mastra/core/agent'
import { Workspace } from '@mastra/core/workspace'
import { VercelSandbox } from '@mastra/vercel'
const workspace = new Workspace({
sandbox: new VercelSandbox({
token: process.env.VERCEL_TOKEN,
}),
})
const agent = new Agent({
name: 'dev-agent',
model: 'anthropic/claude-sonnet-4-6',
workspace,
})
Team-scoped deployment with custom resourcesDirect link to Team-scoped deployment with custom resources
const workspace = new Workspace({
sandbox: new VercelSandbox({
token: process.env.VERCEL_TOKEN,
teamId: 'team_abc123',
regions: ['iad1', 'sfo1'],
maxDuration: 120,
memory: 3008,
env: {
NODE_ENV: 'production',
},
}),
})
Constructor parametersDirect link to Constructor parameters
token?:
string
Vercel API token. Falls back to `VERCEL_TOKEN` environment variable.
teamId?:
string
Vercel team ID for team-scoped deployments.
projectName?:
string
Existing Vercel project name. Auto-generated if omitted.
regions?:
string[]
= ['iad1']
Deployment regions.
maxDuration?:
number
= 60
Function maximum duration in seconds.
memory?:
number
= 1024
Function memory in MB.
env?:
Record<string, string>
Environment variables baked into the deployed function source. These are embedded at deploy time, not set dynamically.
commandTimeout?:
number
= 55000
Per-invocation command timeout in milliseconds.
instructions?:
string | ((opts) => string)
Custom instructions that override the default instructions returned by `getInstructions()`. Pass a string to fully replace, or a function to extend the defaults.
PropertiesDirect link to Properties
id:
string
Unique identifier for this sandbox instance.
name:
'VercelSandbox'
Human-readable name.
provider:
'vercel'
Provider type identifier.
status:
ProviderStatus
Current lifecycle status: `'pending'`, `'starting'`, `'running'`, `'stopping'`, `'stopped'`, `'destroying'`, `'destroyed'`, or `'error'`.
LimitationsDirect link to Limitations
VercelSandbox uses serverless functions under the hood, which means:
- No persistent filesystem: Files written to
/tmpare ephemeral and cleared between invocations. - No interactive shell: Commands run via
/bin/sh -cwith no stdin streaming. - No background processes: No process manager, PIDs, or long-running tasks.
- No mounting: Cloud storage mounting (S3, GCS) is not supported.
- Timeout limits: Maximum execution time is bounded by
maxDuration(default 60s).
RelatedDirect link to Related
- WorkspaceSandbox interface
- Workspace class
- E2BSandbox — full-featured cloud sandbox with persistent filesystem and process management