API Reference

Adversec v1 — API-first adversarial testing for AI agents.

Adversec provides two core capabilities via REST API:

  • Test Generation — Describe your agent, receive a tailored suite of adversarial test cases mapped to the OWASP LLM Top 10.
  • Test Execution — Point a test suite at any live agent endpoint. Get back a scored vulnerability report with confidence values and severity classifications.
Base URL: https://api.adversec.io

Authentication

All endpoints require an API key passed as a Bearer token in the Authorization header:

Authorization: Bearer advc_sk_YOUR_KEY

API keys are generated in the dashboard by visiting the Get API Key page. Keys are hashed server-side (SHA-256) — only the hash is stored, never the raw key.

Security note: Your raw API key is only shown once at creation time. If lost, revoke and generate a new one.

Quick Start

Generate your first adversarial test suite in three steps:

# Step 1: Generate custom adversarial tests for your agent curl https://api.adversec.io/v1/tests/generate \ --header "Authorization: Bearer advc_sk_YOUR_KEY" \ --header "Content-Type: application/json" \ --data '{ "agent_name": "CustomerSupportBot", "description": "Handles refund requests and account queries for an e-commerce platform", "domain": "customer-support", "num_tests": 50, "intensity": "standard" }' # Returns a test_id and array of test cases
# Step 2: Point the test suite at your agent curl https://api.adversec.io/v1/tests/{test_id}/run \ --header "Authorization: Bearer advc_sk_YOUR_KEY" \ --header "Content-Type: application/json" \ --data '{ "target": { "url": "https://your-agent.example.com/chat", "method": "POST", "input_field": "prompt" }, "concurrency": 5, "timeout": 30 }' # Returns a scored vulnerability report

Generate Tests

POST /v1/tests/generate

Generate a tailored adversarial test suite for any AI agent. The engine uses attack taxonomies mapped to the OWASP LLM Top 10 to produce precise, contextual test cases.

Request Body

FieldTypeRequiredDescription
agent_namestringrequiredName of the agent under test
descriptionstringrequiredWhat the agent does — its purpose and context
domainstringoptionale.g. legal, medical, coding, customer-support
expected_input_formatstringoptionalWhat format the agent expects as input
expected_output_formatstringoptionalWhat format the agent should return
focus_areasstring[]optionalAttack categories to emphasize (empty = balanced spread)
num_testsintoptionalNumber of test cases to generate (default: 50, 5-500)
intensitystringoptionalquick | standard | deep (default: standard)
include_multi_turnbooloptionalInclude Crescendo-style multi-turn escalation tests

Response

FieldTypeDescription
test_idstringUUID for this test suite (used for /run)
agent_namestringEcho of the agent name
tests_generatedintNumber of test cases generated
coverageobjectTests per attack category
testsarrayFull array of AdversarialTestCase objects
estimated_costfloatApproximate cost in $ to run via /v1/tests/run
Pro tip: Use intensity: "deep" + include_multi_turn: true for maximum coverage on production-bound agents. Expect higher generation costs but significantly better vulnerability detection.

Run Test Suite

POST /v1/tests/{test_id}/run

Execute a previously generated test suite against a live agent endpoint. The engine fires all adversarial inputs in parallel and scores results using an independent LLM judge.

Path Parameters

ParameterTypeDescription
test_idstringThe test suite ID from /generate

Request Body

FieldTypeRequiredDescription
target.urlstringrequiredFull URL of the agent endpoint
target.methodstringoptionalGET or POST (default: POST)
target.input_fieldstringoptionalJSON key to place the test input under (default: "input")
target.output_fieldstringoptionalJSON key to extract response from (default: root)
target.auth_typestringoptionalbearer | api_key | none
target.auth_valuestringoptionalToken or API key for the target endpoint
target.headersobjectoptionalAdditional HTTP headers
concurrencyintoptionalParallel requests (default: 5, 1-20)
timeoutintoptionalPer-request timeout in seconds (default: 30)
custom_assertionsstring[]optionalExtra natural-language scoring rules

Response

FieldTypeDescription
run_idstringUUID for this test run
total_testsintTotal tests executed
passedintTests where the agent resisted the attack
failedintTests where the attack succeeded (vulnerability found)
pass_ratefloat0.0 - 1.0
attack_success_ratefloat0.0 - 1.0 — how many attacks got through
summaryobjectFailed tests by severity: critical, high, medium, low
results_by_categoryobjectPass/fail per attack category
worst_resultsarrayTop 5 failures by confidence (the most dangerous vulnerabilities)
time_taken_secondsfloatTotal execution time

Get Test Suite Status

GET /v1/tests/{test_id}

Check the status of a test suite and view metadata about generated tests and associated runs.

Response

FieldTypeDescription
test_idstringSuite ID
agent_namestringAgent name
statusstringgenerating | ready | failed | running | complete
tests_generatedintNumber of tests
coverageobjectTests per category
runsstring[]Associated run IDs
created_atstringISO 8601 timestamp

Health Check

GET /health

No authentication required. Returns service status and uptime.

Response: { "status": "ok", "version": "0.1.0", "uptime": 3600.0 }

AdversarialTestCase

Each test case in the generated suite includes:

FieldTypeDescription
idintSequential test number
categorystringAttack category (e.g., prompt_injection)
attack_typestringSpecific technique (e.g., indirect_content)
inputstringThe adversarial input to send to the target
descriptionstringWhy this test matters
expected_failurestringWhat happens if the agent is vulnerable
severitystringlow | medium | high | critical
owasp_categorystringOWASP LLM Top 10 mapping
multi_turn_stepsstring[]Multi-turn conversation (if applicable)

Error Codes

CodeDescription
401Invalid or inactive API key
404Test suite not found
422Invalid request body — validation error
429Monthly quota exceeded
500Internal server error

Rate Limits

TierMonthly QuotaConcurrent Requests
Free501
Pro5,0005
Team50,00010
EnterpriseUnlimited20
Note: The /generate endpoint runs synchronously. For large test suites (100+ tests), expect response times of 15-60 seconds depending on intensity.

SDKs & Libraries

Official SDKs are coming. The API is REST-standard — any HTTP client works.

# Python example with requests import requests API_BASE = "https://api.adversec.io/v1" API_KEY = "advc_sk_YOUR_KEY" # Generate tests response = requests.post( f"{API_BASE}/tests/generate", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "agent_name": "MySupportAgent", "description": "Handles customer inquiries", "num_tests": 50, "intensity": "standard", }, ) suite = response.json() print(suite["tests_generated"], "tests generated") # Run the suite result = requests.post( f"{API_BASE}/tests/{suite['test_id']}/run", headers={"Authorization": f"Bearer {API_KEY}"}, json={ "target": {"url": "https://agent.example.com/chat"}, "concurrency": 5, }, ) report = result.json() print(f"Attack success rate: {report['attack_success_rate']:.1%}")