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

# Vertex AI Thinking

> Enable extended thinking with a 1024-token budget on Claude Sonnet 4 via Vertex AI.

```python thinking.py theme={null}
"""
Vertexai Thinking
=================

Cookbook example for `vertexai/claude/thinking.py`.
"""

from agno.agent import Agent
from agno.models.vertexai.claude import Claude

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

agent = Agent(
    model=Claude(
        id="claude-sonnet-4@20250514",
        max_tokens=2048,
        thinking={"type": "enabled", "budget_tokens": 1024},
    ),
    markdown=True,
)

# Print the response in the terminal

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------
if __name__ == "__main__":
    # --- Sync ---
    agent.print_response("Share a very scary 2 sentence horror story")

    # --- Sync + Streaming ---
    agent.print_response("Share a very scary 2 sentence horror story", stream=True)
```

## Run the Example

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

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno "anthropic[vertex]"
    ```
  </Step>

  <Step title="Export environment variables">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export ANTHROPIC_VERTEX_PROJECT_ID="your_anthropic_vertex_project_id_here"
      export CLOUD_ML_REGION="your_cloud_ml_region_here"
      ```

      ```bash Windows theme={null}
      $Env:ANTHROPIC_VERTEX_PROJECT_ID="your_anthropic_vertex_project_id_here"
      $Env:CLOUD_ML_REGION="your_cloud_ml_region_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Authenticate with Google Cloud">
    Sign in with Application Default Credentials:

    ```bash theme={null}
    gcloud auth application-default login
    ```
  </Step>

  <Step title="Run the example">
    Save the code above as `thinking.py`, then run:

    ```bash theme={null}
    python thinking.py
    ```
  </Step>
</Steps>

Full source: [cookbook/90\_models/vertexai/claude/thinking.py](https://github.com/agno-agi/agno/blob/main/cookbook/90_models/vertexai/claude/thinking.py)
