---
url: >-
  https://adk.nht.io/api/@nhtio/adk/batteries/embeddings/openai/helpers/functions/applyEmbeddingPrefix.md
---

# Function: applyEmbeddingPrefix()

```ts
function applyEmbeddingPrefix(
  texts: readonly string[],
  kind: EmbeddingKind,
  options: Pick<BaseEmbeddingsAdapterOptions, "queryPrefix" | "documentPrefix">,
): string[];
```

Defined in: [batteries/embeddings/openai/helpers.ts:27](https://github.com/NHTIO/ADK/blob/v1.20260605.0/src/batteries/embeddings/openai/helpers.ts#L27)

Applies the configured query/document instruction prefix to a batch of inputs.

## Parameters

| Parameter | Type                                                                                                                                                                                                                       | Description                               |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| `texts`   | readonly `string`\[]                                                                                                                                                                                                        | The raw inputs to embed.                  |
| `kind`    | [`EmbeddingKind`](../../types/type-aliases/EmbeddingKind.md)                                                                                                                                                               | Whether these are queries or documents.   |
| `options` | [`Pick`](https://www.typescriptlang.org/docs/handbook/utility-types.html#picktype-keys)<[`BaseEmbeddingsAdapterOptions`](../../types/interfaces/BaseEmbeddingsAdapterOptions.md), `"queryPrefix"` | `"documentPrefix"`> | Carries `queryPrefix` / `documentPrefix`. |

## Returns

`string`\[]

A new array with prefixes applied (never mutates the input).

## Remarks

`kind: 'query'` → prepend `queryPrefix` (if set); `kind: 'document'` → prepend `documentPrefix`
(if set). When the relevant prefix is unset, inputs pass through verbatim. This is the single
source of truth for prefix handling shared by both batteries.
