add-llm-model
GitHub指导在Stagewise系统中添加或更新LLM模型支持的工作流,涵盖元数据目录维护、Provider路由配置、API验证及展示UI更新。
Trigger Scenarios
Install
npx skills add stagewise-io/stagewise --skill add-llm-model -g -y
SKILL.md
Frontmatter
{
"name": "add-llm-model",
"description": "Use when adding a new LLM\/model to stagewise model catalogs, provider instances, routing, validation, docs, or showcase UI."
}
Add LLM Model
Use this workflow when adding or updating model support in stagewise.
Architecture First
Models are no longer a single global enabled/disabled list. Routing and model
availability are scoped to entries in preferences.providerInstances.
apps/browser/src/shared/available-models.tsis the curated metadata catalog.apps/browser/src/backend/agents/providers/contains stateless provider-type implementations.registry.tsmaps eachProviderInstanceTypeIdto its type.apps/browser/src/backend/agents/model-provider.tsresolves a provider instance, then delegates ID conversion and model creation to its provider type.- Each provider instance owns
enabledModelIds,disabledModelIds, anddiscoveredModels. apps/browser/src/shared/flagship-models.tscurates newly discovered models per provider instance. Catalog models on official APIs are considered flagship. OpenRouter has its own prefixed-ID flagship set.
Read those files and the relevant provider implementation before deciding the change surface. Do not apply guidance written for the old global model list.
Required Checks
-
Research authoritative metadata.
- Confirm the canonical ID, native provider ID, context window, modalities, tool support, reasoning support, and pricing.
- Prefer provider documentation for native behavior and OpenRouter data for the Stagewise/OpenRouter route.
- Keep still-supported sibling models unless removal was explicitly requested.
-
Add or update catalog metadata.
- Edit
apps/browser/src/shared/available-models.ts. - Match the field order and provider options of the nearest sibling.
- Update
apps/browser/src/shared/model-thinking-capabilities.tswhen the model supports configurable thinking/reasoning.
- Edit
-
Audit provider-instance routing.
- Inspect
apps/browser/src/backend/agents/providers/registry.tsand the relevant implementation inapps/browser/src/backend/agents/providers/. - Existing providers are normally model-agnostic; do not add a per-model branch unless the wire ID or API behavior genuinely differs.
- Put canonical-to-wire ID conversion in the provider type's
toWireModelId, not in new branches in the central model provider. - Stagewise routing prefixes canonical IDs for OpenRouter in
providers/stagewise.ts. - Explicit custom endpoint
modelIdMappingvalues must override defaults.
- Inspect
-
Curate discovery intentionally.
- For OpenRouter, update
OPENROUTER_FLAGSHIP_MODELSinapps/browser/src/shared/flagship-models.tswhen the new model should be enabled on first discovery. IDs must include the OpenRouter vendor prefix. - Remove a superseded model from that set only if it should stop being a
default for new discovery. Existing user choices are intentionally
preserved by
computeDisabledModelIdsAfterDiscovery. - Official-provider catalog entries are already treated as flagship; do not
duplicate them in
VENDOR_FLAGSHIP_DISCOVERED_MODELS.
- For OpenRouter, update
-
Do not seed model deprecations in the legacy provider migration.
- Never add a new model ID to the
stagewise-default.disabledModelIdsliteral insidePreferencesService.migrateToProviderInstances. - That function runs only when
providerInstancesis empty. Such a change affects only users crossing the legacy migration and misses users whose instances already exist, creating inconsistent availability. - Do not patch the ID on every startup either; that would override a user's later decision to re-enable the model.
- If product requirements call for changing existing users' model choices, ask first and implement an explicit, idempotent, versioned preference migration with tests. Define which provider-instance types are in scope and preserve choices after the migration has run once.
- If the old model remains supported, keep it in the catalog and leave existing per-instance state untouched. Discovery flagship curation controls defaults for newly discovered provider models.
- Never add a new model ID to the
-
Keep credential validation cheap and broadly available.
- Validation now belongs to the provider type's
validateCredentialsimplementation, usually inproviders/official-api.ts, rather than being hardcoded in central routing. - Do not switch validation to a new flagship/high-tier model by default. Prefer a cheap model broadly available to provider keys.
- Legacy
validate-api-keys.tspaths may still exist for compatibility; inspect callers before editing them.
- Validation now belongs to the provider type's
-
Audit other product surfaces rather than editing mechanically.
- Coding plans:
apps/browser/src/shared/coding-plans.ts. - Homepage showcase:
apps/website/src/app/(home)/_components/model-provider-showcase.tsx. - README files and localized variants.
- Thinking tests, provider tests, and model-selector tests.
- Historical benchmark/comparison copy must not be renamed without evidence.
- Coding plans:
-
Always verify subscription-plan base URLs.
- Many providers use different API endpoints for subscription/token-plan keys vs. pay-as-you-go (BYOK) keys.
- Example: GLM uses
https://api.z.ai/api/paas/v4for BYOK buthttps://api.z.ai/api/coding/paas/v4for coding-plan subscriptions. Xiaomi MiMo useshttps://api.xiaomimimo.com/v1for BYOK buthttps://token-plan-cn.xiaomimimo.com/v1for token-plan subscriptions. - The two key types are often non-interchangeable — a subscription key will be rejected by the BYOK endpoint and vice versa.
- Before finalizing a coding-plan entry, always check the provider's official documentation to confirm:
- Whether subscription tokens require a separate
baseUrl/validationBaseUrl. - The correct cluster or region-specific URL (some providers offer multiple regional endpoints for subscriptions).
- The API key format prefix (e.g.
tp-for MiMo token plan vssk-for BYOK).
- Whether subscription tokens require a separate
- Set
baseUrl,validationBaseUrl,validationModelId,apiKeyPattern, andendpointHelpTexton the coding-plan entry accordingly. - If the provider exposes documentation via
llms.txt, fetch it — it links to raw markdown doc pages that contain the authoritative endpoint and auth details. - Update
apiKeyUrlandhelpTextto point to the subscription management page (not the BYOK API keys page) when the two are separate.
Validation
After changes:
- Run targeted tests for catalog metadata, thinking capabilities, flagship discovery, provider routing, and any preference migration touched.
- Run browser typecheck and Biome on all edited files.
- Search for the new and superseded model IDs across browser and website code.
- Confirm Stagewise/OpenRouter and official-provider wire IDs independently.
- Confirm docs, coding-plan
featuredModelIds, and showcase entries are intentionally aligned. - If preference migration changed, test both empty and already-populated
providerInstances, idempotence, and preservation of user choices.
Version History
-
18ac8a2
Current 2026-08-19 21:42
重构为架构优先模式,引入基于providerInstances的细粒度路由和可用性控制,移除旧的全局开关逻辑,细化元数据与研究检查步骤。
- 45a1544 2026-07-24 21:12


