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

# Gemini 2 to 3

> Migrate a Gemini 2.5 session to Gemini 3.1 Pro Preview by sharing history through SqliteDb.

> [!WARNING]
>
> Google shut down Gemini 3 Pro Preview on March 9, 2026. The pinned `gemini-3-pro-preview` ID currently aliases to `gemini-3.1-pro-preview`; replace it explicitly before running.

```python gemini_2_to_3.py theme={null}
"""
Async example using Gemini with tool calls.
"""

import asyncio
from uuid import uuid4

from agno.agent import Agent
from agno.db.sqlite.sqlite import SqliteDb
from agno.models.google import Gemini
from agno.tools.websearch import WebSearchTools

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

session_id = str(uuid4())

agent = Agent(
    model=Gemini(id="gemini-3.7-flash"),
    db=SqliteDb(db_file="tmp/data.db"),
    tools=[WebSearchTools()],
    markdown=True,
    add_history_to_context=True,
)

asyncio.run(
    agent.aprint_response(
        "Whats the current news in France?", session_id=session_id, stream=True
    )
)

# Create a new agent with Gemini 3 Pro and re-use the history from the previous session
agent = Agent(
    model=Gemini(id="gemini-3.1-pro-preview"),
    db=SqliteDb(db_file="tmp/data.db"),
    markdown=True,
    add_history_to_context=True,
)
asyncio.run(
    agent.aprint_response(
        "Write a 2 sentence story the biggest news highlight in our conversation.",
        session_id=session_id,
        stream=True,
    )
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

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

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno ddgs google-genai sqlalchemy
```

**2. Export your Google API key**

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

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

**3. Use Gemini 3.1 Pro Preview**

Replace `gemini-3-pro-preview` with `gemini-3.1-pro-preview` in the saved Python file before running.

**4. Run the example**

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

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

Full source: [cookbook/90\_models/google/gemini/gemini\_2\_to\_3.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/90_models/google/gemini/gemini_2_to_3.py)


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