Developers
Vercel AI SDK
Use refile with Vercel AI SDK
This guide explains how to integrate Refile’s PDF generation capabilities with the Vercel AI SDK in just a few lines of code. This integration allows AI models to generate PDFs directly from markdown content as part of their response flow.
Prerequisites
- A refile API key (available from your refile dashboard)
- Node.js project with Vercel AI SDK installed
- Basic familiarity with Vercel AI SDK usage patterns
Quick Start
- Install the dependencies:
- Copy the refile tool code from refileTool.js:
- Replace
<token>
in index.js with your refile API key and start generating PDFs!
Customization Options
Want a different look? Just change these parameters when calling getRefileTool()
:
Remember to keep your API key safe by using environment variables in production and never exposing your key in client side code!
For a detailed explanation of the API and all configuration options, visit the API reference.