🎉 ai-infra v1.0 is here — Production-ready AI/LLM infrastructure
What's new
nfrax logonfrax

Infrastructure that just works. Ship products, not boilerplate.

Frameworks

  • svc-infra
  • ai-infra
  • fin-infra
  • robo-infra

Resources

  • Getting Started
  • What's New
  • Contributing

Community

  • GitHub

© 2026 nfrax. All rights reserved.

nfrax logonfrax
Start HereWhat's New
GitHub
ai-infra / API Reference

Callbacks

from ai_infra.callbacks import Callbacks
View source
ai_infra.callbacks
Extends:ABC

Base class for callback handlers. Override methods to receive events. All methods have default no-op implementations, so you only need to override the ones you care about.

Example

class MetricsCallbacks(Callbacks): def __init__(self): self.total_tokens = 0 self.call_count = 0 def on_llm_end(self, event: LLMEndEvent): self.call_count += 1 if event.total_tokens: self.total_tokens += event.total_tokens

Methods

On This Page

on_graph_node_endon_graph_node_erroron_graph_node_starton_llm_endon_llm_erroron_llm_starton_llm_tokenon_mcp_connecton_mcp_disconnecton_mcp_loggingon_mcp_logging_asyncasyncon_mcp_progresson_mcp_progress_asyncasyncon_tool_endon_tool_erroron_tool_start