What
set_model is a control request, a message an app built on the Claude Code SDK sends to change the model during a session. When it rejects bad input, its error now includes code: "invalid_request" next to the existing error message. This covers:
- a model value that is not a string ("set_model: model must be a string")
- an empty
system_prompt("set_model: system_prompt must be a non-empty string when present")
Before, these errors had only ok and error.
Why
Apps that talk to Claude Code can check a fixed code to spot bad input, instead of matching the wording of the error message, which may change.
The entry above is what we published on the day. These lines were added later, as Anthropic's own pages caught up, and they sit beside the original rather than replacing it.
| `set_model(model)` | Change the model for the current session. Pass `None` to reset to [Claude Code's default model](/docs/en/model-config). A session in `auto` mode [changes to `default` mode](/docs/en/agent-sdk/permissions#auto-mode-au…agent-sdk/python see the edit
| `set_model(model)` | Change the model for the current session. Pass `None` to reset to [Claude Code's default model](/docs/en/model-config) |agent-sdk/python see the edit
Anthropic's documentation has since written up set_model, on Agent SDK reference - Python.