Skip to main content
Command-line interface for QWED verification.

Installation

The qwed CLI is automatically available after installation.

Commands

qwed init - onboarding and bootstrap

Onboarding wizard that sets up verification engines, configures your LLM provider, and bootstraps a local API key β€” all in a single command. Run this once after installing QWED.
The wizard runs three steps:
  1. Engine readiness β€” checks that core verification engines (SymPy, Z3, AST, SQLGlot) are installed, then runs deterministic smoke tests to confirm they work correctly
  2. LLM provider setup β€” select a provider, enter credentials with masked input, validate the key format, and test the connection with retry support
  3. API key bootstrap β€” starts a local QWED server, creates an organization, and generates a one-time API key you can use immediately
Supported providers: Example session:

Non-interactive mode (CI/CD)

Use --non-interactive to run qwed init without prompts. This is useful in CI pipelines, Docker builds, or automated provisioning scripts.
All flags:
API keys are never logged or displayed in full. The .env file is written atomically with owner-only permissions (0600 on Unix) and symlink protection. A QWED_JWT_SECRET_KEY is generated automatically for local server authentication.
Local server runtime directory: During Step 3, qwed init starts a local API server and needs a writable location for the SQLite bootstrap database (qwed.db). The CLI resolves the runtime directory as follows:
  1. Current working directory β€” used if it is writable
  2. ~/qwed-demo/ β€” created and used as a fallback when the current directory is read-only (e.g., inside a container, a mounted volume, or a system-managed path)
The server process starts with its working directory set to this runtime directory, and DATABASE_URL is explicitly set to sqlite:///<runtime_dir>/qwed.db. This ensures bootstrap writes never target a read-only path.
If you previously encountered sqlite3.OperationalError: attempt to write a readonly database during qwed init, upgrade to v4.0.0 or later. The fix automatically resolves a writable directory so Step 3 succeeds regardless of where you run the command.
Security guarantees:
  • Keys are entered with masked input and never displayed in full
  • Keys are never written to logs
  • .env is written with 0600 permissions (owner-read/write only on Unix)
  • .gitignore protection is enforced before writing secrets β€” the command aborts if .env cannot be gitignored
  • Atomic file writes prevent partial credential exposure
  • Symlink targets are refused to prevent path traversal
  • .gitignore protection is enforced before writing secrets
Placeholder API key detection: During onboarding, qwed init automatically detects and ignores common placeholder or dummy API key values. If your environment variable or --api-key argument contains a placeholder value, QWED treats it as empty and prompts you for a real key. Recognized placeholders include your-api-key, changeme, placeholder, xxx, and short NVIDIA keys such as nvapi-xxxx. This prevents silent failures caused by example values left in .env files or CI templates. The following patterns are rejected:
  • Generic placeholders: test, dummy, sample, example, placeholder, changeme, null, none
  • Wildcard-style values: strings made entirely of x, *, or . characters (e.g. xxx, ****)
  • Template values: strings starting with your- or replace- that contain key
  • Short NVIDIA keys: nvapi- prefixed values shorter than 20 characters
In non-interactive mode, the CLI checks three key sources: CLI argument, environment variable, and NVIDIA fallback. If all three resolve to a placeholder, the command reports that the key is required and exits. You get a clear error instead of a cryptic provider failure downstream. Re-running qwed init: Running the command again merges new values into your existing .env file. Existing variables that you don’t reconfigure are preserved.

qwed doctor - system health check

Run a local health check that reports the status of verification engines, LLM provider connectivity, the QWED server, and the database. Use this after installation or when verification calls fail unexpectedly.
What it checks: The command exits with code 0 when all required checks pass (status OPERATIONAL) and code 1 when any required check fails (status DEGRADED). Optional engines that are missing do not cause a degraded status.

.env override behavior

The doctor command loads your .env file with override mode enabled. This means values in your .env file take precedence over variables already set in the current shell environment. For example, if your shell has ACTIVE_PROVIDER=ollama but your .env file contains ACTIVE_PROVIDER=openai_compat, the doctor report reflects the .env value (openai_compat). This ensures the health report matches the configuration your application actually uses at runtime.

Database URL resolution

