Skip to main content


Vector embeddings are a powerful tool in AI applications. They represent data in a high-dimensional space where similar data points are closer.

Embeddings generated by AI models from OpenAI, Claude, Mistral, and others condense the semantic essence of unstructured data into a small-size vector. The distance between two vectors indicates the similarity of the corresponding data. This capability opens up many possibilities, such as building recommendation systems, classifying data, and implementing AI techniques like RAG (Retrieval Augmented Generation).

Exograph supports embeddings using the pgvector extension. This support enables storing vector embeddings in Postgres along with other structured data. Exograph extends the GraphQL API to interact with the embeddings, making it easy to query and manipulate them. This, like other Exograph features, helps you focus on the AI-specific logic of your application while Exograph handles the database interactions.

Exograph's embedding support comes in the form of a new type: Vector. Fields of this type provide the ability to:

  • Creating and migrating the database schema.
  • Supporting mutation APIs to store the embeddings in that field.
  • Extending retrieval and ordering APIs to use the distance from the given vector.

To use embeddings in your application, declare a field of the Vector type in your schema.

module DocumentModule {
type Document {
@pk id: Int = autoIncrement()
title: String
content: String
contentVector: Vector?

The Vector type feature plays well with the rest of Exograph's capabilities. For example, you can apply access control to your entities, so searching and sorting automatically consider the user's access rights, thus eliminating a source of privacy issues. You can even specify field-level access control to, for example, expose the vector representation only to privileged users.

Using embeddings in your application involves:

  1. Computing vector representation using an AI model like OpenAI's text-embedding-3-small and storing/updating the vector fields using Exograph APIs
  2. Querying for similar documents using Exograph's query APIs


To use embeddings in Exograph in local Postgres, you must install the pgvector extension. Please refer to the pgvector documentation for installation instructions.

If you use a managed Postgres service, please check with your provider if they have enabled the pgvector extension.