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

# Vercel AI SDK

> Code-execution tool for `tool({...})` + `generateText` / `streamText`.

## Install

```bash theme={null}
npm install podflare ai zod
```

## Use

```ts theme={null}
import { generateText, tool } from "ai";
import { anthropic } from "@ai-sdk/anthropic";
import { z } from "zod";
import { podflareRunCode } from "podflare/ai-sdk";

const pf = podflareRunCode();

const runCode = tool({
  description: pf.description,
  parameters: z.object({
    code: z.string().describe("Python (default) or bash source"),
    language: z.enum(["python", "bash"]).optional(),
  }),
  execute: pf.execute,
});

const { text } = await generateText({
  model: anthropic("claude-opus-4-7"),
  tools: { runCode },
  prompt: "Load /data/sales.csv and tell me the top 5 products by revenue.",
});

console.log(text);
await pf.close();
```

## With `streamText`

```ts theme={null}
import { streamText } from "ai";

const stream = await streamText({
  model: anthropic("claude-opus-4-7"),
  tools: { runCode },
  prompt: "...",
});

for await (const chunk of stream.textStream) {
  process.stdout.write(chunk);
}
await pf.close();
```

## Options

```ts theme={null}
const pf = podflareRunCode({
  host: "https://api.podflare.ai",  // default: PODFLARE_HOSTD_URL env
  template: "python-datasci",         // future: pool flavor
});
```

## Model-agnostic

The adapter doesn't depend on a specific LLM provider — use any
Vercel AI SDK model. The tool shape is provider-agnostic.

## Why not export a pre-wrapped tool?

We don't import `ai` or `zod` in our package so Podflare stays dep-free
for users who don't need Vercel's AI SDK. Wrapping `pf.execute` in
`tool({...})` is an 8-line boilerplate that makes the tool types
explicit at the call site.
