본문으로 바로가기 본문 바로가기
WIKI 기술 지식 베이스

AI 정책

원문 보기 위키 갱신

AI 정책 (AI Policies)

AI Gateway 트래픽에 거버넌스, 보안, 변환, 관찰 가능성을 더하고 싶을 때 AI Policy를 만들면 돼요. 민감 정보 마스킹, 요청량 제한, 프롬프트 검증, 로깅 같은 작업을 정책 하나로 구성할 수 있고요. AI Policy는 Konnect UI, AI Gateway API, kongctl로 관리하며, 데이터 플레인 전체에 적용되는 전역 스코프와 AI Model·AI Agent 같은 엔티티에 적용되는 엔티티 스코프 중 정확히 한 곳에만 설정돼요. 문서 후반부에는 AI PII Sanitizer를 전역 정책으로 설정하는 예시와 스키마, FAQ도 함께 확인할 수 있어요

출처: 문서

본문

AI Policy란 무엇인가요?

AI Gateway 트래픽에 거버넌스, 보안, 변환, 또는 관측성을 추가하고 싶을 때 AI Policy를 만드세요. 예를 들면 다음과 같아요:

액세스를 제어하고 신원을 확인하려면 AI Policy 대신 AI Auth Strategy를 할당하세요.

사용 가능한 policy 유형과 구성의 전체 목록은 AI Policies hub를 참고하세요.

AI Policy 관리

AI Policy는 다음을 통해 관리해요:

  • Konnect UI
  • AI Gateway API: /v1/ai-gateways/{aiGatewayId}/policies
  • kongctl

구성 예시와 단계별 설정 지침은 글로벌 AI Policy 설정하기를 참고하세요.

AI Policy 스코프

각 AI Policy는 정확히 하나의 스코프에 적용되는 독립적인 구성이에요.

사용 가능한 스코프는 다음과 같아요:

  • Global: 부모 엔티티 참조가 없는 AI Policy는 데이터 플레인의 모든 AI Gateway 트래픽에 적용돼요. 같은 데이터 플레인의 AI가 아닌 트래픽은 영향을 받지 않아요.

  • Entity-scoped: AI Model, AI Agent, AI MCP Server, AI Consumer, 또는 AI Consumer Group 엔티티의 policies 배열에서 policy를 참조하세요. policy는 해당 엔티티의 스코프에 적용돼요.

동일한 구성을 여러 곳에 적용하려면 entity-scoped AI Policy를 만들고 각 엔티티의 구성에서 참조하세요.

글로벌 AI Policy 설정하기

AI Policy는 type(예: AI Sanitizer 또는 AI Rate Limiting Advanced)과 그 동작을 구성하는 config 블록을 지정해요. AI Gateway는 여러분이 선택한 스코프에 policy를 적용해요: 모든 트래픽에 전역으로, 또는 참조되는 엔티티에 스코프를 한정해서 적용해요.

다음 예시는 모든 AI Gateway Route에 대해 실행되는 글로벌 AI PII Sanitizer Policy를 만들어요. 이 Policy는 이메일, 전화번호, SSN, 신용카드 같은 고위험 PII 카테고리와 AWS API 키, GitHub 토큰 같은 민감한 토큰의 커스텀 패턴을 익명화해요.

이 Policy는 실제 데이터 정제(sanitization)를 수행하기 위해 host/port의 AI PII Anonymizer 서비스(이 예시에서는 sanitizer-service.internal:8080)에 연결해요. 직접 실행 중인 인스턴스의 주소로 바꿔서 사용하세요. 이미지 접근 방법과 설정 지침은 AI PII Anonymizer service를 참고하세요.

해당 주소에서 접근 가능한 서비스가 없으면 이 Policy를 통과하는 요청은 실패해요.

Konnect API

curl -X POST https://{region}.api.konghq.com/v1/ai-gateways/{AIGatewayId}/policies \
    --header "accept: application/json" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer $KONNECT_TOKEN" \
    --data '
    {
      "display_name": "PII Sanitizer - Global",
      "name": "pii-sanitizer-global",
      "type": "ai-sanitizer",
      "enabled": true,
      "global": true,
      "config": {
        "anonymize": [
          "email",
          "phone",
          "ssn",
          "creditcard",
          "custom"
        ],
        "custom_patterns": [
          {
            "name": "aws_api_key",
            "regex": "AKIA[0-9A-Z]{16}",
            "score": 0.95
          },
          {
            "name": "github_token",
            "regex": "ghp_[A-Za-z0-9]{36}",
            "score": 0.9
          }
        ],
        "host": "sanitizer-service.internal",
        "port": 8080,
        "redact_type": "placeholder",
        "stop_on_error": true,
        "recover_redacted": false
      }
    }
    '

다음 플레이스홀더를 여러분의 값으로 바꿔야 해요:

  • region: 여러분의 Kong Konnect가 호스팅되고 운영되는 지리적 리전이에요.

  • KONNECT_TOKEN: Konnect 계정과 연결된 여러분의 Personal Access Token(PAT)이에요.

  • AIGatewayId: AI Gateway의 id예요.

리전별 URL과 personal access token에 대해 알아보려면 Konnect AI Gateway API reference를 참고하세요.

kongctl

