AlloyDB for PostgreSQL for LlamaIndex
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:
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"
)
Embedding Usage
Use an embedding model to generate embeddings inside AlloyDB with a registered model.
from llama_index_alloydb_pg import AlloyDBEmbedding, AlloyDBEngine
engine = await AlloyDBEngine.afrom_instance(
"project-id", "region", "my-cluster", "my-instance", "my-database"
)
embed_model = AlloyDBEmbedding(engine=engine, model_id="text-embedding-005")
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"
)
ToolSpec Usage
Use a tool spec to give an agent AlloyDB AI functions. See the AI tools sample.
from llama_index_alloydb_pg import AlloyDBEngine, AlloyDBToolSpec
engine = await AlloyDBEngine.afrom_instance(
"project-id", "region", "my-cluster", "my-instance", "my-database"
)
tools = AlloyDBToolSpec(engine).to_tool_list()
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.
Metadata
Release files for llama-index-alloydb-pg 0.4.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| llama_index_alloydb_pg-0.4.0.tar.gz | 88.6 kB | With provenance | Details for llama_index_alloydb_pg-0.4.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| llama_index_alloydb_pg-0.4.0-py3-none-any.whl | Python 3 | none | any | Details for llama_index_alloydb_pg-0.4.0-py3-none-any.whl |
Total release size: 155.8 kB
Release files / llama_index_alloydb_pg-0.4.0.tar.gz
| Download URL | llama_index_alloydb_pg-0.4.0.tar.gz |
|---|---|
| Size | 88.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a0f664220d9a086b7e0b101fb08a7a074f51de1907cda6f6eef6a589c9c736bd
|
|
BLAKE2b-256 checksum How to use checksums |
a1eb8cb87674272be43785c1d63db6d7ec05faf3e6efc0c5500db8bfb1f4f47e
|
| 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 Oct 29, 2026.
Transparency logRelease files / llama_index_alloydb_pg-0.4.0-py3-none-any.whl
| Download URL | llama_index_alloydb_pg-0.4.0-py3-none-any.whl |
|---|---|
| Size | 67.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
36d46b436ac66b3776a3bbaaa2ae90bf9093e91ab84324a1add3a0504bf68ecb
|
|
BLAKE2b-256 checksum How to use checksums |
7ef05a5aebbaf239b2dac4ca41ae7b52edb27f0c6b6b4272e1f7e3de6264376c
|
| 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 Oct 29, 2026.
Transparency logSecurity for llama-index-alloydb-pg 0.4.0
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.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for llama_index_alloydb_pg-0.4.0.tar.gz
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 Oct 29, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.