vercel-blob-ai-sdk
v1.2.0
Published
Vercel Blob storage tools for the AI SDK
Readme
Vercel Blob - AI SDK Tools
A collection of AI SDK tools that give your AI agents the ability to store and manage files using Vercel Blob.
Installation
npm install vercel-blob-ai-sdkSetup
Set the BLOB_READ_WRITE_TOKEN environment variable with your Vercel Blob token.
Usage
import { generateText, stepCountIs } from "ai";
import { uploadAsset, listAssets, downloadAsset } from "vercel-blob-ai-sdk";
const { text } = await generateText({
model: 'openai/gpt-5.2',
tools: { uploadAsset, listAssets, downloadAsset },
prompt: "Save a file called hello.txt with the content 'Hello, world!'",
stopWhen: stepCountIs(3),
});Available Tools
| Tool | Description |
|------|-------------|
| uploadAsset | Upload files, images, or text content to cloud storage |
| listAssets | List stored assets with optional filtering by prefix |
| getAssetInfo | Get metadata about an asset without downloading |
| downloadAsset | Download and retrieve the contents of an asset |
| copyAsset | Copy an asset to a new location |
| deleteAsset | Delete a single asset (requires approval) |
| deleteAssets | Delete multiple assets at once (requires approval) |
Path Prefix
Use createBlobTools to scope all path-based operations under a prefix — useful for multi-tenant apps or organized storage:
import { createBlobTools } from "vercel-blob-ai-sdk";
const { uploadAsset, listAssets, copyAsset } = createBlobTools({
pathPrefix: "tenant-abc",
});
// uploadAsset pathname "doc.txt" → stored as "tenant-abc/doc.txt"
// listAssets with no prefix → lists only "tenant-abc/" assets
// copyAsset destination "backup.txt" → copies to "tenant-abc/backup.txt"The prefix applies to uploadAsset, listAssets, and copyAsset. URL-based tools (deleteAsset, deleteAssets, getAssetInfo, downloadAsset) are unaffected.
Resources
Contributing
Contributions are welcome! Please read our Contributing Guide for more information.
