Migrate Your Applications to use the Atlas Embedding and Reranking API
For the complete MongoDB documentation index, see www.mongodb.com/docs/llms.txt
Migrate Your Applications to use the Atlas Embedding and Reranking API
If you are an existing Voyage AI user, complete the following steps to migrate your application to use the Atlas Embedding and Reranking API.
Procedure
If you're new to Atlas, it creates an organization and project for you.
To learn more, see [Create an Atlas Account.](https://www.mongodb.com/docs/atlas/tutorial/create-atlas-account.md#std-label-create-atlas-account
- Create a model API key for your project.
In your Atlas project, select AI Model APIs from the navigation bar.
Click Create model API key.
Give the API key a name and then click Create.
To confirm your API key is valid, you can make a test request to the Embedding and Reranking API:
bash
curl \
--request POST 'https://ai.mongodb.com/v1/embeddings' \
--header "Authorization: Bearer $VOYAGE_API_KEY" \
--header "Content-Type: application/json" \
--data '{
"input": "Sample text",
"model": "voyage-4-lite",
"input_type": "document"
}'
To learn more about creating and managing API keys, see [Manage Voyage AI Model API Keys.](https://www.mongodb.com/docs/voyageai/management/api-keys.md#std-label-voyage-manage-api-keys
- Replace your existing Voyage API key with the model API key.
For example, if you set your API key as an environment variable, update the value:
bash
VOYAGE_API_KEY="<your-new-model-api-key>"
If you pass the API key directly in your code, update the value where you initialize the client or make API requests.
Note:
If you set your API key as an environment variable, you can run the following command to verify the variable is set:
bash
echo $VOYAGE_API_KEY
- Replace explicit API endpoints with the Embedding and Reranking API endpoints.
If your application explicitly specifies API endpoints, update it to use the equivalent Embedding and Reranking API API endpoints:
| Old Endpoint | New Endpoint |
|---|---|
https://api.voyageai.com/v1/embeddings |
https://ai.mongodb.com/v1/embeddings |
https://api.voyageai.com/v1/rerank |
https://ai.mongodb.com/v1/rerank |
https://api.voyageai.com/v1/multimodalembeddings |
https://ai.mongodb.com/v1/multimodalembeddings |
https://api.voyageai.com/v1/contextualizedembeddings |
https://ai.mongodb.com/v1/contextualizedembeddings |
Note:
If you use the voyageai Python client (version 0.3.7 or later), the client automatically routes requests to the correct endpoint based on the API key format. No endpoint changes are required if you use the client without explicitly setting the base_url parameter.
To learn more, see [Python Client.](https://www.mongodb.com/docs/voyageai/api-and-clients.md#std-label-voyage-python-client
- Verify that your application works with the new API key.
Test your application to ensure it correctly generates embeddings and performs reranking operations using the Embedding and Reranking API.
- Delete your old Voyage AI API key.
After you confirm that your application works with the model API key, delete your old API key from the Voyage AI platform to prevent unauthorized access.
