Agent with Tools

Give a DeepInfra agent web search with WebSearchTools.

Code

This model is used in DeepInfra's tool-calling guide. Model availability and tool support are provider-specific.

import asyncio

from agno.agent import Agent  # noqa
from agno.models.deepinfra import DeepInfra  # noqa
from agno.tools.websearch import WebSearchTools  # noqa

agent = Agent(
    model=DeepInfra(id="deepseek-ai/DeepSeek-V4-Flash-0731"),
    tools=[WebSearchTools()],
    markdown=True,
)

if __name__ == "__main__":
    # --- Sync + Streaming ---
    agent.print_response("Whats happening in France?", stream=True)

    # --- Async + Streaming ---
    asyncio.run(agent.aprint_response("What's the latest news about AI?", stream=True))

Usage

Set up your virtual environment

uv venv --python 3.12
source .venv/bin/activate

Set your API key

export DEEPINFRA_API_KEY=xxx

Install dependencies

uv pip install -U openai ddgs agno

Run Agent

Save the code above as tool_use.py, then run:

python tool_use.py