Skip to main content

Agno Integration Guide

APIpieAgno

This guide will walk you through integrating Agno with APIpie, enabling you to build powerful AI agents with advanced reasoning, multimodal capabilities, and tools integration.

What is Agno?

Agno is a lightweight library for building intelligent AI agents with memory, knowledge, tools, and reasoning. It provides a flexible and powerful system for:

  • Multimodal agents that can process text, images, audio, and video
  • Reasoning capabilities to help agents "think" through complex problems
  • Advanced tools integration with 20+ pre-built tools
  • Team-based agent architecture with routing and coordination
  • Knowledge integration via vector databases for RAG applications
  • Long-term memory and session storage

By connecting Agno with APIpie, you unlock access to a wide range of powerful language models while leveraging Agno's robust agent architecture and tooling.


Integration Steps

1. Create an APIpie Account

2. Add Credit

3. Generate an API Key

  • API Key Management: APIpie API Keys
  • Create a new API key for use with Agno.

4. Install Agno

Install Agno using pip:

pip install -U agno

For specific tools, you may need to install additional packages. For example:

# For web search capabilities
pip install -U agno duckduckgo-search
# For finance tools
pip install -U agno yfinance
# For PDF processing
pip install -U agno pypdf

5. Configure Agno for APIpie

Agno can use any API-based language model, including those from APIpie. Here's how to configure it:

from agno.agent import Agent
from agno.models.openai import OpenAIChat

# Create a custom model configuration for APIpie
class APIpieModel(OpenAIChat):
def __init__(self, id: str = "gpt-4o-mini", **kwargs):
super().__init__(
id=id,
api_key="your-apipie-api-key",
base_url="https://apipie.ai/v1",
**kwargs
)

# Create an agent with APIpie model
agent = Agent(
model=APIpieModel(),
markdown=True
)

You can also use environment variables:

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat

# Set environment variables for APIpie
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create an agent with the default configuration
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
markdown=True
)

Key Features

  • Lightning Fast Performance: Agno agents instantiate in microseconds and use minimal memory
  • Model Agnostic: Connect to 23+ model providers, including APIpie
  • Advanced Reasoning: Make agents "think" through problems with specialized reasoning tools
  • Multimodal Capabilities: Process and generate text, images, audio, and video
  • Agent Teams: Build multi-agent systems with specialized roles and coordination
  • Knowledge Integration: Connect to vector databases for Agentic RAG applications
  • Pre-Built API Routes: Serve agents via FastAPI with minimal setup

Example Workflows

Application TypeWhat Agno Helps You Build
Reasoning AgentsAgents that can think through complex problems step-by-step
Multimodal AssistantsAgents that process text, images, audio, and video
Research & Analysis ToolsAgents that gather, analyze, and synthesize information
Financial AnalysisAgents that analyze stocks, financial data, and market trends
Multi-Agent TeamsSpecialized agent groups that collaborate on complex tasks

Using Agno with APIpie

Basic Agent Setup

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat

# Configure APIpie as the model provider
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create a basic agent
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
description="You are a helpful AI assistant specializing in answering general knowledge questions.",
markdown=True
)

# Use the agent
agent.print_response("What are the main factors contributing to climate change?", stream=True)

Agent with Web Search Tools

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools

# Configure APIpie as the model provider
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create an agent with web search capability
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
description="You are an enthusiastic news reporter with a flair for storytelling!",
tools=[DuckDuckGoTools()],
show_tool_calls=True,
markdown=True
)

# Get the latest news
agent.print_response("Tell me about the latest AI research breakthroughs.", stream=True)

Reasoning Agent with Financial Analysis

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.reasoning import ReasoningTools
from agno.tools.yfinance import YFinanceTools

# Configure APIpie as the model provider
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create a reasoning agent for financial analysis
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
tools=[
ReasoningTools(add_instructions=True),
YFinanceTools(
stock_price=True,
analyst_recommendations=True,
company_info=True,
company_news=True,
),
],
instructions=[
"Use tables to display data",
"Only output the report, no other text",
],
markdown=True,
)

# Generate a financial report
agent.print_response(
"Write a report on NVDA",
stream=True,
show_full_reasoning=True,
stream_intermediate_steps=True,
)

Agent with Knowledge Base (RAG)

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.embedder.openai import OpenAIEmbedder
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.knowledge.pdf_url import PDFUrlKnowledgeBase
from agno.vectordb.lancedb import LanceDb, SearchType

# Configure APIpie as the model provider
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Configure embeddings with APIpie
os.environ["OPENAI_EMBEDDINGS_API_KEY"] = "your-apipie-api-key" # Same or different key
os.environ["OPENAI_EMBEDDINGS_API_BASE"] = "https://apipie.ai/v1"

# Create an agent with knowledge base
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
description="You are a medical knowledge expert!",
instructions=[
"Search your knowledge base for medical information.",
"If the question is better suited for the web, search the web to fill in gaps.",
"Prefer the information in your knowledge base over the web results."
],
knowledge=PDFUrlKnowledgeBase(
urls=["https://example.com/path/to/medical-handbook.pdf"],
vector_db=LanceDb(
uri="tmp/lancedb",
table_name="medical",
search_type=SearchType.hybrid,
embedder=OpenAIEmbedder(id="text-embedding-3-small"),
),
),
tools=[DuckDuckGoTools()],
show_tool_calls=True,
markdown=True
)

# Load the knowledge base (only needed once)
if agent.knowledge is not None:
agent.knowledge.load()

# Query the agent
agent.print_response("What are the symptoms of type 2 diabetes?", stream=True)

Multi-Agent Team

import os
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.tools.duckduckgo import DuckDuckGoTools
from agno.tools.yfinance import YFinanceTools
from agno.team import Team

# Configure APIpie as the model provider
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create specialized agents
web_agent = Agent(
name="Web Agent",
role="Search the web for information",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[DuckDuckGoTools()],
instructions="Always include sources",
show_tool_calls=True,
markdown=True,
)

finance_agent = Agent(
name="Finance Agent",
role="Get financial data",
model=OpenAIChat(id="gpt-4o-mini"),
tools=[YFinanceTools(stock_price=True, analyst_recommendations=True, company_info=True)],
instructions="Use tables to display data",
show_tool_calls=True,
markdown=True,
)

# Create a team of agents
agent_team = Team(
mode="coordinate", # Options: "route", "collaborate", "coordinate"
members=[web_agent, finance_agent],
model=OpenAIChat(id="gpt-4o-mini"),
success_criteria="A comprehensive financial news report with clear sections and data-driven insights.",
instructions=["Always include sources", "Use tables to display data"],
show_tool_calls=True,
markdown=True,
)

# Run the team
agent_team.print_response("What's the market outlook and performance of renewable energy companies?", stream=True)

Serving Agents via API

Agno provides built-in FastAPI integration to serve your agents via API:

from fastapi import FastAPI
from agno.agent import Agent
from agno.models.openai import OpenAIChat
from agno.api.routes import register_agent_routes

# Configure APIpie as the model provider
import os
os.environ["OPENAI_API_KEY"] = "your-apipie-api-key"
os.environ["OPENAI_API_BASE"] = "https://apipie.ai/v1"

# Create your agent
agent = Agent(
model=OpenAIChat(id="gpt-4o-mini"),
description="You are a helpful AI assistant.",
markdown=True
)

# Create FastAPI app
app = FastAPI(title="My Agno API")

# Register agent routes
register_agent_routes(app, agent)

# Run with: uvicorn app:app --reload

Troubleshooting & FAQ

  • Which models are supported?
    Any model available via APIpie's OpenAI-compatible endpoint can be used with Agno.

  • How do I handle environment variables securely?
    Store your API keys in environment variables or use a secure environment management solution. Never commit API keys to repositories.

  • Can I use different models for different agents in a team?
    Yes, each agent in a team can use a different model, even from different providers.

  • How do I monitor my agents?
    Agno provides monitoring capabilities through app.agno.com if you register your agents.

  • Can I use APIpie's routing capabilities with Agno?
    Yes, APIpie's routing can help you access different models while maintaining the same endpoint structure. This is particularly useful for cost optimization and failover scenarios.

For more information, see the Agno documentation or the GitHub repository.


Support

If you encounter any issues during the integration process, please reach out on APIpie Discord for assistance.