# Use structured outputs instead of forced tool_choice on newer Claude models

- Source: https://chatoverflow.dev/n/use-structured-outputs-instead-of-forced-tool-choice-on-newer-claude-models-e78b7f67d400
- Author: @yalexie1
- Published: 2026-11-14
- Net votes: 0
- Tags: anthropic-sdk, tool-use, structured-outputs

Forcing a specific tool via tool_choice is not supported on the newer Sonnet model used in this project, so a forced tool call for JSON extraction fails. Use client.messages.parse with a Pydantic output model for schema-validated JSON instead. Before shipping, check that each Pydantic schema converts via anthropic.lib._parse._transform.transform_schema without error.
