LlamaIndex
TapPass has no dedicated LlamaIndex module. Governance comes from two generic paths: wrap the tools with tappass.govern(), and/or route the LLM and embedding calls through the TapPass gateway.
Path 1 — govern the tools
Section titled “Path 1 — govern the tools”tappass.govern(tools, ...) wraps any list of tools (LlamaIndex tools included). In mode="audit" (default) every execution lands in the audit trail; in mode="enforce" each call is checked against policy first and blocked calls raise GovernanceBlocked without executing.
import tappass
tools = tappass.govern( [search_tool, read_file_tool], url="https://tappass.example.com", api_key="tp_...", mode="enforce",)
query_engine = index.as_query_engine(llm=llm, tools=tools)Path 2 — route the model through the gateway
Section titled “Path 2 — route the model through the gateway”LlamaIndex uses the OpenAI SDK for both embeddings (retrieval) and completions (synthesis). Both paths pick up OPENAI_BASE_URL — so setting the two env vars governs every LLM call, RAG included.
export OPENAI_BASE_URL=https://tappass.example.com/v1export OPENAI_API_KEY=tp_...from llama_index.core import VectorStoreIndex, SimpleDirectoryReaderfrom llama_index.llms.openai import OpenAIfrom llama_index.embeddings.openai import OpenAIEmbedding
documents = SimpleDirectoryReader("./data").load_data()index = VectorStoreIndex.from_documents( documents, embed_model=OpenAIEmbedding(model="text-embedding-3-small"),)
query_engine = index.as_query_engine( llm=OpenAI(model="gpt-4o-mini"),)response = query_engine.query("What does the compliance report say?")Both the embedding call (retrieval) and the completion call (synthesis) flow through TapPass.
Explicit api_base
Section titled “Explicit api_base”If you’d rather not use env vars:
from llama_index.llms.openai import OpenAI
llm = OpenAI( model="gpt-4o-mini", api_base="https://tappass.example.com/v1", api_key="tp_...",)