/** * Default EmbeddingProvider implementation backed by OpenAI's embeddings API. * * Uses native `fetch` so it works in Cloudflare Workers + Node + browsers * without an SDK dependency. Templates pass in the API key (and optionally * a custom `baseUrl` for proxies / Azure OpenAI / OpenRouter etc.). * * Models supported by default: * - `text-embedding-3-small` — 1536d, multilingual, cheapest. **Default.** * - `text-embedding-3-large` — 3072d, multilingual, higher quality. * - `text-embedding-ada-002` — 1536d, legacy (kept for migration paths). * * See `docs/architecture/catalog-architecture.md` for the design. */ import { type EmbeddingProvider } from "./contract.js"; /** * Known OpenAI embedding models. Adding a new entry here is the only place * to touch when OpenAI ships a new model — `createOpenAIEmbeddingProvider` * picks up the dimensions / batch limits automatically. */ declare const OPENAI_MODELS: { readonly "text-embedding-3-small": { readonly dimensions: 1536; readonly maxTokensPerInput: 8191; readonly maxBatchSize: 2048; readonly multilingual: true; }; readonly "text-embedding-3-large": { readonly dimensions: 3072; readonly maxTokensPerInput: 8191; readonly maxBatchSize: 2048; readonly multilingual: true; }; readonly "text-embedding-ada-002": { readonly dimensions: 1536; readonly maxTokensPerInput: 8191; readonly maxBatchSize: 2048; readonly multilingual: true; }; }; export type OpenAIEmbeddingModel = keyof typeof OPENAI_MODELS; export interface OpenAIEmbeddingProviderOptions { /** OpenAI API key. */ apiKey: string; /** * Embedding model to use. Default: `text-embedding-3-small`. * Switching models is a deliberate `bulkReindex` operation — the catalog * plane scopes vector queries to documents matching the active * `embedding_model_id`, so mid-migration mixes are handled cleanly. */ model?: OpenAIEmbeddingModel; /** * Override the API base URL — useful for Azure OpenAI, OpenRouter, * a corporate proxy, or any OpenAI-API-compatible service. Default: * `https://api.openai.com/v1`. */ baseUrl?: string; /** * Optional `fetch` override for testing or custom transport. Default: * the global `fetch`. Must follow the standard Fetch API contract. */ fetchImpl?: typeof fetch; /** * Override the model id stamped onto search-index documents. Defaults * to `openai//v1` — keep this stable across deployments so * documents stay queryable across instances. */ modelId?: string; } /** * Build the default OpenAI EmbeddingProvider. */ export declare function createOpenAIEmbeddingProvider(options: OpenAIEmbeddingProviderOptions): EmbeddingProvider; /** * Helper that chunks a large input array into batches sized to the model's * `maxBatchSize` and concatenates the per-batch results. Use this when * embedding more than `maxBatchSize` texts at once. */ export declare function embedBatched(provider: EmbeddingProvider, texts: string[]): Promise; export { OPENAI_MODELS };