Skip to main content
If you’re deploying your project in a Cloudflare worker, you can use Cloudflare Vectorize with LangChain.js. It’s a powerful and convenient option that’s built directly into Cloudflare.

Setup

CompatibilityCloudflare Vectorize is currently in open beta, and requires a Cloudflare account on a paid plan to use.
After setting up your project, create an index by running the following Wrangler command:
You can see a full list of options for the vectorize command in the official documentation. You’ll then need to update your wrangler.toml file to include an entry for [[vectorize]]:
Finally, you’ll need to install the LangChain Cloudflare integration package:

Usage

Below is an example worker that adds documents to a vectorstore, queries it, or clears it depending on the path used. It also uses Cloudflare Workers AI Embeddings.
If running locally, be sure to run wrangler as npx wrangler dev --remote!
You can also pass a filter parameter to filter by previously loaded metadata. See the official documentation for information on the required format.