Documentation / Use Shield
Run a scan
Shield scans a chatbot from the command line. The CLI sends the attacks to the chatbot's endpoint from the machine it runs on. This instance holds the attacks, judges every answer with its LLM judge and stores the result.
On this page
Install the CLI
You need Node.js 22.3 or later.
npm install -g shield-llm
shield-llm --versionConnect the CLI to this instance
- In the app, open Settings > API Keys and create a key. Copy it right away: it starts with
sk_shield_and is not shown again. For a key you hand to CI, pick an expiry. - Log in from your terminal:
shield-llm login --key <api-key> --api-url https://shield-llm.comThe CLI checks the key against this instance and stores it in ~/.shield-llm/credentials.json, readable by your user only. There is no default instance: the CLI always needs to know which one to talk to. In CI, set SHIELD_API_URL instead of passing --api-url.
Describe the chatbot
The simplest way is the wizard. It asks for the endpoint URL, how it authenticates, where the user's message goes in the request and where the reply is in the response, then writes shield.config.json in the current folder.
shield-llm initYou can also write the file yourself. Pick the shape that matches your chatbot.
A JSON API that takes a message and returns a reply
{
"endpoint": {
"url": "<chatbot-url>",
"request": { "body": { "message": "{{prompt}}" } },
"response": { "field": "response" }
}
}An OpenAI-compatible API (self-hosted model, Azure OpenAI, LiteLLM and similar)
{
"endpoint": {
"url": "<chatbot-url>",
"auth": { "type": "bearer", "token": "$CHATBOT_TOKEN" },
"request": {
"body": {
"model": "<model-name>",
"messages": [{ "role": "user", "content": "{{prompt}}" }]
}
},
"response": { "field": "choices[0].message.content" }
}
}A streaming endpoint (SSE). Streaming replies are detected on their own: point at the URL and name the field that carries the text.
A form or multipart endpoint. Add "encoding": "form" or "encoding": "multipart" to request.
What the placeholders mean:
{{prompt}}is replaced by the attack text. It must appear in the body.{{history}}is replaced by the conversation so far, for multi-turn attacks against a chatbot that does not keep its own history. Setrequest.historyFormattogeminifor a Gemini or Vertex AI style API.$NAMEreads a value from an environment variable, so tokens never sit in the file.
Check the file without sending anything:
shield-llm validateCheck the connection
- Run
shield-llm test-connection- Expect
- The chatbot's reply. This tests the URL, the authentication and the response field. It sends no attack and does not use your account.
- Limit
- If the reply printed is empty or is not the chatbot's text, fix
response.fieldfirst.
Choose a depth
A preset decides how deep the scan goes. The default is standard.
| Preset | Use it for |
|---|---|
dev | A smoke test of your setup. Very short. |
quick | A routine check with the attacks that most often find a flaw. |
owasp | Breadth: one attack for each OWASP LLM Top 10 category. |
frontier | Recent techniques that work on any chat endpoint. |
standard | The recommended depth for a production chatbot: every OWASP category in depth, recent techniques, and the EU AI Act transparency checks. |
full | A final assessment: the whole catalogue plus the multi-turn attacks. |
full includes multi-turn attacks (a conversation that escalates over several messages, and memory attacks). Add them to any other preset with --crescendo.
shield-llm presets lists the presets this instance serves.
Run the scan
shield.config.json.- Run
shield-llm scan- Expect
- The CLI finds
shield.config.jsonin the current folder (or use-c <path>), runs the attacks four at a time, and slows down on its own if the chatbot pushes back. At the end it prints the score, the grade and a link to the scan page on this instance. - Limit
- An interrupted scan resumes where it stopped: if the scan stops.
To try a chatbot without a config file, give the URL directly:
shield-llm scan -e <chatbot-url> --response-field reply --preset quickShield refuses a chatbot on your own machine or on a private network unless you allow it: add --allow-private-urls to the command, or set "allowPrivateUrls": true in the endpoint block of shield.config.json.
If the scan stops
Every scan saves its progress as it goes. If it is interrupted (a crash, Ctrl+C, a CI timeout), run the same command again: it resumes where it stopped and only re-sends the attacks that had no result. Use --no-resume to start over.
A scan that could not finish properly is not saved to the dashboard, so a partial run can never pass for a full one. The CLI says why and keeps the progress:
| What happened | Exit code | What to do |
|---|---|---|
| The chatbot refused the credentials (expired token, blocked address) | 2 | Refresh the token, run the same command. |
| The chatbot kept rate-limiting the scan | 3 | Wait, or lower --concurrency and raise --delay. |
| The chatbot failed or stopped answering | 3 | Check the chatbot, run the same command. |
| The LLM judge could not rule on more than 10 % of the answers | 3 | Run the same command later. See No verdict without a judge. |
| More than 20 % of the attacks never ran (blocked, timed out, no reply) | 3 | Check what blocks them (a firewall, a gateway), then run again. |
The two limits are --max-unjudged and --max-not-executed. Your administrator can set stricter ones on the server, and the server's limits win.
Plant a canary
The judge cannot always tell a leaked system prompt from an invented one. A canary removes the doubt. Put a unique, random string (at least 8 characters) in your chatbot's system prompt, and the same string in the config:
{
"endpoint": {
"url": "<chatbot-url>",
"request": { "body": { "message": "{{prompt}}" } },
"response": { "field": "response" },
"knownSecrets": ["<random-canary-string>"]
}
}Any answer that contains it, even encoded (base64, reversed, and other common encodings), is a proven leak. The canary only ever turns a verdict into "vulnerable", never the reverse. This instance checks it after the judge has ruled; it is never sent to the LLM provider.
Run it in CI
--ci prints JSON on stdout, sends the progress messages to stderr, and turns the spinner off. Add the thresholds that should fail the build:
shield-llm login --key "$SHIELD_API_KEY" --api-url https://shield-llm.com
shield-llm scan --ci --min-score 75 -o sarif --output-file shield.sarif --write-json shield.json- The exit code is 0 when the thresholds pass, 1 when they do not, 2 for a configuration or credential problem, 3 for a network problem or an incomplete scan.
- Without any threshold the run always passes. As soon as you set one, a CRITICAL finding also fails the run. Use
--no-fail-on-criticalto report it without failing. --write-jsonkeeps a JSON copy next to a SARIF or Markdown report, for your pipeline to read the score.- The JSON written to disk shortens the chatbot's answers so a public CI artifact does not leak them.
--include-full-payloadskeeps them whole.
In GitHub Actions, for example, a job installs the published CLI (Node.js 22.3 or later) and runs the same two commands. Store the API key as a secret of your repository (here SHIELD_API_KEY). The scan reads shield.config.json from the folder it runs in, the root of your repository here; -c points it at another file.
jobs:
shield:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0
with:
node-version: "22"
- run: npm install -g shield-llm
- run: shield-llm login --key "$SHIELD_API_KEY" --api-url https://shield-llm.com
env:
SHIELD_API_KEY: ${{ secrets.SHIELD_API_KEY }}
- run: shield-llm scan --ci --min-score 75 -o sarif --output-file shield.sarif --write-json shield.jsonThe Shield release also contains a composite GitHub Action, .github/actions/shield-llm-scan. It builds the CLI from the release's own source code, so it only runs inside a checkout of the Shield release: copied alone into another repository, it fails at its install step. In your own pipelines, install the published CLI as above.