Integrating Agno with LangDB

LangDB provides an AI Gateway platform for comprehensive observability and tracing of AI agents and LLM interactions. By integrating Agno with LangDB, you can gain full visibility into your agent’s operations, including agent runs, tool calls, team interactions, and performance metrics. For detailed integration instructions, see the LangDB Agno documentation.
langdb-agno finance team observability

LangDB Finance Team Trace

Prerequisites

  1. Install Dependencies Ensure you have the necessary packages installed:
    pip install agno 'pylangdb[agno]'
    
  2. Setup LangDB Account
    • Sign up for an account at LangDB
    • Create a new project in the LangDB dashboard
    • Obtain your API key and Project ID from the project settings
  3. Set Environment Variables Configure your environment with the LangDB credentials:
    export LANGDB_API_KEY="<your_langdb_api_key>"
    export LANGDB_PROJECT_ID="<your_langdb_project_id>"
    

Sending Traces to LangDB

Example: Basic Agent Setup

This example demonstrates how to instrument your Agno agent with LangDB tracing.
from pylangdb.agno import init

# Initialize LangDB tracing - must be called before creating agents
init()

from agno.agent import Agent
from agno.models.langdb import LangDB
from agno.tools.duckduckgo import DuckDuckGoTools

# Create agent with LangDB model (uses environment variables automatically)
agent = Agent(
    name="Web Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[DuckDuckGoTools()],
    instructions="Answer questions using web search and provide comprehensive information"
)

# Use the agent
response = agent.run("What are the latest developments in AI agents?")
print(response)

Example: Multi-Agent Team Coordination

For more complex workflows, you can use Agno’s Team class with LangDB tracing:
from pylangdb.agno import init
init()

from agno.agent import Agent
from agno.team import Team
from agno.models.langdb import LangDB
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools

# Research Agent
web_agent = Agent(
    name="Market Research Agent",
    model=LangDB(id="openai/gpt-4.1"),
    tools=[DuckDuckGoTools()],
    instructions="Research current market conditions and news"
)

# Financial Analysis Agent
finance_agent = Agent(
    name="Financial Analyst",
    model=LangDB(id="xai/grok-4"),
    tools=[YFinanceTools(stock_price=True, company_info=True)],
    instructions="Perform quantitative financial analysis"
)

# Coordinated Team
reasoning_team = Team(
    name="Finance Reasoning Team",
    mode="coordinate",
    model=LangDB(id="xai/grok-4"),
    members=[web_agent, finance_agent],
    instructions=[
        "Collaborate to provide comprehensive financial insights",
        "Consider both fundamental analysis and market sentiment"
    ],- **Virtual Models**: Automatic model routing based on cost, performance, or capabilities
    success_criteria="Complete financial analysis with recommendations"
)

# Execute team workflow
reasoning_team.print_response("Analyze Apple (AAPL) investment potential")

Sample Trace

View a complete example trace in the LangDB dashboard: Finance Reasoning Team Trace
langdb-agno finance team observability

LangDB Finance Team Thread

Advanced Features

LangDB Capabilities

  • Virtual Models: Save, share, and reuse model configurations—combining prompts, parameters, tools, and routing logic into a single named unit for consistent behavior across apps
  • MCP Support: Enhanced tool capabilities through Model Context Protocol servers
  • Multi-Provider: Support for OpenAI, Anthropic, Google, xAI, and other providers

Notes

  • Initialization Order: Always call init() before creating any Agno agents or teams
  • Environment Variables: With LANGDB_API_KEY and LANGDB_PROJECT_ID set, you can create models with just LangDB(id="model_name")

Resources

By following these steps, you can effectively integrate Agno with LangDB, enabling comprehensive observability and monitoring of your AI agents.