Wrappers only emit events when called inside an active
session.run() context. If a wrapped client is called outside a session, the original method runs unchanged with no instrumentation overhead.OpenAI
Wrap your OpenAI client once at startup and use it everywhere in your agent. The wrapper instrumentschat.completions.create for both streaming and non-streaming responses.
Anthropic
Wrap your Anthropic client in the same way. The wrapper instrumentsmessages.create and captures streaming content deltas, tool use blocks, and token usage.
Ollama
Wrap the Ollama client to captureollama.chat calls, including JSON-mode requests and streamed responses. Ollama costs are billed externally through ollama.com, so the dashboard shows usage as tracked externally rather than as a USD estimate.
Vercel AI SDK
UsewrapTools and wrapLanguageModel together to instrument Vercel AI SDK agent loops. wrapTools patches each tool’s execute function to emit tool_call events. wrapLanguageModel patches doGenerate and doStream to emit llm_call events.
LangChain
Usemortem.langchainHandler() to get a callback handler and add it to your LangChain chains or agents. The handler captures LLM start/end/error and tool start/end/error events without a hard dependency on @langchain/core.
BaseCallbackHandler for compatibility with stricter LangChain type checks, use the async factory instead:
createLangChainHandlerAsync dynamically imports @langchain/core/callbacks/base at runtime and returns a proper subclass when it is available, falling back to the structural handler if LangChain is not installed.
Solana web3.js Connection
Wrap your SolanaConnection to record sendRawTransaction and sendTransaction calls as solana_tx events. The wrapper also polls for confirmation in the background and updates the event with the confirmation status.
mainnet, devnet, or localnet) and records instruction names from sendTransaction calls where the transaction object exposes them.
Wrapper method reference
Each wrapper is idempotent — calling it more than once on the same client returns the already-patched client without double-wrapping.