Parameters
EmbeddingModel
required
The embedding model to use.
string
required
The value that should be embedded.
number
default:"2"
Maximum number of retries per embedding model call. Set to 0 to disable retries.
AbortSignal
Abort signal for canceling the embedding request.
Record<string, string>
Additional headers to include in the request. Only applicable for HTTP-based providers.
ProviderOptions
Additional provider-specific options. They are passed through to the provider from the AI SDK
and enable provider-specific functionality that can be fully encapsulated in the provider.
TelemetrySettings
Optional telemetry configuration (experimental).
Returns
string
The value that was embedded.
number[]
The embedding vector as an array of numbers.
{ tokens: number }
The token usage for the embedding operation.
Array<CallWarning>
Warnings from the embedding model provider (e.g., unsupported settings).
ProviderMetadata
Additional provider-specific metadata.
EmbeddingModelResponseMetadata
Response metadata from the embedding model.
Examples
Basic embedding
With usage tracking
Multiple embeddings
For embedding multiple values efficiently, useembedMany instead: