The outputguard command validates and repairs structured output from files or
stdin. The CLI is organized around subcommands.
pip install outputguardValidate one output against a JSON Schema file:
outputguard validate response.txt --schema schema.jsonValidate and repair if needed:
outputguard validate response.txt --schema schema.json --repairUse a non-JSON format:
outputguard validate response.yaml --schema schema.json --input-format yamlRead from stdin:
cat response.txt | outputguard validate - --schema schema.jsonRepair one output without schema validation:
outputguard repair response.txtWrite repaired text to a file:
outputguard repair response.txt --output repaired.jsonInspect repairs:
outputguard repair response.txt --diff
outputguard repair response.txt --verboseGenerate feedback for an invalid output:
outputguard retry-prompt response.txt --schema schema.jsonOmit the original output from the generated retry prompt:
outputguard retry-prompt response.txt --schema schema.json --no-message-historyThe batch command reads a JSON array of strings and validates each item against one JSON Schema.
outputguard batch outputs.json --schema schema.json --input-format auto
outputguard batch outputs.json --schema schema.json --repair --input-format jsonEmit machine-readable JSON:
outputguard batch outputs.json --schema schema.json --repair --format jsonoutputguard strategies
outputguard version| Flag | Meaning |
|---|---|
--schema, -s |
JSON Schema file path for validation commands |
--repair, -r |
Attempt repair before final validation |
--input-format |
Input format: json, yaml, toml, python, auto, or forced-json-off |
--format, -f |
CLI output format: text or json |
--quiet, -q |
Suppress non-essential validation output |
--output, -o |
Write repaired or JSON output to a file |
--diff, -d |
Show a repair diff |
--verbose, -v |
Show per-strategy repair details |
--strategies |
Comma-separated repair strategy names for repair |
--no-message-history |
Omit the original output from retry-prompt output |
Run outputguard --help for the exact options supported by the installed
version.
The CLI uses conventional exit codes:
0: command completed successfully and validation passed when applicable.1: validation or repair failed.2: command usage or input shape was invalid.
For automation, inspect both the exit code and --format json output when using
validation or batch commands.
JSON is the default. Pass --input-format whenever the prompt expected another
format. Use auto for mixed historical output and forced-json-off when the
prompt explicitly told the model not to return JSON.