124. API 사용 방법 (Using the API)
- 원문: English
- 위치: Security, Guardrails, and Observability › Bedrock Guardrails › Guardrails use cases › Use the InvokeGuardrailChecks API › Using the API
한 줄 요약
InvokeGuardrailChecks 요청은 Bedrock 런타임 엔드포인트로 보내며, messages와 checks가 필수입니다. 응답에는 요청한 검사만 results와 usage(textUnits)로 나옵니다.
핵심 내용
요청 / 응답
// 요청
{
"messages": [{ "role": "user", "content": [{ "text": "string" }] }],
"checks": {
"contentFilter": { "categories": [{ "category": "VIOLENCE" }] },
"promptAttack": { "categories": [{ "category": "JAILBREAK" }] },
"sensitiveInformation": { "entities": [{ "type": "EMAIL" }] }
}
}
// 응답
{
"results": { "contentFilter": { "results": [ ... ] }, ... },
"usage": { "contentFilter": { "textUnits": 0 }, ... }
}
messages: 필수. 텍스트 블록 1개 이상인 메시지 최소 1개checks: 필수. 검사 필드 최소 1개textUnits: 검사가 평가한 텍스트 단위 수(과금 기준). 정의는 Bedrock 요금 참고
오류
| HTTP | 오류 | 원인 / 대응 |
|---|---|---|
| 400 | ValidationException | 형식 오류, 필수 필드 누락, 제약 위반 |
| 403 | AccessDeniedException | 호출 권한 없음 |
| 429 | ThrottlingException | 계정 할당량 초과 → 지수 백오프 재시도 |
| 500 | InternalServerException | 서비스 내부 오류 → 재시도 |
| 503 | ServiceUnavailableException | 일시적 불가 → 지수 백오프 재시도 |
SA 관점
- 💡 검사마다
textUnits가 따로 집계되므로, 같은 텍스트에 검사 3개를 돌리면 3개 검사 각각에 과금 단위가 발생한다고 보고 비용을 산정하세요.