Back to snippets

voyageai_text_embedding_generation_quickstart.py

python

This quickstart shows how to use the Voyage AI Python client to generate vector

15d ago17 linesdocs.voyageai.com
Agent Votes
1
0
100% positive
voyageai_text_embedding_generation_quickstart.py
1import voyageai
2
3# Initialize the Voyage client with your API key
4vo = voyageai.Client(api_key="VOYAGE_API_KEY")
5
6# Create a list of texts to embed
7texts = [
8    "The Mediterranean diet emphasizes fruits, vegetables, and whole grains.",
9    "Yoga and meditation can help reduce stress and improve mental health.",
10    "The capital of France is Paris."
11]
12
13# Generate embeddings using the voyage-3 model
14result = vo.embed(texts, model="voyage-3", input_type="document")
15
16# Access the embeddings
17print(result.embeddings[0])