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.
Agno is a lightweight library for building intelligent AI agents with memory, knowledge, tools, and reasoning. It provides a flexible and powerful system for:
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.
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
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
)
| Application Type | What Agno Helps You Build |
|---|---|
| Reasoning Agents | Agents that can think through complex problems step-by-step |
| Multimodal Assistants | Agents that process text, images, audio, and video |
| Research & Analysis Tools | Agents that gather, analyze, and synthesize information |
| Financial Analysis | Agents that analyze stocks, financial data, and market trends |
| Multi-Agent Teams | Specialized agent groups that collaborate on complex tasks |
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)
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)
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,
)
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)
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)
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
For more information, see the Agno documentation or the GitHub repository.
If you encounter any issues during the integration process, please reach out on APIpie Discord for assistance.
Hugging Face Integration Guide
Learn how to integrate Hugging Face with APIpie for accessing thousands of open-source models for various AI tasks.
LangChain Integration Guide
Learn how to integrate LangChain with APIpie for building powerful AI applications with language models. Step-by-step setup, configuration, and usage guide.