Agent with Tools
Give a Portkey agent web search tools.
Code
import asyncio
import os
from agno.agent import Agent
from agno.models.portkey import Portkey
from agno.tools.websearch import WebSearchTools
agent = Agent(
model=Portkey(
id="@your-provider-slug/gpt-5-nano",
portkey_api_key=os.getenv("PORTKEY_API_KEY"),
),
tools=[WebSearchTools()],
markdown=True,
)
if __name__ == "__main__":
# --- Sync ---
agent.print_response("What are the latest developments in AI gateways?")
# --- Sync + Streaming ---
agent.print_response(
"What are the latest developments in AI gateways?", stream=True
)
# --- Async ---
asyncio.run(
agent.aprint_response("What are the latest developments in AI gateways?")
)
# --- Async + Streaming ---
asyncio.run(
agent.aprint_response(
"What are the latest developments in AI gateways?", stream=True
)
)Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your Portkey API key
export PORTKEY_API_KEY="your_portkey_api_key_here"Install dependencies
uv pip install -U portkey-ai openai ddgs agnoSet the model ID
Replace @your-provider-slug/gpt-5-nano with a model string from your Portkey Model Catalog. Portkey model strings use the format @provider_slug/model_name.
Run the agent
Save the code above as tool_use.py, then run:
python tool_use.py