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

# Claude Gemini

> Switch a single agent between Claude and Gemini mid-conversation with shared Postgres history.

```python claude_gemini.py theme={null}
import os

from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.anthropic import Claude
from agno.models.google import Gemini


def get_weather(city: str) -> str:
    """Get the current weather for a city."""
    return f"The weather in {city} is sunny and 22C."


def main() -> None:
    db_url = os.getenv(
        "AGNO_POSTGRES_URL",
        "postgresql+psycopg://ai:ai@localhost:5532/ai",
    )
    db = PostgresDb(db_url)

    agent = Agent(
        model=Claude(),
        db=db,
        add_history_to_context=True,
        num_history_runs=10,
        tools=[get_weather],
    )

    # Turn 1 — Claude with tool call
    agent.print_response("What is the weather in Paris?")

    # Turn 2 — Gemini with tool call
    agent.model = Gemini()
    agent.print_response("What is the weather in London?")

    # Turn 3 — Claude with tool call (works fine on its own)
    agent.model = Claude()
    agent.print_response("What is the weather in Tokyo?")

    # Turn 4 — Gemini summary
    agent.model = Gemini()
    agent.print_response("Summarize all the weather we checked.")


if __name__ == "__main__":
    main()
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno "psycopg[binary]" anthropic google-genai sqlalchemy
```

**2. Export your API keys**

```bash Mac/Linux theme={null}
export ANTHROPIC_API_KEY="your_anthropic_api_key_here"
export GOOGLE_API_KEY="your_google_api_key_here"
```

```bash Windows theme={null}
$Env:ANTHROPIC_API_KEY="your_anthropic_api_key_here"
$Env:GOOGLE_API_KEY="your_google_api_key_here"
```

<Snippet file="run-pgvector-step.mdx" />

**3. Run the example**

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

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

Full source: [cookbook/02\_agents/14\_advanced/interchange\_model/claude\_gemini.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/02_agents/14_advanced/interchange_model/claude_gemini.py)


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