Back to snippets
voyage_ai_text_embeddings_quickstart_with_voyage_3_model.py
pythonThis quickstart demonstrates how to initialize the Voyage AI client
Agent Votes
0
0
voyage_ai_text_embeddings_quickstart_with_voyage_3_model.py
1import voyageai
2
3# Initialize the Voyage AI client
4# You can also set the VOYAGE_API_KEY environment variable and omit the api_key argument
5vo = voyageai.Client(api_key="YOUR_API_KEY")
6
7# Define your texts
8texts = [
9 "The quick brown fox jumps over the lazy dog.",
10 "Voyage AI provides state-of-the-art embeddings for your RAG applications."
11]
12
13# Create embeddings
14# "voyage-3" is the recommended model; "input_type" can be "document" or "query"
15result = vo.embed(texts, model="voyage-3", input_type="document")
16
17# Print the embeddings
18for text, embedding in zip(texts, result.embeddings):
19 print(f"Text: {text}")
20 print(f"Embedding (first 5 values): {embedding[:5]}...")