LlamaIndex

Integrate Spooled with LlamaIndex using the callback handler.

Install

pip install spooled-ai[integrations]

Setup

my_llamaindex_agent.py
import spooled
from spooled.integrations.llamaindex import SpooledLlamaIndexCallbackHandler

recorder = spooled.init(agent_id="my_llamaindex_agent")
handler = SpooledLlamaIndexCallbackHandler(recorder)

# Set as the global callback handler
from llama_index.core import Settings
Settings.callback_manager.add_handler(handler)

# Your query engine runs as normal
response = query_engine.query("What are the key findings?")

spooled.shutdown(success=True)
Note
The callback handler requires a recorder instance. Pass the return value of spooled.init().

What's captured

  • LLM calls (model, tokens, latency)
  • Retrieval events (query, result count)
  • Embedding calls (model, dimension)
  • Synthesis steps
  • Query start/end
  • Sub-question decomposition (for sub-question query engines)
Note
Content is stripped to hashes. Only structural metadata is recorded.