Async Agent with Tools

Run a SiliconFlow agent with WebSearchTools asynchronously.

Code

async_tool_use.py
import asyncio

import os

from agno.agent import Agent
from agno.models.siliconflow import Siliconflow
from agno.tools.websearch import WebSearchTools

agent = Agent(
    model=Siliconflow(id=os.environ["SILICONFLOW_MODEL_ID"], base_url="https://api.siliconflow.com/v1"),
    tools=[WebSearchTools()],
    markdown=True,
)

asyncio.run(agent.aprint_response("What's happening in France?", stream=True))

These examples use the SiliconFlow global service: create a key in the global console and use https://api.siliconflow.com/v1. Choose a model available to that account. For a China-region account, use its key, model catalog and https://api.siliconflow.cn/v1 instead. The Agno adapter defaults to the China endpoint when base_url is omitted.

Set SILICONFLOW_MODEL_ID to a model with function calling enabled in your region's catalog. Check the function-calling guide and the selected model's current capabilities. Basic chat availability alone does not establish tool support.

Usage

Set up your virtual environment

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

Set your API key

export SILICONFLOW_API_KEY=xxx
export SILICONFLOW_MODEL_ID=your-tool-capable-model-id

Install dependencies

uv pip install -U agno openai ddgs

Run Agent

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

python async_tool_use.py