File: embed-many.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
Experimental_StdioMCPTransport
Copy markdown
====================================================================================
Embed several values using an embedding model. The type of the value is defined by the embedding model.
embedMany automatically splits large requests into smaller chunks if the model has a limit on how many embeddings can be generated in a single call.
import { openai } from '@ai-sdk/openai';import { embedMany } from 'ai';
const { embeddings } = await embedMany({ model: openai.textEmbeddingModel('text-embedding-3-small'), values: [ 'sunny day at the beach', 'rainy afternoon in the city', 'snowy night in the mountains', ],});
import { embedMany } from "ai"
EmbeddingModel
The embedding model to use. Example: openai.textEmbeddingModel('text-embedding-3-small')
Array<VALUE>
The values to embed. The type depends on the model.
number
Maximum number of retries. Set to 0 to disable retries. Default: 2.
AbortSignal
An optional abort signal that can be used to cancel the call.
Record<string, string>
Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.
TelemetrySettings
Telemetry configuration. Experimental feature.
TelemetrySettings
boolean
Enable or disable telemetry. Disabled by default while experimental.
boolean
Enable or disable input recording. Enabled by default.
boolean
Enable or disable output recording. Enabled by default.
string
Identifier for this function. Used to group telemetry data by function.
Record<string, string | number | boolean | Array<null | undefined | string> | Array<null | undefined | number> | Array<null | undefined | boolean>>
Additional information to include in the telemetry data.
Tracer
A custom tracer to use for the telemetry data.
Array<VALUE>
The values that were embedded.
number[][]
The embeddings. They are in the same order as the values.
EmbeddingModelUsage
The token usage for generating the embeddings.
EmbeddingModelUsage
number
The total number of input tokens.
unknown
The response body.
ProviderMetadata | undefined
Optional metadata from the provider. The outer key is the provider name. The inner values are the metadata. Details depend on the provider.
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: