エラーと拒否/モデルの拒否
モデルの拒否を検出する
Claude モデルが拒否した場合、Wokey は Anthropic の拒否内容をそのまま転送します。下流のプラットフォームは以下のフィールドで拒否を検出し、独自のリスク管理を適用できます。
このページの内容expand_more
概要link
- 拒否はエラーステータスではなく HTTP 200 で返ります。レスポンス内のフィールドで検出してください。
- 拒否の理由はレスポンスの最後に届きます。ストリームでは、拒否の前に送られた内容は取り消されません。
- Wokey は拒否の内容を書き換えません。文言は Anthropic によるものです。
API 形式ごとの検出方法link
Anthropic Messages /v1/messages
検出条件 stop_reason == "refusal"
カテゴリは stop_details.category に、理由は stop_details.explanation に入ります。ストリームでは最後の message_delta イベントに、非ストリーミングのレスポンスではメッセージのトップレベルに含まれます。
SSE
event: message_delta
data: {"type":"message_delta","delta":{"stop_reason":"refusal","stop_sequence":null,"stop_details":{"type":"refusal","category":"cyber","explanation":"This request triggered ..."}},"usage":{...}}
event: message_stop
data: {"type":"message_stop"}OpenAI Chat Completions /v1/chat/completions
検出条件 finish_reason == "content_filter"
理由は refusal フィールドに入ります。ストリームでは最後のチャンクの choices[0].delta.refusal、非ストリーミングでは choices[0].message.refusal で、このとき message.content は null です。この形式にはカテゴリがありません。
SSE
data: {"object":"chat.completion.chunk","choices":[{"index":0,"delta":{"refusal":"This request triggered ..."},"finish_reason":"content_filter"}],"usage":{...}}
data: [DONE]OpenAI Responses /v1/responses
検出条件 output に type が "refusal" の content part が含まれる
理由はその part の refusal フィールドに入ります。ストリームでは response.refusal.delta と response.refusal.done イベントが送られ、output_text は空文字列になります。この形式にはカテゴリがありません。
SSE
event: response.refusal.done
data: {"type":"response.refusal.done","item_id":"msg_...","output_index":0,"content_index":0,"refusal":"This request triggered ..."}拒否のカテゴリと文言link
| category | 意味 | explanation(原文) |
|---|---|---|
| reasoning_extraction | 利用規約:モデル出力のリバースエンジニアリングや複製(蒸留) | This request was blocked as it seems to violate Anthropic's Terms of Service restrictions on reverse engineering or duplicating model outputs. To learn more, visit https://www.anthropic.com/legal/commercial-terms. |
| frontier_llm | 利用規約:競合するモデル製品の開発 | This request was blocked as our automated systems flagged that it may violate Anthropic's Terms of Service restrictions on developing competing model products. To learn more, visit https://www.anthropic.com/legal/commercial-terms. |
| cyber | サイバー関連コンテンツ(Opus 5 以降、Fable、Sonnet 5.5) | This request triggered restrictions on violative cyber content and was blocked under Anthropic's Usage Policy. To learn more, see https://platform.claude.com/docs/en/build-with-claude/refusals-and-fallback. |
| cyber | サイバー関連コンテンツ(Opus 4.x、Sonnet 5、Haiku 5.5) | This request triggered cyber-related safeguards. To learn about the Cyber Verification Program and apply for access, visit our help center: https://support.claude.com/en/articles/14604842-real-time-cyber-safeguards-on-claude. |
| general_harms | 爆発物など、一般的な危害 | This request triggered restrictions on content related to the development of high-yield explosives and was blocked under Anthropic's Usage Policy. To learn more, provide feedback, or request an exemption based on how you use Claude, visit our help center: https://support.claude.com/ |
| bio, others | 生物学関連など、アップストリームが理由を示さないコンテンツ | Anthropic 形式では explanation フィールドがありません。OpenAI 形式では "The upstream model refused this request." が返ります |
注意事項link
- 文言は Anthropic が作成しており、いつでも変更される可能性があります。正確なテキストの照合ではなく、検出用のフィールドと category を使ってください。
- OpenAI 形式には category がありません。拒否を分類するには、上記の文言と照合してください。