DSH / Atlas
2026-10-22implementedarchitecture

The official DeepSeek route follows the official model listing until its catalog is customized

DeepSeek 官方路由在目录未自定义时跟随官方模型列表

The `deepseek-official` route offered whatever its `models` setting held, and that setting defaults to the catalog bundled with each build. A model the DeepSeek API added reached API-key users only through a release, while the account route already followed the service's `GET /models` listing at the same origin. Unlike the account route's catalog, the official route's catalog is user-editable: the Models page stores

English

Problem

The deepseek-official route offered whatever its models setting held, and that setting defaults to the catalog bundled with each build. A model the DeepSeek API added reached API-key users only through a release, while the account route already followed the service's GET /models listing at the same origin. Unlike the account route's catalog, the official route's catalog is user-editable: the Models page stores an edited catalog in models, and a gateway behind baseURL declares its models there.

Decision

  • llm-deepseek-api-key follows GET https://api.deepseek.com/models, authenticated with the API key in x-api-key, only while the Messages origin is https://api.deepseek.com and models equals the built-in catalog. Any other endpoint or catalog sends no listing request.
  • Loading, refresh, fallback, merging, and the client-version gate are the account route's: a first access waits up to modelsTimeoutMs, a listing older than modelsMaxAgeMs refreshes in the background on the next access, a failure keeps the last good listing or the built-in catalog, and the cache lives in memory, keyed by endpoint and key fingerprint.
  • A customized models list wins whole: it replaces the catalog and stops listing requests. A list is customized when it resolves differently from the built-in catalog, because the schema default materializes an absent models as the built-in list and the Models page shows that default as its inherited rows.
  • Switching between a customized catalog and the listing invalidates the cache from a loader/volatile-update listener, so Restore defaults reloads the listing on the next access even when the cached listing is fresh.
  • The listing request, its cache, catalog resolution, and the gate live in the shared Messages transport because two routes consume them; the transport's provider hooks remain connect and admit.

Alternatives considered

Follow the listing on every endpoint. A gateway that publishes an OpenAI-style /models returns entries without api_capabilities.anthropic_messages, which the decoder hides, so the route would offer no models. Every such gateway would also receive an extra request carrying the key.

Merge the customized catalog with the listing by model id. Customized users would keep receiving new listed models, but a model the user deleted would return, and the Models page cannot hide one listed model.

Mark an unset models by removing its schema default. An absent value would select the listing without comparing catalogs, but the Models page would lose the inherited rows it shows and copies, with their hidden systemPromptUpdate and toolUpdate fields, into a customized catalog. Rows copied from the generic model-discovery API would drop those fields.

Fetch once per process, or refresh on a timer. A single fetch leaves a long-running Web or desktop host on its startup catalog, and one transient failure pins it to the built-in catalog. A timer sends requests while the route is idle. Access-triggered background refresh matches the account route.

Reuse the cached listing after Restore defaults. The cache could serve a listing loaded before the customization for up to modelsMaxAgeMs; the request is cheap, so restoring always reloads it. The reload starts on the next access rather than inside the listener, which keeps credential lookup and its failures on the request path; the Web page's settings refresh makes that access right after the save.

Consequences

  • API-key users on the official endpoint receive listed models without a release, and an older build hides or refuses a model that needs a newer client, as account users' builds do.
  • A customized catalog receives no later listed models until Restore defaults, and a models list identical to the built-in catalog counts as uncustomized. The comparison uses the running version's built-in catalog, so a saved list equal to an earlier version's built-in catalog counts as customized once the built-in catalog changes.
  • The Models page shows the built-in rows while the listing is followed, so a model only the listing offers appears only in model selectors, and editing the page's catalog drops it.
  • The first catalog access on the official endpoint can wait up to modelsTimeoutMs, and a suite that boots the route there must answer the listing itself to stay off the network.

中文

问题

deepseek-official 路由提供的是 models 设置里的内容,而这个设置默认是每个构建自带的目录。DeepSeek API 新增的模型只能随发版到达 API key 用户,而账号路由已经在同一个 origin 上跟随服务端的 GET /models 列表。与账号路由不同,官方路由的目录可以由用户编辑:模型页把编辑后的目录存进 models,baseURL 后面的网关也在这里声明自己的模型。

决策

  • llm-deepseek-api-key 只在 Messages 的 origin 是 https://api.deepseek.com、且 models 等于内置目录时,跟随 GET https://api.deepseek.com/models,并用 x-api-key 携带 API key 鉴权。其他端点或目录不发列表请求。
  • 加载、刷新、兜底、合并与客户端版本门控沿用账号路由的规则:首次访问最多等待 modelsTimeoutMs,列表超过 modelsMaxAgeMs 后在下一次访问时后台刷新,失败时保留上一份成功的列表或使用内置目录,缓存只在内存中,以端点和 key 指纹为键。
  • 自定义的 models 列表整份优先:它替换目录,并停止列表请求。解析结果与内置目录不同的列表才算自定义,因为 schema 默认值会把缺省的 models 物化为内置列表,模型页也把这个默认值显示为继承的行。
  • 在自定义目录与列表之间切换时,一个 loader/volatile-update 监听器会让缓存失效,因此点恢复默认后,即使缓存的列表尚未过期,下一次访问也会重新加载。
  • 列表请求、缓存、目录解析和门控放在共享的 Messages 传输包中,因为现在有两条路由使用它们;传输层的提供方钩子仍然只有 connect 和 admit。

考虑过的替代方案

在所有端点上跟随列表。 发布 OpenAI 风格 /models 的网关返回的条目没有 api_capabilities.anthropic_messages,解码器会隐藏它们,路由就不提供任何模型。每个这样的网关还会多收到一个携带 key 的请求。

按模型 id 合并自定义目录与列表。 自定义用户会继续收到新列出的模型,但用户删掉的模型会重新出现,而模型页无法隐藏某一个列出的模型。

去掉 models 的 schema 默认值来标记未设置。 缺省值不用比较目录就能选中列表,但模型页会失去它显示的继承行;这些行连同隐藏的 systemPromptUpdate、toolUpdate 字段会被复制进自定义目录。从通用模型发现 API 复制的行会丢掉这些字段。

每个进程只获取一次,或按定时器刷新。 只获取一次会让常驻的 Web 或桌面宿主停留在启动时的目录,一次偶发失败就会让它固定在内置目录。定时器会在路由空闲时发请求。由访问触发的后台刷新与账号路由一致。

恢复默认后沿用缓存的列表。 缓存可能在 modelsMaxAgeMs 内一直提供自定义之前加载的列表;列表请求代价很小,所以恢复默认总是重新加载。重新加载从下一次访问开始,而不是在监听器里进行,这样凭据查询及其失败都留在请求路径上;Web 页面保存后的设置刷新会立即发起这次访问。

影响

  • 使用官方端点的 API key 用户无需发版就能看到列出的模型,旧构建会像账号用户的构建一样隐藏或拒绝需要新版客户端的模型。
  • 自定义目录在恢复默认之前收不到之后列出的模型;与内置目录完全相同的 models 列表视为未自定义。比较的是当前版本的内置目录,所以保存的列表若等于旧版本的内置目录,内置目录变化后就算作自定义。
  • 跟随列表期间,模型页仍显示内置的行,因此只有列表提供的模型只出现在模型选择器里,在模型页编辑目录会丢掉它。
  • 官方端点上的第一次目录访问可能等待最多 modelsTimeoutMs,在该端点上启动路由的测试套件必须自己应答列表请求,才能不访问网络。