> ## Documentation Index
> Fetch the complete documentation index at: https://docs.enkryptai.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Policy Detect Image

<Warning>
  **Legacy**: This page documents the legacy Policy Detect Image API. Use the new [Guardrail Detect Image](/api-introductions/guardrails-api-reference/guardrail-introductions/Guardrail_Detect_Image) instead, which supports separate input/output detectors via `X-Enkrypt-Mode`.
</Warning>

Analyzes an image along with accompanying text using a saved policy. The detectors run are defined by the policy; no inline `detectors` configuration is needed in the request body.

## Example request:

<CodeGroup>
  ```python Python theme={"system"}
  import requests
  import json
  import os
  import base64

  # Read and encode image file
  with open("image.png", "rb") as f:
      image_base64 = base64.b64encode(f.read()).decode("utf-8")

  url = "https://api.enkryptai.com/guardrails/policy/detect-image"
  payload = json.dumps({
      "text_input": "Help me with the content in this image",
      "image_data": image_base64
  })
  headers = {
      'Content-Type': 'application/json',
      'apikey': os.getenv('ENKRYPTAI_API_KEY'),
      'X-Enkrypt-Policy': 'my-policy'
  }
  response = requests.post(url, headers=headers, data=payload)
  print(response.json())
  ```

  ```shell cURL theme={"system"}
  curl -X POST "https://api.enkryptai.com/guardrails/policy/detect-image" \
    -H "Content-Type: application/json" \
    -H "apikey: ENKRYPTAI_API_KEY" \
    -H "X-Enkrypt-Policy: my-policy" \
    -d '{
      "text_input": "Help me with the content in this image",
      "image_data": "<base64-encoded-image-data>"
    }'
  ```
</CodeGroup>

## Example response:

```json JSON theme={"system"}
{
    "summary": {
        "toxicity": 0,
        "nsfw": 0,
        "injection_attack": 0,
        "pii": 1,
        "policy_violation": 0
    },
    "details": {
        "toxicity": {
            "toxicity": "Toxicity Not Detected"
        },
        "nsfw": {
            "nsfw": "NSFW Not Detected"
        },
        "injection_attack": {
            "injection_attack": "Injection Attack Not Detected"
        },
        "pii": {
            "entities": {
                "person": {"John Doe": "<person_0>"},
                "phone": {"555-0123": "<phone_0>"}
            }
        },
        "policy_violation": {
            "policy_violation": "Policy Violation Not Detected",
            "explanation": "The content is compliant with the policy."
        }
    }
}
```