When checking database health, doctor prefers the DATABASE_URL environment variable (including values loaded from .env) over the application settings default. The resolution order is:
  1. DATABASE_URL from environment / .env β€” used if present and non-empty
  2. Application settings β€” the DATABASE_URL from your QWED configuration
  3. Default β€” falls back to sqlite:///./qwed.db
This ensures the doctor report checks the database your deployment actually connects to, even when DATABASE_URL is set via environment variables rather than application config. Example output:

JSON output (CI/CD)

Use --json for machine-readable output. Useful in CI pipelines or monitoring scripts.
Options:
Run qwed doctor --json in CI to gate deployments on system health. A non-zero exit code means at least one required component is degraded.

qwed test - deterministic verification tests

Run the built-in deterministic test suite across the Math, Logic, SQL, and Code engines. Every test case has a known expected result and does not depend on an LLM, so outcomes are fully reproducible.
Use this command to confirm that verification engines are working correctly after installation, upgrades, or environment changes. What it tests: The command exits with code 0 when all tests pass and code 1 when any test fails. Example output:

Verbose mode

Use --verbose to show additional detail per test case, such as computed values and internal status codes.
Options:

qwed verify - one-shot verification

Verify a query and exit.
Options:
  • --provider, -p - LLM provider (openai, anthropic, gemini)
  • --model, -m - Model name (e.g., gpt-4o-mini, llama3)
  • --base-url - Custom API endpoint (for Ollama: http://localhost:11434/v1)
  • --api-key - API key (or use QWED_API_KEY env var)
  • --no-cache - Disable caching
  • --quiet, -q - Minimal output (for scripts)
  • --mask-pii - Mask PII (emails, phone numbers, etc.) before sending queries to the LLM
Examples:

qwed interactive - interactive mode

Start an interactive REPL session.
Usage:
Special commands:
  • stats - Show cache statistics
  • exit, quit, q - Exit interactive mode

qwed cache - cache management

Manage verification result cache.

qwed cache stats

Show cache statistics.

qwed cache clear

Clear all cached results.

qwed pii - PII detection

Test PII detection on arbitrary text. Requires the qwed[pii] extra.
Example output:
Install PII support with pip install 'qwed[pii]' and download the spaCy model: python -m spacy download en_core_web_lg.

Environment variables

ACTIVE_PROVIDER

Set by qwed init. Tells the CLI which provider to use when no --provider or --base-url flag is given.
Valid values: openai, anthropic, gemini, openai_compat.

Provider-specific variables

These are written to .env by qwed init and loaded automatically via python-dotenv: The recommended way to set these is via qwed init, which writes them to a .env file automatically. You can also export them manually.

DATABASE_URL

Override the default database connection used by QWED. When set, qwed doctor uses this value for its health check instead of the application settings default.
Supported schemes include sqlite, postgresql, mysql, and mariadb. For SQLite, use the sqlite:/// prefix (e.g., sqlite:///./qwed.db for a relative path or sqlite:////absolute/path/qwed.db for an absolute path).

QWED_API_KEY

Fallback API key when a provider-specific key is not set.

QWED_QUIET

Disable colorful branding output.

Configuration

Provider priority

When you run qwed verify without explicit flags, the CLI resolves the provider in this order:
  1. Command-line flags β€” --provider or --base-url take highest precedence
  2. ACTIVE_PROVIDER env var β€” set by qwed init or manually in .env
  3. Ollama default β€” falls back to http://localhost:11434/v1 with model llama3
If you have run qwed init, the ACTIVE_PROVIDER value in your .env determines which provider and credentials are used automatically.

Default models


Output formats

Colorful output (default)

Quiet output (--quiet)

Error output


qwed provider - custom provider management

Manage custom LLM providers defined in ~/.qwed/providers.yaml. See Custom providers for the full guide.

qwed provider import <url>

Import a community provider definition from a URL. The YAML file is downloaded, validated, and saved locally.
Example output:
After importing, the new provider appears as a selectable option when you run qwed init.
Only http and https URLs are accepted. The imported YAML must contain base_url and api_key_env fields. Downloads time out after 10 seconds.

Use cases

1. Quick verification

2. Scripting

3. Local development

4. Cache performance testing


Troubleshooting

”Ollama not running"

"API key required"

"Module not found”


Advanced features

Caching behavior

  • Default: Enabled (24h TTL)
  • Disable: --no-cache flag
  • Clear: qwed cache clear
  • Stats: qwed cache stats

Multiple providers