標題
名稱
|
必要
|
說明
|
Authorization |
是
|
用於驗證的持有者令牌。
|
查詢參數
名稱
|
必要
|
說明
|
detailedResponse |
否
|
API 回應的詳細程度。
可能的值包括:
|
請求
OpenAI 聊天完成請求格式:
{ "model": "us.meta.llama3-1-70b-instruct-v1:0", "messages": [ { "role": "user", "content": "Your prompt text here" } ] }
OpenAI 聊天完成回應格式:
{ "id": "chatcmpl-8f88f71a-7d42-c548-d587-8fc8a17091b6", "object": "chat.completion", "created": 1748535080, "model": "us.meta.llama3-1-70b-instruct-v1:0", "choices": [ { "index": 0, "message": { "role": "assistant", "content": "Response content here", "refusal": null }, "finish_reason": "stop" } ], "usage": { "prompt_tokens": 139, "completion_tokens": 97, "total_tokens": 236 } }
簡單字串格式:
{ "guard": "Your prompt text here" }
回應
範例回應(當
detailedResponse: false
):{ "id": "1234567890abcdef", "action": "Block", "reason": "[Violation] Policy Name: harmful_content" }
範例回應(當
detailedResponse: true
):{ "id": "1234567890abcdef", "action": "Allow", "reason": "No policy violations detected", "harmful_content": [ { "name": "harmful_content", "content_violation": false, "confidence_score": 0.05 } ], "sensitive_information": { "content_violation": false, "rule": "" }, "prompt_attack": [ { "name": "prompt_injection", "content_violation": false, "confidence_score": 0.02 } ] }
參數
|
說明
|
id |
AI Guard 評估的唯一識別碼。
|
action |
建議的操作。
可能的值包括:
|
reason |
該操作的說明,包括設定違規詳情。
|
harmful_content |
在輸入或輸出中檢測到的任何有害內容,附帶信心分數。
|
sensitive_information |
任何與個人識別信息 (PII) 或敏感信息相關的違規檢測。
|
prompt_attack |
檢測到的任何提示攻擊的陣列,附有信心水準分數。
|
常見錯誤
API 返回標準 HTTP 狀態碼:
-
400
錯誤請求:請檢查錯誤訊息以獲取詳細資訊 -
403
禁止:用戶權限不足或驗證問題 -
429
請求過多:超出速率限制 -
500
內部伺服器錯誤:伺服器端發生暫時性問題