---
title: "Vercel AI SDK integration"
description: "Pass a Promigence sandbox to the Vercel AI SDK as experimental_sandbox, or to bash-tool. The commands your tools run and the files they touch stay in the…"
url: "https://www.promigence.ai/integrations/vercel-ai-sdk"
site: "Promigence"
---

# Vercel AI SDK integration

Pass a Promigence sandbox to the Vercel AI SDK as `experimental_sandbox`, or to bash-tool. The commands your tools run and the files they touch stay in the sandbox, away from your server.

The package is `promigence-ai-sdk-sandbox` on npm, for TypeScript.

## Install

Install it and set your key.

```bash
npm install promigence-ai-sdk-sandbox @promigence/sdk ai zod bash-tool
export PROMIGENCE_API_KEY=prom_api_...
```

## Example

From the guide [Run Vercel AI SDK agents in a Promigence sandbox](https://www.promigence.ai/docs/guides/vercel-ai-sdk), which goes on to the spend cap, cleaning up, and what the package does not support.

```ts
import { generateText, tool } from "ai";
import { Sandbox } from "@promigence/sdk";
import { promigenceSandbox } from "promigence-ai-sdk-sandbox";
import { z } from "zod";

const sandbox = await Sandbox.create({ timeoutMs: 600_000, spendCap: 1 });
const session = promigenceSandbox(sandbox, { workingDirectory: "/workspace" });

try {
  await generateText({
    model: "anthropic/claude-sonnet-4-5",
    prompt: "run the tests and fix what fails",
    experimental_sandbox: session,
    tools: {
      shell: tool({
        description: "run a shell command",
        inputSchema: z.object({ command: z.string() }),
        execute: async ({ command }, { experimental_sandbox }) => {
          const { exitCode, stdout, stderr } = await experimental_sandbox!.run({ command });
          return `${exitCode}\n${stdout}${stderr}`;
        },
      }),
    },
  });
} finally {
  await session.stop();
}
```

## Next

- [Run Vercel AI SDK agents in a Promigence sandbox](https://www.promigence.ai/docs/guides/vercel-ai-sdk)
- [promigence-ai-sdk-sandbox on npm](https://www.npmjs.com/package/promigence-ai-sdk-sandbox)
- [All integrations](https://www.promigence.ai/integrations)

