Before running the examples on this page, make sure you have a VectorAI DB collection created and your VectorAI DB instance running. See Collections for setup instructions.
Supported models
Installation
Install the OpenAI Python client and the VectorAI DB client:Generate and store embeddings
The following example generates embeddings for a set of texts using OpenAI’stext-embedding-3-small model, stores them in a VectorAI DB collection, and runs a similarity search:
Search with OpenAI embeddings
Before running this example, create the collection and upsert the sample points from the previous section. To search, generate an embedding for the query text using the same model, then pass it as the query vector:Always use the same embedding model for both indexing and querying. Mixing models produces incompatible vector spaces and returns meaningless results.
Using text-embedding-3-large
For higher accuracy, use text-embedding-3-large, which produces 3072-dimensional vectors. Update the model name and collection dimension accordingly:
Next steps
To continue building with embeddings, see the following resources:- LangChain — Use OpenAI embeddings with VectorAI DB through the LangChain framework.
- Vectors — Learn how VectorAI DB stores and indexes vector data.
- Search — Explore the vector search operations available in VectorAI DB.
- Collections — Understand how collections organize your vectors.