from meshai import MeshAI
from meshai.integrations.llamaindex import MeshAILlamaHandler
from llama_index.core import Settings, VectorStoreIndex
from llama_index.core.callbacks import CallbackManager
client = MeshAI(api_key="msh_...", agent_name="my-index")
client.register(framework="llamaindex")
# Add to the global callback manager
handler = MeshAILlamaHandler(client)
Settings.callback_manager = CallbackManager([handler])
# Use LlamaIndex as normal — all LLM calls tracked
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
response = query_engine.query("What is MeshAI?")
# Model and tokens captured automatically