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

# Agent with Tools

## 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 cookbook/90_models/cloudflare/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

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

  <Step title="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"
    ```
  </Step>

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U openai ddgs agno
    ```
  </Step>

  <Step title="Run Agent">
    ```bash theme={null}
    python cookbook/90_models/cloudflare/tool_use.py
    ```
  </Step>
</Steps>
