Vector

Add provider-agnostic named vector indexes with similarity search.

Use Vector to define named vector indexes once and resolve them at runtime with getVector(name) across Cloudflare Vectorize, pgvector-backed Postgres, and Upstash Vector.

  • Define indexes in server/vectors/**.
  • Register an index with defineVector(options).
  • Resolve a handle with getVector(name).

What Vector is

Vector gives you one portable handle for embedding, upserting, querying, fetching, and deleting vector records while keeping provider config in app setup.

When Vector fits

Vector is a good fit when you want to:

  • keep named vector indexes in the repo
  • use similarity search behind one runtime API
  • switch vector backends without rewriting application call sites
  • keep index metadata and optional embedding generation close to the index definition

Use When to use Vector when you need to choose between vector search, relational queries, and other storage primitives.

What stays portable

These parts stay stable when you switch providers:

  • the discovery directory
  • the definition API defineVector()
  • the runtime API getVector()
  • the vector name derived from the file path
  • the common handle methods such as embed(), upsert(), fetch(), query(), and delete()

Provider-specific credentials, binding names, namespaces, and connection details live on the provider pages.

Where to go next

Quickstart
Set up a first vector index against a pgvector-backed Postgres database.
Runtime API
Look up defineVector, getVector, handle methods, and the core Vector types.
When to use Vector
Decide when vector search is the right primitive for your data.
Troubleshooting
Diagnose provider, schema, and query problems.

Providers

Cloudflare
Use a Vectorize binding inside Cloudflare Workers.
Postgres
Use pgvector inside your own Postgres database.
Upstash
Use a hosted vector API over HTTP.