Agno is a multi-agent AI framework designed for building sophisticated AI systems with multiple specialized agents. It provides a powerful platform for creating teams of AI agents that can collaborate, reason, and execute complex tasks. With Truefoundry AI Gateway integration, you can route your Agno AI requests via Gateway for enhanced security, cost tracking, and access controls while leveraging multiple model providers.
Before integrating Agno AI with TrueFoundry, ensure you have:
TrueFoundry Account: Create a Truefoundry account with atleast one model provider and generate a Personal Access Token by following the instructions in Generating Tokens. For a quick setup guide, see our Gateway Quick Start
Agno Installation: Install Agno using pip: pip install agno-agi[openai]
Create your Agno agents with TrueFoundry Gateway configuration:
Copy
Ask AI
from agno.agent import Agentfrom agno.models.openai import OpenAIChat# Configure agent with TrueFoundry Gatewayagent = Agent( model=OpenAIChat( id="openai-main/gpt-4o", # Use TrueFoundry model name. Similarly you can call any model from any model provider like anthropic, gemini etc api_key="your-truefoundry-api-key", base_url="your-truefoundry-gateway-url" ), description="AI assistant powered by TrueFoundry Gateway", instructions=[ "You are a helpful AI assistant", "Provide accurate and concise responses" ])
Create a simple agent using the configured TrueFoundry Gateway:
Copy
Ask AI
from agno.agent import Agentfrom agno.models.openai import OpenAIChat# Single agent with TrueFoundry Gatewayagent = Agent( model=OpenAIChat(id="openai-main/gpt-4o"), name="Assistant", description="General purpose AI assistant")# Run the agentresponse = agent.run("What is the capital of Brazil?")print(response.content)
Create a team of specialized agents for complex tasks:
Copy
Ask AI
from agno.agent import Agentfrom agno.team import Teamfrom agno.models.openai import OpenAIChat# Research Agentresearcher = Agent( model=OpenAIChat(id="openai-main/gpt-4o"), name="Researcher", description="Conducts thorough research on topics", instructions=[ "Research the given topic thoroughly", "Provide factual and well-sourced information" ])# Writer Agentwriter = Agent( model=OpenAIChat(id="openai-main/gpt-4o"), name="Writer", description="Creates well-structured content", instructions=[ "Write clear and engaging content", "Structure information logically" ])# Create teamresearch_team = Team( agents=[researcher, writer], instructions=[ "Researcher should investigate the topic first", "Writer should create content based on research findings" ])# Execute team taskresult = research_team.run("Research and write about sustainable energy solutions")
Integrate Agno agents with custom tools and TrueFoundry Gateway:
Copy
Ask AI
from agno.agent import Agentfrom agno.models.openai import OpenAIChatfrom agno.tools.python import PythonTools# Agent with toolscoding_agent = Agent( model=OpenAIChat(id="openai-main/gpt-4o"), name="Coding Assistant", description="Helps with coding and data analysis", tools=[PythonTools()], instructions=[ "Write clean and efficient code", "Explain your code solutions" ])# Use agent for coding tasksresponse = coding_agent.run("Create a Python function to calculate the Fibonacci sequence")
For persistent configuration across all Agno agents, set these environment variables:
Copy
Ask AI
# Add to your ~/.bashrc, ~/.zshrc, or equivalentexport OPENAI_API_KEY="your-truefoundry-api-key"export OPENAI_BASE_URL="your-truefoundry-gateway-url"# Optional: Set default modelexport OPENAI_MODEL="openai-main/gpt-4o"