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 withpip install agentvista[anthropic].
AnthropicAdapter works with both sync responses (client.messages.create(...)) and streaming responses (stream.get_final_message()).
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 withpip 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.
cached_tokens from the usage details object and uses it to compute an accurate cost estimate.
LangChain
Installlangchain-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:
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.