Agent with Tools and Streaming
Stream a Portkey agent's tool-calling response as it searches the web with WebSearchTools.
Create a provider integration in your Portkey Model Catalog, then copy an allowed model string in the form @provider_slug/model_name. Replace @your-provider-slug/gpt-5-nano in the example with that value. The slug is specific to your workspace. These catalog examples need PORTKEY_API_KEY; they do not require a separate virtual key. Pass the key explicitly as portkey_api_key, because the Agno adapter does not read that environment variable automatically.
Code
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,
)
# Print the response in the terminal
agent.print_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=***Install dependencies
uv pip install -U portkey-ai openai ddgs agnoRun Agent
Save the code above as tool_use.py, then run:
python tool_use.py