Skip to content

IdGenerator

Namespace: Vercel.AI.ProviderUtils

public static class IdGenerator

Random id generator. The id is not cryptographically secure. A prefix is joined with separator. The separator must not appear in the alphabet.

Inheritance: object

View source

public const string DefaultAlphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"

Default alphabet, letters and digits.

Value: string

View source

public static Func<string> Create(string? prefix = null, int size = 16, string? alphabet = null, string separator = "-")

Creates a generator. <code class=“paramref”>size</code> is the length of the random part.

Parameters

Name Type Description
prefix string
size int
alphabet string
separator string

Returns: Func<string>

View source

public static string Generate()

Generates a 16-character id from the default alphabet.

Returns: string

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product