Skip to main content

preview pypi versions

The AlloyDB for PostgreSQL for LlamaIndex package provides a first class experience for connecting to AlloyDB instances from the LlamaIndex ecosystem while providing the following benefits:

  • Simplified & Secure Connections: easily and securely create shared connection pools to connect to Google Cloud databases utilizing IAM for authorization and database authentication without needing to manage SSL certificates, configure firewall rules, or enable authorized networks.

  • Better integration with AlloyDB: built-in methods to take advantage of AlloyDB’s advanced indexing and scalability capabilities.

  • Improved metadata handling: store metadata in columns instead of JSON, resulting in significant performance improvements.

  • Clear separation: clearly separate table and extension creation, allowing for distinct permissions and streamlined workflows.

Quick Start

In order to use this library, you first need to go through the following steps:

  1. Select or create a Cloud Platform project.

  2. Enable billing for your project.

  3. Enable the AlloyDB API.

  4. Setup Authentication.

Installation

Install this library in a virtualenv using pip. virtualenv is a tool to create isolated Python environments. The basic problem it addresses is one of dependencies and versions, and indirectly permissions.

With virtualenv, it’s possible to install this library without needing system install permissions, and without clashing with the installed system dependencies.

Supported Python Versions

Python >= 3.10

Mac/Linux

pip install virtualenv
virtualenv <your-env>
source <your-env>/bin/activate
<your-env>/bin/pip install llama-index-alloydb-pg

Windows

pip install virtualenv
virtualenv <your-env>
<your-env>\Scripts\activate
<your-env>\Scripts\pip.exe install llama-index-alloydb-pg

Example Usage

Code samples and snippets live in the samples/ folder.

Vector Store Usage

Use a vector store to store embedded data and perform vector search.

import google.auth
from llama_index.core import Settings
from llama_index.embeddings.vertex import VertexTextEmbedding
from llama_index_alloydb_pg import AlloyDBEngine, AlloyDBVectorStore


credentials, project_id = google.auth.default()
engine = await AlloyDBEngine.afrom_instance(
   "project-id", "region", "my-cluster", "my-instance", "my-database"
)
Settings.embed_model = VertexTextEmbedding(
   model_name="textembedding-gecko@003",
   project="project-id",
   credentials=credentials,
)

vector_store = await AlloyDBVectorStore.create(
   engine=engine, table_name="vector_store"
)

Chat Store Usage

A chat store serves as a centralized interface to store your chat history.

from llama_index.core.memory import ChatMemoryBuffer
from llama_index_cloud_sql_pg import AlloyDBChatStore, AlloyDBEngine


engine = await AlloyDBEngine.afrom_instance(
   "project-id", "region", "my-cluster", "my-instance", "my-database"
)
chat_store = await AlloyDBChatStore.create(
   engine=engine, table_name="chat_store"
)
memory = ChatMemoryBuffer.from_defaults(
   token_limit=3000,
   chat_store=chat_store,
   chat_store_key="user1",
)

Document Reader Usage

A Reader ingest data from different data sources and data formats into a simple Document representation.

from llama_index.core.memory import ChatMemoryBuffer
from llama_index_cloud_sql_pg import AlloyDBReader, AlloyDBEngine


engine = await AlloyDBEngine.afrom_instance(
   "project-id", "region", "my-cluster", "my-instance", "my-database"
)
reader = await AlloyDBReader.create(
   engine=engine, table_name="my-db-table"
)
documents = reader.load_data()

Document Store Usage

Use a document store to make storage and maintenance of data easier.

from llama_index_alloydb_pg import AlloyDBEngine, AlloyDBDocumentStore


engine = await AlloyDBEngine.afrom_instance(
   "project-id", "region", "my-cluster", "my-instance", "my-database"
)
doc_store = await AlloyDBDocumentStore.create(
   engine=engine, table_name="doc_store"
)

Index Store Usage

Use an index store to keep track of indexes built on documents.

from llama_index_alloydb_pg import AlloyDBIndexStore, AlloyDBEngine


engine = await AlloyDBEngine.from_instance(
   "project-id", "region", "my-cluster", "my-instance", "my-database"
)
index_store = await AlloyDBIndexStore.create(
   engine=engine, table_name="index_store"
)

Contributions

Contributions to this library are always welcome and highly encouraged.

See CONTRIBUTING for more information how to get started.

Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms. See Code of Conduct for more information.

License

Apache 2.0 - See LICENSE for more information.

Disclaimer

This is not an officially supported Google product.

Release files for llama-index-alloydb-pg 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for llama-index-alloydb-pg 0.3.1
File Size Uploaded
llama_index_alloydb_pg-0.3.1.tar.gz 62.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for llama-index-alloydb-pg 0.3.1
File Interpreter ABI Platform
llama_index_alloydb_pg-0.3.1-py3-none-any.whl Python 3 none any Details

Total release size: 114.3 kB

Release files / llama_index_alloydb_pg-0.3.1.tar.gz

Download URL llama_index_alloydb_pg-0.3.1.tar.gz
Size 62.8 kB
Tags Source
SHA-256 checksum
How to use checksums
538a0d9e72de14240dfb9a21318a05a40722d531a1c65e409b8e5365866eea4e
BLAKE2b-256 checksum
How to use checksums
b44c41cc2d5bd0f2817b3922c748ba10198dff56ddb076f7f954e5e74546c75e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Aug 17, 2026.

Transparency log

Release files / llama_index_alloydb_pg-0.3.1-py3-none-any.whl

Download URL llama_index_alloydb_pg-0.3.1-py3-none-any.whl
Size 51.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f95bbd44f616ea9c9db14caca5ef7abf335a9c14d3f74ed2cc138f0eabf3222d
BLAKE2b-256 checksum
How to use checksums
dd61c20927c1d08d4a83320cada3280c36a84354f910101ab7815899a8259008
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.2.0 CPython/3.11.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by Google Cloud, verified by PyPI on Aug 17, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.1 This release

2 release files

0.3.0

2 release files

0.2.3

2 release files

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page