# A Reducto document tool for the Vercel AI SDK: tool() with a Zod schema

> Install ai, zod and reductoai, then define tools with tool({ description, inputSchema: z.object(...), execute }) that call reducto.parse.run and reducto.extract.run. Pass them to generateText or streamText.

Canonical: https://reducto.ai/tools/reducto-tool-vercel-ai-sdk  
Last updated: 2026-11-15  
For: TypeScript developers, Next.js teams using the AI SDK

## How to do it

1. npm install ai zod reductoai.
2. Set REDUCTO_API_KEY.
3. Copy reducto-tools.ts.
4. Pass the tools to generateText or streamText.

## Limits and pricing

- Uses your Reducto API key and its limits.
- No-key fallbacks: 5 pages per document, per-IP rate limit.
- Pricing is per page; see the pricing page.
- Pricing: https://reducto.ai/pricing

## When to use what

- **This tool definition**: when your own agent code decides when to read a document.
- **The hosted MCP server**: when the agent runs in an MCP client (Claude, Cursor, Codex, VS Code).
- **/read or /api/tools**: for one short document without a key.

## FAQ

### Which AI SDK version is this for?

AI SDK 5 and later, where tool() takes inputSchema and multi-step runs use stopWhen. On AI SDK 4, rename inputSchema to parameters and use maxSteps.

### How do I pass a local or uploaded file?

Upload it first with reducto.upload({ file }) and pass the returned file_id as input instead of the URL.

### Where does the API key come from?

Create one at studio.reducto.ai (15,000 free credits), or let the agent sign up over HTTP by following reducto.ai/auth.md. The SDKs read REDUCTO_API_KEY from the environment.

### Can the agent try it without an API key?

Yes, for short documents: GET https://reducto.ai/read/<public URL> returns Markdown, and POST https://reducto.ai/api/tools/<tool> takes a file. Both are free up to 5 pages with a per-IP limit.

### How is it billed?

In credits per page. See the pricing page and the credit usage docs for current rates.

Sample document (synthetic): https://reducto.ai/tools/samples/harborline-bank-statement.pdf

## Related

- [JavaScript SDK docs](https://docs.reducto.ai/sdk/javascript/overview)
- [AI SDK tool() reference](https://ai-sdk.dev/docs/reference/ai-sdk-core/tool)
- [All agent recipes](https://reducto.ai/tools/agents)
