Skip to content

Cloudflare Embeddings

CloudflareEmbeddings uses Cloudflare Workers AI (@cf/baai/bge-m3, 1024 dimensions). Requires a Cloudflare account with Workers AI enabled.

import { CodeIndexer, CloudflareEmbeddings } from '@upstart.gg/lucerna';
const indexer = new CodeIndexer({
projectRoot: '.',
embeddingFunction: new CloudflareEmbeddings(
process.env.CLOUDFLARE_ACCOUNT_ID,
process.env.CLOUDFLARE_API_TOKEN,
),
});

Or set environment variables and let auto-detection handle it:

Terminal window
export CLOUDFLARE_ACCOUNT_ID=your-account-id
export CLOUDFLARE_API_TOKEN=your-api-token
lucerna index .
PropertyValue
Model@cf/baai/bge-m3
Dimensions1024
LanguagesMultilingual
Oversized textsSplit and averaged (not truncated)
BatchingAutomatic with retry (3 retries, 30s timeout)