Pre-requisites
Mindgard’s CLI requires a working python 3.10+ environment, and pip, pipx, or equivalent package manager. If your organization has custom ssl certificates deployed for purposes of traffic inspection then these must be available to the python certificate store.Installation
Install the Mindgard CLI using pip:pip install mindgard
Login to Mindgard
The Mindgard CLI works in conjunction with a Mindgard SaaS deployment. Before you can run tests, you will need to login withmindgard login
For Mindgard enterprise private tenant customers only, login to your enterprise instance using the command
mindgard login --instance <name>.Constructing a Test Command
Mindgard test commands follow the form ofSpecifying Test Type
Mindgard’s CLI can conduct three types of test against an external AI model. Use therecon, test or run commands to conduct reconnaissance and attacks with techniques using one or multiple prompts. The general command forms are:
- Reconnaissance
- Single-turn
- Mutli-turn
Discover the target’s capabilities and defenses using reconnaissance techniquesNumerous recon tests are available. To start we suggest trying:
input-encoding, output-encoding, and guardrail.Project ID
Every test you run must be associated with a project identifier. The ID can be found just under the project’s name on any project’s results page along with a copy button to make it easier to transplant to your terminal..

mindgard list projects.
Specifying your target
To test a target, Mindgard’s CLI needs to know:- The URL where it will submit prompts and receive responses
- Prompt and response schemas
- API key if your target requires authentication
Direct Configuration
Direct Configuration
Response Formatting
--selectorMindgard expects all responses to be JSON formatted. Selector is a JSON Path expression, that tells Mindgard how to identify your target’s answer to our prompts within the API response.Your browser devtools may be useful to observe the structure of your API response to determine what this should be set to. In the example in the below screenshot “$.text” would be used to match the text response from the chatbot.Request Formatting
--request-templateThe Request Template option tells Mindgard how to format an outbound request to your test target API. Without this option the test prompts will be sent in this format:{prompt} Mindgard will replace this placeholder with an adversarial input as part of an attack technique.{system_prompt} Mindgard will replace this with the system prompt you specify below. This will allow you to test how the system behaves with different system instructions.The screenshot above would require a Request Template of {"inputs": "{system_prompt} {prompt}"}. In this case the other data you see in the browser’s request is not required for Mindgard to operate. Start small configuring request templates. The goal is to define the minimum set of information required to deliver prompts to your target.
If you ever find yourself struggling with either request or response formatting please contact Mindgard support (support@mindgard.ai) for help. An agent will be happy to troubleshoot with you.Preset Configuration
Preset Configuration
Multiple preset configurations exist within the CLI that will handle some of the required targeting options. Notably, request and response templates are already configured for many of the presets. Using a preset when possible can save significant configuration work.The targeting options required for each preset are:
| Preset | Required options |
|---|---|
| openai | api-key |
| openai-compatible | url, api-key |
| huggingface | url, request-template, api-key |
| huggingface-openai | url, api-key |
| anthropic | api-key |
| azure-aistudio | url, system-prompt, api-key |
| azure-openai | url, az-api-version, model-name, api-key |
Validating Targeting Options
Target configuration can be tested with:Configuration Files
Once your configuration validates you have everything you need to start testing. Before diving in, consider saving your options to a configuration file. Configuration files are formatted text files that can be saved in any location you prefer. Be mindful of configuration file security when they hold API keys related to targets. Any test or targeting option can be stored in a configuration file including project identifiers. We recommend saving the project ID and targeting options in a configuration file at a minimum. When you find yourself repeating tests for a target, add those options to a test specific configuration file as well. To use a configuration file called test-config.toml with a test:- Reconnaissance
- Single-turn
- Mutli-turn
Discover the target’s capabilities and defenses using reconnaissance techniques
Viewing Results in Web
After running a test, the CLI will provide a link to the results in the Web UI. From the Web UI you can also share projects with other stakeholders allowing them to review results without needing to install or operate the command line interface.

