Back to Guides

LlamaIndex

Connect custom data sources to LLMs with data frameworks

Pythonmedium

LlamaIndex enables building RAG (Retrieval-Augmented Generation) applications. Decyra captures all LLM queries, providing visibility into your RAG pipeline's model interactions.

Prerequisites

  • Decyra account with API key
  • Python 3.8+ installed
  • LlamaIndex package installed

Installation

pip install llama-index llama-index-llms-openai decyra-sdk

Integration

Configure OpenAI LLM with Decyra's proxy:

from llama_index.llms.openai import OpenAI
import os

llm = OpenAI(
    model="gpt-4",
    api_base="https://proxy.decyra.com/v1",
    api_key=os.getenv("DECYRA_API_KEY"),
    default_headers={
        "X-Decyra-API-Key": os.getenv("DECYRA_API_KEY")
    }
)

Create and use a query engine:

from llama_index.core import VectorStoreIndex, SimpleDirectoryReader

documents = SimpleDirectoryReader("data").load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine(llm=llm)

response = query_engine.query("What is the main topic?")
print(response)

What Gets Captured

FieldDescription
ModelThe AI model identifier
TemperatureTemperature setting
QueryThe user's query text
Context LengthLength of retrieved context
Prompt HashHash of query + context
Response TimeTime for query processing
Token UsageTokens used in query/response
CostEstimated API cost

Verify

Open your Decyra dashboard and check the traces page. Each query will appear with the model call details and retrieved context information.

Next Steps