Skip to main content
Red teaming sends adversarial prompts at your LLM application to find exploitable weaknesses before they reach production. evaluatorq automates this process by generating attack strategies based on OWASP LLM and ASI vulnerability categories, running them against your target, and producing a scored report. The full set of examples referenced in this guide is available on GitHub.

Prerequisites

Install the package with the redteam extras:
Set the appropriate API key depending on your target:

Your first red team run

The simplest run tests an LLM target in dynamic mode: attack prompts are generated at runtime based on the target’s system prompt and selected categories.
Or run it from the CLI:
The CLI accepts agent:<key> and deployment:<key> targets. To red team a raw OpenAI model, use OpenAIModelTarget from the Python API instead.

Modes

The mode parameter controls how attack prompts are sourced. Choose based on your tradeoff between coverage, reproducibility, and speed.
Generates attack prompts using an LLM at runtime based on your target’s system prompt and selected categories. More varied coverage, but non-deterministic: results differ between runs.

Selecting OWASP categories

Use the categories parameter to scope a run to specific risk areas:
The supported categories are: To list categories at runtime:

Targeting specific vulnerabilities

For more precision, use vulnerabilities instead of categories. This targets individual attack vectors and takes precedence over categories when both are set.
To see all available vulnerability IDs:

Red teaming an orq.ai Agent

When your application is deployed as an Agent in orq.ai, set backend="orq" and use the agent: target prefix. The pipeline auto-discovers the agent’s system prompt, tools, and memory stores, and generates tailored attacks including tool-misuse and memory-poisoning vectors.
Find your agent key in the Agents section of orq.ai. See Agents for more.

Red teaming a LangGraph agent

When your target is a LangGraph agent, wrap the compiled graph in a LangGraphTarget and pass it directly to red_team(). The target provides automatic tool and memory introspection, isolated thread state per attack, and per-call token usage tracking. Install the LangGraph extra to enable this integration:
Each LangGraphTarget instance generates its own memory_entity_id, used as the LangGraph thread_id so parallel attacks never share checkpointer state. Tools and memory stores are discovered by introspecting the compiled graph and surfaced on report.agent_context.

Red teaming an OpenAI Agents SDK agent

When the target is an OpenAI Agents SDK Agent, wrap it in an OpenAIAgentTarget and pass it to red_team(). The target preserves conversation state through Runner.run() and captures tool calls and token usage from each turn. Install the OpenAI Agents extra:
Pass extra arguments to the underlying Runner.run() via run_kwargs (for example max_turns or context). Conversation history is held client-side in the target instance, so each parallel job uses a fresh OpenAIAgentTarget via new().

Red teaming a custom callable

For frameworks without a dedicated integration, wrap any sync or async function in a CallableTarget. The function takes a prompt string and returns either a string or an AgentResponse.
Pass reset_fn to clear shared state between attacks, usage_fn to plumb token counts from the underlying framework, and agent_context to enable capability-aware strategy filtering:

Red teaming an OpenAI-hosted model directly

To test a raw OpenAI model without an agent wrapper, use OpenAIModelTarget, exported directly from evaluatorq.redteam (the other integration targets live under evaluatorq.integrations.*). This replaces the previous "llm:<model>" string target prefix, which has been removed.

Reading the report

The report object returned by red_team() contains: Iterating over results:
Exporting to JSON:

Results in orq.ai

When ORQ_API_KEY is set, results are automatically pushed to your orq.ai workspace as an Experiment run. A direct link is printed at the end of the run:
Red team results in orq.ai Experiments
Each attack is logged as a datapoint with its category, vulnerability, prompt, response, and verdict, so you can filter, compare runs, and track resistance rates over time. The run is also auto-saved locally to ~/.evaluatorq/runs/<name>_<timestamp>.json. To visualize it with the local UI, install the ui extras and run:
The local UI is a multi-tab Streamlit dashboard with five views:
Red Team Security Report - Summary tab

ASR, critical exposure count, eval coverage, and per-vulnerability breakdown at a glance.

All views share a Filters panel in the sidebar. Use it to slice results by outcome (All / Vulnerable / Resistant / Error), OWASP category, severity, attack technique, delivery method, and vulnerability ID.
Red Team Security Report - Filters panel

Filters panel, available on all views, to narrow results to a specific attack vector or outcome.

Advanced LLM configuration

By default, red_team() picks sensible models for the attacker and evaluator roles. To override per-role models, temperature, or token limits, pass an LLMConfig:
LLMConfig also controls retry behaviour (retry_count, retry_on_codes), cleanup timeout (cleanup_timeout_ms), and target agent timeout (target_agent_timeout_ms). The per-role LLMCallConfig.max_tokens caps tokens for attacker and evaluator generations independently — useful when comparing models with different context windows.
The default parallelism is 30. Lower this if your target’s rate limits are strict, or raise it for faster runs against high-throughput endpoints.

CI integration

Use the exit-code-gating pattern to fail a build if vulnerabilities are found:
Or as a CLI one-liner:

Routing through orq.ai

You can route all LLM calls in the pipeline (attack generation, scoring, and the model under test) through the AI Gateway by passing a custom llm_client:
This gives you full observability over every LLM call made during the red team run in your orq.ai workspace. See AI Gateway for supported models and configuration.