Skip to content

OpenRouter accepts invalid API keys as enabled #69

@ElioNeto

Description

@ElioNeto

Original issue tinyhumansai#2366 by @Al629176 on 2026-05-20T19:11:19Z


Summary

OpenRouter can be enabled with a random invalid API key, so users think the provider is connected even though it was never validated.

Problem

In the custom/cloud provider setup flow, entering a random API key for OpenRouter is accepted and the OpenRouter provider toggle becomes enabled. The app does not appear to validate the key or endpoint before marking the provider usable.

Expected behavior: OpenRouter should only be enabled after the key and endpoint are validated, or it should clearly show an unverified/pending state until validation succeeds.

Actual behavior: a random key is accepted and OpenRouter appears enabled.

Impact: users can configure a broken provider and only discover the failure later in chat or routing, where the cause is much harder to understand.

Steps to reproduce:

  1. Open Settings → AI → LLM.
  2. Add a cloud provider.
  3. Select OpenRouter.
  4. Enter a random invalid API key.
  5. Save the provider.
  6. Observe that OpenRouter is enabled despite the invalid key.

Version / platform: macOS desktop app, screenshot captured May 21, 2026. Exact app version unknown.

Solution (optional)

Validate provider credentials before enabling the provider. For OpenRouter, use the correct OpenRouter endpoint and a lightweight validation call. If offline validation is not possible, mark the provider as “saved but unverified” rather than enabled.

Acceptance criteria

  • Invalid key rejected — A random OpenRouter key does not enable OpenRouter as a usable provider.
  • Correct provider endpoint — OpenRouter validation uses the OpenRouter endpoint, not an OpenAI endpoint.
  • Clear state — Saved but unverified credentials are shown as pending/unverified, not connected/enabled.
  • Routing protected — Routing does not select an unverified provider for chat or background workloads.
  • Regression safety — Tests cover invalid key, valid mocked key, and endpoint mismatch behavior.
  • Diff coverage ≥ 80% — the fix PR meets the changed-lines coverage gate (Vitest + cargo-llvm-cov, enforced by .github/workflows/coverage.yml).

Related

  • Screenshot: Screenshot 2026-05-21 at 12.34.59 AM.png

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions