Docs
Skip to content

VectorsDB

Embeddings_

Generate text embeddings with Appwrite VectorsDB. Turn text into vector embeddings with built-in models and store them in your documents for vector search.

3 min read

Raw

An embedding is a list of numbers that represents the meaning of a piece of text. Appwrite generates embeddings for you with built-in models, so you can turn text into vectors and store them in a collection without running a separate embedding service.

The typical flow is two steps: generate an embedding from your text, then store that embedding in a document's embeddings field. Once stored, you can run vector search over your documents.

Generate embeddings

Embeddings come from the Embeddings service rather than the VectorsDB service, and generating them doesn't involve a database or collection at all.

Use the createTextEmbeddings method to turn one or more strings into vector embeddings. Pass an array of texts and, optionally, a model. When you omit model, Appwrite uses the default nomic-embed-text model. Appwrite Server SDKs require an API key with the embeddings.write scope.

The response is an embedding list. The embeddings array holds one entry per input text, in the same order you passed them.

JSON
{
"total": 1,
"embeddings": [
{
"model": "nomic-embed-text",
"dimension": 768,
"embedding": [-0.012246467, 0.02621112, -0.15247375, ...],
"error": ""
}
]
}

Each entry contains:

FieldDescription
modelThe model that generated this embedding.
dimensionThe number of values in the embedding vector.
embeddingThe embedding vector as an array of floats. If generation fails, this is an empty array.
errorAn error message if this text could not be embedded. An empty string means there was no error.

Available models

Appwrite ships with the following text embedding models. The dimension of a model is the length of the vector it produces, and it must match the dimension you set on the collection where you store the embeddings.

ModelDimensionProviderLanguagesBest forNotes
nomic-embed-text768Nomic AIEnglishGeneral-purpose retrieval over long English documentsDefault. 8K context window, so long documents embed in one call.
embedding-gemma768Google100+Multilingual search and cross-language retrievalA query in one language matches content in another.
all-minilm384Sentence TransformersEnglishHigh-volume workloads where speed and storage matter mostFast to generate and cheap to store, at some cost to accuracy.
bge-small384BAAIEnglishRanking and reranking short English passagesTuned for ranking quality over speed.

Store embeddings

Once you have an embedding, store it in a document's embeddings field. The collection's dimension must match the embedding's dimension. You can store any related data alongside the vector in the document's metadata field.

Next steps

With embeddings stored in your documents, you can find the most similar documents to a query vector with vector search.

Was this page helpful?

Share what worked or what we should fix. Once approved, our agents automatically apply suggested updates to the docs.