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
Set the API keys required by each provider before running the example. See Environment variables.
Switch Models
from agno.agent import Agentfrom agno.db.sqlite import SqliteDbfrom agno.models.google import Geminifrom agno.models.openai import OpenAIChatagent = 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 provideragent.model = OpenAIChat(id="gpt-5.4-mini")agent.print_response("What are the main applications?")# Switch providers and keep the same session historyagent.model = Gemini(id="gemini-3.5-flash")agent.print_response("Summarize our discussion so far.")
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Agno","colors":{"primary":"#FF4017","light":"#FF4017","dark":"#FF4017"},"logo":{"light":"https://mintcdn.com/agno-v2/SgkhZ8Fg5uYnD8iq/logo/black.svg?fit=max\u0026auto=format\u0026n=SgkhZ8Fg5uYnD8iq\u0026q=85\u0026s=fbe4dbb306f50c4d379aff3861e202fa","dark":"https://mintcdn.com/agno-v2/SgkhZ8Fg5uYnD8iq/logo/white.svg?fit=max\u0026auto=format\u0026n=SgkhZ8Fg5uYnD8iq\u0026q=85\u0026s=362cc549cb8a40935ac490f9175afbae"},"favicon":"https://mintcdn.com/agno-v2/Y7twezR0wF2re1xh/favicon.png?fit=max\u0026auto=format\u0026n=Y7twezR0wF2re1xh\u0026q=85\u0026s=929e6495078b426821db16391294be2b","background":{"color":{"light":"#FFFFFF","dark":"#111113"}},"navbar":{"links":[{"icon":"help","href":"https://docs.agno.com/get-help","label":"Support"},{"icon":"github","href":"https://github.com/agno-agi/agno","label":"Github"}],"primary":{"type":"button","label":"Try AgentOS","href":"https://os.agno.com"}},"footer":{"socials":{"github":"https://github.com/agno-agi/agno/discussions","x":"https://x.com/AgnoAgi","linkedin":"https://www.linkedin.com/company/agno-agi","youtube":"https://agno.link/youtube","website":"https://agno.com"}},"fonts":{"heading":{"family":"Inter","weight":750},"body":{"family":"Inter","weight":400}},"integrations":{"gtm":{"tagId":"GTM-WBTFNG7M"}},"contextual":{"options":["copy","mcp","cursor","chatgpt","claude"],"display":"header"},"styling":{"latex":true},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"agno-v2","hasAudioNarration":false,"actualSubdomain":"agno-v2","customDomains":[],"gitSource":{"type":"github","owner":"agno-agi","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":false,"mountPath":"","label":""},"feedback":{"thumbs":true,"issues":true,"edits":true,"agentFeedback":true},"entitlements":{"AI_CHAT":{"status":"DISABLED"}},"buildId":"6aaba6ee5a9aeab2eab5d50e","clientVersion":"0.0.4324","searchFilterCounts":[{"language":"default","tag":"Examples","count":1983},{"language":"default","tag":"SDK","count":1258},{"language":"default","tag":"Usage","count":663},{"language":"default","tag":"Models","count":641},{"language":"default","tag":"Providers","count":605},{"language":"default","tag":"Tools","count":494},{"language":"default","tag":"Primitives","count":493},{"language":"default","tag":"Reference","count":444},{"language":"default","tag":"Model Providers","count":442},{"language":"default","tag":"Basics","count":407}]},"assistantConfig":{},"basePath":"","hasChatPermissions":false,"hasWebMcpPermissions":false,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-rbac-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"rbac-expansion","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"site-roles","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"full-page-search","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-dual-write","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-metadata","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"sso-setup-deadline-banner","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"turbopuffer-serve","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"live-agents","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"starter-pricing","enabled":true,"variant":{"name":"treatment","enabled":true,"payload":{"type":"string","value":"treatment"},"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"wildcard-email-auth","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"starterQuestions":[],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","content":"#content{margin-top:0.75rem!important}#content>span:first-of-type,#content>p:first-of-type{margin-top:1.5rem!important}#content>span+h2,#content>p+h2{margin-top:1.5rem!important}"}]}
{"page":{"pagePath":"faq/switching-models","slug":"/faq/switching-models","pageMetadata":{"title":"How to Switch Between Different Models","sidebarTitle":"Switching Models","description":"Switch models and supported providers within one agent session while preserving message and tool-call history.","href":"/faq/switching-models"},"description":{"compiledSource":"\"use strict\";\nconst {jsx: _jsx} = arguments[0];\nconst {useMDXComponents: _provideComponents} = arguments[0];\nfunction _createMdxContent(props) {\n const _components = {\n p: \"p\",\n ..._provideComponents(),\n ...props.components\n };\n return _jsx(_components.p, {\n children: \"Switch models and supported providers within one agent session while preserving message and tool-call history.\"\n });\n}\nfunction MDXContent(props = {}) {\n const {wrapper: MDXLayout} = {\n ..._provideComponents(),\n ...props.components\n };\n return MDXLayout ? _jsx(MDXLayout, {\n ...props,\n children: _jsx(_createMdxContent, {\n ...props\n })\n }) : _createMdxContent(props);\n}\nreturn {\n default: MDXContent\n};\n","frontmatter":{},"scope":{}},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,li:`li`,p:`p`,pre:`pre`,span:`span`,tbody:`tbody`,td:`td`,th:`th`,thead:`thead`,tr:`tr`,ul:`ul`,..._provideComponents(),...props.components},{CodeBlock,Heading,Table}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);if(!Table)_missingMdxReference(`Table`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`Reuse one `,_jsx(_components.code,{children:`Agent`}),` and assign a new model to `,_jsx(_components.code,{children:`agent.model`}),` between turns. Agno reformats stored messages and tool-call IDs for supported providers before sending the history to the next model.`]}),`\n`,_jsx(Heading,{level:`2`,id:`provider-support`,children:`Provider Support`}),`\n`,_jsxs(Table,{children:[_jsx(_components.thead,{children:_jsxs(_components.tr,{children:[_jsx(_components.th,{children:`Switch`}),_jsx(_components.th,{children:`Guidance`})]})}),_jsxs(_components.tbody,{children:[_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Different model from the same provider`}),_jsx(_components.td,{children:`Supported`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`OpenAI Chat, OpenAI Responses, Anthropic Claude, Google Gemini, and AWS Claude`}),_jsx(_components.td,{children:`Supported, including stored tool calls and results`})]}),_jsxs(_components.tr,{children:[_jsx(_components.td,{children:`Other provider combinations`}),_jsx(_components.td,{children:`Test provider-specific content such as reasoning blocks, server tools, and multimodal messages before production`})]})]})]}),`\n`,_jsx(_components.p,{children:`Install dependencies:`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`1`,language:`shellscript`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`shellscript`,children:_jsxs(_components.code,{language:`shellscript`,numberOfLines:`1`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#DCDCAA`},children:`uv`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` pip`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` install`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` agno`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` google-genai`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` openai`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` sqlalchemy`})]}),`\n`]})})}),`\n`,_jsxs(_components.p,{children:[`Set the API keys required by each provider before running the example. See `,_jsx(_components.a,{href:`/faq/environment-variables`,children:`Environment variables`}),`.`]}),`\n`,_jsx(Heading,{level:`2`,id:`switch-models`,children:`Switch Models`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`22`,language:`python`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`python`,children:_jsxs(_components.code,{language:`python`,numberOfLines:`22`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agno.agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agno.db.sqlite `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` SqliteDb`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agno.models.google `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Gemini`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` agno.models.openai `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAIChat`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Agent(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` model`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`OpenAIChat(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-5.4\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` instructions`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"You are a helpful assistant for technical discussions.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` db`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`SqliteDb(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`db_file`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"tmp/model_switching.db\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`),`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` add_history_to_context`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:`True`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:` num_history_runs`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`10`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent.print_response(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Explain quantum computing basics\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Switch models within the same provider`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent.model `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` OpenAIChat(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gpt-5.4-mini\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent.print_response(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"What are the main applications?\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`# Switch providers and keep the same session history`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent.model `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` Gemini(`}),_jsx(_components.span,{style:{color:`#953800`,\"--shiki-dark\":`#9CDCFE`},children:`id`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"gemini-3.5-flash\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`agent.print_response(`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\"Summarize our discussion so far.\"`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`)`})]}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`learn-more`,children:`Learn More`}),`\n`,_jsxs(_components.ul,{children:[`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/examples/agents/advanced/interchange-model/all-providers`,children:`Five-provider model switching example`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/models/overview`,children:`All supported models`})}),`\n`,_jsx(_components.li,{children:_jsx(_components.a,{href:`/faq/environment-variables`,children:`Environment variables`})}),`\n`]})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"config":{},"pageMetadata":{"title":"How to Switch Between Different Models","sidebarTitle":"Switching Models","description":"Switch models and supported providers within one agent session while preserving message and tool-call history.","href":"/faq/switching-models"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Provider Support","slug":"provider-support","depth":2,"children":[]},{"title":"Switch Models","slug":"switch-models","depth":2,"children":[]},{"title":"Learn More","slug":"learn-more","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":[],"subdomain":"agno-v2","siteName":"Agno","title":"How to Switch Between Different Models - Agno","contextualStarterQuestions":[],"navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-07-19T00:40:02.280Z","originalFileLocation":"faq/switching-models.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"description\" content=\"Switch models and supported providers within one agent session while preserving message and tool-call history.\">\u003cmeta data-mint-head name=\"application-name\" content=\"Agno\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"How to Switch Between Different Models - Agno\">\u003cmeta data-mint-head property=\"og:description\" content=\"Switch models and supported providers within one agent session while preserving message and tool-call history.\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Agno\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://agno-v2.mintlify.app/faq/switching-models\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://agno-v2.mintlify.site/_mintlify/api/og/v2?division=FAQs\u0026amp;title=How+to+Switch+Between+Different+Models\u0026amp;description=Switch+models+and+supported+providers+within+one+agent+session+while+preserving+message+and+tool-call+history.\u0026amp;theme=7d6ed0e1508fc3847f5d47b3\u0026amp;signature=c4c8bc8df0009fe6efa54564b9b45e3ed77152dd2c74e863559f92f7594895a4\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"How to Switch Between Different Models - Agno\">\u003cmeta data-mint-head name=\"twitter:description\" content=\"Switch models and supported providers within one agent session while preserving message and tool-call history.\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://agno-v2.mintlify.site/_mintlify/api/og/v2?division=FAQs\u0026amp;title=How+to+Switch+Between+Different+Models\u0026amp;description=Switch+models+and+supported+providers+within+one+agent+session+while+preserving+message+and+tool-call+history.\u0026amp;theme=7d6ed0e1508fc3847f5d47b3\u0026amp;signature=c4c8bc8df0009fe6efa54564b9b45e3ed77152dd2c74e863559f92f7594895a4\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/agno-v2/queHaJYpMArYtYjI/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Agno\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#FF4017\">\u003clink data-mint-head rel=\"canonical\" href=\"https://agno-v2.mintlify.app/faq/switching-models\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/faq/switching-models.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://agno-v2.mintlify.app/#organization\",\"name\":\"Agno\",\"url\":\"https://agno-v2.mintlify.app\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://mintcdn.com/agno-v2/SgkhZ8Fg5uYnD8iq/logo/black.svg?fit=max\u0026auto=format\u0026n=SgkhZ8Fg5uYnD8iq\u0026q=85\u0026s=fbe4dbb306f50c4d379aff3861e202fa\"}},{\"@type\":\"WebSite\",\"@id\":\"https://agno-v2.mintlify.app#website\",\"name\":\"Agno\",\"url\":\"https://agno-v2.mintlify.app\",\"publisher\":{\"@id\":\"https://agno-v2.mintlify.app/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://agno-v2.mintlify.app/faq/switching-models#webpage\",\"url\":\"https://agno-v2.mintlify.app/faq/switching-models\",\"name\":\"How to Switch Between Different Models\",\"description\":\"Switch models and supported providers within one agent session while preserving message and tool-call history.\",\"dateModified\":\"2026-07-19T00:40:02.280Z\",\"isPartOf\":{\"@id\":\"https://agno-v2.mintlify.app#website\"},\"breadcrumb\":{\"@id\":\"https://agno-v2.mintlify.app/faq/switching-models#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://agno-v2.mintlify.app/faq/switching-models#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"FAQs\",\"item\":\"https://agno-v2.mintlify.app/faq/environment-variables\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"How to Switch Between Different Models\",\"item\":\"https://agno-v2.mintlify.app/faq/switching-models\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://agno-v2.mintlify.app/faq/switching-models#article\",\"headline\":\"How to Switch Between Different Models\",\"name\":\"How to Switch Between Different Models\",\"description\":\"Switch models and supported providers within one agent session while preserving message and tool-call history.\",\"url\":\"https://agno-v2.mintlify.app/faq/switching-models\",\"mainEntityOfPage\":{\"@id\":\"https://agno-v2.mintlify.app/faq/switching-models#webpage\"},\"dateModified\":\"2026-07-19T00:40:02.280Z\",\"publisher\":{\"@id\":\"https://agno-v2.mintlify.app/#organization\"},\"isPartOf\":{\"@id\":\"https://agno-v2.mintlify.app#website\"}}]}\u003c/script>\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@type\":\"WebSite\",\"name\":\"Agno\",\"publisher\":{\"@type\":\"Organization\",\"name\":\"Agno\"},\"provider\":{\"@type\":\"Organization\",\"name\":\"Mintlify\",\"url\":\"https://mintlify.com\"}}\u003c/script>","agentPointerHref":"/faq/switching-models.md","siteName":"Agno","nav":{"global":null,"tabs":[{"tab":"Home","pages":[{"title":"Home","href":""}]},{"tab":"SDK","pages":[{"title":"SDK","href":"/sdk/introduction"}]},{"tab":"AgentOS","pages":[{"title":"AgentOS","href":"/agent-os/introduction"}]},{"tab":"Templates","pages":[{"title":"Templates","href":"/deploy/introduction"}]},{"tab":"Examples","pages":[{"title":"Examples","href":"/examples/introduction"}]},{"tab":"Reference","pages":[{"title":"Reference","href":"/reference/agents/agent"}]},{"tab":"FAQs","groups":[{"group":"FAQs","pages":[{"title":"Environment Variables","sidebarTitle":"Environment Variables","href":"/faq/environment-variables"},{"title":"ImportError - Missing Dependencies","sidebarTitle":"Import Errors","href":"/faq/import-errors"},{"title":"Why does my agent use gpt-5.4?","sidebarTitle":"Default Model","href":"/faq/default-model"},{"title":"OpenAI Key Request While Using Other Models","sidebarTitle":"OpenAI Key Request While Using Other Models","description":"Agno defaults to OpenAI for models and embedders. Set both explicitly to remove the OPENAI_API_KEY requirement.","href":"/faq/openai-key-request-for-other-models"},{"title":"How to Switch Between Different Models","sidebarTitle":"Switching Models","href":"/faq/switching-models"},{"title":"Structured outputs","sidebarTitle":"Structured outputs","description":"Structured Outputs vs JSON mode: how Agno enforces output_schema and when to fall back to use_json_mode.","href":"/faq/structured-outputs"},{"title":"Tokens-per-minute rate limiting","sidebarTitle":"TPM rate limiting","href":"/faq/tpm-issues"},{"title":"When to use a Workflow vs a Team","sidebarTitle":"Workflow vs Team","href":"/faq/workflow-vs-team"},{"title":"Where does the agno command come from?","sidebarTitle":"The agno CLI","href":"/faq/agno-cli"},{"title":"AgentOS Connection Issues","sidebarTitle":"AgentOS Connection Issues","href":"/faq/agentos-connection"},{"title":"Authorization Failed - JWT Verification","sidebarTitle":"Authorization Failed - JWT Verification","href":"/faq/rbac-auth-failed"},{"title":"Connecting to TablePlus","sidebarTitle":"Connecting to TablePlus","href":"/faq/connecting-to-tableplus"},{"title":"Could Not Connect To Docker","sidebarTitle":"Docker Connection Error","href":"/faq/could-not-connect-to-docker"}]}]}]},"basePath":"","title":"How to Switch Between Different Models - Agno","deploymentId":"dpl_72MSwyBnA59N55RmMByBKiJ6RWpG","buildId":"dpl_72MSwyBnA59N55RmMByBKiJ6RWpG","dynamics":[],"chunks":[]}