Langtrace
Monitoring Agents and Swarms with Langtrace
Langtrace is an open source observability and evaluations platform for AI Agents. You can use it to track vital LLM metrics, store & version control your prompts, compare the performance of your prompts across different models and much more.

Configuring Langtrace for SwarmZero
Setup
First, signup on Langtrace.
Create a new project.
Give it a name and description.
Set the project type to Default.
Install Langtrace
Install the Python SDK for Langtrace in your existing SwarmZero project.
pip install langtrace-python-sdk
Import and initialize Langtrace before you import the SwarmZero SDK.
import os
from dotenv import load_dotenv
load_dotenv()
from langtrace_python_sdk import langtrace
langtrace.init(
api_key=os.getenv("LANGTRACE_API_KEY", ""),
disable_instrumentations={ "only": ["sqlalchemy"] } # optional
)
from swarmzero import Agent
# ...
Add the Langtrace API Key
Generate a Langtrace API Key from the Langtrace app dashboard.
Select the Setup Project button on the newly created project card.
Click Generate API Key and follow the on-screen instructions.
Copy the API key.
In the .env file of your SwarmZero project, add this:
LANGTRACE_API_KEY=<your_generated_api_key>
Restart the agent server if you are using the
agent.run()
method.If not, just call
agent.chat(...)
again from your Python script.

Examples of Langtrace integration can be found in the examples repository.
Last updated
Was this helpful?