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

# How to Switch Between Different Models

> Switch models and supported providers within one agent session while preserving message and tool-call history.

Reuse one `Agent` and assign a new model to `agent.model` between turns. Agno reformats stored messages and tool-call IDs for supported providers before sending the history to the next model.

## Provider Support

| Switch | Guidance |
| - | - |
| Different model from the same provider | Supported |
| OpenAI Chat, OpenAI Responses, Anthropic Claude, Google Gemini, and AWS Claude | Supported, including stored tool calls and results |
| Other provider combinations | Test provider-specific content such as reasoning blocks, server tools, and multimodal messages before production |

Install dependencies:

```shell theme={null}
uv pip install agno google-genai openai sqlalchemy
```

Set the API keys required by each provider before running the example. See [Environment variables](https://agno-v2.mintlify.site/faq/environment-variables.md).

## Switch Models

```python theme={null}
from agno.agent import Agent
from agno.db.sqlite import SqliteDb
from agno.models.google import Gemini
from agno.models.openai import OpenAIChat

agent = Agent(
    model=OpenAIChat(id="gpt-5.4"),
    instructions="You are a helpful assistant for technical discussions.",
    db=SqliteDb(db_file="tmp/model_switching.db"),
    add_history_to_context=True,
    num_history_runs=10,
)

agent.print_response("Explain quantum computing basics")

# Switch models within the same provider
agent.model = OpenAIChat(id="gpt-5.4-mini")
agent.print_response("What are the main applications?")

# Switch providers and keep the same session history
agent.model = Gemini(id="gemini-3.5-flash")
agent.print_response("Summarize our discussion so far.")
```

## Learn More

* [Five-provider model switching example](https://agno-v2.mintlify.site/examples/agents/advanced/interchange-model/all-providers.md)
* [All supported models](https://agno-v2.mintlify.site/models/overview.md)
* [Environment variables](https://agno-v2.mintlify.site/faq/environment-variables.md)


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