Skip to content

Claude API 400 tool_choice: type "tool" and "any" are not supported for this model の原因と解決策 ​

強制ツール呼び出しに対応していないモデルに対して tool_choice: {"type": "any"} や tool_choice: {"type": "tool", "name": "..."} を指定すると、POST /v1/messages(およびトークン計測エンドポイント)は HTTP 400 invalid_request_error を返します。

最短の結論

Claude Fable 5.2、Claude Mythos 5.2、Claude Opus 5.5、Claude Sonnet 5.5、Claude Fable 5.1、Claude Mythos 5.1 では強制ツール呼び出し(tool_choice の type が "any" または "tool")が拒否されます。tool_choice を {"type": "auto"} に変更(または省略)し、ツール定義に "strict": true(および input_schema 内の additionalProperties: false と required)を設定したうえで、system プロンプトで呼び出すツール名を明示してください。JSON 抽出目的だけでツール呼び出しを強制していた場合は、構造化出力(output_config.format)へ切り替えます。

最終確認日:2026-11-14(Anthropic API Errors — Common validation errors に基づく)。

エラーメッセージと症状 ​

対象モデル(トークン計測エンドポイントを含む)に tool_choice: {"type": "any"} または tool_choice: {"type": "tool", "name": "..."} を送ると、次のメッセージで HTTP 400 が返されます。

text
tool_choice: type "tool" and "any" are not supported for this model.

レスポンス JSON 全体:

json
{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "tool_choice: type \"tool\" and \"any\" are not supported for this model."
  }
}

モデル更新時に同時に遭遇しやすい他の 400 バリデーションエラー:

対象モデルと対応状況 ​

モデル強制ツール呼び出し("any"、"tool")指定可能な tool_choice
Claude Fable 5.2非対応(400)"auto"(既定)、"none"
Claude Mythos 5.2非対応(400)"auto"(既定)、"none"
Claude Opus 5.5(claude-opus-5-5)非対応(400)"auto"(既定)、"none"
Claude Sonnet 5.5(claude-sonnet-5-5)非対応(400)"auto"(既定)、"none"
Claude Fable 5.1非対応(400)"auto"(既定)、"none"
Claude Mythos 5.1非対応(400)"auto"(既定)、"none"
以前のモデル(claude-opus-5、claude-opus-4-8、claude-sonnet-5 など)対応"auto"、"any"、"tool"、"none"

発生する主な原因 ​

  1. モデル ID のみの差し替え: claude-opus-5、claude-opus-4-8、claude-sonnet-5 向けに書かれた既存コードで {"type": "tool", "name": "..."} が動いていたものの、モデル文字列を claude-opus-5-5 や claude-sonnet-5-5 に更新した直後から HTTP 400 で失敗するケース。
  2. 構造化 JSON 抽出のためのダミーツール利用: スキーマ通りの JSON を返させる目的で単一ツールを定義し、"type": "tool" を強制していた従来の実装パターン。
  3. トークン計測リクエストでのボディ使い回し: 本番リクエストと同じ tool_choice をトークン計測エンドポイントに渡して同じ検証エラーを踏むケース。

対処 1:tool_choice: {"type": "auto"} と Strict Tool Use を組み合わせる ​

tool_choice を {"type": "auto"} に変更(またはフィールドごと省略)し、ツール引数がスキーマに厳密準拠するよう Strict Tool Use を有効化したうえで、system プロンプトに対象ツールの呼び出し指示を明記します。

Strict Tool Use の設定ポイント:

  • ツール定義のトップレベル(name、description、input_schema と同じ階層)に "strict": true を追加する。
  • input_schema 内に "additionalProperties": false と "required" を含める。

失敗するリクエスト(POST /v1/messages) ​

json
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather for a city.",
      "input_schema": {
        "type": "object",
        "properties": {
          "city": { "type": "string" }
        },
        "required": ["city"]
      }
    }
  ],
  "tool_choice": {
    "type": "tool",
    "name": "get_weather"
  },
  "messages": [
    {
      "role": "user",
      "content": "What is the weather in Tokyo?"
    }
  ]
}

修正後のリクエスト(POST /v1/messages) ​

json
{
  "model": "claude-sonnet-5-5",
  "max_tokens": 1024,
  "system": "Always call the get_weather tool to answer weather questions.",
  "tools": [
    {
      "name": "get_weather",
      "description": "Get the current weather for a city.",
      "strict": true,
      "input_schema": {
        "type": "object",
        "properties": {
          "city": { "type": "string" }
        },
        "required": ["city"],
        "additionalProperties": false
      }
    }
  ],
  "tool_choice": {
    "type": "auto"
  },
  "messages": [
    {
      "role": "user",
      "content": "What is the weather in Tokyo?"
    }
  ]
}

対処 2:固定 JSON が欲しいだけなら構造化出力(output_config.format)を使う ​

Anthropic 公式ドキュメントの案内どおり、最終レスポンスを特定の JSON 形式で受け取るためだけにツール呼び出しを強制していた場合は、tools + tool_choice ではなく output_config.format による構造化出力へ移行してください(具体的な JSON 例は assistant prefill 解決ガイド を参照)。

API ゲートウェイ経由で呼び出す場合 ​

この HTTP 400 はアップストリーム API のリクエスト検証で発生し、byesu(サブスク不要・従量課金)などの AI API ゲートウェイはエラー内容をそのまま透過返却します。直接呼び出す場合でも https://byesu.com 経由で claude-opus-5-5 や claude-sonnet-5-5 を呼び出す場合でも、"tool" や "any" を {"type": "auto"} または {"type": "none"} に置き換えてください。その他のトラブルは よくあるエラー一覧、prompt is too long 解決ガイド、Claude Code ベース URL エラー を参照してください。

よくある質問 ​

tool_choice の "tool" と "any" が拒否される Claude モデルはどれですか? ​

Claude Fable 5.2、Claude Mythos 5.2、Claude Opus 5.5、Claude Sonnet 5.5、Claude Fable 5.1、および Claude Mythos 5.1 では強制ツール呼び出しがサポートされておらず、type に "tool" または "any" を指定すると HTTP 400 invalid_request_error が返されます。

Claude Opus 5.5 と Sonnet 5.5 で指定できる tool_choice の値は何ですか? ​

これらのモデルで受け付けられるのは {"type": "auto"}(既定値)と {"type": "none"} のみです。tool_choice 自体を省略してデフォルトの "auto" 挙動に任せることもできます。

強制ツール呼び出しなしで確実にツール実行や JSON 取得を行うには? ​

tool_choice を {"type": "auto"} に設定したうえで、Strict Tool Use(ツール定義に "strict": true、input_schema に additionalProperties: false と required を指定)を有効化し、system プロンプトで呼び出すべきツール名を明示します。固定フォーマットの JSON を得る目的だけでダミーツールを強制していた場合は、output_config.format による構造化出力へ移行してください。

トークン計測エンドポイント(count_tokens)でも同じ 400 エラーになりますか? ​

はい。対象モデルに対してトークン計測エンドポイントへ {"type": "any"} や {"type": "tool", "name": "..."} を送信した場合も、まったく同じ HTTP 400 invalid_request_error が返されます。

お困りですか?サポートへご連絡、またはグループにご参加ください。