axonpush
TypeScript SDKIntegrations

LlamaIndex

AxonPushLlamaIndexHandler exposes explicit hooks for LlamaIndex.TS LLM, embedding, retriever, and query stages.

AxonPushLlamaIndexHandler is a set of plain instance methods you call at the boundaries you care about. It does not auto-register with LlamaIndex’s Settings or callbackManager, you wire each hook into the code that already orchestrates retrieval and generation.

Tested against llamaindex@^0.8.

Install

npm install @axonpush/sdk llamaindex

Wire up the hooks

import { AxonPush, AxonPushLlamaIndexHandler } from "@axonpush/sdk";

const client = new AxonPush();
const handler = new AxonPushLlamaIndexHandler({
  client,
  channelId: process.env.AXONPUSH_CHANNEL_ID!,
  agentId: "rag-pipeline",
});

handler.onQueryStart(question);

handler.onRetrieverStart(question);
const nodes = await retriever.retrieve(question);
handler.onRetrieverEnd(nodes.length);

handler.onLLMStart("gpt-4o", 1);
const response = await index.asQueryEngine().query(question);
handler.onLLMEnd(response);

handler.onQueryEnd(response);

For streaming, call handler.onLLMStream(token) per token.

agentId defaults to "llamaindex".

Method reference

MethodIdentifieraxonpush eventTypePayload
onLLMStart(model?, promptCount?)llm.startagent.startmodel, prompt_count
onLLMEnd(output?)llm.endagent.endtruncated output
onLLMStream(token)llm.tokenagent.llm.tokentoken
onEmbeddingStart(model?, textCount?)embedding.startagent.tool_call.startmodel, text_count
onEmbeddingEnd(embeddingCount?)embedding.endagent.tool_call.endembedding_count
onRetrieverStart(query)retriever.queryagent.tool_call.startquery
onRetrieverEnd(nodeCount?)retriever.resultagent.tool_call.endnode_count
onQueryStart(query)query.startagent.startquery
onQueryEnd(response?)query.endagent.endtruncated response

Every argument is optional except the query strings. Omitted models record as "unknown" and omitted counts as 0, so a partially-wired pipeline still produces a readable trace.

Queries are cut to 500 characters; outputs and responses are JSON-serialised and truncated at 500 characters, then run through the client’s redactor. Every event carries metadata.framework: "llamaindex", and all of them share one trace for the life of the handler, build a handler per request, or seed traceId, if you want one trace per query rather than one per process.