Docs Menu
Docs Home
/

Voyage AI Quick Start

In this guide, you learn how to generate your first vector embeddings with Voyage AI and build a basic application.

Work with a runnable version of this tutorial as a Python notebook.

To access Voyage AI models, create a model API key in the MongoDB Atlas UI.

1

If you're new to Atlas, it creates an organization and project for you.

To learn more, see Create an Atlas Account.

2
  1. In your Atlas project, select AI Models from the navigation bar.

  2. Click Create model API key.

  3. Give the API key a name and then click Create.

To learn more, see Model API Keys.

3

Copy the API key and store it in a safe location. Then, export the API key as an environment variable in your terminal so the Voyage client can access it.

export VOYAGE_API_KEY="<your-model-api-key>"
set VOYAGE_API_KEY=<your-model-api-key>

In this section, you generate vector embeddings using a Voyage AI embedding model and the Python client.

Voyage AI embedding diagram
1

Run the following commands in your terminal to create your project and install the Voyage AI Python client.

mkdir mongodb-voyage-quickstart
cd mongodb-voyage-quickstart
pip install --upgrade voyageai
2

Create a file named quickstart.py in your project and paste the following code into it. This code initializes the Voyage AI client, defines sample texts, and uses the client to access the Voyage API to generate vector embeddings with the voyage-4-large model.

For details, see Python Client or explore the full API specification.

import voyageai
# Initialize Voyage client
vo = voyageai.Client()
# Sample texts
texts = [
"hello, world",
"welcome to voyage ai!"
]
# Generate embeddings
result = vo.embed(
texts,
model="voyage-4-large"
)
print(f"Generated {len(result.embeddings)} embeddings")
print(f"Each embedding has {len(result.embeddings[0])} dimensions")
print(f"First embedding (truncated): {result.embeddings[0][:5]}...")
3

Run the following command in your terminal to generate the embeddings.

python quickstart.py
Generated 2 embeddings
Each embedding has 1024 dimensions
First embedding (truncated): [-0.02806740067899227, 0.05503412336111069, 0.0038576999213546515, -0.04668188467621803, 0.007834268733859062]...

Now that you know how to generate vector embeddings, build a basic RAG application to learn how to use Voyage AI models to implement AI search and retrieval. RAG enables LLMs to generate context-aware responses by retrieving relevant information from your data before generating answers.

Note

RAG applications require access to an LLM. This tutorial provides examples using Anthropic or OpenAI, but you can use any LLM provider of your choice.

Basic Voyage AI RAG diagram

Now that you've created your first application with Voyage AI, expand the following sections to learn more about the concepts covered in this quick start:

To continue learning, see the following resources:

Skill Level
Documentation Resources

Basic

Intermediate

Back

Introduction

On this page