/** * VoyageAI provider — best-in-class embeddings + reranking (#B10). * * Implements `EmbeddingAdapter` + `RerankingAdapter` only — Voyage has * no chat-completions surface, so `create()` throws. Apps reach this * provider through `AI.embed(...)` and `AI.rerank(...)` (or their facade * equivalents). * * Wire-protocol via raw `fetch` (no SDK peer dep), matching the Jina / * ElevenLabs shape. Voyage's REST API is small enough that pulling in * an SDK would add weight without much leverage. * * @example Config-driven (recommended) * ```ts * // config/ai.ts * export default { * default: 'openai/gpt-4o', * providers: { * openai: { driver: 'openai', apiKey: env('OPENAI_API_KEY')! }, * voyage: { driver: 'voyage', apiKey: env('VOYAGE_API_KEY')! }, * }, * } * * // somewhere in app code * const { embeddings } = await AI.embed('hello world', { model: 'voyage/voyage-3-large' }) * const ranked = await AI.rerank({ * model: 'voyage/rerank-2.5', * query: 'how do I reset my password?', * documents: [...], * topK: 5, * }) * ``` * * # Model strings * * - **Embeddings:** `voyage-3` (general), `voyage-3-large` (best quality), * `voyage-code-3` (code), `voyage-finance-2` (finance), `voyage-law-2` (legal). * - **Reranking:** `rerank-2.5` (best), `rerank-2.5-lite`, `rerank-2`. * * # Embedding `input_type` * * Voyage embeddings perform measurably better when the API knows whether * a string is a search **query** or an indexed **document**. We default * `input_type` to `'document'` because that's the most common case for * RAG pipelines (matches `@gemstack/ai-sdk`'s `similaritySearch` and * `EmbeddingUserMemory` ingestion paths). Apps building query-side * pipelines should override via `inputType: 'query'` on the embed call * — see {@link VoyageEmbedExtras}. */ import type { ProviderFactory, ProviderAdapter, EmbeddingAdapter, RerankingAdapter } from '../types.js'; /** * Voyage-specific extras on embed calls. Threaded through the standard * `EmbeddingAdapter.embed(input, model)` signature via a 3rd opt arg — * not exposed through `AI.embed()` directly today (would need a contract * widening to add `inputType` to `EmbeddingOptions`). Apps that need this * knob can build the adapter directly from the registry or pass via a * custom `Symbol.for(...)` slot in the future. * * For v1, the adapter applies a sensible default (`'document'`) and * exposes the override surface here as documentation. */ export interface VoyageEmbedExtras { /** * Voyage's `input_type` hint. `'document'` is the right default for * indexing pipelines (RAG ingestion); `'query'` for the search side. * Defaults to `'document'`. */ inputType?: 'query' | 'document'; } export interface VoyageConfig { apiKey: string; /** * Override `https://api.voyageai.com`. Useful for proxying through a * gateway or for self-hosted Voyage-compatible APIs. */ baseUrl?: string; /** * Default `input_type` for embed calls. See {@link VoyageEmbedExtras}. * Per-deployment override; defaults to `'document'`. */ defaultInputType?: 'query' | 'document'; } export declare class VoyageProvider implements ProviderFactory { readonly name = "voyage"; private readonly config; constructor(config: VoyageConfig); create(_model: string): ProviderAdapter; createEmbedding(model: string): EmbeddingAdapter; createReranking(model: string): RerankingAdapter; } //# sourceMappingURL=voyage.d.ts.map