ai_gateway_policies:
  - ref: pii-sanitizer-global
    ai_gateway: !lookup {id: !env AI_GATEWAY_ID}
    display_name: PII Sanitizer - Global
    name: pii-sanitizer-global
    type: ai-sanitizer
    enabled: true
    global: true
    config:
      anonymize:
      - email
      - phone
      - ssn
      - creditcard
      - custom
      custom_patterns:
      - name: aws_api_key
        regex: AKIA[0-9A-Z]{16}
        score: 0.95
      - name: github_token
        regex: ghp_[A-Za-z0-9]{36}
        score: 0.9
      host: sanitizer-service.internal
      port: 8080
      redact_type: placeholder
      stop_on_error: true
      recover_redacted: false

{: data-file="policy.yaml" data-tool="kongctl" }

다음 플레이스홀더를 여러분의 값으로 바꿔야 해요:

  • AI_GATEWAY_ID: 여러분의 AI Gateway의 id예요.

UI

이 AI Gateway 엔티티 타입에는 아직 UI 지침이 제공되지 않아요.

스키마

{
  "type": "object",
  "properties": {
    "display_name": {
      "description": "The display name for this policy instance.",
      "type": "string",
      "example": "My Cool AI PII Sanitizer Policy",
      "maxLength": 256,
      "minLength": 1
    },
    "name": {
      "description": "A user-defined unique identifier for this policy instance, used as a stable human-readable reference. This value is immutable after creation.",
      "example": "ai-pii-sanitizer-1234",
      "allOf": [
        {
          "$ref": "#/components/schemas/AIGatewayEntityIdentifier"
        }
      ]
    },
    "type": {
      "description": "The type of the Policy. This is equivalent to the Kong 3 plugin name.\nSome examples are: 'ai-sanitizer', 'ai-prompt-guard', and 'rate-limiting'.\nNote: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the [Developer Docs](https://developer.konghq.com/plugins/).\n",
      "type": "string",
      "example": "ai-sanitizer"
    },
    "enabled": {
      "description": "Whether the policy is enabled.",
      "type": "boolean",
      "example": true,
      "default": true
    },
    "global": {
      "description": "Whether the policy is globally applied to all resources.",
      "type": "boolean",
      "example": false,
      "default": false
    },
    "config": {
      "description": "Configuration for the policy. This is equivalent to the Kong 3 plugin configuration.\nNote: Plugins have been renamed to Policies in Kong AI Gateway. Policy types and configuration documentation can be found in the [Developer Docs](https://developer.konghq.com/plugins/).\n",
      "type": "object",
      "example": {
        "anonymize": [
          "phone",
          "creditcard"
        ],
        "stop_on_error": true
      },
      "additionalProperties": true
    },
    "condition": {
      "description": "An expression used for conditional control over plugin execution. If the expression evaluates to `true` during the request flow, the plugin is executed; otherwise, it is skipped.\n\n**Requires a minimum runtime version of `2.1`**.",
      "type": "string",
      "maxLength": 1024,
      "nullable": true,
      "x-min-runtime-version": "2.1"
    },
    "labels": {
      "$ref": "#/components/schemas/PublicLabels"
    },
    "managed_by": {
      "$ref": "#/components/schemas/ManagedBy"
    },
    "id": {
      "$ref": "#/components/schemas/UUID"
    },
    "created_at": {
      "$ref": "#/components/schemas/CreatedAt"
    },
    "updated_at": {
      "$ref": "#/components/schemas/UpdatedAt"
    }
  },
  "additionalProperties": false,
  "required": [
    "display_name",
    "name",
    "type",
    "config",
    "id",
    "created_at",
    "updated_at"
  ]
}

FAQ

  • AI Policy는 여러 엔티티에서 공유되나요? 각 AI Policy는 독립적인 엔티티예요. 각 엔티티의 구성에서 policy를 참조하면 같은 AI Policy를 여러 다른 엔티티에 적용할 수 있어요.

  • AI Policy는 플러그인과 어떻게 다른가요? AI Policy는 기존의 /plugins 엔드포인트가 아닌 AI Gateway 엔티티 서페이스를 통해 만드는 policy 구성이에요. 런타임 효과는 같아요: 적절한 스코프에 붙은 policy라는 점이에요.

  • AI Policy의 스코프를 AI Consumer나 AI Consumer Group으로 설정할 수 있나요? 네. AI Consumer 또는 AI Consumer Group의 policies 배열에 AI Policy의 name 또는 id를 추가하세요. Policy는 요청 중에 AI Consumer가 식별될 때, 또는 AI Consumer Group의 멤버가 식별될 때 실행돼요.

  • 부모 엔티티가 삭제되면 AI Policy는 어떻게 되나요? policies 배열을 통해 부모 엔티티에서 참조되는 독립형 AI Policy는 독립적이어서 참조하던 부모가 삭제되어도 삭제되지 않아요. 참조만 제거돼요.

관련 리소스

더 알아보기 (Learn more)

  • 사용 가능한 모든 AI Policy 유형과 설정을 한곳에서 확인할 수 있어요 — AI Policies hub
  • 예시로 등장하는 PII 익명화 정책의 상세 설정이 궁금할 때 참고해요 — AI PII Sanitizer
  • 접근 제어와 신원 검증이 목적이라면 정책 대신 이 엔티티를 사용해요 — AI Auth Strategy
  • API로 AI Policy를 관리할 때 필요한 엔드포인트를 확인할 수 있어요 — Konnect AI Gateway API reference
  • AI Gateway 전체가 궁금하면 먼저 훑어보는 게 좋아요 — About AI Gateway