You'll noticeTier: how much it should matter to you
1Useful: my rating, 1 to 5
1Signal: worth watching, 1 to 5
SDKArea: what it touches
Internal ChangesKind: in v2.1.281,
ImprovementsSection of the release
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")
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.
Read from
Names in the bundleset_model
Since it was published
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.
Added sinceA small documentation edit on Agent SDK reference - Python touched a line naming set_model after this was published.| `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/pythonsee the edit
Confirmed sinceAnthropic's documentation has since written up set_model, on Claude Code changelog.* Fixed switching models mid-session with a `set_model` request (such as the Agent SDK's `setModel`) leaving the new model on the built-in output-token limit and auto-compact window until restartchangelogsee the edit
How sure we are
One source agreesOne thing we can check says the same as this entry.
Anthropic's documentation agreesAnthropic's documentation has since written up set_model, on Claude Code changelog.