-
Type:
Task
-
Resolution: Unresolved
-
Priority:
Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
None
The class VoyageEmbeddings in the LangChainJS framework is making use of the endpoints at https://api.voyageai.com/v1. This only works for API keys created directly on Voyage AI's website (https://dashboard.voyageai.com/api-keys).
API Keys created on the Atlas UI as described in our official documentation require the API url https://ai.mongodb.com/v1. We need to update the VoyageEmbeddings class in LangChainJS to support both endpoints.
Desired User Experiece
The current way to work with Atlas-created Voyage keys is to manually set the API's url:
const embeddings = new VoyageEmbeddings({ apiKey: "my-voyage-api-key", basePath: "https://ai.mongodb.com/v1", }); // This fails because the request calls the wrong domain: // 'api.voyage.com' instead of 'ai.mongodb.com' await embeddings.embedQuery("Hello world"); console.log(embeddingModel.apiUrl) // outputs: 'htps://api.voyageai.com/v1/embeddings' // Workaround: set apiUrl directly embeddingModel.apiUrl = "https://ai.mongodb.com/v1/embeddings"; await embeddings.embedQuery("Hello world"); // works!
Users should be able to pass the apiUrl param in the constructor:
const embeddings = new VoyageEmbeddings({ apiKey: "my-voyage-api-key", basePath: "https://ai.mongodb.com/v1", }); expect(embeddings.apiUrl).toBe("https://ai.mongodb.com/v1/embeddings");
Acceptance Criteria
- A PR has been opened against https://github.com/langchain-ai/langchainjs
- The LangChain team has acknowledge this PR.
- Test that apiUrl is set to the domain passed in the VoyageEmbeddings constructor.
Nice to have: auto-endpoint detection similar to Python. (Could not find evidence/samples of this in the Python repository).