Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

📝 docs: consolidate model provider onboarding skill (#19207)

YuTengjing36fd9405ef69
diff --git a/.agents/skills/add-model-provider/SKILL.md b/.agents/skills/add-model-provider/SKILL.md
new file mode 100644
index 00000000000..ed9a5045539
--- /dev/null
+++ b/.agents/skills/add-model-provider/SKILL.md
@@ -0,0 +1,61 @@
+---
+name: add-model-provider
+description: Add an AI model provider to LobeHub, including runtime integration, model cards, configuration, branding, documentation, and acceptance. Also use for provider documentation updates; adding models to an existing provider does not require a new provider integration.
+disable-model-invocation: true
+argument-hint: '[provider-name]'
+---
+
+# Add a Model Provider
+
+Deliver a provider that users can configure, recognize, and use through the supported API paths. This skill includes the documentation workflow formerly maintained in `add-provider-doc`.
+
+Paths below are relative to the open-source repository root. In a Cloud checkout, prefix them with `lobehub/` and follow the parent repository's install and Git rules. Hosted model configuration is a separate workflow: use the deployment operator's model-onboarding process when that is the requested target. Do not copy private deployment settings or routing information into this skill or an OSS change.
+
+For a documentation-only request, inspect the implemented configuration and follow [Provider documentation](references/documentation.md); do not add runtime code merely to satisfy this checklist.
+
+For a model-only request on an existing provider, follow [model-bank-metadata](../model-bank-metadata/SKILL.md) for `knowledgeCutoff`, `family`, and `generation`, using its single-model guidance rather than the repo-wide sweep. Use the research and focused validation below for other model-card fields, including capabilities, pricing, and context limits. Skip new provider registration, authentication configuration, and provider-list reordering unless the requested model exposes a confirmed gap in those paths.
+
+## Establish the Integration Contract
+
+- Distinguish a new provider from a model added to an existing provider. Record the stable provider ID, display name, model IDs, authentication method, endpoint, and supported API modes. File/export casing may differ from the lowercase provider ID; follow actual consumers.
+- Read the official announcement, API reference, model catalog, pricing, and migration notes. Record source URLs and access dates for capabilities, constraints, and pricing. Search for announcements as well as documentation: parameter changes often appear only in release notes. Use a rendered browser when a fetched page is an empty client-rendered shell.
+- Verify the endpoint actually being integrated. A model's advertised capabilities do not prove that a compatible endpoint supports its search parameters, tools, images, or structured output. Do not describe a third-party endpoint or its credentials as the provider's official API.
+- Compare the latest provider addition and the closest existing implementation by protocol and authentication. Read their diffs, not just file lists. [Integration map and precedents](references/integration-map.md) identifies the registration chain and contrasting examples; historical omissions are not requirements to repeat.
+- Set model metadata from evidence: exact IDs, family/generation, context and output limits, release/cutoff dates when known, capabilities, extend parameters, search behavior, pricing currency and units. Distinguish API usage prices from subscription entitlements, cached input from ordinary input, and current promotions from list prices. Mark unknowns rather than inventing values; preserve existing supported models.
+
+## Implement the Provider
+
+Use [Integration map and precedents](references/integration-map.md) while tracing the request from settings through configuration to the runtime.
+
+1. Register the provider ID, provider card, separate model cards, model imports/map/exports, and package subpath export. Keep `chatModels: []` on modern provider cards when the separate model bank is the source of truth.
+2. Set a usable `checkModel` and accurate settings for authentication, model fetching, SDK family, and browser requests. A static model catalog may be correct when the API has no model-list endpoint. Trace consumers of both top-level and nested browser-request flags before relying on one of them.
+3. Reuse the appropriate runtime factory or adapter. Register the runtime and its public export. If the provider needs a distinct routed API adapter, wire the RouterRuntime API type and base-runtime map too; provider registration alone does not establish that path.
+4. Validate protocol selection separately for streaming chat, non-streaming chat, and structured generation. Responses-only providers may need both chat and `generateObject` configuration, plus protection against a caller selecting an unsupported mode. Map tools, search, response formats, and reasoning only where supported. Never enable a capability solely because a sibling provider does.
+5. Add authentication/configuration plumbing appropriate to the provider. For API-key providers, check both environment schema and runtime bindings, then the generic server configuration and runtime initialization. OAuth providers need their authorization, refresh, disconnect, and account-metadata paths instead of invented API-key variables.
+6. For a new user-facing parameter, trace the model-card type, stored chat configuration, controls, request resolver, and translations. Prefer existing parameter definitions when their semantics match. If reasoning state must survive multiple turns, test serialization and replay through the real stream/non-stream paths rather than only the initial request.
+
+Keep changes to shared factories or error handlers conditional on an observed gap. The checklist is not a mandate to modify every listed file.
+
+## Branding, Ordering, and Documentation
+
+- Check provider and model icons independently in `@lobehub/icons`: the provider brand and model family can require different artwork. Inspect the actual model-ID matcher, including prefixes, case variants, and collisions with existing model names. When changing a matcher, verify the new IDs and preserve the older family's matches.
+- If an icon is missing, identify the missing asset/mapping and prepare an appropriate change or explicit fallback within the authorized scope. Do not silently use an unrelated brand. An external icon PR or release is a separate authorized action; verify that the consumer's installed release contains the intended mapping before claiming the UI is fixed.
+- Place the provider deliberately in `DEFAULT_MODEL_PROVIDER_LIST` beside appropriate peers. This array controls default list order; import order and enum order do not. Preserve a user-specified position and existing user-customized ordering. Do not turn one provider addition into an unrelated list reordering.
+- Follow [Provider documentation](references/documentation.md) for bilingual usage/setup instructions, environment references, existing Docker configuration, safe examples, and screenshots. Keep the public provider identity and actual credential/endpoint requirements consistent across UI and docs.
+- Add `<provider-id>.description` to `locales/en-US/providers.json` and `locales/zh-CN/providers.json` for the provider's description. The default namespace in `packages/locales/src/default/providers.ts` is derived from provider cards; do not duplicate the description there. Follow repository conventions for other new copy and verify fallback behavior. Avoid running a repository-wide translation job for a few provider keys.
+
+## Validate the User Path
+
+Use the existing provider test harness (`packages/model-runtime/src/providerTestUtils.ts`) and focused package tests. Cover the supported behavior rather than asserting that registration strings exist:
+
+- Provider/model lookup resolves the new cards and runtime; connection checking uses a supported model.
+- Requests select the intended API mode and endpoint, carry the right authentication, transform supported parameters, and preserve tool calls and structured results. Exercise streaming and non-streaming paths when supported.
+- Missing/invalid credentials, failed model fetching, and connection errors produce useful localized messages rather than raw codes or translation keys. Use synthetic HTTP responses for legacy/invalid wire payloads instead of casting them into a stricter current response type.
+- The provider settings page and model row display the intended name, icon, capabilities, and default order in light/dark themes. Check English and Chinese where copy changed. Inspect both provider and model icons in the real UI.
+- When shared runtime errors or lazy namespaces change, check other affected surfaces such as Workbench. Its separate language bundle may need a namespace even when the main application already loads it.
+
+Run the owning repository's quality command and relevant package tests. For an OSS PR developed inside Cloud, verify the OSS type-check/build context as well: a passing parent type-check does not establish that the standalone OSS configuration passes. Attribute workspace-resolution failures separately; do not remove valid checks to manufacture a pass.
+
+Use the repository's acceptance workflow for authorized live checks. Do not read secret files, put credentials into logs/screenshots, invent screenshots, or claim a successful inference from mocks. If live credentials or access are unavailable, report the precise unverified path and the completed offline checks.
+
+When delivery includes a PR, follow repository commit/PR workflows and monitor CI and deployment for the current head. Attribute failures, fix in-scope issues, validate, push, and continue until checks complete or a concrete blocker is reached. Preserve applicable independent-review gates and human-only merge rules. Report changed behavior, validation, evidence, and remaining limitations.
diff --git a/.agents/skills/add-provider-doc/agents/openai.yaml b/.agents/skills/add-model-provider/agents/openai.yaml
similarity index 100%
rename from .agents/skills/add-provider-doc/agents/openai.yaml
rename to .agents/skills/add-model-provider/agents/openai.yaml
diff --git a/.agents/skills/add-model-provider/references/documentation.md b/.agents/skills/add-model-provider/references/documentation.md
new file mode 100644
index 00000000000..631b464770c
--- /dev/null
+++ b/.agents/skills/add-model-provider/references/documentation.md
@@ -0,0 +1,46 @@
+# Provider Documentation
+
+This replaces the former `add-provider-doc` workflow. Use it for a new integration or a documentation-only update. Derive instructions from implemented behavior and verified public sources, not from a generic API-key template.
+
+## Usage Guide
+
+Create or update the corresponding pair:
+
+- `docs/usage/providers/<provider>.mdx`
+- `docs/usage/providers/<provider>.zh-CN.mdx`
+
+Use a nearby provider with the same authentication method as the structural example. `docs/usage/providers/fal.mdx` demonstrates the MDX frontmatter, `Image`, and `Steps` components; its image-generation workflow is not a chat-provider template.
+
+Explain:
+
+- Where the user obtains access and which account, API key, subscription, or OAuth login is required, with real public registration/dashboard links.
+- How to find the provider in LobeHub, authenticate or enter configuration, choose a supported model, and verify the connection.
+- The implemented endpoint and API-mode restrictions that affect setup. Clearly distinguish an official API from a compatible third-party service.
+- Relevant availability, billing model, and a link to current authoritative pricing. Do not present subscription access as per-token API billing or copy volatile prices without a source/date.
+- Actionable setup errors and limitations that were actually verified.
+
+Use concise positioning and instructions. Do not include internal deployment, private routing, credentials, or implementation details unrelated to user decisions.
+
+## Environment and Deployment
+
+Update applicable entries in both:
+
+- `docs/self-hosting/environment-variables/model-provider.mdx`
+- `docs/self-hosting/environment-variables/model-provider.zh-CN.mdx`
+
+Document only variables the implementation consumes. For each, give required/optional status in the supported setup, purpose, safe example, and default or enablement behavior. Common API-key conventions include `ENABLED_<ID>`, `<ID>_API_KEY`, `<ID>_MODEL_LIST`, and `<ID>_PROXY_URL`, but provider-specific endpoint names and authentication methods can differ. OAuth-only providers do not acquire API-key variables merely to fill this list.
+
+Explain model-list syntax only if the provider uses the shared parser; match current examples for add/hide/rename operations. Avoid labeling an API key globally required when UI configuration or another documented authentication path can supply credentials.
+
+Inspect the current `Dockerfile` and any deployment templates that already expose neighboring providers. Extend the applicable environment block without recreating obsolete files: `Dockerfile.database` and `Dockerfile.pglite` were named by the old skill but may not exist in the checkout. Keep Docker entries, runtime configuration, and docs consistent. Add commented placeholders to the safe `.env.example` template where appropriate; never read actual `.env` files.
+
+## Images and Discoverability
+
+- Add a cover or screenshots when they help users complete setup, following neighboring docs. There is no fixed screenshot quota.
+- Capture real, current UI with credentials, personal data, and account identifiers removed or hidden before sharing. Use unmistakable placeholders in text examples. Never fabricate dashboard screenshots or claim that a generated image is verification evidence.
+- Follow the repository's existing asset workflow; current provider guides use the public CDN `hub-apac-1.lobeobjects.space`. Uploading images to an external host requires authorization for that destination; otherwise keep local reviewable assets and state the remaining publication step.
+- Inspect how neighboring provider pages enter navigation or generated indexes and update those sources when required. Do not invent a sidebar file when discovery is automatic.
+
+## Validate
+
+Run `bun run check <changed-document-paths>` using the owning repository's path conventions, and inspect the rendered guide when layout or images change. Check both languages, public links, image references, variable names and setup steps against the implementation. Report unavailable screenshots, credentials or live access as explicit gaps rather than claiming the guide was exercised end to end.
diff --git a/.agents/skills/add-model-provider/references/integration-map.md b/.agents/skills/add-model-provider/references/integration-map.md
new file mode 100644
index 00000000000..08a79323a96
--- /dev/null
+++ b/.agents/skills/add-model-provider/references/integration-map.md
@@ -0,0 +1,45 @@
+# Integration Map and Precedents
+
+Use this map to locate the current code. Verify paths and consumers before editing; additions with different authentication or protocols need different subsets.
+
+## Registration and Configuration
+
+| Concern | Current location | What to verify |
+| ----------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
+| Provider identity | `packages/model-bank/src/const/modelProvider.ts` | Stable `ModelProvider` ID used by all maps |
+| Provider card | `packages/model-bank/src/modelProviders/<provider>.ts` | Name, public URLs, `checkModel`, authentication, fetcher and browser settings |
+| Provider registration | `packages/model-bank/src/modelProviders/index.ts` | Import, `DEFAULT_MODEL_PROVIDER_LIST` position, card export |
+| Model cards | `packages/model-bank/src/aiModels/<provider>.ts` | Evidence-backed metadata, supported abilities, default enablement, prices |
+| Model registration | `packages/model-bank/src/aiModels/index.ts` | Import, `staticModelMap`, named export keyed to the provider ID |
+| Package access | `packages/model-bank/package.json` | New model module's subpath export, including filename casing |
+| Runtime implementation | `packages/model-runtime/src/providers/<provider>/index.ts` | Factory reuse, endpoint, protocol, payload and response behavior |
+| Runtime registration | `packages/model-runtime/src/runtimeMap.ts`, `packages/model-runtime/src/index.ts` | ID-to-runtime map and public export |
+| Distinct routed adapter | `packages/model-runtime/src/core/RouterRuntime/apiTypes.ts`, `baseRuntimeMap.ts` | Add only when this adapter is needed; test runtime selection |
+| API-key environment | `packages/env/src/llm.ts` | Schema and `runtimeEnv`; enablement semantics |
+| Server provider configuration | `apps/server/src/globalConfig/genServerAiProviderConfig.ts` | Generic uppercase ID conventions, model list and enablement overrides |
+| Runtime credentials/options | `apps/server/src/modules/ModelRuntime/index.ts` | Generic API-key/proxy handling versus provider-specific initialization |
+| OAuth flow | `apps/server/src/services/oauthDeviceFlow/`, `apps/server/src/routers/lambda/oauthDeviceFlow.ts` | Factory registration, token exchange/refresh, account metadata, disconnect |
+| New parameter controls | `packages/model-bank/src/types/aiModel.ts`, `packages/types/src/agent/chatConfig.ts`, `src/services/chat/mecha/modelParamsResolver.ts` | Trace consumers into controls and translations; avoid changing types alone |
+| Default list consumption | `packages/database/src/repositories/aiInfra/index.ts`, `src/store/aiInfra/slices/aiProvider/selectors.ts` | Built-in order versus enabled-provider custom sort |
+
+Provider-specific `*_MODEL_LIST` and `*_PROXY_URL` may be consumed dynamically. Trace the configuration path before adding redundant schema entries or documenting an unsupported variable. The deprecated `LOBE_DEFAULT_MODEL_LIST` is not a substitute for the modern model map; inspect actual consumers before changing it.
+
+Provider description translations live in `locales/en-US/providers.json` and `locales/zh-CN/providers.json` as flat `<provider-id>.description` keys. `packages/locales/src/default/providers.ts` derives defaults from the cards and is not a per-provider manual registry. Verify these translations even if the precedent PR omitted them.
+
+## Contrasting Examples
+
+Read these as evidence of different integration shapes, not as code to copy wholesale. Use the latest source and relevant official API documentation for a new provider.
+
+- [PR lobehub#17527](https://github.com/lobehub/lobehub/pull/17527), ChatGPT subscription authentication: a provider with OAuth device authorization, account metadata and Responses support. The diff also extends reasoning-signature transport and structured generation. It does not establish that all providers need OAuth, private protocol headers, or shared streaming changes. Its reported public endpoint checks are not proof of live authenticated inference.
+- [PR lobehub#13713](https://github.com/lobehub/lobehub/pull/13713), AntGroup: a conventional API-key provider using the OpenAI-compatible factory, environment bindings, separate model/provider cards and provider-specific reasoning controls. Missing runtime tests or setup documentation in an older diff do not exempt a new integration from validation or documentation.
+- [PR lobehub#19152](https://github.com/lobehub/lobehub/pull/19152), Meta: Responses-only chat and structured generation, explicit RouterRuntime registration and package export, independent provider/model branding, and deliberate list placement. This was an open PR when inspected on 2026-09-06; verify which changes exist in the checkout before reusing them. Its shared error-translation and Workbench fixes are conditional regression lessons, not files every provider must modify.
+
+## Focused Regression Lessons
+
+**Protocol selection:** `chatCompletion.useResponse` does not prove `generateObject` selects Responses. Test the actual structured-generation call and whether an explicit caller mode can select an unsupported API. Append hosted search tools without losing existing function tools; map response formats without dropping unrelated fields.
+
+**State across turns:** when a provider requires encrypted reasoning or other opaque state, verify preservation across streaming, non-streaming, persistence and subsequent requests. Follow the provider's replay rules, including cross-provider boundaries. Do not request reasoning state for unrelated providers by default.
+
+**Brand collisions:** a model containing `Spark` can match another provider's generic Spark rule. Verify the intended match against the installed icon release and the rendered model row; a correct provider icon alone is insufficient.
+
+**Error localization:** examine `packages/fetch-sse/src/parseError.ts`, `packages/model-runtime/src/errors/specs.ts` (`getErrorCodeSpec`) and `src/utils/locale/runtimeErrorMessage.ts` if errors show raw keys. The Meta PR introduces `packages/model-runtime/src/errors/i18nKey.ts` to centralize that routing; use it when present in the checkout. Non-React code may need namespace loading. Workbench's client loader is `apps/workbench/app/stubs/loadI18nNamespaceModule.client.ts`; its default and translated language globs must agree. Reuse existing helpers when available instead of adding parallel error-routing logic.
diff --git a/.agents/skills/add-provider-doc/SKILL.md b/.agents/skills/add-provider-doc/SKILL.md
deleted file mode 100644
index 00e7d2c610a..00000000000
--- a/.agents/skills/add-provider-doc/SKILL.md
+++ /dev/null
@@ -1,94 +0,0 @@
----
-name: add-provider-doc
-description: Add documentation for a new AI provider — usage docs, env vars, Docker config, image resources.
-disable-model-invocation: true
-argument-hint: '[provider-name]'
----
-
-# Adding New AI Provider Documentation
-
-Complete workflow for adding documentation for a new AI provider.
-
-## Overview
-
-1. Create usage documentation (EN + CN)
-2. Add environment variable documentation (EN + CN)
-3. Update Docker configuration files
-4. Update .env.example
-5. Prepare image resources
-
-## Step 1: Create Provider Usage Documentation
-
-### Required Files
-
-- `docs/usage/providers/{provider-name}.mdx` (English)
-- `docs/usage/providers/{provider-name}.zh-CN.mdx` (Chinese)
-
-### Key Requirements
-
-- 5-6 screenshots showing the process
-- Cover image for the provider
-- Real registration and dashboard URLs
-- Pricing information callout
-- **Never include real API keys** - use placeholders
-
-Reference: `docs/usage/providers/fal.mdx`
-
-## Step 2: Update Environment Variables Documentation
-
-### Files to Update
-
-- `docs/self-hosting/environment-variables/model-provider.mdx` (EN)
-- `docs/self-hosting/environment-variables/model-provider.zh-CN.mdx` (CN)
-
-### Content Format
-
-```markdown
-### `{PROVIDER}_API_KEY`
-
-- Type: Required
-- Description: API key from {Provider Name}
-- Example: `{api-key-format}`
-
-### `{PROVIDER}_MODEL_LIST`
-
-- Type: Optional
-- Description: Control model list. Use `+` to add, `-` to hide
-- Example: `-all,+model-1,+model-2=Display Name`
-```
-
-## Step 3: Update Docker Files
-
-Update all Dockerfiles at the **end** of ENV section:
-
-- `Dockerfile`
-- `Dockerfile.database`
-- `Dockerfile.pglite`
-
-```dockerfile
-# {New Provider}
-{PROVIDER}_API_KEY="" {PROVIDER}_MODEL_LIST=""
-```
-
-## Step 4: Update .env.example
-
-```bash
-### {Provider Name} ###
-# {PROVIDER}_API_KEY={prefix}-xxxxxxxx
-```
-
-## Step 5: Image Resources
-
-- Cover image
-- 3-4 API dashboard screenshots
-- 2-3 LobeHub configuration screenshots
-- Host on LobeHub CDN: `hub-apac-1.lobeobjects.space`
-
-## Checklist
-
-- [ ] EN + CN usage docs
-- [ ] EN + CN env var docs
-- [ ] All 3 Dockerfiles updated
-- [ ] .env.example updated
-- [ ] All images prepared
-- [ ] No real API keys in docs