Skip to main content
QWED works with any LLM provider. The fastest way to get configured is the onboarding command:
This verifies your verification engines are operational, walks you through provider selection and secure key entry, and bootstraps a local API key — all in a single command. For CI/CD pipelines, pass --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

You can add any OpenAI-compatible provider (Groq, Together, Fireworks, and others) using a YAML configuration file. See Custom providers for details.

Configuration options

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, run qwed 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.
QWED loads .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

You can configure any of these providers interactively by running qwed init.

OpenAI

Key format: sk-... or sk-proj-... — get yours at platform.openai.com/api-keys.

Anthropic (Claude)

Key format: 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:
Only 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 native GeminiProvider powered by the google-generativeai SDK. Install the dependency first:
Then configure your environment:
You can also use 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
You can define custom LLM providers using a YAML configuration file at ~/.qwed/providers.yaml. This is useful for managing multiple providers, custom endpoints, or community-contributed provider configs.

YAML format

The YAML file is written with 0600 permissions (owner-only) for security. The ~/.qwed/ directory is created with 0700 permissions.

Import community providers

You can import provider configurations from a URL:
Or use the CLI:
Imported providers are validated and sandboxed — only the allowed fields listed above are saved. Provider slugs are sanitized and cannot shadow built-in providers.

Key validation

QWED validates API keys in two stages:
  1. Format check — Regex-based pattern matching (no network call). Built-in patterns include sk-... for OpenAI and sk-ant-... for Anthropic.
  2. Connection test — Lightweight read-only request to the provider’s models endpoint to confirm the key works.
Run 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 like openai-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 parse
  • client.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 structured
  • client.verify_logic("(AND (GT x 5) (LT x 10))") — Already in DSL
  • client.verify_sql("SELECT * FROM users") — Already structured
  • client.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):
  1. GPT-4o (best)
  2. Claude 3 Opus
  3. Gemini Pro
  4. GPT-3.5-turbo (good for simple queries)

Is the LLM translation deterministic?

We set temperature=0 for reproducibility, but LLMs are inherently probabilistic. That’s why QWED verification is essential — it provides the determinism guarantee.

Next steps