query() offers two model-selection modes:
- Fixed model (default): the entire session uses one model.
- Dynamic selection: a callback is called before every LLM request to return the model. You can route by purpose (main conversation, sub-agent, context compaction, etc.) or return a BYOK credential to use your own API key.
Fixed model
Specify it via the model option; omit to use the account default:Dynamic selection
Provide a callback function that is invoked before every LLM request:Routing by purpose
Use a different model per purpose:Returning model parameters
Returnparameters with the selected model to override the context window and thinking depth for that LLM request. These keys are camelCase at the SDK control boundary:
context.availableModels through ModelInfo.context_config and ModelInfo.thinking_config.