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-sdk

Setup

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),
});

Peer dependencies

This package requires ai (^6.0.67) and zod (^4.3.6) as peer dependencies.

Available Tools

ToolDescriptionNeeds approval
uploadAssetUpload files, images, or text content to blob storageNo
listAssetsList stored assets with optional prefix filtering and paginationNo
getAssetInfoGet metadata (size, content type, upload date) without downloadingNo
downloadAssetDownload and retrieve file contents (text or base64)No
copyAssetCopy an asset to a new path without re-uploadingNo
deleteAssetPermanently delete a single assetYes
deleteAssetsPermanently delete multiple assets at onceYes

Configuring tools

Use createBlobTools to scope operations under a path prefix, configure access control, and customize individual tool behavior.

import { createBlobTools } from "vercel-blob-ai-sdk";

const tools = createBlobTools({
  pathPrefix: "tenant-abc",
  access: "private",
  allowOverwrite: true,
  overrides: {
    deleteAsset: { needsApproval: false },
    uploadAsset: { description: "Store tenant files" },
  },
});

Options

OptionTypeDefaultDescription
pathPrefixstring""Prefix prepended to all asset paths
access"public" | "private""public"Default access level for uploaded/copied assets
addRandomSuffixbooleanfalseAdd a random suffix to filenames to avoid conflicts
allowOverwritebooleanfalseAllow overwriting existing assets at the same path
overridesRecord<string, ToolOverrides>—Per-tool overrides (see below)

The path prefix applies to uploadAsset, listAssets, and copyAsset. URL-based tools (deleteAsset, deleteAssets, getAssetInfo, downloadAsset) are unaffected by the prefix.

Tool overrides

The overrides option lets you customize any AI SDK tool() property on a per-tool basis, keyed by tool name.

import type { ToolOverrides } from "vercel-blob-ai-sdk";

Supported override properties:

PropertyTypeDescription
descriptionstringCustom tool description for the model
titlestringHuman-readable title
strictbooleanStrict mode for input generation
needsApprovalboolean | functionGate execution behind approval
providerOptionsProviderOptionsProvider-specific metadata
onInputStartfunctionCallback when argument streaming starts
onInputDeltafunctionCallback on each streaming delta
onInputAvailablefunctionCallback when full input is available
toModelOutputfunctionCustom mapping of tool result to model output

Core properties (execute, inputSchema, outputSchema) cannot be overridden.

Resources

Contributing

Contributions are welcome! Please read our Contributing Guide for more information.

License

MIT License

Author

Ben Sabic | Vercel Labs