Documentation Index
Fetch the complete documentation index at: https://docs.agno.com/llms.txt
Use this file to discover all available pages before exploring further.
Code
The OpenAI tools / tool_calls schema is forwarded as-is by the gateway. The upstream Workers AI model must support function calling. @cf/zai-org/glm-4.7-flash does.
cookbook/90_models/cloudflare/tool_use.py
import asyncio
from agno.agent import Agent
from agno.models.cloudflare import Cloudflare
from agno.tools.websearch import WebSearchTools
agent = Agent(
model=Cloudflare(id="@cf/zai-org/glm-4.7-flash"),
tools=[WebSearchTools()],
markdown=True,
add_datetime_to_context=True,
)
if __name__ == "__main__":
# --- Sync ---
agent.print_response("Whats happening in France?")
# --- Sync + Streaming ---
agent.print_response("Whats happening in France?", stream=True)
# --- Async + Streaming ---
asyncio.run(agent.aprint_response("Whats happening in France?", stream=True))
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activate
Set your environment variables
export CLOUDFLARE_API_TOKEN=xxx
export CLOUDFLARE_ACCOUNT_ID=xxx
export CLOUDFLARE_AI_GATEWAY_ID=xxx # optional, defaults to "default"
Install dependencies
uv pip install -U openai ddgs agno
Run Agent
python cookbook/90_models/cloudflare/tool_use.py