가드레일 공급자: Aim Security
가드레일 공급자: Aim Security
출처: 문서
본문
빠른 시작 (Quick Start)
1. 새 Aim Guard 만들기
Aim Application으로 가서 새 guard를 만드세요.
프롬프트가 뜨면 API 옵션을 선택하고 guard 이름을 정하세요.
note
guard를 온프레미스로 호스팅하고 싶다면, guard를 만들기 전에 Aim Outpost를 설치해 이 옵션을 활성화할 수 있어요.
2. Aim Guard 정책 구성
새로 만든 guard의 페이지에서 이 guard의 프롬프트 정책 센터에 대한 참조를 찾을 수 있어요.
어떤 탐지를 활성화할지 결정하고 각 탐지의 임계값을 설정할 수 있어요.
info
LiteLLM을 가상 키와 함께 사용할 때, guard를 만들 때 가상 키 별칭을 지정해 키별 정책을 Aim의 guards 페이지에서 직접 설정할 수 있어요. 가상 키의 별칭만(실제 키 시크릿은 아님) Aim으로 보내져요.
3. LiteLLM config.yaml에 Aim guardrail 추가
guardrails 섹션 아래에 guardrail을 정의하세요.
model_list:
- model_name: gpt-5.6-luna
litellm_params:
model: openai/gpt-5.6-luna
api_key: os.environ/OPENAI_API_KEY
guardrails:
- guardrail_name: aim-protected-app
litellm_params:
guardrail: aim
mode: [pre_call, post_call] # "During_call" is also available
api_key: os.environ/AIM_API_KEY
api_base: os.environ/AIM_API_BASE # Optional, use only when using a self-hosted Aim Outpost
ssl_verify: False # Optional, set to False to disable SSL verification or a string path to a custom CA bundle
inspect_embeddings: false # Optional, set to true to inspect /embeddings input
api_key 아래에 발급받은 API 키를 넣으세요. 키는 guard의 페이지에서 찾을 수 있어요. AIM_API_KEY를 환경 변수로도 설정할 수 있어요.
기본적으로 api_base는 https://api.aim.security로 설정돼요. 자체 호스팅 Aim Outpost를 사용한다면 api_base를 Outpost URL로 설정할 수 있어요.
4. LiteLLM 게이트웨이 시작
litellm --config config.yaml
5. 첫 요청 보내기
note
다음 예시는 guard에서 PII 탐지를 활성화하는 것에 달려 있어요. 다른 guard 정책과 일치하도록 요청 콘텐츠를 조정할 수 있어요.
차단된 요청 예시:
note
LiteLLM을 가상 키와 함께 사용할 때는 가상 키가 있는 Authorization 헤더가 필요해요.
curl -i http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-luna",
"messages": [
{"role": "user", "content": "hi my email is [email protected]"}
],
"guardrails": ["aim-protected-app"]
}'
올바르게 구성했다면, [email protected]가 Aim Guard에 의해 PII로 감지되므로 400 Bad Request 상태 코드와 함께 다음과 유사한 응답을 받게 돼요:
{
"error": {
"message": "\"[email protected]\" detected as email",
"type": "None",
"param": "None",
"code": "400"
}
}
허용된 요청 예시:
note
LiteLLM을 가상 키와 함께 사용할 때는 가상 키가 있는 Authorization 헤더가 필요해요.
curl -i http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.6-luna",
"messages": [
{"role": "user", "content": "hi what is the weather"}
],
"guardrails": ["aim-protected-app"]
}'
위 요청은 차단되지 않아야 하고, 일반적인 LLM 응답을 받아야 해요 (간결히 단순화):
{
"model": "gpt-5.6-luna",
"choices": [
{
"finish_reason": "stop",
"index": 0,
"message": {
"content": "I can’t provide live weather updates without the internet. Let me know if you’d like general weather trends for a location and season instead!",
"role": "assistant"
}
}
]
}
고급 (Advanced)
Aim Guard는 사용자별 가드레일 정책을 제공하여 개별 사용자에게 맞춤 정책을 적용할 수 있게 해줘요. 이 기능을 사용하려면 x-aim-user-email 헤더를 설정해 요청 페이로드에 최종 사용자의 이메일을 포함하세요.
curl -i http://localhost:4000/v1/chat/completions \
-H "Content-Type: application/json" \
-H "x-aim-user-email: [email protected]" \
-d '{
"model": "gpt-5.6-luna",
"messages": [
{"role": "user", "content": "hi what is the weather"}
],
"guardrails": ["aim-protected-app"]
}'