翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。
モデルから検証済みの JSON 結果を取得する
構造化出力は Amazon Bedrock の機能であり、モデルレスポンスがユーザー定義の JSON スキーマとツール定義に準拠し、本番 AI デプロイでのカスタム解析および検証メカニズムの必要性が軽減されます。
利点
構造化出力は、本番稼働用 AI アプリケーションの重要な課題に対処します。
-
スキーマのコンプライアンスを確保 — プロンプトベースのアプローチからエラー率と再試行ループを排除
-
開発の複雑さの軽減 – カスタム解析および検証ロジックが不要
-
運用コストの削減 – 失敗したリクエストと再試行を削減
-
本番稼働の信頼性 – 予測可能で機械読み取り可能な出力を必要とする AI アプリケーションの確実なデプロイを可能にします。
仕組み
構造化出力は、特定のスキーマに従うようにモデルレスポンスを制限し、ダウンストリーム処理のために有効で解析可能な出力を確保します。構造化出力は、次の 2 つの補完的なメカニズムを通じて使用できます。
JSON スキーマ出力形式
Anthropic Claude モデルを使用した InvokeModel API の場合は、 output_config.formatリクエストフィールドを使用します。オープンウェイトモデルでは、 response_formatリクエストフィールドを使用します。Converse APIs、 outputConfig.textFormatリクエストフィールドを使用します。モデルのレスポンスは、指定された JSON スキーマに準拠します。
厳格なツールの使用
ツール定義に strict: trueフラグを追加して、ツール名と入力のスキーマ検証を有効にします。その後、モデルのツール呼び出しは、定義されたツール入力スキーマに従います。
これらのメカニズムは、個別に使用することも、同じリクエストで一緒に使用することもできます。詳細については、Bedrock API ドキュメントを参照してください。
リクエストワークフロー
以下に、Amazon Bedrock が構造化された出力でリクエストを処理する方法について説明します。
-
初期リクエスト –
outputConfig.textFormat、、またはresponse_formatパラメータを介して JSON スキーマを含めるかoutput_config.format、推論リクエストにstrict: trueフラグを持つツール定義を含めます。 -
スキーマの検証 – Amazon Bedrock は、サポートされている JSON Schema Draft 2020-12 サブセットに対して JSON スキーマ形式を検証します。スキーマにサポートされていない機能が含まれている場合、Amazon Bedrock はすぐに 400 エラーを返します。
-
初回コンパイル – 新しいスキーマの場合、Amazon Bedrock は文法をコンパイルします。これには数分かかる場合があります。
-
キャッシュ — 正常にコンパイルされた文法は、最初のアクセスから 24 時間キャッシュされます。キャッシュされた文法は AWS が管理するキーで暗号化されます。
-
後続のリクエスト – 同じアカウントからの同じスキーマはキャッシュされた文法を使用するため、オーバーヘッドを最小限に抑えながら、推論レイテンシーは標準リクエストと同等になります。
-
レスポンス – 厳密なスキーマコンプライアンスで標準の推論レスポンスを受け取ります。
サポートされている APIsまたは機能
構造化出力は、次の Amazon Bedrock 機能で使用できます。
Converse および ConverseStream APIs – Converse および ConverseStream APIs で構造化された出力を使用して会話推論を行います。
InvokeModel API と InvokeModelWithResponseStream APIs シングルターン推論にはInvokeModel API と InvokeModelWithResponseStream APIs で構造化出力を使用します。
クロスリージョン推論 – 追加セットアップなしで、クロスリージョン推論内で構造化出力を使用します。
バッチ推論 – 追加のセットアップなしで、バッチ推論内で構造化出力を使用します。
注記
構造化出力は、Anthropic モデルの引用と互換性がありません。構造化出力の使用中に引用を有効にすると、モデルは 400 エラーを返します。
サポートされているモデル
構造化出力は、一部の Amazon Bedrock サーバーレスモデルのすべての商用 AWS リージョンで一般利用可能です。サポートされているモデルのリストについては、「機能別のモデルサポート」を参照してください。
- Anthropic
-
Claude Haiku 4.5 (
anthropic.claude-haiku-4-5-20251001-v1:0)Claude Sonnet 4.5 (
anthropic.claude-sonnet-4-5-20250929-v1:0)Claude Opus 4.5 (
anthropic.claude-opus-4-5-20251101-v1:0)Claude Opus 4.6 (
anthropic.claude-opus-4-6-v1)
- Qwen
-
Qwen3 235B A22B 2507 (
qwen.qwen3-235b-a22b-2507-v1:0)Qwen3 32B (高密度) (
qwen.qwen3-32b-v1:0)Qwen3-Coder-30B-A3B-Instruct (
qwen.qwen3-coder-30b-a3b-v1:0)Qwen3 Coder 480B A35B 指示 (
qwen.qwen3-coder-480b-a35b-v1:0)Qwen3 Next 80B A3B (
qwen.qwen3-next-80b-a3b)Qwen3 VL 235B A22B (
qwen.qwen3-vl-235b-a22b)
- OpenAI
-
gpt-oss-120b (
openai.gpt-oss-120b-1:0)gpt-oss-20b (
openai.gpt-oss-20b-1:0)GPT OSS セーフガード 120B (
openai.gpt-oss-safeguard-120b)GPT OSS セーフガード 20B (
openai.gpt-oss-safeguard-20b)
- DeepSeek
-
DeepSeek-V3.1 (
deepseek.v3-v1:0)
-
Gemma 3 12B IT (
google.gemma-3-12b-it)Gemma 3 27B PT (
google.gemma-3-27b-it)
- MiniMax
-
MiniMax M2 (
minimax.minimax-m2)
- Mistral AI
-
Magistral Small 2509 (
mistral.magistral-small-2509)最小 3B (
mistral.ministral-3-3b-instruct)ミニストラル 3 8B (
mistral.ministral-3-8b-instruct)最小 14B 3.0 (
mistral.ministral-3-14b-instruct)Mistral Large 3 (
mistral.mistral-large-3-675b-instruct)Voxtral Mini 3B 2507 (
mistral.voxtral-mini-3b-2507)Voxtral Small 24B 2507 (
mistral.voxtral-small-24b-2507)
- ムーンショット AI
-
Kimi K2 思考 (
moonshot.kimi-k2-thinking)
- NVIDIA
-
NVIDIA Nemotron Nano 12B v2 VL BF16 (
nvidia.nemotron-nano-12b-v2)NVIDIA Nemotron Nano 9B v2 (
nvidia.nemotron-nano-9b-v2)
リクエストの例
JSON スキーマ出力形式
次の例は、構造化出力で JSON スキーマ出力形式を使用する方法を示しています。
Converse API
{ "messages": [ { "role": "user", "content": [ { "text": "Given the following unstructured data, extract it into the provided structure." }, { "text": "..." } ] } ], "outputConfig": { "textFormat": { "type": "json_schema", "structure": { "jsonSchema": { "schema": "{\"type\": \"object\", \"properties\": {\"title\": {\"type\": \"string\", \"description\": \"title\"}, \"summary\": {\"type\": \"string\", \"description\": \"summary\"}, \"next_steps\": {\"type\": \"string\", \"description\": \"next steps\"}}, \"required\": [\"title\", \"summary\", \"next_steps\"], \"additionalProperties\": false}", "name": "data_extraction", "description": "Extract structured data from unstructured text" } } } } }
InvokeModel (Anthropic Claude)
{ "anthropic_version": "bedrock-2023-05-31", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "Given the following unstructured data, extract it into the provided structure." }, { "type": "text", "text": "..." } ] } ], "max_tokens": 3000, "temperature": 1.0, "output_config": { "format": { "type": "json_schema", "schema": { "type": "object", "properties": { "title": { "type": "string", "description": "title" }, "summary": { "type": "string", "description": "summary" }, "next_steps": { "type": "string", "description": "next steps" } }, "required": [ "title", "summary", "next_steps" ], "additionalProperties": false } } } }
InvokeModel (オープンウェイトモデル)
{ "messages": [ { "role": "user", "content": "Given the following unstructured data, extract it into the provided structure." }, { "role": "user", "content": "..." } ], "inferenceConfig": { "maxTokens": 3000, "temperature": 1.0 }, "response_format": { "json_schema": { "name": "summarizer", "schema": { "type": "object", "properties": { "title": { "type": "string", "description": "title" }, "summary": { "type": "string", "description": "summary" }, "next_steps": { "type": "string", "description": "next steps" } }, "required": [ "title", "summary", "next_steps" ], "additionalProperties": false } }, "type": "json_schema" } }
厳格なツールの使用
次の例は、ツールで strict フィールドを使用する方法を示しています。
Converse API
{ "messages": [ { "role": "user", "content": [ { "text": "What's the weather like in New York?" } ] } ], "toolConfig": { "tools": [ { "toolSpec": { "name": "get_weather", "description": "Get the current weather for a specified location", "strict": true, "inputSchema": { "json": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": [ "fahrenheit", "celsius" ], "description": "The temperature unit to use" } }, "required": [ "location", "unit" ] } } } } ] } }
InvokeModel (Anthropic Claude)
{ "anthropic_version": "bedrock-2023-05-31", "messages": [ { "role": "user", "content": [ { "type": "text", "text": "What's the weather like in San Francisco?" } ] } ], "max_tokens": 3000, "temperature": 1.0, "tools": [ { "name": "get_weather", "description": "Get the current weather for a specified location", "strict": true, "input_schema": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": [ "fahrenheit", "celsius" ], "description": "The temperature unit to use" } }, "required": [ "location", "unit" ], "additionalProperties": false } } ] }
InvokeModel (オープンウェイトモデル)
{ "messages": [ { "role": "user", "content": "What's the weather like in San Francisco?" } ], "tools": [ { "type": "function", "function": { "name": "get_weather", "description": "Get the current weather for a specified location", "strict": true, "parameters": { "type": "object", "properties": { "location": { "type": "string", "description": "The city and state, e.g. San Francisco, CA" }, "unit": { "type": "string", "enum": [ "fahrenheit", "celsius" ], "description": "The temperature unit to use" } }, "required": [ "location", "unit" ] } } } ], "tool_choice": "auto", "max_tokens": 2000, "temperature": 1.0 }