檢視次數:

將 AI Guard 整合到您的應用程式中,以掃瞄您的 AI 使用情況,檢測有害內容生成、敏感信息洩漏和提示注入。

步驟

  1. 配置下列AI Guard設定。
    1. 輸入設定的「名稱」
    2. 選取下列選項中的安全層級:
      • 謹慎
      • 加強
      注意
      注意
      趨勢科技建議您選取「中」
    3. 使用切換開關來決定 AI Guard 掃瞄哪些內容類型:
      • Scan for harmful content
      • Scan for sensitive information
      • Scan for prompt attacks
    4. 您可以點擊「Copy settings code」來測試您環境中的AI Guard設定。
  2. 按一下「套用」以儲存設定。
  3. 為 AI Guard 建立 API 金鑰。
    1. 移至「AdministrationAPI Keys」。
    2. 按一下「Add API Key」以建立新 API 金鑰。
    3. 指定 API 金鑰的名稱、使用者角色和到期時間。
      重要
      重要
      在新增 API 金鑰時,您必須選擇具有在 AI 掃瞄器中執行掃瞄權限的「角色」。如果您的組織沒有具備必要權限的現有使用者角色,請建立自訂角色或聯絡您的管理員。
      如需詳細資訊,請參閱API 金鑰
    4. 按一下「新增」。
    5. 複製並保留 API 金鑰。
  4. 將 AI Guard 與您的應用程式整合。
    請參考以下程式碼片段進行整合。
    import os
    import requests
    
    # Get your Trend Vision One API key from environment variable
    api_key = os.environ.get("V1_API_KEY")
    if not api_key:
        raise ValueError("Missing V1_API_KEY environment variable")
    
    # Configure headers
    headers = {
        "Authorization": f"Bearer {api_key}",
        "Content-Type": "application/json"
    }
    
    # Prepare the payload for AI security scanning
    payload = {
        "guard": "your_prompt_or_response_here"
    }
    
    
    url = "https://<BASE_V1_URL>/beta/aiSecurity/guard?detailedResponse=false"
    
    # Make the API request
    response = requests.post(
        url,
        headers=headers,
        json=payload
    )
    
    # Check response status
    if response.status_code == 200:
        result = response.json()
        print("Scan completed successfully")
    else:
        print(f"Error: {response.status_code} - {response.text}")
    注意
    注意
    趨勢科技 建議將您的 API 金鑰儲存於 AI Guard 名稱 $V1_API_KEY 下。
    在 API 請求中將以下設置為基礎 URL:<https://api.{region}.xdr.trendmicro.com/beta/aiSecurity>
    除非您的 Trend Vision One 帳戶地區是美國(預設地區),否則請在基本 URL 中將 {region} 替換為適用的地區代碼:
    • eu
    • jp
    • au
    • in
    • sg
    • mea
    如需詳細資訊,請參閱AI Guard API 參考