Skip to main content

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.

For more info on various providers, please refer to the GET Defaults API response.

Install required libraries

Shell
pip install requests python-dotenv tabulate pandas enkryptai-sdk

Setup your development

Sign up for a account on our dashboard and create a API Key. Export the API Keys as environment variables:
Shell
export OPENAI_API_KEY="YOUR_OPENAI_API_KEY"
export ENKRYPTAI_API_KEY="YOUR_ENKRYPTAI_API_KEY"

Example Usage

Here is an example of how to use the Red Team API to run a red team test:
import requests
import json
import os
import uuid

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

payload = json.dumps({
    "test_name": f"redteam_test_{str(uuid.uuid4())[:8]}",  # Required: Unique test identifier
    "dataset_configuration": {
        "system_description": "System description for your AI application",
        "policy_description": "Do not generate any content that is illegal, harmful, or violates the rights of others.",
        "max_prompts": 100,
        "scenarios": 2,
        "categories": 2,
        "depth": 2,
    },
    "redteam_test_configurations": {
        "bias_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": {"basic": {"params": {}}}
            }
        },
        "cbrn_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": {"basic": {"params": {}}}
            }
        },
        "harmful_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": {"basic": {"params": {}}}
            }
        },
        "insecure_code_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": {"basic": {"params": {}}}
            }
        },
        "toxicity_test": {
            "sample_percentage": 1,
            "attack_methods": {
                "basic": {"basic": {"params": {}}}
            }
        }
    },
    "endpoint_configuration": {
        "testing_for": "foundationModels",
        "model_name": "gpt-4o",
        "model_config": {
            "model_provider": "openai",
            "endpoint": {
                "scheme": "https",
                "host": "api.openai.com",
                "port": 443,
                "base_path": "/v1/chat/completions"
            },
            "auth_data": {
                "header_name": "Authorization",
                "header_prefix": "Bearer",
                "space_after_prefix": True
            },
            "apikeys": [os.getenv('OPENAI_API_KEY')],
            "input_modalities": ["text"],
            "output_modalities": ["text"]
        }
    }
})
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:
JSON
{
  "status": "Success",
  "task_id": "generate-and-redteam-6c3babbe-3bc4-4553-a0b7-454df720579f",
  "message": "Task submitted successfully",
  "data": {
    ...
  }
}