Skip to main content
The Firecrawl Reader with asynchronous processing uses the Firecrawl API to scrape and crawl web content efficiently, converting it into documents for your knowledge base.

Code

examples/concepts/knowledge/readers/firecrawl_reader_async.py
import os
import asyncio

from agno.agent import Agent
from agno.knowledge.knowledge import Knowledge
from agno.knowledge.reader.firecrawl_reader import FirecrawlReader
from agno.vectordb.pgvector import PgVector

api_key = os.getenv("FIRECRAWL_API_KEY")
db_url = "postgresql+psycopg://ai:ai@localhost:5532/ai"

knowledge = Knowledge(
    vector_db=PgVector(
        table_name="firecrawl_documents",
        db_url=db_url,
    ),
)

agent = Agent(
    knowledge=knowledge,
    search_knowledge=True,
)

async def main():
    # Add Firecrawl content to knowledge base
    await knowledge.add_content_async(
        url="https://github.com/agno-agi/agno",
        reader=FirecrawlReader(
            api_key=api_key,
            mode="scrape",
            chunk=True,
            params={"formats": ["markdown"]},
        ),
    )

    # Query the knowledge base
    await agent.aprint_response(
        "What is the main purpose of this repository?",
        markdown=True,
    )

if __name__ == "__main__":
    asyncio.run(main())

Usage

1

Create a virtual environment

Open the Terminal and create a python virtual environment.
python3 -m venv .venv
source .venv/bin/activate
2

Install libraries

pip install -U firecrawl-py sqlalchemy psycopg pgvector agno
3

Set API Key

export FIRECRAWL_API_KEY="your-firecrawl-api-key"
4

Run PgVector

docker run -d \
  -e POSTGRES_DB=ai \
  -e POSTGRES_USER=ai \
  -e POSTGRES_PASSWORD=ai \
  -e PGDATA=/var/lib/postgresql/data/pgdata \
  -v pgvolume:/var/lib/postgresql/data \
  -p 5532:5432 \
  --name pgvector \
  agno/pgvector:16
5

Run Agent

python examples/concepts/knowledge/readers/firecrawl_reader_async.py

Params

ParameterTypeDefaultDescription
api_keyOptional[str]NoneFirecrawl API key for authentication
paramsOptional[Dict]NoneAdditional parameters to pass to the Firecrawl API
modeLiteral["scrape", "crawl"]"scrape"Mode of operation - "scrape" for single page, "crawl" for multiple pages
urlstrRequiredURL of the website to scrape or crawl