Switch Model • AI Agent SDK

switch_model: Switch the agent's LLM model while preserving conversation history.

switch_model

Method

</div>

This is a method of the Agent class in the agent module.

Switch the agent’s LLM model while preserving conversation history.

Signature

python
def switch_model(new_model: str) -> None

Parameters

ParamField str

The new model name to switch to (e.g., “gpt-4o”, “claude-3-sonnet”)

Uses

  • LLM

Source

View on GitHub

praisonaiagents/agent/agent.py at line 6087