Setup your development

Sign up for a account on our dashboard and create a API Key.

Export the API Key as an environment variable:

export ENKRYPTAI_API_KEY=<your-api-key>

Example Usage

Here is an example of how to use the Guardrails API to use all of the available detectors:

import requests
import json
import os

url = "https://api.enkryptai.com/redteam/add-task"

payload = json.dumps({
    "test_name": "Test 1",
    "dataset_name": "standard", // Or your custom dataset name
    "redteam_test_configurations": {
        "bias_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": [
                    "basic"
                ]
            }
        },
        "cbrn_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": [
                    "basic"
                ]
            }
        },
        "harmful_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": [
                    "basic"
                ]
            }
        },
        "insecure_code_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": [
                    "basic"
                ]
            }
        },
        "toxicity_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": [
                    "basic"
                ]
            }
        }
    },
    "target_model_configuration": {
        "model_name": "google/gemma-7b-it",
        "model_type": "text_2_text",
        "system_prompt": "",
        "conversation_template":"",
        "model_source": "https://docs.anyscale.com",
        "model_provider": "Google",
        "model_endpoint_url": "https://api.endpoints.anyscale.com/v1/chat/completions",
        "model_api_key": "ANYSCALE_API_KEY"
    }
})
headers = {
  'Content-Type': 'application/json'
  'apikey': os.getenv('ENKRYPTAI_API_KEY')
}

response = requests.request("POST", url, headers=headers, data=payload)

formatted_response = json.dumps(json.loads(response.text), indent=4)
print(formatted_response)

Response:

{
  "task_id": "redteam-job-6c3babbe-3bc4-4553-a0b7-454df720579f"
}