Skip to main content

Installation

pip install meshai-sdk[autogen]

Usage

from meshai import MeshAI
from meshai.integrations.autogen import track_autogen

client = MeshAI(api_key="msh_...", agent_name="my-autogen-team")
client.register(framework="autogen")

# Enable global tracking
track_autogen(client)

# Run AutoGen agents as normal
from autogen import AssistantAgent, UserProxyAgent

assistant = AssistantAgent("assistant", llm_config={"model": "gpt-4o"})
user_proxy = UserProxyAgent("user_proxy")
user_proxy.initiate_chat(assistant, message="Write a poem")
# All LLM calls tracked with model and token counts

How It Works

AutoGen logs LLM calls via Python’s logging module. MeshAI adds a custom handler that:
  1. Captures LLMCall events from the autogen_core logger
  2. Extracts model, tokens, and provider from each event
  3. Sends to MeshAI (buffered, non-blocking)

AG2 Compatibility

The integration also works with AG2 (AutoGen’s fork) — the logging interface is compatible.