Skip to content

Function: generateShortId()

@providerprotocol/ai


@providerprotocol/ai / utils / generateShortId

generateShortId(prefix): string

Defined in: src/utils/id.ts:55

Generates a short alphanumeric identifier.

Creates a 12-character random string using alphanumeric characters (a-z, A-Z, 0-9). Useful for tool call IDs and other cases where a full UUID is not required.

string = ''

Optional prefix to prepend to the generated ID

string

A string containing the prefix followed by 12 random alphanumeric characters

const toolCallId = generateShortId('call_');
// => "call_aB3xY9mK2pQr"
const simpleId = generateShortId();
// => "Tz4wN8vL1sHj"