|
| 1 | +--- |
| 2 | +title: Agno Integration |
| 3 | +sidebar_label: Agno |
| 4 | +description: Integrate Apify with Agno to power AI agents with web scraping, automation, and data insights. |
| 5 | +sidebar_position: 14 |
| 6 | +slug: /integrations/agno |
| 7 | +--- |
| 8 | + |
| 9 | +**Integrate Apify with Agno to power AI agents with web scraping, automation, and data insights.** |
| 10 | + |
| 11 | +--- |
| 12 | + |
| 13 | +## What is Agno? |
| 14 | + |
| 15 | +[Agno](https://docs.agno.com/) is an open-source framework for building intelligent AI agents. It provides a flexible architecture to create agents with custom tools, enabling seamless integration with external services like Apify for tasks such as web scraping, data extraction and automation. |
| 16 | + |
| 17 | +:::note Agno documentation |
| 18 | + |
| 19 | +Check out the [Agno documentation](https://docs.agno.com/introduction) for more details on building AI agents. |
| 20 | + |
| 21 | +::: |
| 22 | + |
| 23 | +## How to use Apify with Agno |
| 24 | + |
| 25 | +This guide shows how to integrate Apify Actors with Agno to empower your AI agents with real-time web data. We'll use the [RAG Web Browser](https://apify.com/apify/rag-web-browser) Actor to fetch web content and the [Google Places Crawler](https://apify.com/compass/crawler-google-places) Actor to extract location-based data. It is very easy to use with any other Actor by just passing the name of the Actor. See and choose from thousands of Actors in the [Apify Store](https://apify.com/store). |
| 26 | + |
| 27 | +### Prerequisites |
| 28 | + |
| 29 | +- _Apify API token_: Obtain your API token from the [Apify console](https://console.apify.com/account/integrations). |
| 30 | +- _OpenAI API key_: Get your API key from the [OpenAI platform](https://platform.openai.com/account/api-keys). |
| 31 | + |
| 32 | +:::tip Alternative LLM providers |
| 33 | + |
| 34 | +While our examples use OpenAI, Agno supports other LLM providers as well. You'll need to adjust the environment variables and configuration according to your chosen provider. Check out the [Agno models documentation](https://docs.agno.com/models/introduction) for details on supported providers and configuration. |
| 35 | + |
| 36 | +::: |
| 37 | + |
| 38 | +- _Python environment_: Ensure Python is installed (version 3.8+ recommended). |
| 39 | +- _Required packages_: Install the following dependencies in your terminal: |
| 40 | + |
| 41 | +```bash |
| 42 | +pip install agno apify-client |
| 43 | +``` |
| 44 | + |
| 45 | +## Basic integration example |
| 46 | + |
| 47 | +Start by setting up an Agno agent with Apify tools. This example uses the RAG Web Browser Actor to extract content from a specific URL. |
| 48 | + |
| 49 | +```python |
| 50 | +import os |
| 51 | + |
| 52 | +from agno.agent import Agent |
| 53 | +from agno.tools.apify import ApifyTools |
| 54 | + |
| 55 | +os.environ["APIFY_API_TOKEN"] = "YOUR_APIFY_API_TOKEN" # Replace with your Apify API token |
| 56 | +os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY" # Replace with your OpenAI API key |
| 57 | + |
| 58 | +# Initialize the agent with Apify tools |
| 59 | +agent = Agent( |
| 60 | + tools=[ApifyTools( actors=["apify/rag-web-browser"])], |
| 61 | + show_tool_calls=True, |
| 62 | + markdown=True |
| 63 | +) |
| 64 | + |
| 65 | +# Fetch and display web content |
| 66 | +agent.print_response("Extract key details from https://docs.agno.com/introduction", markdown=True) |
| 67 | +``` |
| 68 | + |
| 69 | +Running this code will scrape the specified URL and return formatted content your agent can use. |
| 70 | + |
| 71 | +### Advanced scenario: Travel planning agent |
| 72 | + |
| 73 | +Combine multiple Apify Actors to create a powerful travel planning agent. This example uses the RAG Web Browser and Google Places Crawler to gather travel insights and local business data. |
| 74 | + |
| 75 | +```python |
| 76 | +import os |
| 77 | + |
| 78 | +from agno.agent import Agent |
| 79 | +from agno.tools.apify import ApifyTools |
| 80 | + |
| 81 | +os.environ["APIFY_API_TOKEN"] = "YOUR_APIFY_API_TOKEN" # Replace with your Apify API token |
| 82 | +os.environ["OPENAI_API_KEY"] = "YOUR_OPENAI_API_KEY" # Replace with your OpenAI API key |
| 83 | + |
| 84 | +# Create a travel planning agent |
| 85 | +agent = Agent( |
| 86 | + name="Travel Planner", |
| 87 | + instructions=[ |
| 88 | + "You are a travel planning assistant. Use web data and location insights to provide detailed travel recommendations." |
| 89 | + ], |
| 90 | + tools=[ |
| 91 | + ApifyTools( |
| 92 | + actors=[ |
| 93 | + "apify/rag-web-browser", # For general web research |
| 94 | + "compass/crawler-google-places" # For location-based data |
| 95 | + ] |
| 96 | + ) |
| 97 | + ], |
| 98 | + show_tool_calls=True, |
| 99 | + markdown=True |
| 100 | +) |
| 101 | + |
| 102 | +# Plan a trip to Tokyo |
| 103 | +agent.print_response( |
| 104 | + """ |
| 105 | + I'm traveling to Tokyo next month. |
| 106 | + 1. Research the best time to visit and top attractions. |
| 107 | + 2. Find a highly rated sushi restaurant near Shinjuku. |
| 108 | + Compile a travel guide with this information. |
| 109 | + """, |
| 110 | + markdown=True |
| 111 | +) |
| 112 | +``` |
| 113 | + |
| 114 | +This agent will fetch travel-related data and restaurant recommendations, providing a comprehensive travel guide: |
| 115 | + |
| 116 | +1. Use the RAG Web Browser to research Tokyo travel details. |
| 117 | +2. Use the Google Places Crawler to find a top sushi restaurant. |
| 118 | +3. Combine the results into a comprehensive guide. |
| 119 | + |
| 120 | +:::tip Apify Store |
| 121 | + |
| 122 | +Browse the [Apify Store](https://apify.com/store) to find additional Actors for tasks like social media scraping, e-commerce data extraction, or news aggregation. |
| 123 | + |
| 124 | +::: |
| 125 | + |
| 126 | +### Available Apify tools |
| 127 | + |
| 128 | +Agno supports any Apify Actor via the ApifyTools class. You can specify a single Actor ID or a list of Actor IDs to register multiple tools for your agent at once. |
| 129 | + |
| 130 | +## Configuration options |
| 131 | + |
| 132 | +`apify_api_token` (string, default: `None`) |
| 133 | +: Apify API token (or set via APIFY_API_TOKEN environment variable) |
| 134 | + |
| 135 | +`actors` (string or List[string], default: `None`) |
| 136 | +: Single Actor ID or list of Actor IDs to register |
| 137 | + |
| 138 | +## Resources |
| 139 | + |
| 140 | +- [How to build an AI Agent](https://blog.apify.com/how-to-build-an-ai-agent/) |
| 141 | +- [Agno Framework Documentation](https://docs.agno.com) |
| 142 | +- [Apify Platform Documentation](https://docs.apify.com) |
| 143 | +- [Apify Actor Documentation](https://docs.apify.com/actors) |
| 144 | +- [Apify Store - Browse available Actors](https://apify.com/store) |
| 145 | +- [Agno Apify Toolkit Documentation](https://docs.agno.com/tools/toolkits/others/apify#apify) |
0 commit comments