docs/design/openrouter-auth-and-models.md
This document captures the design intent behind the OpenRouter auth flow and the model management changes introduced with it. It intentionally focuses on the product and architectural choices, not implementation history.
/auth./manage-models.OpenRouter is integrated as an OpenAI-compatible provider:
AuthType.USE_OPENAImodelProviders.openaiOPENROUTER_API_KEYhttps://openrouter.ai/api/v1This avoids introducing an OpenRouter-specific AuthType when the runtime model
provider path is already OpenAI-compatible. It keeps auth status, model
resolution, provider selection, and settings schema aligned with the existing
provider abstraction.
The user-facing flows are:
qwen auth openrouter --key <key> for automation or direct API-key setup.qwen auth openrouter for browser-based OAuth./auth → API Key → OpenRouter for the TUI flow.Browser OAuth uses OpenRouter's PKCE flow and writes the exchanged API key into
settings before refreshing auth as AuthType.USE_OPENAI.
OpenRouter exposes a large dynamic model catalog. Writing every discovered model
into modelProviders.openai would make /model noisy and would turn a long-term
settings field into a cache of a remote catalog.
The key design split is:
/model and
be persisted in user settings.For the initial OpenRouter flow, auth should finish with a useful default enabled set instead of interrupting the user with a large picker. The recommended set should be small, stable, and biased toward models that let users try the product successfully, including free models when available.
/model remains a fast model switcher. It should not become the place where
users browse and curate a full provider catalog.
/manage-modelsRicher model management belongs in a separate /manage-models entry point. That
flow should let users:
free or
vision;The source dimension must remain part of this design. OpenRouter is only the first dynamic catalog source; future sources such as ModelScope and ModelStudio should fit the same shape. UI complexity can be reduced, but the underlying source abstraction should stay available as the extension point.
This change should do the minimum needed to make OpenRouter auth and model setup pleasant:
/manage-models.The design principle is simple: authentication should get users to a working state quickly, while model curation should live in a dedicated management flow.