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.

✨ feat(provider): add Unsloth provider support (#18339)

YuTengjing8d852279db49
diff --git a/.agents/skills/add-model-provider/SKILL.md b/.agents/skills/add-model-provider/SKILL.md
index ed9a5045539..aa62785d29f 100644
--- a/.agents/skills/add-model-provider/SKILL.md
+++ b/.agents/skills/add-model-provider/SKILL.md
@@ -20,6 +20,7 @@ For a model-only request on an existing provider, follow [model-bank-metadata](.
- 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.
+- For local servers or desktop applications, read [Local provider integration](references/local-providers.md). Verify launch modes, installed-model discovery, browser access, and capability refresh separately; an OpenAI-compatible model list alone does not establish these behaviors.
- 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.
@@ -28,7 +29,7 @@ For a model-only request on an existing provider, follow [model-bank-metadata](.
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.
+2. Set a usable static `checkModel` when the provider guarantees that model is available. Otherwise, omit it and let the user select and persist a connection-check model from the fetched local list; do not put an arbitrary example in the card. Set accurate authentication, model-fetching, SDK-family, and browser-request settings. 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.
@@ -40,7 +41,12 @@ Keep changes to shared factories or error handlers conditional on an observed ga
- 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.
+- Place the provider deliberately in `DEFAULT_MODEL_PROVIDER_LIST`; this array controls default list order, not imports or enum declarations. Apply these ordering principles:
+ - Favor providers with greater community popularity toward the front. Use current evidence of adoption and ecosystem recognition rather than alphabetical order, implementation convenience, or an invented numeric popularity score.
+ - Keep local model managers and inference servers together, such as Ollama, LM Studio, vLLM, and Unsloth Studio.
+ - Keep router/aggregator services together: services exposing models from multiple upstream providers through a unified API, such as OpenRouter and AIHubMix. Using the internal `RouterRuntime` abstraction alone does not place a provider in this group.
+ - Group continuity takes precedence over strictly sorting every individual provider by popularity. Use community popularity to position groups and standalone providers, and to order providers within each group. Preserve an explicit user-specified position and existing user-customized ordering.
+ - Insert a new provider into its appropriate group without reordering unrelated providers. A requested broader ordering cleanup can move the affected peers together.
- 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.
@@ -51,6 +57,7 @@ Use the existing provider test harness (`packages/model-runtime/src/providerTest
- 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.
+- Trigger a connection failure and expand its details: the error must remain recoverable within the settings page. A successful connection does not exercise lazy error components or their shared UI contexts.
- 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.
diff --git a/.agents/skills/add-model-provider/references/integration-map.md b/.agents/skills/add-model-provider/references/integration-map.md
index 08a79323a96..246816edf09 100644
--- a/.agents/skills/add-model-provider/references/integration-map.md
+++ b/.agents/skills/add-model-provider/references/integration-map.md
@@ -42,4 +42,6 @@ Read these as evidence of different integration shapes, not as code to copy whol
**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.
+**Icon registration and package identity:** an exported brand component does not prove `ProviderIcon` or `ProviderCombine` has a provider-ID mapping. Check the installed mapping and the actual consumer. In a workspace with duplicate dependency instances, registration or a React context may reach only one copy; compare resolved module paths before attributing a lazy error-panel crash to the provider API. `src/libs/providerIcon.ts` is the Unsloth workaround: it registers the missing mapping near its consumers to avoid importing the full registry at startup. Remove the registration once the installed upstream release includes the mapping, checking rendered icons and tree shaking when changing it.
+
**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-model-provider/references/local-providers.md b/.agents/skills/add-model-provider/references/local-providers.md
new file mode 100644
index 00000000000..35662bc8b61
--- /dev/null
+++ b/.agents/skills/add-model-provider/references/local-providers.md
@@ -0,0 +1,39 @@
+# Local Provider Integration
+
+Use this reference for a local model server or desktop application's external API. These are integration checks, not requirements to patch the upstream application, expose a public tunnel, or change the user's security settings.
+
+## Establish What Is Reachable
+
+Distinguish the API destination from the browser origin. CORS checks the requesting page's scheme, host, and port; it does not require that port to match the API port. Check the installed release and actual launch mode: desktop API-only and CLI web-server modes can expose the same protocol with different access policies. Keep runtime defaults, settings placeholders, and documentation aligned with the upstream default; an explicit test port is not a new default.
+
+Trace the effective request path, including stored browser-request settings and default selectors. An unchecked switch is not proof of a server request. For server requests, loopback refers to the server or container; for browser requests, it refers to the user's machine.
+
+Inspect `isProviderFetchOnClient` in `src/store/aiInfra/slices/aiProvider/selectors.ts`. Its base-URL-only default selects browser requests. The current `providerWhitelist` allows an explicit saved preference to take precedence; membership alone does not change an undefined preference. When a local provider must support an explicit server request without a key, check this path and its tests rather than changing only the provider card.
+
+Separate the following evidence:
+
+| Check | What it establishes |
+| ------------------------------------------------------------ | --------------------------------------------------------- |
+| Listener / health | The selected service is running |
+| Preflight with the actual Origin, method and request headers | Browser CORS admission for that request |
+| Endpoint authentication | Whether the actual caller and credential are admitted |
+| Model discovery | Which model IDs the instance advertises |
+| Inference / tool round trip | Whether the selected model serves the requested operation |
+
+A successful terminal request or preflight does not establish browser authentication. A keyless option may restrict cross-site browser callers independently of CORS. Check the provider's policy and the SDK's actual Authorization header: a placeholder key can be rejected instead of treated as absent. Do not recommend arbitrary credentials, disabling authentication, or tunneling as a generic fix. Search upstream issues and fixes before declaring a setting unavailable; an unmerged PR's environment variable is not a released configuration option.
+
+## Discover Models and Capabilities
+
+Model IDs from local servers can include publisher prefixes, format suffixes, aliases, and quantization variants. Exact matching against a bundled catalog can miss a supported model. A sibling adapter using that lookup is a precedent to inspect, not proof that it handles unknown local IDs correctly.
+
+- Inspect the actual model-list payload before interpreting missing capability fields as unsupported. Prefer explicit server metadata when it describes the selected model; use verified catalog metadata as a fallback. Do not infer tools or vision merely from a model-family substring.
+- If a separate properties endpoint describes only the resident model, match its public model ID to the list and respect explicit unloaded state. Do not assign one loaded model's capabilities to all downloaded models. Preserve authentication and reverse-proxy prefixes; bound optional probes and retain model discovery when older servers lack that endpoint.
+- Preserve explicit `false` values when the field measures the capability itself. Parameter support is narrower: for example, `supports_reasoning_effort: false` does not disprove reasoning through other controls such as `enable_thinking`. Prefer a valid positive configured context length to the model's theoretical maximum. Treat metadata as evidence for UI capability flags, not proof of a successful tool execution.
+- Follow capabilities through runtime output, persistence/refresh, selectors, and the Agent-mode control. Start at `src/store/aiInfra/slices/aiModel/action.ts` and `packages/database/src/models/aiModel.ts`. Check whether refreshing updates existing records and whether merge rules can clear stale capabilities; returning the correct runtime object alone may not repair saved data.
+- Test an unknown-but-capable ID, mismatched or unloaded models, explicit negative capabilities, and an unavailable optional metadata endpoint when those cases apply. Use realistic HTTP payloads and content types at the SDK boundary.
+
+Do not default-enable example models that the user's instance may not have installed. Keep examples or catalog metadata separate from discovery, and preserve existing user choices. Explain that fetching models, choosing a connection-check model, and loading it for inference are distinct steps. For resident-only metadata, tell users to load the model and refresh discovery before relying on its capability flags.
+
+## Unsloth Example
+
+During the September 2026 integration, `/v1/models` advertised a loaded GGUF model and its configured context length but omitted tool and vision flags. Studio's `/props` exposed `model_path`, `chat_template_caps`, and `modalities`; matching that ID allowed capability discovery without guessing from the model name. The [LobeHub adapter at that revision](https://github.com/lobehub/lobehub/blob/f03cd9d253e3fd7954469393ffc194a634696b1b/packages/model-runtime/src/providers/unsloth/index.ts) records the implementation. Inspect the current [Unsloth compatibility route](https://github.com/unslothai/unsloth/blob/main/studio/backend/routes/llama_compat.py) before reusing it: these fields and access policies are provider- and version-specific.
diff --git a/.env.example b/.env.example
index 81374879199..2b596fc730d 100644
--- a/.env.example
+++ b/.env.example
@@ -107,6 +107,17 @@ OPENAI_API_KEY=sk-xxxxxxxxx
# OLLAMA_MODEL_LIST=your_ollama_model_names
+# ## Unsloth Studio ####
+
+# Use a real Studio key when authentication is required. A non-empty key enables the provider.
+# UNSLOTH_API_KEY=your-unsloth-studio-api-key
+
+# Use the address reachable from the LobeHub server; loopback inside Docker refers to the container.
+# UNSLOTH_PROXY_URL=http://127.0.0.1:8888/v1
+
+# Replace the placeholder with a model ID returned by your Studio instance.
+# UNSLOTH_MODEL_LIST=-all,+your-local-model-id=Local Model
+
# ## OpenRouter Service ###
# OPENROUTER_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
diff --git a/Dockerfile b/Dockerfile
index 51bc2105f42..6f62782ec05 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -328,6 +328,8 @@ ENV \
TAICHU_API_KEY="" TAICHU_MODEL_LIST="" \
# TogetherAI
TOGETHERAI_API_KEY="" TOGETHERAI_MODEL_LIST="" \
+ # Unsloth
+ UNSLOTH_API_KEY="" UNSLOTH_MODEL_LIST="" UNSLOTH_PROXY_URL="" \
# Upstage
UPSTAGE_API_KEY="" UPSTAGE_MODEL_LIST="" \
# v0 (Vercel)
diff --git a/apps/server/src/globalConfig/index.ts b/apps/server/src/globalConfig/index.ts
index 6d3e776f927..b9ddf4ffd78 100644
--- a/apps/server/src/globalConfig/index.ts
+++ b/apps/server/src/globalConfig/index.ts
@@ -77,6 +77,9 @@ export const getServerGlobalConfig = async () => {
enabledKey: 'ENABLED_TENCENT_CLOUD',
modelListKey: 'TENCENT_CLOUD_MODEL_LIST',
},
+ unsloth: {
+ fetchOnClient: isDesktop ? false : undefined,
+ },
volcengine: {
withDeploymentName: true,
},
diff --git a/docs/self-hosting/environment-variables/model-provider.mdx b/docs/self-hosting/environment-variables/model-provider.mdx
index 36e4302674d..a61be392515 100644
--- a/docs/self-hosting/environment-variables/model-provider.mdx
+++ b/docs/self-hosting/environment-variables/model-provider.mdx
@@ -884,4 +884,29 @@ NewAPI is a multi-provider model aggregation service that supports automatic mod
- Default: `-`
- Example: `-all,+straico-model-1,+straico-model-2=straico-special`
+## Unsloth
+
+Connect to your own Unsloth Studio instance. See [Using Unsloth in LobeHub](/docs/usage/providers/unsloth) for browser authentication and desktop CORS limitations.
+
+### `UNSLOTH_API_KEY`
+
+- Type: Optional for the deployment; set a real Studio key when providing authenticated server access. Users can instead configure their key in provider settings.
+- Description: The API key for your Studio instance. A non-empty value enables the provider in server configuration. `ENABLED_UNSLOTH` is derived from this key and is not an independent environment switch. Keyless local server access depends on Studio's access policy; cross-origin browser requests require valid authentication.
+- Default: Unset; no shared server key.
+- Example: `your-unsloth-studio-api-key`
+
+### `UNSLOTH_PROXY_URL`
+
+- Type: Optional
+- Description: Overrides the OpenAI-compatible API base URL. Use an address reachable from the LobeHub server. Inside Docker, `127.0.0.1` refers to the container, not the host running Studio. An explicitly configured Studio port overrides its default `8888`.
+- Default: `http://127.0.0.1:8888/v1`
+- Example: `http://studio.example.com:8888/v1`
+
+### `UNSLOTH_MODEL_LIST`
+
+- Type: Optional
+- Description: Customizes the model list using the shared [model-list syntax][model-list]: `+` adds a model, `-` hides a model, and `model_id=display_name` renames a model. Separate entries with commas. Use IDs returned by your Studio instance; this setting does not download models.
+- Default: Unset; uses the built-in example model list with the examples disabled. This does not guarantee local availability or change existing saved model selections.
+- Example: `-all,+your-local-model-id=Local Model`
+
[model-list]: /docs/self-hosting/advanced/model-list
diff --git a/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx b/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx
index 5d9ef981256..3d3c627bc96 100644
--- a/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx
+++ b/docs/self-hosting/environment-variables/model-provider.zh-CN.mdx
@@ -885,4 +885,29 @@ LobeHub 在部署时提供了丰富的模型服务商相关的环境变量,你
- 默认值:`-`
- 示例:`-all,+straico-model-1,+straico-model-2=straico-special`
+## Unsloth
+
+连接你自己的 Unsloth Studio 实例。浏览器认证和桌面版 CORS 限制请参阅[在 LobeHub 中使用 Unsloth](/zh/docs/usage/providers/unsloth)。
+
+### `UNSLOTH_API_KEY`
+
+- 类型:部署时可选;提供需要认证的共享服务端访问时,应填写真实的 Studio 密钥。用户也可以在服务商设置中自行配置密钥。
+- 描述:你的 Studio 实例的 API 密钥。非空值会在服务端配置中启用此服务商。`ENABLED_UNSLOTH` 由密钥派生,不是独立的环境变量开关。本地服务端无密钥访问取决于 Studio 的访问策略;跨来源浏览器请求需要有效认证。
+- 默认值:未设置,不提供共享服务端密钥。
+- 示例:`your-unsloth-studio-api-key`
+
+### `UNSLOTH_PROXY_URL`
+
+- 类型:可选
+- 描述:覆盖 OpenAI 兼容 API 的基础地址。请填写 LobeHub 服务器可访问的地址。在 Docker 内,`127.0.0.1` 指容器自身,不是运行 Studio 的宿主机。若启动 Studio 时明确指定端口,请使用该端口替代默认的 `8888`。
+- 默认值:`http://127.0.0.1:8888/v1`
+- 示例:`http://studio.example.com:8888/v1`
+
+### `UNSLOTH_MODEL_LIST`
+
+- 类型:可选
+- 描述:使用共享的[模型列表语法][model-list]配置模型列表:`+` 增加模型,`-` 隐藏模型,`模型ID=显示名称` 重命名模型,多个条目用英文逗号分隔。请使用 Studio 实例返回的模型 ID;此配置不会下载模型。
+- 默认值:未设置,使用内置示例模型列表,示例默认不启用;不保证这些模型已在本地安装,也不会改变已有的模型选择。
+- 示例:`-all,+your-local-model-id=Local Model`
+
[model-list]: /zh/docs/self-hosting/advanced/model-list
diff --git a/docs/usage/providers/unsloth.mdx b/docs/usage/providers/unsloth.mdx
new file mode 100644
index 00000000000..cce052c318e
--- /dev/null
+++ b/docs/usage/providers/unsloth.mdx
@@ -0,0 +1,45 @@
+---
+title: Using Unsloth in LobeHub
+description: >-
+ Learn how to configure and use Unsloth to run local AI models, including your
+ own fine-tuned models, for conversations within LobeHub.
+tags:
+ - LobeHub
+ - Unsloth
+ - Open Source Models
+ - Fine-tuning
+---
+
+# Using Unsloth in LobeHub
+
+[Unsloth](https://unsloth.ai/) runs local models and exposes an OpenAI-compatible API through Unsloth Studio. LobeHub connects to your running instance; this integration does not provide a hosted inference account or download models for you. Check the model's license and your hardware requirements before downloading it.
+
+<Steps>
+ ### Step 1: Start Unsloth Studio
+
+ - Follow the [official installation guide](https://unsloth.ai/docs) to install Unsloth Studio and start its desktop app or CLI service.
+ - Download a model in Studio and make it available for inference. The [Unsloth model catalog](https://huggingface.co/unsloth) lists available models; a catalog entry does not mean the model is installed locally.
+ - The default API base URL is `http://127.0.0.1:8888/v1`. If you explicitly start Studio on another port, replace `8888` with that port, such as `8000`. Use the base URL ending in `/v1`, not the full `/chat/completions` path.
+
+ ### Step 2: Choose How LobeHub Connects
+
+ - Server requests require the LobeHub server to reach Studio. `127.0.0.1` refers to the server itself; inside Docker it refers to the container. Use an address reachable from that server or container when Studio runs elsewhere.
+ - Client Request Mode sends requests from your browser. Studio must allow the LobeHub page's origin through CORS, and requests from another browser origin require a real API key from your Studio instance. A successful keyless terminal request does not establish browser access. Do not use a made-up key.
+
+ ### Step 3: Configure and Check the Connection
+
+ - Go to the `App Settings` in LobeHub and open the `AI Service Providers` section
+ - Find and select the `Unsloth` provider from the list
+ - Enable the provider, enter your API base URL, and enter the real Studio API key when authentication is required. Enable Client Request Mode only for a browser-accessible endpoint.
+ - Click **Fetch Model List** and choose a model returned by your running Studio instance. If adding a model manually, use its exact local API model ID. The two built-in example models are not enabled by default and are not guaranteed to be installed. Existing saved model selections are preserved.
+ - Load the model in Studio, then fetch the list again to discover its tool and vision capabilities. Studio reports these capabilities for the loaded model; they may be unavailable for models that are not loaded.
+ - Select that model for **Connection Check** and run the check. After it succeeds, select the same model for your assistant.
+</Steps>
+
+## Connection Problems
+
+- **CORS or failed preflight:** As of September 6, 2026, Studio desktop API-only mode rejects browser origins on other local ports. The upstream fix, [unsloth#10084](https://github.com/unslothai/unsloth/pull/10084), is still open. Enabling Client Request Mode alone does not fix this. Use a Studio mode that allows your origin, or a server request from a host that can reach Studio.
+- **Not authenticated / Invalid token payload:** Cross-origin browser calls need valid Studio authentication even when a keyless terminal call works. Enter a real key; an arbitrary placeholder will be rejected.
+- **Connection refused or unknown model:** Check the actual listening port, server/container reachability, and the model list returned by this Studio instance. Fetching the list does not itself prove that model inference succeeds.
+
+For shared server configuration, see the [Unsloth environment variables](/docs/self-hosting/environment-variables/model-provider#unsloth). Local inference uses your own hardware; this provider does not define a per-token hosted API price. Refer to [Unsloth's official site](https://unsloth.ai/) for current product availability and commercial offerings.
diff --git a/docs/usage/providers/unsloth.zh-CN.mdx b/docs/usage/providers/unsloth.zh-CN.mdx
new file mode 100644
index 00000000000..dee6001aa67
--- /dev/null
+++ b/docs/usage/providers/unsloth.zh-CN.mdx
@@ -0,0 +1,43 @@
+---
+title: 在 LobeHub 中使用 Unsloth
+description: 学习如何配置并使用 Unsloth 运行本地 AI 模型(包括你自己微调的模型),在 LobeHub 中进行对话。
+tags:
+ - LobeHub
+ - Unsloth
+ - 开源模型
+ - 微调
+---
+
+# 在 LobeHub 中使用 Unsloth
+
+[Unsloth](https://unsloth.ai/) 可运行本地模型,并通过 Unsloth Studio 提供 OpenAI 兼容 API。LobeHub 连接到你已经启动的实例,不提供托管推理账号,也不会代你下载模型。下载前请检查模型许可证和硬件要求。
+
+<Steps>
+ ### 第一步:启动 Unsloth Studio
+
+ - 参考[官方安装指南](https://unsloth.ai/docs)安装 Unsloth Studio,并启动桌面应用或 CLI 服务。
+ - 在 Studio 中下载模型并准备进行推理。[Unsloth 模型目录](https://huggingface.co/unsloth)列出的模型不代表已经安装在本地。
+ - 默认 API 基础地址为 `http://127.0.0.1:8888/v1`。如果启动时明确指定了其他端口,请将 `8888` 替换为实际端口,例如 `8000`。填写以 `/v1` 结尾的基础地址,不要填写完整的 `/chat/completions` 路径。
+
+ ### 第二步:选择连接方式
+
+ - 服务端请求要求 LobeHub 服务器能够访问 Studio。`127.0.0.1` 指服务器自身;在 Docker 中则指容器自身。如果 Studio 运行在其他位置,请使用服务器或容器可访问的地址。
+ - 客户端请求模式由浏览器直接请求。Studio 必须通过 CORS 允许 LobeHub 页面来源,来自其他浏览器来源的请求还需要该 Studio 实例的真实 API 密钥。终端无密钥请求成功不代表浏览器也能访问,不要填写虚构密钥。
+
+ ### 第三步:配置并检查连接
+
+ - 打开 LobeHub 的 `应用设置`,进入 `AI 服务商` 板块
+ - 在列表中找到并选择 `Unsloth` 服务商
+ - 开启服务商,填写 API 基础地址,并在需要认证时填写真实的 Studio API 密钥。只有端点支持浏览器访问时才开启客户端请求模式。
+ - 点击「获取模型列表」,选择当前 Studio 实例返回的模型。如果手动添加模型,请使用本地 API 返回的准确模型 ID。内置的两个示例模型默认不启用,也不保证已在本地安装;已有的模型选择会保留。
+ - 在 Studio 中加载模型后,再次获取列表,以读取该模型的工具调用和视觉能力。Studio 仅为已加载的模型提供这些能力信息,未加载模型的能力可能暂时无法获取。
+ - 在「连通性检查」中选择该模型并执行检查。成功后,为助手选择同一个模型。
+</Steps>
+
+## 连接问题
+
+- CORS 或预检失败:截至 2026 年 9 月 6 日,Studio 桌面版 API-only 模式会拒绝来自其他本地端口的浏览器请求。上游修复 [unsloth#10084](https://github.com/unslothai/unsloth/pull/10084) 尚未合并,仅开启客户端请求模式不能解决此问题。请使用允许页面来源的 Studio 模式,或通过可访问 Studio 的服务器发起请求。
+- Not authenticated / Invalid token payload:即使终端无密钥请求成功,跨来源浏览器请求仍需要有效的 Studio 认证。请填写真实密钥,任意占位字符串都会被拒绝。
+- 连接被拒绝或模型不存在:检查实际监听端口、服务器或容器的网络可达性,以及该 Studio 实例返回的模型列表。获取列表成功不等于模型推理成功。
+
+共享服务端配置请参阅 [Unsloth 环境变量](/zh/docs/self-hosting/environment-variables/model-provider#unsloth)。本地推理使用你自己的硬件,此服务商不定义托管 API 的每 token 价格。产品可用性和商业服务请查看 [Unsloth 官网](https://unsloth.ai/)。
diff --git a/locales/en-US/modelProvider.json b/locales/en-US/modelProvider.json
index 0ef0587c1e7..4254d776cf5 100644
--- a/locales/en-US/modelProvider.json
+++ b/locales/en-US/modelProvider.json
@@ -349,6 +349,8 @@
"sortModal.success": "Sort update successful",
"sortModal.title": "Custom Order",
"sortModal.update": "Update",
+ "unsloth.checker.guidance": "For browser network errors, check that Studio allows this page through CORS. For authentication errors, enter a real Studio API key; keyless terminal access does not grant browser access.",
+ "unsloth.checker.setupGuide": "Unsloth connection setup guide",
"updateAiProvider.confirmDelete": "Delete this AI provider?",
"updateAiProvider.confirmDeleteDescription": "Once deleted, this AI provider cannot be recovered.",
"updateAiProvider.deleteSuccess": "Deletion successful",
diff --git a/locales/en-US/providers.json b/locales/en-US/providers.json
index 8f726945549..ba8a7fa9a4a 100644
--- a/locales/en-US/providers.json
+++ b/locales/en-US/providers.json
@@ -70,6 +70,7 @@
"taichu.description": "A next-generation multimodal model from CASIA and the Wuhan Institute of AI, supporting multi-turn QA, writing, image generation, 3D understanding, and signal analysis with stronger cognition and creativity.",
"tencentcloud.description": "LLM Knowledge Engine Atomic Power provides end-to-end knowledge QA for enterprises and developers, with modular services like document parsing, chunking, embeddings, and multi-turn rewriting to assemble custom AI solutions.",
"togetherai.description": "Together AI delivers leading performance with innovative models, broad customization, rapid scaling, and straightforward deployment for enterprise needs.",
+ "unsloth.description": "Unsloth is a framework for fine-tuning and running LLMs locally, exposing loaded GGUF models through an OpenAI-compatible API endpoint.",
"upstage.description": "Upstage builds AI models for business needs, including Solar LLM and Document AI, with chat APIs that support function calling, translation, embeddings, and domain-specific use cases.",
"v0.description": "v0 is a pair-programming assistant that turns natural-language ideas into code and UI for your project.",
"vercelaigateway.description": "Vercel AI Gateway provides a unified API for 100+ models across OpenAI, Anthropic, Google, and more, with budgeting, usage monitoring, load balancing, and failover.",
diff --git a/locales/zh-CN/modelProvider.json b/locales/zh-CN/modelProvider.json
index 1f7156722fd..150ace26257 100644
--- a/locales/zh-CN/modelProvider.json
+++ b/locales/zh-CN/modelProvider.json
@@ -349,6 +349,8 @@
"sortModal.success": "排序更新成功",
"sortModal.title": "自定义排序",
"sortModal.update": "更新",
+ "unsloth.checker.guidance": "浏览器网络错误请检查 Studio 是否通过 CORS 允许当前页面访问;认证错误请填写真实的 Studio API 密钥,终端无密钥访问成功不代表浏览器也能访问。",
+ "unsloth.checker.setupGuide": "Unsloth 连接配置指南",
"updateAiProvider.confirmDelete": "删除该 AI 服务商?",
"updateAiProvider.confirmDeleteDescription": "删除后将无法找回。",
"updateAiProvider.deleteSuccess": "删除成功",
diff --git a/locales/zh-CN/providers.json b/locales/zh-CN/providers.json
index 4a5daee6248..c83b8bfb2b1 100644
--- a/locales/zh-CN/providers.json
+++ b/locales/zh-CN/providers.json
@@ -70,6 +70,7 @@
"taichu.description": "太初是中科院自动化所与武汉人工智能研究院联合研发的新一代多模态模型,支持多轮问答、写作、图像生成、3D 理解与信号分析,具备更强的认知与创造力。",
"tencentcloud.description": "腾讯云大模型知识引擎原子能力为企业与开发者提供端到端知识问答服务,支持文档解析、切分、向量化、多轮重写等模块化服务,助力构建定制 AI 方案。",
"togetherai.description": "Together AI 提供领先性能的创新模型,支持广泛定制、快速扩展与简便部署,满足企业需求。",
+ "unsloth.description": "Unsloth 是一个用于本地微调与运行大语言模型的框架,可将加载的 GGUF 模型通过 OpenAI 兼容 API 对外提供服务。",
"upstage.description": "Upstage 构建面向商业需求的 AI 模型,包括 Solar LLM 与文档 AI,其聊天 API 支持函数调用、翻译、向量化与行业场景应用。",
"v0.description": "v0 是一款配对编程助手,可将自然语言想法转化为项目中的代码与界面。",
"vercelaigateway.description": "Vercel AI Gateway 提供统一 API,支持 100 多个模型(包括 OpenAI、Anthropic、Google 等),具备预算控制、使用监控、负载均衡与故障转移功能。",
diff --git a/package.json b/package.json
index ca5dfd33344..063fcd5ac2c 100644
--- a/package.json
+++ b/package.json
@@ -26,6 +26,7 @@
"author": "LobeHub <[email protected]>",
"sideEffects": [
"./src/initialize.ts",
+ "./src/libs/providerIcon.ts",
"./src/spa/entry.auth.tsx",
"./src/spa/entry.desktop.tsx",
"./src/spa/entry.mobile.tsx",
diff --git a/packages/business/config/src/llm.ts b/packages/business/config/src/llm.ts
index 02f297a0337..101e5077599 100644
--- a/packages/business/config/src/llm.ts
+++ b/packages/business/config/src/llm.ts
@@ -16,6 +16,7 @@ const providerDefaults: Partial<
[ModelProvider.Ollama]: { fetchOnClient: true },
[ModelProvider.OpenAI]: { enabled: true },
[ModelProvider.OpenCodeZen]: { enabledModels: enabledOpenCodeZenModels },
+ [ModelProvider.Unsloth]: { fetchOnClient: true },
};
const genUserLLMConfig = (): UserModelProviderConfig => {
diff --git a/packages/env/src/llm.ts b/packages/env/src/llm.ts
index 33653c72702..75d13ea9c98 100644
--- a/packages/env/src/llm.ts
+++ b/packages/env/src/llm.ts
@@ -99,6 +99,9 @@ export const getLLMConfig = () => {
ENABLED_LMSTUDIO: z.boolean(),
LMSTUDIO_API_KEY: z.string().optional(),
+ ENABLED_UNSLOTH: z.boolean(),
+ UNSLOTH_API_KEY: z.string().optional(),
+
ENABLED_QINIU: z.boolean(),
QINIU_API_KEY: z.string().optional(),
@@ -358,6 +361,9 @@ export const getLLMConfig = () => {
ENABLED_LMSTUDIO: !!process.env.LMSTUDIO_API_KEY,
LMSTUDIO_API_KEY: process.env.LMSTUDIO_API_KEY,
+ ENABLED_UNSLOTH: !!process.env.UNSLOTH_API_KEY,
+ UNSLOTH_API_KEY: process.env.UNSLOTH_API_KEY,
+
ENABLED_QINIU: !!process.env.QINIU_API_KEY,
QINIU_API_KEY: process.env.QINIU_API_KEY,
diff --git a/packages/locales/src/default/modelProvider.ts b/packages/locales/src/default/modelProvider.ts
index f1de06229a0..40bea9aaa52 100644
--- a/packages/locales/src/default/modelProvider.ts
+++ b/packages/locales/src/default/modelProvider.ts
@@ -441,6 +441,9 @@ export default {
'sortModal.success': 'Sort update successful',
'sortModal.title': 'Custom Order',
'sortModal.update': 'Update',
+ 'unsloth.checker.guidance':
+ 'For browser network errors, check that Studio allows this page through CORS. For authentication errors, enter a real Studio API key; keyless terminal access does not grant browser access.',
+ 'unsloth.checker.setupGuide': 'Unsloth connection setup guide',
'updateAiProvider.confirmDelete': 'Delete this AI provider?',
'updateAiProvider.confirmDeleteDescription':
'Once deleted, this AI provider cannot be recovered.',
diff --git a/packages/model-bank/package.json b/packages/model-bank/package.json
index b66ea15d3e7..4d067ee799b 100644
--- a/packages/model-bank/package.json
+++ b/packages/model-bank/package.json
@@ -80,6 +80,7 @@
"./taichu": "./src/aiModels/taichu.ts",
"./tencentcloud": "./src/aiModels/tencentcloud.ts",
"./togetherai": "./src/aiModels/togetherai.ts",
+ "./unsloth": "./src/aiModels/unsloth.ts",
"./upstage": "./src/aiModels/upstage.ts",
"./v0": "./src/aiModels/v0.ts",
"./vercelaigateway": "./src/aiModels/vercelaigateway.ts",
diff --git a/packages/model-bank/src/aiModels/index.ts b/packages/model-bank/src/aiModels/index.ts
index f56a857a899..773eb0f9875 100644
--- a/packages/model-bank/src/aiModels/index.ts
+++ b/packages/model-bank/src/aiModels/index.ts
@@ -71,6 +71,7 @@ import { default as supergrok } from './superGrok';
import { default as taichu } from './taichu';
import { default as tencentcloud } from './tencentcloud';
import { default as togetherai } from './togetherai';
+import { default as unsloth } from './unsloth';
import { default as upstage } from './upstage';
import { default as v0 } from './v0';
import { default as vercelaigateway } from './vercelaigateway';
@@ -182,6 +183,7 @@ const staticModelMap: ModelsMap = {
taichu,
tencentcloud,
togetherai,
+ unsloth,
upstage,
v0,
vercelaigateway,
@@ -299,6 +301,7 @@ export { default as supergrok } from './superGrok';
export { default as taichu } from './taichu';
export { default as tencentcloud } from './tencentcloud';
export { default as togetherai } from './togetherai';
+export { default as unsloth } from './unsloth';
export { default as upstage } from './upstage';
export { default as v0 } from './v0';
export { default as vercelaigateway } from './vercelaigateway';
diff --git a/packages/model-bank/src/aiModels/unsloth.ts b/packages/model-bank/src/aiModels/unsloth.ts
new file mode 100644
index 00000000000..2dd838d85ea
--- /dev/null
+++ b/packages/model-bank/src/aiModels/unsloth.ts
@@ -0,0 +1,39 @@
+import type { AIChatModelCard } from '../types/aiModel';
+
+const unslothChatModels: AIChatModelCard[] = [
+ {
+ abilities: {
+ functionCall: true,
+ reasoning: true,
+ },
+ contextWindowTokens: 40_960,
+ description:
+ 'Qwen3 is the latest generation of the Qwen series, supporting seamless switching between thinking and non-thinking modes.',
+ displayName: 'Qwen3 1.7B',
+ enabled: false,
+ family: 'qwen',
+ generation: 'qwen3',
+ id: 'unsloth/Qwen3-1.7B-GGUF',
+ type: 'chat',
+ },
+ {
+ abilities: {
+ functionCall: true,
+ vision: true,
+ },
+ contextWindowTokens: 128_000,
+ description:
+ 'Gemma 3 is a lightweight open model family from Google, supporting multimodal input and strong instruction following.',
+ displayName: 'Gemma 3 4B',
+ enabled: false,
+ family: 'gemma',
+ generation: 'gemma-3',
+ id: 'unsloth/gemma-3-4b-it-GGUF',
+ knowledgeCutoff: '2024-08',
+ type: 'chat',
+ },
+];
+
+export const allModels = [...unslothChatModels];
+
+export default allModels;
diff --git a/packages/model-bank/src/const/modelProvider.ts b/packages/model-bank/src/const/modelProvider.ts
index 80fbd955d0c..9c654ebb463 100644
--- a/packages/model-bank/src/const/modelProvider.ts
+++ b/packages/model-bank/src/const/modelProvider.ts
@@ -70,6 +70,7 @@ export enum ModelProvider {
Taichu = 'taichu',
TencentCloud = 'tencentcloud',
TogetherAI = 'togetherai',
+ Unsloth = 'unsloth',
Upstage = 'upstage',
V0 = 'v0',
VercelAIGateway = 'vercelaigateway',
diff --git a/packages/model-bank/src/modelProviders/index.ts b/packages/model-bank/src/modelProviders/index.ts
index ff43e0dcb09..134c30c6d8b 100644
--- a/packages/model-bank/src/modelProviders/index.ts
+++ b/packages/model-bank/src/modelProviders/index.ts
@@ -72,6 +72,7 @@ import SuperGrokProvider from './superGrok';
import TaichuProvider from './taichu';
import TencentcloudProvider from './tencentcloud';
import TogetherAIProvider from './togetherai';
+import UnslothProvider from './unsloth';
import UpstageProvider from './upstage';
import V0Provider from './v0';
import VercelAIGatewayProvider from './vercelaigateway';
@@ -172,6 +173,7 @@ export const DEFAULT_MODEL_PROVIDER_LIST = [
OllamaProvider,
OllamaCloudProvider,
VLLMProvider,
+ UnslothProvider,
ComfyUIProvider,
HuggingFaceProvider,
CloudflareProvider,
@@ -326,6 +328,7 @@ export { default as SuperGrokProviderCard } from './superGrok';
export { default as TaichuProviderCard } from './taichu';
export { default as TencentCloudProviderCard } from './tencentcloud';
export { default as TogetherAIProviderCard } from './togetherai';
+export { default as UnslothProviderCard } from './unsloth';
export { default as UpstageProviderCard } from './upstage';
export { default as V0ProviderCard } from './v0';
export { default as VercelAIGatewayProviderCard } from './vercelaigateway';
diff --git a/packages/model-bank/src/modelProviders/unsloth.ts b/packages/model-bank/src/modelProviders/unsloth.ts
new file mode 100644
index 00000000000..cbef872037e
--- /dev/null
+++ b/packages/model-bank/src/modelProviders/unsloth.ts
@@ -0,0 +1,25 @@
+import type { ModelProviderCard } from '../types';
+
+// ref: https://unsloth.ai/docs/basics/api
+const Unsloth: ModelProviderCard = {
+ chatModels: [],
+ description:
+ 'Unsloth is a framework for fine-tuning and running LLMs locally, exposing loaded GGUF models through an OpenAI-compatible API endpoint.',
+ id: 'unsloth',
+ modelsUrl: 'https://huggingface.co/unsloth',
+ name: 'Unsloth',
+ settings: {
+ defaultShowBrowserRequest: true,
+ proxyUrl: {
+ placeholder: 'http://127.0.0.1:8888/v1',
+ },
+ responseAnimation: {
+ speed: 2,
+ text: 'smooth',
+ },
+ showModelFetcher: true,
+ },
+ url: 'https://unsloth.ai',
+};
+
+export default Unsloth;
diff --git a/packages/model-runtime/src/providers/unsloth/index.test.ts b/packages/model-runtime/src/providers/unsloth/index.test.ts
new file mode 100644
index 00000000000..79dab20872a
--- /dev/null
+++ b/packages/model-runtime/src/providers/unsloth/index.test.ts
@@ -0,0 +1,181 @@
+// @vitest-environment node
+import { ModelProvider } from 'model-bank';
+import OpenAI from 'openai';
+import { describe, expect, it, vi } from 'vitest';
+
+import { testProvider } from '../../providerTestUtils';
+import { LobeUnslothAI, params } from './index';
+
+const provider = ModelProvider.Unsloth;
+const defaultBaseURL = 'http://127.0.0.1:8888/v1';
+
+testProvider({
+ Runtime: LobeUnslothAI,
+ chatDebugEnv: 'DEBUG_UNSLOTH_CHAT_COMPLETION',
+ chatModel: 'unsloth/Qwen3-1.7B-GGUF',
+ defaultBaseURL,
+ provider,
+ test: {
+ skipAPICall: true,
+ },
+});
+
+describe('LobeUnslothAI - custom features', () => {
+ it('discovers loaded model abilities from server props without a catalog ID match', async () => {
+ const client = new OpenAI({
+ apiKey: 'test-key',
+ baseURL: 'http://localhost:8000/v1',
+ fetch: async (input) => {
+ const url = String(input);
+ return new Response(
+ JSON.stringify(
+ url.endsWith('/v1/models')
+ ? {
+ data: [
+ { id: 'unsloth/Qwen3.8-27B-GGUF', loaded: true, context_length: 214528 },
+ { id: 'unloaded-model', loaded: false },
+ ],
+ }
+ : {
+ model_path: 'unsloth/Qwen3.8-27B-GGUF',
+ chat_template_caps: {
+ supports_tools: true,
+ supports_tool_calls: true,
+ supports_reasoning_effort: true,
+ },
+ modalities: { vision: true },
+ },
+ ),
+ { headers: { 'Content-Type': 'application/json' } },
+ );
+ },
+ });
+
+ const models = await params.models({ client });
+ expect(models).toEqual(
+ expect.arrayContaining([
+ expect.objectContaining({
+ id: 'unsloth/Qwen3.8-27B-GGUF',
+ functionCall: true,
+ vision: true,
+ reasoning: true,
+ contextWindowTokens: 214528,
+ }),
+ expect.objectContaining({ id: 'unloaded-model', functionCall: false, vision: false }),
+ ]),
+ );
+ });
+
+ describe('params export', () => {
+ it('should export params with correct structure', () => {
+ expect(params).toBeDefined();
+ expect(params.provider).toBe(ModelProvider.Unsloth);
+ expect(params.baseURL).toBe(defaultBaseURL);
+ expect(params.apiKey).toBe('placeholder-to-avoid-error');
+ expect(params.debug).toBeDefined();
+ expect(params.models).toBeDefined();
+ });
+
+ it('should return false when DEBUG_UNSLOTH_CHAT_COMPLETION is not set', () => {
+ delete process.env.DEBUG_UNSLOTH_CHAT_COMPLETION;
+ expect(params.debug?.chatCompletion()).toBe(false);
+ });
+
+ it('should return true when DEBUG_UNSLOTH_CHAT_COMPLETION is set to 1', () => {
+ process.env.DEBUG_UNSLOTH_CHAT_COMPLETION = '1';
+ expect(params.debug?.chatCompletion()).toBe(true);
+ delete process.env.DEBUG_UNSLOTH_CHAT_COMPLETION;
+ });
+ });
+
+ describe('models function', () => {
+ it.each(['http://localhost:8000/proxy/v1', 'http://localhost:8000/proxy/v1/'])(
+ 'preserves authentication and proxy prefixes for %s',
+ async (baseURL) => {
+ const fetchMock = vi.fn(async (input, init) => {
+ if (String(input).includes('/models'))
+ return new Response(
+ JSON.stringify({ data: [{ id: 'unsloth/Qwen3-1.7B-GGUF', loaded: true }] }),
+ { headers: { 'Content-Type': 'application/json' } },
+ );
+ expect(String(input)).toBe('http://localhost:8000/proxy/v1/props');
+ expect(new Headers(init?.headers).get('Authorization')).toBe('Bearer test-key');
+ return new Response(
+ JSON.stringify({
+ model_path: 'unsloth/Qwen3-1.7B-GGUF',
+ chat_template_caps: {
+ supports_tools: false,
+ supports_tool_calls: false,
+ supports_reasoning_effort: false,
+ },
+ modalities: { vision: false },
+ }),
+ { headers: { 'Content-Type': 'application/json' } },
+ );
+ });
+ const client = new OpenAI({ apiKey: 'test-key', baseURL, fetch: fetchMock });
+ const models = await params.models({ client });
+ expect(fetchMock).toHaveBeenCalledTimes(2);
+ // A template can use enable_thinking without supporting reasoning_effort.
+ expect(models[0]).toMatchObject({ functionCall: false, reasoning: true, vision: false });
+ },
+ );
+
+ it('keeps model discovery working when an older server has no props endpoint', async () => {
+ const client = new OpenAI({
+ apiKey: 'test-key',
+ baseURL: 'http://localhost:8000/v1',
+ fetch: async (input) =>
+ String(input).endsWith('/models')
+ ? Response.json({ data: [{ id: 'unsloth/Qwen3-1.7B-GGUF' }] })
+ : new Response('{}', { status: 404 }),
+ });
+ expect(await params.models({ client })).toEqual([
+ expect.objectContaining({ id: 'unsloth/Qwen3-1.7B-GGUF', functionCall: true }),
+ ]);
+ });
+
+ it('does not query resident model props when all listed models are unloaded', async () => {
+ const fetchMock = vi.fn(async () =>
+ Response.json({ data: [{ id: 'custom', loaded: false }] }),
+ );
+ const client = new OpenAI({ apiKey: 'test-key', fetch: fetchMock });
+ expect(await params.models({ client })).toEqual([
+ expect.objectContaining({ id: 'custom', functionCall: false }),
+ ]);
+ expect(fetchMock).toHaveBeenCalledTimes(1);
+ });
+
+ it('should fetch and enrich known models from LOBE_DEFAULT_MODEL_LIST', async () => {
+ const mockClient = {
+ models: {
+ list: vi.fn().mockResolvedValue({
+ data: [{ id: 'unsloth/Qwen3-1.7B-GGUF' }, { id: 'custom-local-model' }],
+ }),
+ },
+ };
+
+ const models = await params.models!({ client: mockClient as any });
+ expect(mockClient.models.list).toHaveBeenCalled();
+ expect(models).toHaveLength(2);
+
+ const known = models.find((m) => m.id === 'unsloth/Qwen3-1.7B-GGUF');
+ expect(known?.displayName).toBe('Qwen3 1.7B');
+ expect(known?.functionCall).toBe(true);
+
+ const unknown = models.find((m) => m.id === 'custom-local-model');
+ expect(unknown?.enabled).toBe(false);
+ });
+
+ it('should handle empty model list', async () => {
+ const mockClient = {
+ models: {
+ list: vi.fn().mockResolvedValue({ data: [] }),
+ },
+ };
+
+ const models = await params.models!({ client: mockClient as any });
+ expect(models).toEqual([]);
+ });
+ });
+});
diff --git a/packages/model-runtime/src/providers/unsloth/index.ts b/packages/model-runtime/src/providers/unsloth/index.ts
new file mode 100644
index 00000000000..a29d6608ea2
--- /dev/null
+++ b/packages/model-runtime/src/providers/unsloth/index.ts
@@ -0,0 +1,102 @@
+import type { ChatModelCard } from '@lobechat/types';
+import debug from 'debug';
+import { ModelProvider } from 'model-bank';
+import { APIConnectionTimeoutError, APIError } from 'openai';
+
+import type { OpenAICompatibleFactoryOptions } from '../../core/openaiCompatibleFactory';
+import { createOpenAICompatibleRuntime } from '../../core/openaiCompatibleFactory';
+
+const log = debug('lobe-model-runtime:unsloth');
+
+export interface UnslothModelCard {
+ context_length?: number;
+ display_name?: string;
+ id: string;
+ loaded?: boolean;
+}
+
+interface UnslothModelProps {
+ chat_template_caps?: {
+ supports_reasoning_effort?: boolean;
+ supports_tool_calls?: boolean;
+ supports_tools?: boolean;
+ };
+ default_generation_settings?: { n_ctx?: number };
+ modalities?: { vision?: boolean };
+ model_path?: string;
+}
+
+export const params = {
+ apiKey: 'placeholder-to-avoid-error',
+ baseURL: 'http://127.0.0.1:8888/v1',
+ debug: {
+ chatCompletion: () => process.env.DEBUG_UNSLOTH_CHAT_COMPLETION === '1',
+ },
+ models: async ({ client }) => {
+ const { LOBE_DEFAULT_MODEL_LIST } = await import('model-bank');
+
+ const modelsPage = await client.models.list();
+ const modelList: UnslothModelCard[] = modelsPage.data;
+ let props: UnslothModelProps | undefined;
+
+ /** Studio's OpenAI model list omits abilities. Its llama.cpp-compatible props
+ * describe only the resident model, so never apply them to other downloaded models.
+ * https://github.com/unslothai/unsloth/blob/main/studio/backend/routes/llama_compat.py
+ */
+ if (modelList.some((model) => model.loaded !== false)) {
+ try {
+ /** Keep the configured API prefix: a reverse proxy may expose only /v1 routes. */
+ props = await client.get<UnslothModelProps>(`${client.baseURL.replace(/\/$/, '')}/props`, {
+ maxRetries: 0,
+ timeout: 2000,
+ });
+ } catch (error) {
+ /** Error bodies and configured URLs can contain credentials; log only safe diagnostics. */
+ log('Model properties unavailable; using catalog metadata. %O', {
+ reason: error instanceof APIConnectionTimeoutError ? 'timeout' : 'request_failed',
+ route: 'props',
+ status: error instanceof APIError ? error.status : undefined,
+ });
+ }
+ }
+
+ return modelList.map((model) => {
+ const knownModel = LOBE_DEFAULT_MODEL_LIST.find(
+ (m) => model.id.toLowerCase() === m.id.toLowerCase(),
+ );
+ const modelProps =
+ model.loaded !== false && props?.model_path === model.id ? props : undefined;
+ const caps = modelProps?.chat_template_caps;
+ const supportsTools = caps?.supports_tools;
+ const supportsToolCalls = caps?.supports_tool_calls;
+ const functionCall =
+ supportsTools === false || supportsToolCalls === false
+ ? false
+ : (supportsTools ?? supportsToolCalls ?? knownModel?.abilities?.functionCall ?? false);
+ const contextWindowTokens = [
+ model.context_length,
+ modelProps?.default_generation_settings?.n_ctx,
+ knownModel?.contextWindowTokens,
+ ].find((value) => typeof value === 'number' && Number.isFinite(value) && value > 0);
+ /** Effort-parameter support is a positive hint, not an exhaustive thinking capability.
+ * Templates using enable_thinking can report false here while still supporting reasoning.
+ * https://github.com/ggml-org/llama.cpp/blob/d59d455f/common/jinja/caps.cpp
+ */
+ const reasoning =
+ caps?.supports_reasoning_effort === true || knownModel?.abilities?.reasoning === true;
+
+ return {
+ contextWindowTokens,
+ displayName: model.display_name ?? knownModel?.displayName,
+ enabled: model.loaded ?? false,
+ functionCall,
+ id: model.id,
+ reasoning,
+ vision: modelProps?.modalities?.vision ?? knownModel?.abilities?.vision ?? false,
+ };
+ }) satisfies ChatModelCard[];
+ },
+ provider: ModelProvider.Unsloth,
+} satisfies OpenAICompatibleFactoryOptions;
+
+export const LobeUnslothAI = createOpenAICompatibleRuntime(params);
diff --git a/packages/model-runtime/src/runtimeMap.ts b/packages/model-runtime/src/runtimeMap.ts
index 178f717726b..0eec41411b0 100644
--- a/packages/model-runtime/src/runtimeMap.ts
+++ b/packages/model-runtime/src/runtimeMap.ts
@@ -69,6 +69,7 @@ import { LobeSuperGrokAI } from './providers/superGrok';
import { LobeTaichuAI } from './providers/taichu';
import { LobeTencentCloudAI } from './providers/tencentcloud';
import { LobeTogetherAI } from './providers/togetherai';
+import { LobeUnslothAI } from './providers/unsloth';
import { LobeUpstageAI } from './providers/upstage';
import { LobeV0AI } from './providers/v0';
import { LobeVercelAIGatewayAI } from './providers/vercelaigateway';
@@ -156,6 +157,7 @@ export const providerRuntimeMap = {
taichu: LobeTaichuAI,
tencentcloud: LobeTencentCloudAI,
togetherai: LobeTogetherAI,
+ unsloth: LobeUnslothAI,
upstage: LobeUpstageAI,
v0: LobeV0AI,
vercelaigateway: LobeVercelAIGatewayAI,
diff --git a/src/components/ModelSelect/index.tsx b/src/components/ModelSelect/index.tsx
index 395f1849c9d..7baad18649a 100644
--- a/src/components/ModelSelect/index.tsx
+++ b/src/components/ModelSelect/index.tsx
@@ -1,6 +1,6 @@
import { type ChatModelCard } from '@lobechat/types';
import { type IconAvatarProps } from '@lobehub/icons';
-import { LobeHub, ModelIcon, ProviderIcon } from '@lobehub/icons';
+import { LobeHub, ModelIcon } from '@lobehub/icons';
import { type FlexboxProps } from '@lobehub/ui';
import { Flexbox, Icon, Tooltip } from '@lobehub/ui';
import { Avatar, Tag, Text } from '@lobehub/ui/base-ui';
@@ -20,6 +20,7 @@ import { type CSSProperties, type FC } from 'react';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type AiProviderSourceType } from '@/types/aiProvider';
import { formatTokenNumber } from '@/utils/format';
diff --git a/src/components/OllamaSetupGuide/index.tsx b/src/components/OllamaSetupGuide/index.tsx
index c34b5513bac..7ee956095f8 100644
--- a/src/components/OllamaSetupGuide/index.tsx
+++ b/src/components/OllamaSetupGuide/index.tsx
@@ -1,4 +1,3 @@
-import { ProviderCombine } from '@lobehub/icons';
import { Flexbox, Highlighter, Snippet } from '@lobehub/ui';
import { Tabs } from '@lobehub/ui/base-ui';
import { Steps } from 'antd';
@@ -7,6 +6,8 @@ import { readableColor } from 'polished';
import React, { memo, useMemo } from 'react';
import { Trans, useTranslation } from 'react-i18next';
+import { ProviderCombine } from '@/libs/providerIcon';
+
const prefixCls = 'ant';
const styles = createStaticStyles(({ css, cssVar }) => ({
diff --git a/src/features/Conversation/Error/ChatInvalidApiKey.tsx b/src/features/Conversation/Error/ChatInvalidApiKey.tsx
index 913472f8e22..df51d9312dc 100644
--- a/src/features/Conversation/Error/ChatInvalidApiKey.tsx
+++ b/src/features/Conversation/Error/ChatInvalidApiKey.tsx
@@ -1,4 +1,3 @@
-import { ProviderIcon } from '@lobehub/icons';
import { Button } from '@lobehub/ui/base-ui';
import { ModelProvider } from 'model-bank';
import { memo } from 'react';
@@ -7,6 +6,7 @@ import urlJoin from 'url-join';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useProviderName } from '@/hooks/useProviderName';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type GlobalLLMProviderKey } from '@/types/user/settings/modelProvider';
import { useConversationStore } from '../store';
diff --git a/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx b/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
index 7cc5cd736db..8cc34bc42a6 100644
--- a/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
+++ b/src/features/ModelSwitchPanel/components/List/__tests__/MultipleProvidersModelItem.test.tsx
@@ -48,6 +48,9 @@ vi.mock('@lobehub/ui/base-ui', () => ({
vi.mock('@lobehub/icons', () => ({
LobeHub: { Morden: () => <span /> },
ModelIcon: () => <span />,
+}));
+
+vi.mock('@/libs/providerIcon', () => ({
ProviderIcon: () => <span />,
}));
diff --git a/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx b/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
index 0bc7e9c1fe2..9346896086a 100644
--- a/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
+++ b/src/features/Settings/provider/(list)/ProviderGrid/Card.tsx
@@ -1,5 +1,4 @@
import { BRANDING_PROVIDER } from '@lobechat/business-const';
-import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
import { Flexbox } from '@lobehub/ui';
import { Avatar, Skeleton, Tag, Text } from '@lobehub/ui/base-ui';
import { Divider } from 'antd';
@@ -9,6 +8,7 @@ import { useTranslation } from 'react-i18next';
import { BrandingProviderCard } from '@/business/client/features/BrandingProviderCard';
import { useIsDark } from '@/hooks/useIsDark';
+import { ProviderCombine, ProviderIcon } from '@/libs/providerIcon';
import { type AiProviderListItem } from '@/types/aiProvider';
import EnableSwitch from './EnableSwitch';
diff --git a/src/features/Settings/provider/ProviderMenu/Item.tsx b/src/features/Settings/provider/ProviderMenu/Item.tsx
index 0fdb1ecad89..664fc1115ef 100644
--- a/src/features/Settings/provider/ProviderMenu/Item.tsx
+++ b/src/features/Settings/provider/ProviderMenu/Item.tsx
@@ -1,5 +1,4 @@
import { BRANDING_PROVIDER } from '@lobechat/business-const';
-import { ProviderIcon } from '@lobehub/icons';
import { Center } from '@lobehub/ui';
import { Avatar } from '@lobehub/ui/base-ui';
import { Badge } from 'antd';
@@ -9,6 +8,7 @@ import { useLocation } from 'react-router';
import { ProductLogo } from '@/components/Branding/ProductLogo';
import { isCustomBranding } from '@/const/version';
import NavItem from '@/features/NavPanel/components/NavItem';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type AiProviderListItem } from '@/types/aiProvider';
import { AiProviderSourceEnum } from '@/types/aiProvider';
diff --git a/src/features/Settings/provider/ProviderMenu/SortProviderModal/GroupItem.tsx b/src/features/Settings/provider/ProviderMenu/SortProviderModal/GroupItem.tsx
index 62aa7dd0b64..e26877ea12f 100644
--- a/src/features/Settings/provider/ProviderMenu/SortProviderModal/GroupItem.tsx
+++ b/src/features/Settings/provider/ProviderMenu/SortProviderModal/GroupItem.tsx
@@ -1,8 +1,8 @@
-import { ProviderIcon } from '@lobehub/icons';
import { Flexbox, SortableList } from '@lobehub/ui';
import { Avatar } from '@lobehub/ui/base-ui';
import { memo } from 'react';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type AiProviderListItem } from '@/types/aiProvider';
interface GroupItemProps extends AiProviderListItem {
diff --git a/src/features/Settings/provider/detail/index.tsx b/src/features/Settings/provider/detail/index.tsx
index bdbe5273c6e..48e484579cf 100644
--- a/src/features/Settings/provider/detail/index.tsx
+++ b/src/features/Settings/provider/detail/index.tsx
@@ -21,6 +21,10 @@ const Ollama = dynamic(() => import('./ollama'), {
loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
});
+const Unsloth = dynamic(() => import('./unsloth'), {
+ loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
+ ssr: false,
+});
const ComfyUI = dynamic(() => import('./comfyui'), {
loading: () => <SurfaceSkeleton header={false} variant={'form'} />,
ssr: false,
@@ -92,6 +96,9 @@ const ProviderDetailPage = (props: ProviderDetailPageProps) => {
case 'vertexai': {
return <VertexAI />;
}
+ case 'unsloth': {
+ return <Unsloth />;
+ }
default: {
return <DefaultPage id={id} />;
}
diff --git a/src/features/Settings/provider/detail/unsloth/CheckError.tsx b/src/features/Settings/provider/detail/unsloth/CheckError.tsx
new file mode 100644
index 00000000000..1bc111faf71
--- /dev/null
+++ b/src/features/Settings/provider/detail/unsloth/CheckError.tsx
@@ -0,0 +1,22 @@
+import { BASE_PROVIDER_DOC_URL } from '@lobechat/const';
+import { Flexbox } from '@lobehub/ui';
+import { Text } from '@lobehub/ui/base-ui';
+import { useTranslation } from 'react-i18next';
+
+import type { CheckErrorRender } from '../../features/ProviderConfig/Checker';
+
+export const CheckError: CheckErrorRender = ({ defaultError, error }) => {
+ const { t } = useTranslation('modelProvider');
+
+ if (!error) return defaultError;
+
+ return (
+ <Flexbox gap={8}>
+ {defaultError}
+ <Text type={'secondary'}>{t('unsloth.checker.guidance')}</Text>
+ <a href={`${BASE_PROVIDER_DOC_URL}/unsloth`} rel={'noreferrer'} target={'_blank'}>
+ {t('unsloth.checker.setupGuide')}
+ </a>
+ </Flexbox>
+ );
+};
diff --git a/src/features/Settings/provider/detail/unsloth/index.tsx b/src/features/Settings/provider/detail/unsloth/index.tsx
new file mode 100644
index 00000000000..1d8de851866
--- /dev/null
+++ b/src/features/Settings/provider/detail/unsloth/index.tsx
@@ -0,0 +1,8 @@
+import { UnslothProviderCard } from 'model-bank/modelProviders';
+
+import ProviderDetail from '../default';
+import { CheckError } from './CheckError';
+
+const Page = () => <ProviderDetail {...UnslothProviderCard} checkErrorRender={CheckError} />;
+
+export default Page;
diff --git a/src/features/Settings/provider/features/CreateNewProvider/Content.tsx b/src/features/Settings/provider/features/CreateNewProvider/Content.tsx
index 57ba22b109c..991677c2bcf 100644
--- a/src/features/Settings/provider/features/CreateNewProvider/Content.tsx
+++ b/src/features/Settings/provider/features/CreateNewProvider/Content.tsx
@@ -1,6 +1,5 @@
'use client';
-import { ProviderIcon } from '@lobehub/icons';
import { Flexbox, Input, InputPassword, TextArea } from '@lobehub/ui';
import { Button, Select, Text, toast, useModalContext } from '@lobehub/ui/base-ui';
import { Form } from 'antd';
@@ -9,6 +8,7 @@ import { memo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { ProviderIcon } from '@/libs/providerIcon';
import { useAiInfraStore } from '@/store/aiInfra/store';
import { type CreateAiProviderParams } from '@/types/aiProvider';
diff --git a/src/features/Settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx b/src/features/Settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx
index 834b4b0f78a..b71d8256a07 100644
--- a/src/features/Settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx
+++ b/src/features/Settings/provider/features/ProviderConfig/UpdateProviderInfo/SettingModal.tsx
@@ -1,6 +1,5 @@
'use client';
-import { ProviderIcon } from '@lobehub/icons';
import { Flexbox, Icon, Input, TextArea } from '@lobehub/ui';
import {
Button,
@@ -21,6 +20,7 @@ import { memo, type ReactNode, useState } from 'react';
import { useTranslation } from 'react-i18next';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
+import { ProviderIcon } from '@/libs/providerIcon';
import { useAiInfraStore } from '@/store/aiInfra/store';
import { type AiProviderDetailItem, type UpdateAiProviderParams } from '@/types/aiProvider';
diff --git a/src/features/Settings/provider/features/ProviderConfig/index.tsx b/src/features/Settings/provider/features/ProviderConfig/index.tsx
index d93e748959a..82e00e4f7f5 100644
--- a/src/features/Settings/provider/features/ProviderConfig/index.tsx
+++ b/src/features/Settings/provider/features/ProviderConfig/index.tsx
@@ -2,7 +2,6 @@
import { BRANDING_PROVIDER } from '@lobechat/business-const';
import { AES_GCM_URL, BASE_PROVIDER_DOC_URL, FORM_STYLE } from '@lobechat/const';
-import { ProviderCombine, ProviderIcon } from '@lobehub/icons';
import { type FormGroupItemType, type FormItemProps } from '@lobehub/ui';
import { Center, Flexbox, Form, Icon, stopPropagation, Tooltip } from '@lobehub/ui';
import { Avatar, Skeleton, Switch } from '@lobehub/ui/base-ui';
@@ -19,6 +18,7 @@ import urlJoin from 'url-join';
import { FormInput, FormPassword } from '@/components/FormInput';
import { SkeletonInput, SkeletonSwitch } from '@/components/Skeleton';
import { usePermission } from '@/hooks/usePermission';
+import { ProviderCombine, ProviderIcon } from '@/libs/providerIcon';
import { lambdaQuery } from '@/libs/trpc/client';
import { aiProviderSelectors, useAiInfraStore } from '@/store/aiInfra';
import { serverConfigSelectors, useServerConfigStore } from '@/store/serverConfig';
diff --git a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/ModelTable.tsx b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/ModelTable.tsx
index f32a4d61014..d9b6dcc31a0 100644
--- a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/ModelTable.tsx
+++ b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/ModelTable.tsx
@@ -1,5 +1,5 @@
import { CategoryBar, useThemeColorRange } from '@lobehub/charts';
-import { ModelIcon, ProviderIcon } from '@lobehub/icons';
+import { ModelIcon } from '@lobehub/icons';
import { Collapse, Flexbox } from '@lobehub/ui';
import { Avatar, Skeleton, Tag } from '@lobehub/ui/base-ui';
import { cssVar } from 'antd-style';
@@ -7,6 +7,7 @@ import { memo, useMemo } from 'react';
import { useTranslation } from 'react-i18next';
import InlineTable from '@/components/InlineTable';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type UsageLog, type UsageRecordItem } from '@/types/usage/usageRecord';
import { formatPrice } from '@/utils/format';
diff --git a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.test.tsx b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.test.tsx
index eeef53b8ff0..f9c6d08fa5e 100644
--- a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.test.tsx
+++ b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.test.tsx
@@ -12,6 +12,9 @@ import ActiveModels from './index';
vi.mock('@lobehub/icons', () => ({
ModelIcon: ({ model }: { model: string }) => <span>{model}</span>,
+}));
+
+vi.mock('@/libs/providerIcon', () => ({
ProviderIcon: ({ provider }: { provider: string }) => <span>{provider}</span>,
}));
diff --git a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.tsx b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.tsx
index 340e2c1edc0..74fc46005ce 100644
--- a/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.tsx
+++ b/src/features/Settings/stats/features/usage/UsageCards/ActiveModels/index.tsx
@@ -1,4 +1,4 @@
-import { ModelIcon, ProviderIcon } from '@lobehub/icons';
+import { ModelIcon } from '@lobehub/icons';
import { Flexbox } from '@lobehub/ui';
import { ActionIcon, Avatar } from '@lobehub/ui/base-ui';
import { cssVar } from 'antd-style';
@@ -9,6 +9,7 @@ import { useTranslation } from 'react-i18next';
import ImperativeModal from '@/components/ImperativeModal';
import StatisticCard from '@/components/StatisticCard';
import TitleWithPercentage from '@/components/StatisticCard/TitleWithPercentage';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type UsageLog } from '@/types/usage/usageRecord';
import { formatNumber } from '@/utils/format';
diff --git a/src/features/Settings/stats/features/usage/UsageTable.test.tsx b/src/features/Settings/stats/features/usage/UsageTable.test.tsx
index 542d12f98cf..1a25a8408e6 100644
--- a/src/features/Settings/stats/features/usage/UsageTable.test.tsx
+++ b/src/features/Settings/stats/features/usage/UsageTable.test.tsx
@@ -9,7 +9,7 @@ import { describe, expect, it, vi } from 'vitest';
import UsageTable from './UsageTable';
-vi.mock('@lobehub/icons', () => ({
+vi.mock('@/libs/providerIcon', () => ({
ProviderIcon: ({ provider }: { provider: string }) => <span>{provider}</span>,
}));
diff --git a/src/features/Settings/stats/features/usage/UsageTable.tsx b/src/features/Settings/stats/features/usage/UsageTable.tsx
index 0ecfe9ee9f4..6c0fbf06213 100644
--- a/src/features/Settings/stats/features/usage/UsageTable.tsx
+++ b/src/features/Settings/stats/features/usage/UsageTable.tsx
@@ -1,4 +1,3 @@
-import { ProviderIcon } from '@lobehub/icons';
import { Flexbox, Tooltip } from '@lobehub/ui';
import { Text } from '@lobehub/ui/base-ui';
import { type TableColumnType } from 'antd';
@@ -11,6 +10,7 @@ import SpendType, { type SpendTypeValue } from '@/components/SpendType';
import TablePagination from '@/components/TablePagination';
import TotalToken from '@/components/TotalToken';
import { parseAsInteger, useQueryStates } from '@/hooks/useQueryParam';
+import { ProviderIcon } from '@/libs/providerIcon';
import { useClientDataSWR } from '@/libs/swr';
import { statsKeys } from '@/libs/swr/keys';
import { usageService } from '@/services/usage';
diff --git a/src/libs/providerIcon.test.ts b/src/libs/providerIcon.test.ts
new file mode 100644
index 00000000000..49a903331d4
--- /dev/null
+++ b/src/libs/providerIcon.test.ts
@@ -0,0 +1,18 @@
+import { createElement } from 'react';
+import { renderToStaticMarkup } from 'react-dom/server';
+import { describe, expect, it } from 'vitest';
+
+import { ProviderCombine, ProviderIcon } from './providerIcon';
+
+describe('provider artwork', () => {
+ it.each(['unsloth', 'Unsloth'])('renders the official %s avatar and wordmark', (provider) => {
+ const avatar = renderToStaticMarkup(createElement(ProviderIcon, { provider, type: 'avatar' }));
+ const wordmark = renderToStaticMarkup(createElement(ProviderCombine, { provider }));
+
+ expect(avatar).toContain('<title>Unsloth</title>');
+ expect(avatar).not.toContain('lucide-provider');
+ expect(wordmark).toContain('<title>Unsloth</title>');
+ expect(wordmark).not.toContain('lucide-provider');
+ expect((wordmark.match(/<svg /g) || []).length).toBe(2);
+ });
+});
diff --git a/src/libs/providerIcon.ts b/src/libs/providerIcon.ts
new file mode 100644
index 00000000000..c654bd5d4e5
--- /dev/null
+++ b/src/libs/providerIcon.ts
@@ -0,0 +1,15 @@
+import { ProviderCombine, ProviderIcon, providerMappings, Unsloth } from '@lobehub/icons';
+
+/**
+ * @lobehub/icons 5.18 exports Unsloth but omits its provider mapping. Register
+ * the official artwork until the library includes it, preserving an upstream
+ * mapping when present. Keep this alongside provider icon consumers so the
+ * complete mapping table stays outside the SPA's initial dependency graph.
+ */
+if (
+ !providerMappings.some(({ keywords }) => keywords.some((key) => key.toLowerCase() === 'unsloth'))
+) {
+ providerMappings.push({ Icon: Unsloth, keywords: ['unsloth'] });
+}
+
+export { ProviderCombine, ProviderIcon };
diff --git a/src/routes/(main)/(create)/features/GenerationInput/GenerationInvalidAPIKey.tsx b/src/routes/(main)/(create)/features/GenerationInput/GenerationInvalidAPIKey.tsx
index b0a8fb47b2b..7ab5597db45 100644
--- a/src/routes/(main)/(create)/features/GenerationInput/GenerationInvalidAPIKey.tsx
+++ b/src/routes/(main)/(create)/features/GenerationInput/GenerationInvalidAPIKey.tsx
@@ -1,6 +1,5 @@
'use client';
-import { ProviderIcon } from '@lobehub/icons';
import { Button } from '@lobehub/ui/base-ui';
import { ModelProvider } from 'model-bank';
import { memo } from 'react';
@@ -10,6 +9,7 @@ import urlJoin from 'url-join';
import BaseErrorForm from '@/features/Conversation/Error/BaseErrorForm';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import { useProviderName } from '@/hooks/useProviderName';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type GlobalLLMProviderKey } from '@/types/user/settings/modelProvider';
interface GenerationInvalidAPIKeyProps {
diff --git a/src/routes/(main)/community/(detail)/model/features/Details/Overview/ProviderList/index.tsx b/src/routes/(main)/community/(detail)/model/features/Details/Overview/ProviderList/index.tsx
index e978c47c7c1..dd322544095 100644
--- a/src/routes/(main)/community/(detail)/model/features/Details/Overview/ProviderList/index.tsx
+++ b/src/routes/(main)/community/(detail)/model/features/Details/Overview/ProviderList/index.tsx
@@ -1,6 +1,5 @@
'use client';
-import { ProviderIcon } from '@lobehub/icons';
import { Block, Flexbox, Icon, Tooltip, TooltipGroup } from '@lobehub/ui';
import { ActionIcon } from '@lobehub/ui/base-ui';
import { cssVar } from 'antd-style';
@@ -13,6 +12,7 @@ import InlineTable from '@/components/InlineTable';
import { ModelInfoTags } from '@/components/ModelSelect';
import { BASE_PROVIDER_DOC_URL } from '@/const/url';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { ProviderIcon } from '@/libs/providerIcon';
import { formatPriceByCurrency, formatTokenNumber } from '@/utils/format';
import { getTextInputUnitRate, getTextOutputUnitRate } from '@/utils/pricing';
diff --git a/src/routes/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx b/src/routes/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
index a420bec81ad..7e0d0cca49b 100644
--- a/src/routes/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
+++ b/src/routes/(main)/community/(detail)/model/features/Sidebar/ActionButton/ChatWithModel.tsx
@@ -1,6 +1,5 @@
'use client';
-import { ProviderIcon } from '@lobehub/icons';
import { DropdownMenu } from '@lobehub/ui';
import { Button, SplitButton } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
@@ -10,6 +9,7 @@ import urlJoin from 'url-join';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { ProviderIcon } from '@/libs/providerIcon';
import { useDetailContext } from '../../DetailProvider';
diff --git a/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx b/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
index b0b0f090b95..9ea9a55d369 100644
--- a/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
+++ b/src/routes/(main)/community/(detail)/model/features/Sidebar/RelatedProviders/Item.tsx
@@ -1,10 +1,10 @@
-import { ProviderIcon } from '@lobehub/icons';
import { Block, Flexbox } from '@lobehub/ui';
import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type DiscoverModelDetailProviderItem } from '@/types/discover';
const styles = createStaticStyles(({ css, cssVar }) => {
diff --git a/src/routes/(main)/community/(detail)/provider/features/Header.tsx b/src/routes/(main)/community/(detail)/provider/features/Header.tsx
index 0c964684d24..8ec4e2c5f29 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Header.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Header.tsx
@@ -1,6 +1,6 @@
'use client';
-import { Github, ProviderCombine } from '@lobehub/icons';
+import { Github } from '@lobehub/icons';
import { Flexbox, stopPropagation } from '@lobehub/ui';
import { ActionIcon } from '@lobehub/ui/base-ui';
import { cssVar, useResponsive } from 'antd-style';
@@ -9,6 +9,8 @@ import { memo } from 'react';
import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
+import { ProviderCombine } from '@/libs/providerIcon';
+
import { useDetailContext } from './DetailProvider';
const Header = memo<{ mobile?: boolean }>(({ mobile: isMobile }) => {
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
index 6300e31be09..3ce7b92f3d8 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/ActionButton/index.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ModelTag, ProviderIcon } from '@lobehub/icons';
+import { ModelTag } from '@lobehub/icons';
import { Flexbox } from '@lobehub/ui';
import { Tag } from '@lobehub/ui/base-ui';
import { memo } from 'react';
@@ -8,6 +8,7 @@ import { useTranslation } from 'react-i18next';
import urlJoin from 'url-join';
import { OFFICIAL_URL } from '@/const/url';
+import { ProviderIcon } from '@/libs/providerIcon';
import ShareButton from '../../../../features/ShareButton';
import { useDetailContext } from '../../DetailProvider';
diff --git a/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx b/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
index 44ec2aab950..74b4c3b880f 100644
--- a/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
+++ b/src/routes/(main)/community/(detail)/provider/features/Sidebar/Related/Item.tsx
@@ -1,10 +1,10 @@
-import { ProviderIcon } from '@lobehub/icons';
import { Block, Flexbox } from '@lobehub/ui';
import { Text } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
import { memo } from 'react';
import { useTranslation } from 'react-i18next';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type DiscoverProviderItem } from '@/types/discover';
const styles = createStaticStyles(({ css, cssVar }) => {
diff --git a/src/routes/(main)/community/(list)/model/features/Category/useCategory.tsx b/src/routes/(main)/community/(list)/model/features/Category/useCategory.tsx
index c84dea273ac..e843854bfd8 100644
--- a/src/routes/(main)/community/(list)/model/features/Category/useCategory.tsx
+++ b/src/routes/(main)/community/(list)/model/features/Category/useCategory.tsx
@@ -1,10 +1,11 @@
-import { ProviderIcon } from '@lobehub/icons';
import { uniqBy } from 'es-toolkit/compat';
import { LayoutPanelTopIcon } from 'lucide-react';
import { DEFAULT_MODEL_PROVIDER_LIST } from 'model-bank/modelProviders';
import { useMemo } from 'react';
import { useTranslation } from 'react-i18next';
+import { ProviderIcon } from '@/libs/providerIcon';
+
export const useCategory = () => {
const { t } = useTranslation('discover');
diff --git a/src/routes/(main)/community/(list)/model/features/List/Item.tsx b/src/routes/(main)/community/(list)/model/features/List/Item.tsx
index ea773109689..8e173cc8919 100644
--- a/src/routes/(main)/community/(list)/model/features/List/Item.tsx
+++ b/src/routes/(main)/community/(list)/model/features/List/Item.tsx
@@ -1,6 +1,6 @@
'use client';
-import { ModelIcon, ProviderIcon } from '@lobehub/icons';
+import { ModelIcon } from '@lobehub/icons';
import { Block, Flexbox, Icon, Popover } from '@lobehub/ui';
import { Tag, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles } from 'antd-style';
@@ -14,6 +14,7 @@ import { ModelInfoTags } from '@/components/ModelSelect';
import PublishedTime from '@/components/PublishedTime';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { ProviderIcon } from '@/libs/providerIcon';
import { type DiscoverModelItem } from '@/types/discover';
import ModelTypeIcon from './ModelTypeIcon';
diff --git a/src/routes/(main)/community/(list)/provider/features/List/Item.tsx b/src/routes/(main)/community/(list)/provider/features/List/Item.tsx
index 0599a752e47..fe9f75f7070 100644
--- a/src/routes/(main)/community/(list)/provider/features/List/Item.tsx
+++ b/src/routes/(main)/community/(list)/provider/features/List/Item.tsx
@@ -1,4 +1,4 @@
-import { Github, ModelTag, ProviderCombine } from '@lobehub/icons';
+import { Github, ModelTag } from '@lobehub/icons';
import { Block, Flexbox, MaskShadow, stopPropagation } from '@lobehub/ui';
import { ActionIcon, Text } from '@lobehub/ui/base-ui';
import { createStaticStyles, cssVar } from 'antd-style';
@@ -10,6 +10,7 @@ import urlJoin from 'url-join';
import { GITHUB } from '@/const/url';
import { useWorkspaceAwareNavigate } from '@/features/Workspace/useWorkspaceAwareNavigate';
import WorkspaceLink from '@/features/Workspace/WorkspaceLink';
+import { ProviderCombine } from '@/libs/providerIcon';
import { type DiscoverProviderItem } from '@/types/discover';
const styles = createStaticStyles(({ css, cssVar }) => {
diff --git a/src/store/aiInfra/slices/aiProvider/selectors.ts b/src/store/aiInfra/slices/aiProvider/selectors.ts
index b12785c119f..078de1a048b 100644
--- a/src/store/aiInfra/slices/aiProvider/selectors.ts
+++ b/src/store/aiInfra/slices/aiProvider/selectors.ts
@@ -48,7 +48,7 @@ const activeProviderConfig = (s: AIProviderStoreState) =>
const isAiProviderConfigLoading = (id: string) => (s: AIProviderStoreState) =>
!s.aiProviderDetailMap[id];
-const providerWhitelist = new Set(['ollama', 'lmstudio']);
+const providerWhitelist = new Set(['ollama', 'lmstudio', 'unsloth']);
const activeProviderKeyVaults = (s: AIProviderStoreState) => activeProviderConfig(s)?.keyVaults;