llms_txt_tools.py
Run the Example
1
Set up your virtual environment
2
Install dependencies
3
Export your OpenAI API key
4
Run the example
Save the code above as
llms_txt_tools.py, then run:Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Read an llms.txt index with LLMsTxtTools, then fetch only the documentation pages the agent decides are relevant.
"""
LLMs.txt Tools - Agentic Documentation Discovery
=============================
Demonstrates how to use LLMsTxtTools in agentic mode where the agent:
1. Reads the llms.txt index to discover available documentation pages
2. Decides which pages are relevant to the user's question
3. Fetches only the specific pages it needs
The llms.txt format (https://llmstxt.org) is a standardized way for websites
to provide LLM-friendly documentation indexes.
"""
from agno.agent import Agent
from agno.models.openai import OpenAIResponses
from agno.tools.llms_txt import LLMsTxtTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=OpenAIResponses(id="gpt-5.4"),
tools=[LLMsTxtTools()],
instructions=[
"You can read llms.txt files to discover documentation for any project.",
"First use get_llms_txt_index to see what pages are available.",
"Then use read_llms_txt_url to fetch only the pages relevant to the user's question.",
],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
agent.print_response(
"Using the llms.txt at https://docs.agno.com/llms.txt, "
"find and read the documentation about how to create an agent with tools",
markdown=True,
stream=True,
)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Install dependencies
uv pip install -U agno beautifulsoup4 openai
Export your OpenAI API key
export OPENAI_API_KEY="your_openai_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
Run the example
llms_txt_tools.py, then run:python llms_txt_tools.py
Was this page helpful?