Router Tool Use
Give a RampRouter agent WebSearchTools and run it in sync, async, and streaming modes.
"""
Router Tool Use
===============
Cookbook example for `ramp/tool_use.py`.
"""
import asyncio
from agno.agent import Agent
from agno.models.ramp import RampRouter
from agno.tools.websearch import WebSearchTools
# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------
agent = Agent(
model=RampRouter(id="gpt-5.6-luna"),
tools=[WebSearchTools()],
markdown=True,
)
# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
# --- Sync ---
agent.print_response("Whats happening in France?")
# --- Sync + Streaming ---
agent.print_response("Whats happening in France?", stream=True)
# --- Async ---
asyncio.run(agent.aprint_response("Whats happening in France?"))
# --- Async + Streaming ---
asyncio.run(agent.aprint_response("Whats happening in France?", stream=True))Run the Example
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateInstall dependencies
uv pip install -U agno ddgs openaiExport your API keys
export RAMP_ROUTER_API_KEY="your_ramp_router_api_key_here"Select models available to your key
Choose exact callable IDs from the authenticated GET https://api.router.com/v1/models catalog, following Router's model selection guide. Select candidates with the tool or structured-output capabilities required by this example. Access is specific to your API key.
Update id or the models list in the saved file as needed. In the basic example, also update the model string: keep its ramp: provider prefix and put the selected callable ID after it. Do not pass both id and models.
Run the example
Save the code above as tool_use.py, then run:
python tool_use.pyFull source: cookbook/90_models/ramp/tool_use.py