# How to Switch Between Different Models (/faq/switching-models)



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 [#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
uv pip install agno google-genai openai sqlalchemy
```

Set the API keys required by each provider before running the example. See [Environment variables](/faq/environment-variables).

## Switch Models [#switch-models]

```python
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 [#learn-more]

* [Five-provider model switching example](/examples/agents/advanced/interchange-model/all-providers)
* [All supported models](/models/overview)
* [Environment variables](/faq/environment-variables)
