Installation
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.
- Engine readiness β checks that core verification engines (SymPy, Z3, AST, SQLGlot) are installed, then runs deterministic smoke tests to confirm they work correctly
- LLM provider setup β select a provider, enter credentials with masked input, validate the key format, and test the connection with retry support
- API key bootstrap β starts a local QWED server, creates an organization, and generates a one-time API key you can use immediately
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.
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.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:
- Current working directory β used if it is writable
~/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)
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.- Keys are entered with masked input and never displayed in full
- Keys are never written to logs
.envis written with0600permissions (owner-read/write only on Unix).gitignoreprotection is enforced before writing secrets β the command aborts if.envcannot be gitignored- Atomic file writes prevent partial credential exposure
- Symlink targets are refused to prevent path traversal
.gitignoreprotection is enforced before writing secrets
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-orreplace-that containkey - Short NVIDIA keys:
nvapi-prefixed values shorter than 20 characters
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.
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:
DATABASE_URLfrom environment /.envβ used if present and non-empty- Application settings β the
DATABASE_URLfrom your QWED configuration - Default β falls back to
sqlite:///./qwed.db
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.
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.
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.
qwed verify - one-shot verification
Verify a query and exit.
--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 useQWED_API_KEYenv 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
qwed interactive - interactive mode
Start an interactive REPL session.
stats- Show cache statisticsexit,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.
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.
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.
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 runqwed verify without explicit flags, the CLI resolves the provider in this order:
- Command-line flags β
--provideror--base-urltake highest precedence ACTIVE_PROVIDERenv var β set byqwed initor manually in.env- Ollama default β falls back to
http://localhost:11434/v1with modelllama3
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.
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-cacheflag - Clear:
qwed cache clear - Stats:
qwed cache stats
Multiple providers
Related docs
- QWEDLocal guide β Python API for local verification
- Ollama integration β use free local LLMs
- LLM configuration β provider setup details