Logging & Monitoring AI Responses

πŸ“Š Logging & Monitoring AI Responses

Why Monitor AI Responses?

AI security doesn’t stop at real-time filtering. Effective logging & monitoring ensures:

βœ… Full visibility into AI decisions β†’ Track why prompts were accepted or blocked.
βœ… Auditability & Compliance β†’ Maintain a record of all AI interactions for security reviews.
βœ… Continuous AI improvement β†’ Use log data to fine-tune AI behavior & policies.

The AIandMe Firewall automatically logs every API request and response, enabling detailed post-analysis.


AIandMe Firewall Logs

Each firewall API call generates a unique log_id, which you can use to retrieve detailed assessments later.

πŸ“Œ Example: Firewall Log Dashboard
Firewall Logs

πŸ“Œ Example: Detailed Log Analysis
Detailed Logs


Retrieving Logs via API

You can fetch logs programmatically using the AIandMe API.

πŸ”Ή Request Format

Send a GET request with the log ID to retrieve the full AI analysis:

curl -X GET "https://your-firewall-endpoint/logs/{log_id}" \
     -H "Authorization: Bearer your-api-key"

πŸ”Ή Python Example

Here’s how to retrieve AIandMe Firewall logs using Python:

import requests
 
log_id = "your-log-id"
api_url = f"https://your-firewall-endpoint/logs/{log_id}"
headers = {"Authorization": "Bearer your-api-key"}
 
response = requests.get(api_url, headers=headers)
 
if response.status_code == 200:
    log_data = response.json()
    print("Log Details:", log_data)
else:
    print("Failed to retrieve log:", response.status_code)

Log Data Breakdown

The API returns structured JSON data, containing:

  • status β†’ pass or fail
  • fail_category β†’ off_topic, violation, or restriction
  • assessment_rationale β†’ Explanation of why the prompt passed or failed
  • timestamp β†’ When the request was processed

πŸ“Œ Example Response:

{
  "log_id": "123456",
  "status": "fail",
  "fail_category": "restriction",
  "assessment_rationale": "User attempted to request sensitive data.",
  "timestamp": "2025-01-26T13:45:00Z"
}

Best Practices for AI Logging

  • Regularly review logs β†’ Identify patterns in AI failures.
  • Use logs for model tuning β†’ Improve accuracy based on failure cases.
  • Enable alerts for critical failures β†’ Automate responses to security violations.

πŸ’‘ Need help? Check out FAQs or Join the AIandMe Community.