File: generate-id.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
Experimental_StdioMCPTransport
Copy markdown
=======================================================================================
Generates a unique identifier. You can optionally provide the length of the ID.
This is the same id generator used by the AI SDK.
import { generateId } from 'ai';
const id = generateId();
import { generateId } from "ai"
number
The length of the generated ID. It defaults to 16. This parameter is deprecated and will be removed in the next major version.
A string representing the generated ID.
On this page
Deploy and Scale AI Apps with Vercel.
Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.
Trusted by industry leaders: