Skip to content

Vectorize

azure_openai_vectorize

azure_openai_vectorize(batch, api_key=None, azure_endpoint=None, api_version=None, model=None, max_retries=5, provider=None, base_url=None, openai_client=None)

Generates vector embeddings of each string item in a list. Uses the Azure OpenAI service.

Inputs are made safe for the embeddings API before sending: each item is truncated to the model's per-input token limit (a long code prompt or query response would otherwise 400 the request), and the batch is chunked to stay under the endpoint's per-request input cap. One embedding is returned per input string, in the original order, regardless of how many requests the batch is split across.

Note: temperature is intentionally not exposed here — it does not apply to embedding generation, which is deterministic at the API level.

Parameters:

Name Type Description Default
batch list[str]

A list of strings to vectorize. Items should be non-empty; the embeddings API rejects empty strings, and items are matched to outputs by position so they are never dropped.

required
api_key str | None

Access key for the Azure OpenAI resource

None
azure_endpoint str | None

Your Azure endpoint, including the resource, e.g. https://example-resource.azure.openai.com/. if not provided will default to environment variable AZURE_OPENAI_ENDPOINT.

None
api_version str | None

API version for Azure resource.

None
model str | None

Model deployment name within the Azure resource. If not provided will default to environment variable AZURE_OPENAI_DEPLOYMENT.

None
max_retries int

Maximum number of unsuccessful call attempts to the OpenAI service before returning an error.

5
provider str | None

Optional model provider ("azure_openai" default, or "openai_compatible"). Defaults to env MODEL_PROVIDER, then Azure OpenAI.

None
base_url str | None

Base URL for an OpenAI-compatible endpoint (ignored for Azure).

None
openai_client LanguageModelClient | None

Optional pre-built client to reuse. If not provided, one is created for the resolved provider.

None

Returns:

Name Type Description
embeddings list[list[float]]

A list of vector embeddings, one per input string.