Embed

The embed function generates vector embeddings for text inputs, enabling similarity search and RAG workflows.

Parameters

input:

string | string[] | { text: string; metadata?: Record<string, any> }[]
Content to embed. Can be a single string, an array of strings, or an array of objects with `text` and optional `metadata`.

options:

object
Configuration for the embedding call.
'openai' | 'anthropic' | 'google' | 'custom'
string

Return Value

embedding:

number[] | number[][]
The embedding vector(s). If `input` is a single string, returns one vector; if multiple, returns an array of vectors.

MIT 2025 © Nextra.