Skip to main content
Adapters read the response object returned by an LLM provider SDK and extract a normalized dict of telemetry fields. You pass that dict directly to agentvista.record() or attach it inside an agentvista.run() block — no manual token counting required. Every adapter returns a subset of these fields: Fields present in the response are included; fields that cannot be determined are omitted from the dict.

Anthropic

Install with pip install agentvista[anthropic]. AnthropicAdapter works with both sync responses (client.messages.create(...)) and streaming responses (stream.get_final_message()).
The Anthropic adapter includes cache token counts (cache_creation_input_tokens and cache_read_input_tokens) in the input_tokens total and uses them for accurate cost calculation when prompt caching is active.

OpenAI

Install with pip install agentvista[openai]. OpenAIAdapter handles both the Chat Completions API (client.chat.completions.create) and the Responses API (client.responses.create). It auto-detects which response shape is present.
For responses with prompt caching, the adapter reads cached_tokens from the usage details object and uses it to compute an accurate cost estimate.

LangChain

Install langchain-core in addition to agentvista. No extra install extra is required. AgentVistaCallbackHandler is a drop-in LangChain callback handler. Add it to any chain or agent via the callbacks argument and spans are produced automatically — no manual span() calls needed.

Span mapping

The handler maps LangChain events to AgentVista span types:

Combining with agentvista.run()

When you add the handler inside an existing run() context, its spans become children of that root trace. This lets you attach an outcome signal:
When used without an enclosing run(), the handler auto-creates a trace that is flushed when the outermost chain completes.
If langchain_core is not installed, AgentVistaCallbackHandler is still importable but behaves as a silent no-op. This means you can add the handler to shared code without making langchain_core a hard dependency for all consumers.