Firecrawl + LlamaIndex
Add Firecrawl web search and crawling to LlamaIndex agents and RAG pipelines.
Load search results, single pages or whole sites as LlamaIndex documents.
companies of all sizes
Key Features
How do I give a LlamaIndex agent web search?
To give a LlamaIndex agent web search, wrap Firecrawl search in a FunctionTool and pass it to a FunctionAgent. The agent decides when to search the live web. For RAG pipelines, FireCrawlWebReader in search mode loads the results of a web query straight into LlamaIndex documents you can index.
Install the packages
Install LlamaIndex, the Firecrawl Python SDK, the LlamaIndex web readers, and OpenAI integrations for the LLM and embeddings. Set FIRECRAWL_API_KEY from your Firecrawl dashboard and the key for your model provider.
pip install -U llama-index-core llama-index-llms-openai llama-index-embeddings-openai llama-index-readers-web firecrawl-py
export FIRECRAWL_API_KEY="fc-YOUR-API-KEY"
export OPENAI_API_KEY="sk-YOUR-API-KEY"Wrap Firecrawl search as a tool
FunctionTool turns a Python function into a LlamaIndex tool, using the docstring as the tool description. This function calls the Firecrawl search API and returns each result's title, URL and description.
from firecrawl import Firecrawl
from llama_index.core.tools import FunctionTool
firecrawl = Firecrawl()
def web_search(query: str) -> str:
"""Search the web with Firecrawl and return titles, URLs and descriptions."""
results = firecrawl.search(query, limit=5)
return "\n\n".join(f"{r.title}\n{r.url}\n{r.description}" for r in (results.web or []))
search_tool = FunctionTool.from_defaults(fn=web_search)Give the tool to an agent
FunctionAgent calls web_search whenever a question needs current information, then answers with the sources in context.
import asyncio
from llama_index.core.agent.workflow import FunctionAgent
from llama_index.llms.openai import OpenAI
agent = FunctionAgent(
tools=[search_tool],
llm=OpenAI(model="gpt-6-luna"),
system_prompt="Use web_search for anything current and cite the URLs you used.",
)
async def main():
response = await agent.run("What did LlamaIndex release this month?")
print(response)
asyncio.run(main())Load search results for RAG
FireCrawlWebReader runs one search and returns LlamaIndex documents. Pass a query in search mode, or a URL in scrape, crawl or map mode.
import os
from llama_index.core import VectorStoreIndex
from llama_index.readers.web import FireCrawlWebReader
reader = FireCrawlWebReader(
api_key=os.environ["FIRECRAWL_API_KEY"],
mode="search",
params={"limit": 5},
)
documents = reader.load_data(query="LlamaIndex agent workflows")
index = VectorStoreIndex.from_documents(documents)People love
building with Firecrawl











Firecrawl is an open-source framework that takes a URL, crawls it, and conver..."

Upload a CSV of emails and..."



Firecrawl is an open-source framework that takes a URL, crawls it, and conver..."

Upload a CSV of emails and..."
Frequently
asked questions
Flexible pricing
Free Plan
Hobby
StandardMost popular
Growth
Scale Plans
High-volume plans for teams that need more power and dedicated support. Get access to higher rate limits, more concurrent browsers, and priority support. Scale checks out instantly, no sales call needed.
Need more? Contact usAlso on AWS Marketplace and Google Cloud Marketplace.

















