Skip to content

Vector search

Vector search converts your query into a vector embedding and finds chunks with similar meaning. It is enabled by default on all AI Search instances. For an overview of search modes, refer to Search modes.

Built-in vector index

Instances created after April 16, 2026 include a built-in vector index powered by Vectorize. The vector index stores embeddings generated from your content and is created and maintained automatically. You do not need to create or manage a Vectorize index yourself.

Instances created before this date use a Vectorize index provisioned on your account. These instances are billed separately for Vectorize usage. All instances will be migrated to managed infrastructure. Migration details are coming soon.

Embedding model

The embedding model determines the vector dimensions for the vector index. The embedding model is set when creating an instance and cannot be changed after creation.

Vector search is the default index method for all instances. To switch to keyword search only, set index_method.vector to false. At least one of vector or keyword must be true.

TypeScript
const instance = await env.AI_SEARCH.create({
id: "my-instance",
index_method: {
vector: false,
keyword: true,
},
});

Per-request overrides

You can force vector-only search on a per-request basis using ai_search_options.retrieval.retrieval_type, even if keyword search is also enabled on the instance.

TypeScript
const instance = env.AI_SEARCH.get("my-instance");
const results = await instance.search({
messages: [{ role: "user", content: "What is Cloudflare?" }],
ai_search_options: {
retrieval: {
retrieval_type: "vector",
},
},
});

Scoring details

When using vector search, each chunk includes a scoring_details object:

FieldTypeDescription
vector_scorenumberVector similarity score (0 to 1).
vector_ranknumberRank position in the result set.

Limits

For vector index limits, refer to Limits and pricing.