--non-interactive with --provider and --api-key flags. See the CLI reference for the full walkthrough.
The rest of this page covers manual configuration and advanced options.
Understanding QWED’s architecture
QWED uses LLMs as untrusted translators, not as answer generators:Key Insight: The LLM translates natural language to structured form. QWED then verifies the structured form using deterministic engines. The LLM can be wrong — QWED catches and corrects errors.
Supported LLM providers
Configuration options
Option 1: use QWED’s built-in translation (recommended)
QWED can handle LLM translation internally:Option 2: bring your own LLM
Use QWED purely as a verification layer:Option 3: Self-hosted with custom LLM
For self-hosted deployments, runqwed init or manually create a .env file:
When
ACTIVE_PROVIDER is not set, QWED defaults to Ollama as a safe local fallback. Set ACTIVE_PROVIDER explicitly if you want to use a cloud provider..env files in a specific order: the project-level .env (in the current working directory) takes precedence, followed by the global ~/.qwed/.env. This ensures your project-specific configuration always overrides global defaults. If python-dotenv is not installed, .env loading is skipped gracefully with a warning.
Provider-specific setup
OpenAI
sk-... or sk-proj-... — get yours at platform.openai.com/api-keys.
Anthropic (Claude)
sk-ant-... — get yours at console.anthropic.com/settings/keys.
Local LLMs (Ollama)
No API key needed. Install Ollama, pull a model, and configure QWED:OpenAI-compatible endpoint
For any service with an OpenAI-compatible API — DigitalOcean, Groq, Together AI, LM Studio, vLLM, and others:CUSTOM_BASE_URL is required. If your endpoint does not require authentication (for example, a local vLLM or LM Studio server), you can omit CUSTOM_API_KEY entirely. QWED supplies a placeholder token so the underlying client initializes correctly.
Google Gemini
Gemini uses a nativeGeminiProvider powered by the google-generativeai SDK. Install the dependency first:
GEMINI_API_KEY instead of GOOGLE_API_KEY. Get yours at aistudio.google.com/app/apikey.
The Gemini provider supports math translation, logic verification, stats query generation, fact verification, and image claim verification. All API calls use a 30-second timeout and temperature=0.0 for deterministic output. If google-generativeai is not installed, QWED returns a structured ImportError instead of crashing.
Azure OpenAI
Claude Opus
Universal provider config (YAML)
New in v4.0.0
~/.qwed/providers.yaml. This is useful for managing multiple providers, custom endpoints, or community-contributed provider configs.
YAML format
Import community providers
You can import provider configurations from a URL:Key validation
QWED validates API keys in two stages:- Format check — Regex-based pattern matching (no network call). Built-in patterns include
sk-...for OpenAI andsk-ant-...for Anthropic. - Connection test — Lightweight read-only request to the provider’s models endpoint to confirm the key works.
qwed init to validate your keys interactively, or test programmatically:
Provider routing
QWED automatically routes queries to the appropriate provider based on your configuration and query content.Alias normalization
Provider names are normalized before routing, so common variations likeopenai-compatible, openai_compatible, and openai_compat all resolve to the same OpenAI-compatible provider. You do not need to worry about exact casing or separators when specifying a provider in API requests or environment variables.
Content-aware routing
When no preferred provider is specified in a request, QWED uses the configured default. For certain query types, QWED applies content-aware heuristics:
You can always override routing by passing an explicit
provider parameter in your API request.
Programmatic configuration
Translation vs verification
Understanding the two phases:When you need an LLM
client.verify("Is the derivative of x² equal to 2x?")— Needs LLM to parseclient.verify("Calculate compound interest on $1000 at 5%")— Needs LLM
When you don’t need an LLM
client.verify_math("diff(x**2, x) == 2*x")— Already structuredclient.verify_logic("(AND (GT x 5) (LT x 10))")— Already in DSLclient.verify_sql("SELECT * FROM users")— Already structuredclient.verify_code("import os; os.system('rm -rf /')")— Code, not NL
FAQ
Do I need an LLM to use QWED?
No. If you’re sending structured queries (math expressions, SQL, code, QWED-Logic DSL), you don’t need an LLM. QWED engines work directly on structured input.Can I use my own LLM and just use QWED for verification?
Yes. This is the “Bring Your Own LLM” pattern. Call your LLM, then pass its output to QWED for verification.Which LLM is best for QWED translation?
For translation accuracy, use one of the following (in order of preference):- GPT-4o (best)
- Claude 3 Opus
- Gemini Pro
- GPT-3.5-turbo (good for simple queries)
Is the LLM translation deterministic?
We settemperature=0 for reproducibility, but LLMs are inherently probabilistic. That’s why QWED verification is essential — it provides the determinism guarantee.
Next steps
- Quick start tutorial
- Custom providers — add any OpenAI-compatible endpoint via YAML
- QWED-Logic DSL reference
- Self-hosting guide