Skip to content

Add type-safe model names with TypedVoyageAIClient#20

Open
ntedvs wants to merge 1 commit intovoyage-ai:mainfrom
ntedvs:main
Open

Add type-safe model names with TypedVoyageAIClient#20
ntedvs wants to merge 1 commit intovoyage-ai:mainfrom
ntedvs:main

Conversation

@ntedvs
Copy link
Copy Markdown

@ntedvs ntedvs commented Aug 10, 2025

Summary

  • Adds strongly-typed model names for all VoyageAI endpoints to prevent runtime errors from invalid model strings
  • Introduces TypedVoyageAIClient with full TypeScript autocomplete and validation
  • Maintains 100% backward compatibility with existing VoyageAIClient

What's New

  • Type-safe model definitions (EmbedModel, RerankModel, etc.) with all current models
  • TypedVoyageAIClient - wrapper providing compile-time model validation
  • Enhanced DX - IDE autocomplete for model names prevents typos
  • Future-proof - won't be overwritten by SDK regeneration

Model Coverage

  • Embedding models: voyage-3-large, voyage-3.5, voyage-code-3, etc. (16 models)
  • Reranking models: rerank-2.5, rerank-2, rerank-lite-1, etc. (6 models)
  • Multimodal: voyage-multimodal-3
  • Contextualized: voyage-context-3

Usage Examples

// New: Type-safe with autocomplete
import { TypedVoyageAIClient } from "voyageai";
const client = new TypedVoyageAIClient({ apiKey: "key" });
await client.embed({
  input: "text",
  model: "voyage-3-large" // ✅ Autocomplete + validation
});

// Existing: Still works unchanged
import { VoyageAIClient } from "voyageai";
const client = new VoyageAIClient({ apiKey: "key" });
await client.embed({ input: "text", model: "voyage-3-large" }); // ✅ No changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant