Code
huggingface_tool_use.py
Usage
1
Set up your virtual environment
2
Set your API key
3
Install dependencies
4
Save the example
Save the code above as
huggingface_tool_use.py.5
Run Agent
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Give a HuggingFace agent web search with WebSearchTools.
from agno.agent import Agent
from agno.models.huggingface import HuggingFace
from agno.tools.websearch import WebSearchTools
agent = Agent(
model=HuggingFace(id="openai/gpt-oss-120b"),
tools=[WebSearchTools()],
markdown=True,
)
if __name__ == "__main__":
# --- Sync ---
agent.print_response("What is the latest news on AI?")
# --- Sync + Streaming ---
agent.print_response("What is the latest news on AI?", stream=True)
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
uv venv --python 3.12
.venv\Scripts\activate
Set your API key
export HF_TOKEN=xxx
Install dependencies
uv pip install -U huggingface_hub ddgs agno
Save the example
huggingface_tool_use.py.Run Agent
python huggingface_tool_use.py
Was this page helpful?