> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mirage.strukto.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

> Wire mirage tools into the Vercel AI SDK via the @struktoai/mirage-agents/vercel adapter.

The [Vercel AI SDK](https://sdk.vercel.ai) (`ai`) drives tool-calling agents around any provider in its registry. Mirage ships an AI SDK 7 tool factory that gives `generateText`, `streamText` and agent loops a session's seven tools.

## Install

`@struktoai/mirage-agents/vercel` is runtime-agnostic. Pair it with `@struktoai/mirage-node` for Node or `@struktoai/mirage-browser` for the browser.

<CodeGroup>
  ```bash Node theme={null}
  pnpm add @struktoai/mirage-agents @struktoai/mirage-node ai @ai-sdk/openai
  ```

  ```bash Browser theme={null}
  pnpm add @struktoai/mirage-agents @struktoai/mirage-browser ai @ai-sdk/openai
  ```
</CodeGroup>

## Usage

```ts theme={null}
import { MountMode, RAMVFS, Workspace } from '@struktoai/mirage-node'
import { generateText, stepCountIs } from 'ai'
import { openai } from '@ai-sdk/openai'
import { mirageTools } from '@struktoai/mirage-agents/vercel'
import { buildSystemPrompt } from '@struktoai/mirage-agents/openai'

const ws = new Workspace({ '/': new RAMVFS() }, { mode: MountMode.WRITE })

const { text } = await generateText({
  model: openai('gpt-5.4-mini'),
  system: await buildSystemPrompt({
    mountInfo: { '/': 'In-memory filesystem (read/write)' },
  }),
  prompt:
    "Create /hello.txt with 'hi from mirage' and /data/numbers.csv with 3 sample rows. " +
    'Then list and read every file back.',
  tools: mirageTools(ws),
  stopWhen: stepCountIs(20),
})

console.log(text)
```

## Exports

| Symbol | Purpose |
| - | - |
| `mirageTools(ws, options?)` | `{ shell, read, write, edit, ls, grep, glob }`, each an `ai` `tool()` to spread into `tools`. They answer as the session's [`session.tools`](/typescript/access/in-app#session-tools) do; `options` takes `sessionId` and `staleWriteProtection`. |

`read` uses AI SDK 7's `toModelOutput`: text files come back as numbered lines, PDFs and supported images become file content parts, and other binary formats return a metadata note.

## Examples

* [`examples/typescript/agents/vercel/ram_vercel.ts`](https://github.com/strukto-ai/mirage/blob/main/examples/typescript/agents/vercel/ram_vercel.ts), RAM-only sandbox driven by `gpt-5.4-mini`.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.