> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Agent with Tools

> Give a Cloudflare agent web search with WebSearchTools.

## 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.

```python tool_use.py theme={null}
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

<Snippet file="create-venv-step.mdx" />

**1. Set your environment variables**

```bash theme={null}
export CLOUDFLARE_API_TOKEN=xxx
export CLOUDFLARE_ACCOUNT_ID=xxx
export CLOUDFLARE_AI_GATEWAY_ID=xxx  # optional, defaults to "default"
```

**2. Install dependencies**

```bash theme={null}
uv pip install -U openai ddgs agno
```

**3. Run Agent**

Save the code above as `tool_use.py`, then run:

```bash theme={null}
python tool_use.py
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.