--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.An ACTIVE_PROVIDER that names no provider QWED knows stops the request with an error naming ACTIVE_PROVIDER. A request that names its own provider must name one QWED knows, or it is refused. Each request runs on the provider it names, else on the one ACTIVE_PROVIDER selects..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.
The server’s Anthropic provider is an Azure AI Foundry client: set ANTHROPIC_ENDPOINT to your Foundry endpoint in the server’s environment. On the server, ANTHROPIC_ENDPOINT and ANTHROPIC_API_KEY are both required, or the provider stops with Missing Anthropic environment variables. The qwed CLI calls the Anthropic API directly instead: it reads ANTHROPIC_API_KEY and ANTHROPIC_MODEL, and stops if ANTHROPIC_ENDPOINT is set.
The Anthropic provider doesn’t send temperature, top_p, or top_k. The anthropic SDK has had no sampling parameters since 1.0, and Anthropic API version 2026-10-21, which the 2.x SDK sends, refuses them. Claude samples with the model’s defaults, and no QWED setting overrides them. Sampling can vary the translations Claude returns and the verdicts verify_fact and verify_image return. QWED’s fact and image verifiers record those verdicts only as advisory checks, never as VERIFIED.
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 and CUSTOM_MODEL are 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
temperature and samples with the model’s defaults. Sampling can vary translations and the verdicts verify_fact and verify_image return. QWED records those verdicts only as advisory checks, never as VERIFIED.
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?
QWED is model-agnostic and recommends no model. Use any model your provider serves: the deterministic engines check every translation it produces.Is the LLM translation deterministic?
No. LLMs are inherently probabilistic. The Anthropic and Claude Opus providers don’t sendtemperature, so Claude samples with the model’s defaults. Sampling can vary translations and the verdicts verify_fact and verify_image return. QWED’s fact and image verifiers record those verdicts only as advisory checks, never as VERIFIED. The OpenAI, Azure OpenAI, OpenAI-compatible, Gemini, and Ollama providers send temperature=0.0, which reduces variation but doesn’t remove it.
That’s why QWED verification is essential. The deterministic engines give the same verdict for the same translation. They check the expression the model produced, not whether it matches your question, so two different translations of one question can get different verdicts.
Next steps
- Quick start tutorial
- Custom providers — add any OpenAI-compatible endpoint via YAML
- QWED-Logic DSL reference
- Self-hosting guide