Pydantic AI
Trace a Pydantic AI agent with Neatlogs (Python).
Wrap a Pydantic AI Agent with neatlogs.wrap() and its runs — model calls and tool calls — are captured.
Prerequisites
pip install -U "neatlogs[pydantic-ai]" pydantic-aiUsage
import os
import neatlogs
from pydantic_ai import Agent
neatlogs.init(api_key=os.environ["NEATLOGS_API_KEY"], workflow_name="pydantic-ai-demo")
agent = neatlogs.wrap(Agent("openai:gpt-4o", system_prompt="Be concise."))
result = agent.run_sync("In one sentence, what is Pydantic AI?")
print(result.output)
neatlogs.flush()
neatlogs.shutdown()The agent run becomes an AGENT trace root automatically, with nested LLM and TOOL spans — no manual WORKFLOW wrapper needed. Add one only to group several agent runs into a single trace.