models_catalog_static.py 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724
  1. """Static provider/model catalog tables (data only — no network).
  2. Curated per-provider model lists, the canonical provider registry, display groups and alias
  3. maps. Split out of ``hermes_cli.models``.
  4. """
  5. from __future__ import annotations
  6. from typing import Any, NamedTuple
  7. class CuratedFallbackModels(list[str]):
  8. """A curated list served because the provider's live catalog was unavailable. The disk cache
  9. treats it as a placeholder, never as the account's real catalog (#107391)."""
  10. # Fallback OpenRouter snapshot used when the live catalog is unavailable, as
  11. # ``(model_id, description shown in menus)``. ``:free`` SKUs are described "free".
  12. _OPENROUTER_DESCRIPTIONS = {
  13. "anthropic/claude-opus-5-fast": "2x price, higher output speed",
  14. "anthropic/claude-opus-4.8-fast": "2x price, higher output speed",
  15. "deepseek/deepseek-v4-pro-0813": "dated snapshot of v4-pro",
  16. "deepseek/deepseek-v4.1-flash-1017": "dated snapshot of v4.1-flash",
  17. "deepseek/deepseek-v4-flash-0731": "dated snapshot of v4-flash",
  18. "moonshotai/kimi-k3": "recommended",
  19. "z-ai/glm-5.3": "default",
  20. "z-ai/glm-5.3-flashx": "high-speed tier of glm-5.3-flash",
  21. "openrouter/pareto-code": "auto-routes to cheapest coder meeting openrouter.min_coding_score",
  22. "openai/gpt-6-astra-fast": "2x price, priority tier",
  23. "openai/gpt-6-astra-flex": "0.5x price, flex tier",
  24. "openai/gpt-6-astra-pro-fast": "2x price, priority tier",
  25. "openai/gpt-6-astra-pro-flex": "0.5x price, flex tier",
  26. "stealth/union-alpha": "free, stealth model",
  27. "stealth/space-bunny-alpha": "free, stealth model",
  28. }
  29. OPENROUTER_MODELS: list[tuple[str, str]] = [
  30. (mid, _OPENROUTER_DESCRIPTIONS.get(mid, "free" if mid.endswith(":free") else ""))
  31. for mid in (
  32. "anthropic/claude-fable-5.1", "anthropic/claude-fable-5", "anthropic/claude-opus-5.5",
  33. "anthropic/claude-opus-5", "anthropic/claude-opus-5-fast", "anthropic/claude-opus-4.8", "anthropic/claude-opus-4.8-fast",
  34. "anthropic/claude-sonnet-5.5", "anthropic/claude-sonnet-5", "anthropic/claude-haiku-5.5", "anthropic/claude-haiku-4.5",
  35. "openai/gpt-6-astra", "openai/gpt-6-astra-fast", "openai/gpt-6-astra-flex", "openai/gpt-6-astra-pro",
  36. "openai/gpt-6-astra-pro-fast", "openai/gpt-6-astra-pro-flex",
  37. "openai/gpt-6.1-sol", "openai/gpt-6.1-sol-pro", "openai/gpt-6.1-terra", "openai/gpt-6-sol", "openai/gpt-6-sol-pro",
  38. "openai/gpt-6-luna", "openai/gpt-6-luna-pro",
  39. "openai/gpt-5.5", "openai/gpt-5.5-pro", "openai/gpt-5.4-mini", "google/gemini-4-argon",
  40. "google/gemini-3.1-pro-preview",
  41. "google/gemini-3.8-flash", "google/gemini-3.7-flash", "x-ai/grok-4.7", "x-ai/grok-4.6",
  42. "deepseek/deepseek-v4-pro",
  43. "deepseek/deepseek-v4-pro-0813", "deepseek/deepseek-v4.1-flash", "deepseek/deepseek-v4.1-flash-1017",
  44. "deepseek/deepseek-v4-flash-0731",
  45. "qwen/qwen3.8-max-0902", "qwen/qwen3.8-flash", "moonshotai/kimi-k3", "minimax/minimax-m3", "z-ai/glm-5.3",
  46. "z-ai/glm-5.3-flash", "z-ai/glm-5.3-flashx", "z-ai/glm-5.2",
  47. "xiaomi/mimo-v2.6-pro", "xiaomi/mimo-v2.6-flash", "xiaomi/mimo-v2.6-pro-ultraspeed", "xiaomi/mimo-v2.5-pro", "tencent/hy4-preview",
  48. "tencent/hy3",
  49. "stepfun/step-3.7-flash", "nvidia/nemotron-3-super-120b-a12b", "meta/muse-spark-1.2",
  50. "meta/muse-spark-1.2-contributor", "meta/muse-spark-1.3", "meta/muse-spark-1.3-contributor", "sakana/fugu-ultra",
  51. "upstage/solar-pro4", "upstage/solar-mini4",
  52. "openrouter/pareto-code", "thinkingmachines/inkling:free", "thinkingmachines/inkling-small:free",
  53. "minimax/minimax-m3:free", "z-ai/glm-5.2:free", "poolside/laguna-s-2.1:free", "poolside/laguna-xs-2.1:free",
  54. "nvidia/nemotron-3-super-120b-a12b:free", "nvidia/nemotron-3-ultra-550b-a55b:free",
  55. "inclusionai/ling-3.0-flash:free", "nvidia/nemotron-3.5-lightning:free", "stealth/union-alpha",
  56. "stealth/space-bunny-alpha",
  57. )
  58. ]
  59. # OpenRouter entries the Nous Portal does not carry (routing/fast variants, free tier —
  60. # ``stealth/union-alpha`` is a $0 stealth SKU without the ``:free`` suffix).
  61. _OPENROUTER_ONLY = {
  62. "anthropic/claude-opus-5-fast", "anthropic/claude-opus-4.8-fast",
  63. "meta/muse-spark-1.2-contributor", "meta/muse-spark-1.3-contributor", "openrouter/pareto-code",
  64. "stealth/union-alpha",
  65. }
  66. # Fallback Vercel AI Gateway snapshot (open-weight first, then closed-source by family). Slugs
  67. # match Vercel's /v1/models catalog (``alibaba/`` for Qwen, ``zai/`` and ``xai/`` without hyphens).
  68. VERCEL_AI_GATEWAY_MODELS: list[tuple[str, str]] = [("moonshotai/kimi-k2.6", "recommended")] + [
  69. (mid, "") for mid in (
  70. "alibaba/qwen3.6-plus", "zai/glm-5.1", "minimax/minimax-m2.7", "anthropic/claude-sonnet-4.6",
  71. "anthropic/claude-opus-4.7", "anthropic/claude-opus-4.6", "anthropic/claude-haiku-4.5",
  72. "openai/gpt-5.4", "openai/gpt-5.4-mini", "openai/gpt-5.3-codex", "google/gemini-3.1-pro-preview",
  73. "google/gemini-3-flash", "google/gemini-3.1-flash-lite-preview", "xai/grok-4.20-reasoning",
  74. )
  75. ]
  76. def _codex_curated_models() -> list[str]:
  77. """openai-codex curated list from codex_models.py (DEFAULT_CODEX_MODELS + forward-compat
  78. synthesis) so the gateway /model picker and the CLI ``hermes model`` flow share one source."""
  79. from hermes_cli.codex_models import DEFAULT_CODEX_MODELS, _finalize_codex_models
  80. return _finalize_codex_models(list(DEFAULT_CODEX_MODELS))
  81. # Static xAI fallback when the models.dev disk cache is empty (fresh install, offline first run).
  82. # Mirrors the xAI-direct IDs from $HERMES_HOME/models_dev_cache.json; the cache overrides it on the
  83. # next refresh. Models xAI retired on 2026-05-15 (grok-4*, grok-4-fast*, grok-4-1-fast*,
  84. # grok-code-fast-1) are excluded — see docs.x.ai/developers/migration/may-15-retirement.
  85. _XAI_STATIC_FALLBACK: list[str] = [
  86. "grok-4.6", "grok-build-0.1", "grok-4.5", "grok-4.3", "grok-4.20-0309-reasoning",
  87. "grok-4.20-0309-non-reasoning", "grok-4.20-multi-agent-0309",
  88. ]
  89. # Callable via xAI OAuth but omitted from models.dev and /v1/models listings. grok-4.6 / grok-4.5
  90. # stay here until the models.dev disk cache refreshes.
  91. _XAI_CURATED_EXTRAS: list[str] = ["grok-4.6", "grok-4.5", "grok-composer-2.5-fast"]
  92. _XAI_TOP_MODEL = "grok-4.6"
  93. def _xai_promote_top(ids: list[str]) -> list[str]:
  94. """Pin the headline xAI model to the top of the curated list."""
  95. if _XAI_TOP_MODEL in ids:
  96. return [_XAI_TOP_MODEL] + [m for m in ids if m != _XAI_TOP_MODEL]
  97. return ids
  98. def _xai_merge_curated_extras(ids: list[str]) -> list[str]:
  99. """Append Hermes-curated xAI models missing from models.dev, right after the pinned headline."""
  100. out = list(ids)
  101. for extra in _XAI_CURATED_EXTRAS:
  102. if extra not in out:
  103. out.insert(1 if out and out[0] == _XAI_TOP_MODEL else len(out), extra)
  104. return out
  105. def _xai_finalize_catalog(ids: list[str]) -> list[str]:
  106. return _xai_promote_top(_xai_merge_curated_extras(ids))
  107. def _xai_curated_models() -> list[str]:
  108. """Offline curated floor for xAI / xAI OAuth pickers: $HERMES_HOME/models_dev_cache.json
  109. (no network), else ``_XAI_STATIC_FALLBACK``. Any failure falls through to the static list.
  110. Reads through the process-wide models.dev copy, so the parse is the one every later reader shares."""
  111. try:
  112. from agent.models_dev import fetch_models_dev
  113. data = fetch_models_dev(allow_network=False)
  114. xai = data.get("xai") if isinstance(data, dict) else None
  115. models = xai.get("models") if isinstance(xai, dict) else None
  116. if isinstance(models, dict) and models:
  117. ids = [mid for mid in models if isinstance(mid, str)]
  118. if ids:
  119. return _xai_finalize_catalog(sorted(ids))
  120. except Exception:
  121. pass
  122. return _xai_finalize_catalog(list(_XAI_STATIC_FALLBACK))
  123. _XAI_ROWS = ("xai", "xai-oauth")
  124. class _CuratedCatalog(dict):
  125. """``_PROVIDER_MODELS``: static rows, except xAI's, which come from the models.dev disk cache.
  126. That cache is a full parse of the whole catalog (tens of MiB resident), so it is read on the first
  127. lookup of an xAI row or a whole-table walk, never at import: a process that never asks for xAI
  128. never pays for it. Until then the xAI rows hold the static fallback, and they are filled in place,
  129. so a list handed out earlier sees the same ids. Overriding ``__iter__`` keeps ``dict(table)`` and
  130. ``{**table}`` on the slow path that reads values through ``__getitem__``."""
  131. _xai_ready = False
  132. def _ensure_xai(self) -> None:
  133. if self._xai_ready:
  134. return
  135. ids = _xai_curated_models()
  136. for row in _XAI_ROWS:
  137. current = dict.get(self, row)
  138. if isinstance(current, list):
  139. current[:] = ids
  140. self._xai_ready = True
  141. def __iter__(self):
  142. return dict.__iter__(self)
  143. def __getitem__(self, key):
  144. if key in _XAI_ROWS:
  145. self._ensure_xai()
  146. return dict.__getitem__(self, key)
  147. def get(self, key, default=None):
  148. if key in _XAI_ROWS:
  149. self._ensure_xai()
  150. return dict.get(self, key, default)
  151. def values(self):
  152. self._ensure_xai()
  153. return dict.values(self)
  154. def items(self):
  155. self._ensure_xai()
  156. return dict.items(self)
  157. def copy(self):
  158. self._ensure_xai()
  159. return dict(dict.items(self))
  160. # Native OpenAI Chat Completions (api.openai.com).
  161. _OPENAI_CHAT_MODELS = [
  162. "gpt-5.4", "gpt-5.4-mini", "gpt-5-mini", "gpt-5.3-codex", "gpt-5.2-codex", "gpt-4.1", "gpt-4o", "gpt-4o-mini",
  163. ]
  164. _MINIMAX_MODELS = ["MiniMax-M3", "MiniMax-M2.7", "MiniMax-M2.5", "MiniMax-M2.1", "MiniMax-M2"]
  165. _TENCENT_MODELS = ["hy4-preview", "hy3", "hy3-preview"]
  166. # Alibaba DashScope Coding platform (coding-intl): Qwen + third-party (GLM, Kimi, MiniMax, DeepSeek).
  167. # Classic DashScope keys should override DASHSCOPE_BASE_URL to
  168. # https://dashscope-intl.aliyuncs.com/compatible-mode/v1 (OpenAI-compat) or /apps/anthropic.
  169. _ALIBABA_MODELS = [
  170. "qwen3.8-max", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus", "qwen3.6-flash", "kimi-k2.5",
  171. "qwen3.5-plus", "qwen3-coder-plus", "qwen3-coder-next", "glm-5.2", "glm-5", "glm-4.7",
  172. "deepseek-v4-pro", "deepseek-v4-flash-0731", "MiniMax-M2.5",
  173. ]
  174. _ALIBABA_CODING_PLAN_MODELS = [
  175. "qwen3.7-plus", "qwen3.6-plus", "qwen3.5-plus", "qwen3-max-2026-01-23", "qwen3-coder-plus",
  176. "qwen3-coder-next", "kimi-k2.5", "glm-5", "glm-4.7", "MiniMax-M2.5",
  177. ]
  178. # Verified against a live Token Plan subscription (key tier ``sk-sp-...``).
  179. _ALIBABA_TOKEN_PLAN_MODELS = [
  180. "qwen3.8-max-0902", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus", "qwen3.6-flash", "deepseek-v4-pro",
  181. "deepseek-v4-flash", "deepseek-v3.2", "kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "glm-5.2", "glm-5.1", "glm-5",
  182. ]
  183. # Curated per-provider lists. ``-cn`` twins share the international catalog on a domestic endpoint.
  184. _PROVIDER_MODELS: dict[str, list[str]] = _CuratedCatalog({
  185. "moa": ["default"],
  186. "nous": [mid for mid, _ in OPENROUTER_MODELS if mid not in _OPENROUTER_ONLY and not mid.endswith(":free")],
  187. # Used by /model counts and provider_model_ids fallback when /v1/models is unavailable.
  188. "openai": list(_OPENAI_CHAT_MODELS),
  189. "openai-api": [
  190. "gpt-6.1-sol", "gpt-6.1-sol-pro", "gpt-6-sol", "gpt-6-sol-pro", "gpt-6-luna", "gpt-6-luna-pro",
  191. "gpt-5.6-sol", "gpt-5.6-sol-pro", "gpt-5.6-terra", "gpt-5.6-terra-pro", "gpt-5.6-luna",
  192. "gpt-5.6-luna-pro", "gpt-5.5", "gpt-5.5-pro", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano",
  193. "gpt-5-mini", "gpt-5.3-codex", "gpt-4.1", "gpt-4o", "gpt-4o-mini",
  194. ],
  195. "openai-codex": _codex_curated_models(),
  196. "xai-oauth": _xai_finalize_catalog(list(_XAI_STATIC_FALLBACK)),
  197. "gemini": [
  198. # Argon second: [0] is the silent default when no model is configured, and a flagship never is.
  199. "gemini-3.8-flash", "gemini-4-argon", "gemini-3.7-flash",
  200. "gemini-3.1-pro-preview", "gemini-3-pro-preview", "gemini-3.6-flash", "gemini-3.1-flash-lite-preview",
  201. ],
  202. "zai": [
  203. "glm-5.3", "glm-5.3-flash", "glm-5.2", "glm-5.1", "glm-5", "glm-5v-turbo", "glm-5-turbo",
  204. "glm-4.7", "glm-4.5", "glm-4.5-flash",
  205. ],
  206. "xai": _xai_finalize_catalog(list(_XAI_STATIC_FALLBACK)),
  207. # Nemotron flagships, then third-party agentic models hosted on build.nvidia.com.
  208. "nvidia": [
  209. "nvidia/nemotron-3.5-super-vl-120b-a12b", "nvidia/nemotron-3-ultra-550b-a55b", "nvidia/nemotron-3-super-120b-a12b",
  210. "nvidia/nemotron-3.5-lightning-30b-a3b", "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning",
  211. "z-ai/glm-5.3", "z-ai/glm-5.2", "moonshotai/kimi-k2.6", "minimaxai/minimax-m3",
  212. ],
  213. "kimi-coding": [
  214. "kimi-k3", "kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "kimi-for-coding", "kimi-for-coding-highspeed",
  215. "kimi-k2-thinking", "kimi-k2-thinking-turbo", "kimi-k2-turbo-preview", "kimi-k2-0905-preview",
  216. ],
  217. "kimi-coding-cn": [
  218. "kimi-k3", "kimi-k2.7-code", "kimi-k2.7-code-highspeed", "kimi-k2.6", "kimi-k2.5",
  219. "kimi-k2-thinking", "kimi-k2-turbo-preview", "kimi-k2-0905-preview",
  220. ],
  221. "stepfun": ["step-3.7-flash", "step-3.5-flash", "step-3.5-flash-2603"],
  222. "moonshot": [
  223. "kimi-k3", "kimi-k2.6", "kimi-k2.5", "kimi-k2-thinking", "kimi-k2-turbo-preview", "kimi-k2-0905-preview",
  224. ],
  225. "minimax": list(_MINIMAX_MODELS),
  226. "minimax-oauth": ["MiniMax-M3", "MiniMax-M2.7", "MiniMax-M2.7-highspeed"],
  227. "minimax-cn": list(_MINIMAX_MODELS),
  228. "anthropic": [
  229. "claude-fable-5.1", "claude-fable-5", "claude-opus-5-5", "claude-opus-5", "claude-sonnet-5",
  230. "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6",
  231. "claude-sonnet-4-6", "claude-opus-4-5-20251101", "claude-sonnet-4-5-20250929",
  232. "claude-opus-4-20250514", "claude-sonnet-4-20250514", "claude-haiku-4-5-20251001",
  233. ],
  234. "deepseek": ["deepseek-flash", "deepseek-v4-pro"],
  235. "xiaomi": [
  236. "mimo-v2.6-pro", "mimo-v2.6-flash", "mimo-v2.6-pro-ultraspeed",
  237. "mimo-v2.5-pro", "mimo-v2.5", "mimo-v2-pro", "mimo-v2-omni", "mimo-v2-flash",
  238. ],
  239. "tencent-tokenhub": list(_TENCENT_MODELS),
  240. "tencent-tokenplan": list(_TENCENT_MODELS),
  241. "arcee": ["trinity-large-thinking", "trinity-large-preview", "trinity-mini"],
  242. "gmi": [
  243. "zai-org/GLM-5.1-FP8", "deepseek-ai/DeepSeek-V3.2", "moonshotai/Kimi-K2.5",
  244. "google/gemini-3.1-flash-lite-preview", "anthropic/claude-sonnet-5",
  245. "anthropic/claude-sonnet-4.6", "openai/gpt-5.4",
  246. ],
  247. # Synced against opencode.ai/docs/zen + live GET /zen/v1/models. Zen/Go are
  248. # _LIVE_FIRST_PICKER_PROVIDERS, so this is a discovery floor: live entries lead in the picker
  249. # and stale curated names never pollute the top. "x-preview-f-free" = "Ox Alpha" stealth model.
  250. "opencode-zen": [
  251. "x-preview-f-free", "kimi-k3", "kimi-k2.5", "kimi-k2.6", "gpt-5.6-sol", "gpt-5.6-terra", "gpt-5.6-luna",
  252. "gpt-5.5", "gpt-5.5-pro", "gpt-5.4-pro", "gpt-5.4", "gpt-5.4-mini", "gpt-5.4-nano", "gpt-5.3-codex",
  253. "gpt-5.3-codex-spark", "gpt-5.2", "gpt-5.2-codex", "gpt-5.1", "gpt-5.1-codex", "gpt-5.1-codex-max",
  254. "gpt-5.1-codex-mini", "gpt-5", "gpt-5-codex", "gpt-5-nano", "claude-fable-5", "claude-opus-5",
  255. "claude-sonnet-5", "claude-opus-4-8", "claude-opus-4-7", "claude-opus-4-6", "claude-opus-4-5",
  256. "claude-sonnet-4-6", "claude-sonnet-4-5", "claude-sonnet-4", "claude-haiku-4-5", "gemini-3.8-flash",
  257. "gemini-3.7-flash", "gemini-3.6-flash", "gemini-3.5-flash", "gemini-3.5-flash-lite", "gemini-3.1-pro", "gemini-3-flash",
  258. "grok-4.6", "grok-4.5", "grok-build-0.1", "muse-spark-1.2", "minimax-m3", "minimax-m2.7", "minimax-m2.5",
  259. "glm-5.3", "glm-5.3-flash", "glm-5.2", "glm-5.1", "glm-5", "kimi-k2.7-code", "deepseek-v4-pro",
  260. "deepseek-v4-flash", "qwen3.6-plus", "qwen3.5-plus", "big-pickle", "mimo-v2.5-free",
  261. "nemotron-3-ultra-free", "nemotron-3.5-lightning-free",
  262. "muse-spark-1.2-contributor-free", "muse-spark-1.3-contributor-free",
  263. ],
  264. # Synced against opencode.ai/docs/go + live GET /zen/go/v1/models. Known-delisted models are
  265. # REMOVED (the live-first merge would otherwise keep offering a model that 401s): "ox-alpha-free"
  266. # — the Go-subscription twin of Zen's Ox Alpha — was delisted 2026-09-09.
  267. "opencode-go": [
  268. "kimi-k3", "kimi-k2.7-code", "kimi-k2.6", "kimi-k2.5", "gpt-5.6-luna", "grok-4.5", "glm-5.3",
  269. "glm-5.3-flash", "glm-5.2", "glm-5.1", "glm-5", "mimo-v2.5-pro", "mimo-v2.5", "mimo-v2-pro",
  270. "mimo-v2-omni", "minimax-m3", "minimax-m2.7", "minimax-m2.5", "deepseek-v4-pro",
  271. "deepseek-v4-flash", "qwen3.8-max", "qwen3.7-max", "qwen3.7-plus", "qwen3.6-plus",
  272. "qwen3.5-plus", "hy3", "hy3-preview", "muse-spark-1.2-contributor", "muse-spark-1.3-contributor",
  273. ],
  274. "kilocode": [
  275. "anthropic/claude-opus-4.6", "anthropic/claude-sonnet-4.6", "openai/gpt-5.4",
  276. "google/gemini-3-pro-preview", "google/gemini-3-flash-preview",
  277. ],
  278. "alibaba": list(_ALIBABA_MODELS),
  279. "alibaba-cn": list(_ALIBABA_MODELS),
  280. "alibaba-coding-plan": list(_ALIBABA_CODING_PLAN_MODELS),
  281. "alibaba-coding-plan-cn": list(_ALIBABA_CODING_PLAN_MODELS),
  282. "alibaba-token-plan": list(_ALIBABA_TOKEN_PLAN_MODELS),
  283. "alibaba-token-plan-cn": list(_ALIBABA_TOKEN_PLAN_MODELS),
  284. # Only agentic HF models that map to OpenRouter defaults.
  285. "huggingface": [
  286. "moonshotai/Kimi-K2.5", "Qwen/Qwen3.5-397B-A17B", "Qwen/Qwen3.5-35B-A3B",
  287. "deepseek-ai/DeepSeek-V3.2", "MiniMaxAI/MiniMax-M2.5", "zai-org/GLM-5",
  288. "XiaomiMiMo/MiMo-V2-Flash", "moonshotai/Kimi-K2-Thinking", "moonshotai/Kimi-K2.6",
  289. ],
  290. # Static fallback when live discovery (ListFoundationModels + ListInferenceProfiles) is
  291. # unavailable. Inference-profile IDs (us.*) because most models require them.
  292. "bedrock": [
  293. # [0] is the provider default (get_default_model_for_provider) — keep the cheaper Sonnet there.
  294. "us.anthropic.claude-sonnet-5", "us.anthropic.claude-opus-5-5", "us.anthropic.claude-sonnet-4-6",
  295. "us.anthropic.claude-opus-4-6-v1",
  296. "us.anthropic.claude-haiku-4-5-20251001-v1:0", "us.anthropic.claude-sonnet-4-5-20250929-v1:0",
  297. "openai.gpt-6-astra", "openai.gpt-6.1-sol", "openai.gpt-6.1-terra", "openai.gpt-6-sol", "openai.gpt-6-luna",
  298. "openai.gpt-5.5", "openai.gpt-5.6-sol", "openai.gpt-5.6-terra", "openai.gpt-5.6-luna", "openai.gpt-5.4",
  299. "us.amazon.nova-pro-v1:0", "us.amazon.nova-lite-v1:0", "us.amazon.nova-micro-v1:0", "deepseek.v3.2",
  300. "us.meta.llama4-maverick-17b-instruct-v1:0", "us.meta.llama4-scout-17b-instruct-v1:0",
  301. ],
  302. # Azure Foundry models depend on the user's endpoint configuration.
  303. "azure-foundry": [],
  304. # Vertex's OpenAI-compatible endpoint has no /models route, so without this the /model picker
  305. # only shows the configured model. IDs carry the "google/" publisher prefix Vertex expects
  306. # (see hermes_cli/model_setup_flows.py); validated live against a GCP project (global region).
  307. "vertex": [
  308. "google/gemini-3.8-flash", "google/gemini-4-argon", "google/gemini-3.7-flash", # [0] = silent default
  309. "google/gemini-3.1-pro-preview", "google/gemini-3-pro-preview", "google/gemini-3.6-flash",
  310. "google/gemini-3.5-flash", "google/gemini-3.5-flash-lite", "google/gemini-3-flash-preview",
  311. "google/gemini-3.1-flash-lite-preview", "google/gemini-3.1-flash-lite",
  312. ],
  313. "novita": [
  314. "moonshotai/kimi-k2.5", "minimax/minimax-m2.7", "zai-org/glm-5", "deepseek/deepseek-v3-0324",
  315. "deepseek/deepseek-r1-0528", "qwen/qwen3-235b-a22b-fp8",
  316. ],
  317. # Bare ids derived from the picker snapshot so both stay in sync.
  318. "ai-gateway": [mid for mid, _ in VERCEL_AI_GATEWAY_MODELS],
  319. })
  320. # ---------------------------------------------------------------------------
  321. # Canonical provider list — single source of truth for provider identity. Every code path that
  322. # lists, displays, or iterates providers (hermes model, /model, list_authenticated_providers)
  323. # derives from it. slug = internal ID (config.yaml, --provider); label = short display name;
  324. # tui_desc = longer description for the `hermes model` picker.
  325. # ---------------------------------------------------------------------------
  326. class ProviderEntry(NamedTuple):
  327. slug: str
  328. label: str
  329. tui_desc: str
  330. CANONICAL_PROVIDERS: list[ProviderEntry] = [ProviderEntry(*row) for row in (
  331. ("nous", "Nous Portal", "Nous Portal (Everything your agent needs, 300+ models with bundled tool use)"),
  332. ("fireworks", "Fireworks AI", "Fireworks AI (OpenAI-compatible direct model API)"),
  333. ("openrouter", "OpenRouter", "OpenRouter (Pay-per-use API aggregator)"),
  334. ("moa", "Mixture of Agents", "Mixture of Agents (named presets; aggregator acts after reference models)"),
  335. ("novita", "NovitaAI", "NovitaAI (Cloud: Model API, Agent Sandbox, GPU Cloud)"),
  336. ("lmstudio", "LM Studio", "LM Studio (Local desktop app with built-in model server)"),
  337. ("anthropic", "Anthropic", "Anthropic (Claude models via API key or Claude Code)"),
  338. ("openai-codex", "ChatGPT or Codex Subscription", "ChatGPT or Codex Subscription (Sign in with your ChatGPT account, uses Codex models)"),
  339. ("openai-api", "OpenAI API", "OpenAI API (api.openai.com, API key)"),
  340. ("alibaba", "Qwen Cloud", "Qwen Cloud / DashScope (Qwen + multi-provider)"),
  341. ("xai-oauth", "xAI Grok OAuth (SuperGrok / Premium+)", "xAI Grok OAuth (SuperGrok / Premium+ subscription)"),
  342. ("xiaomi", "Xiaomi MiMo", "Xiaomi MiMo (MiMo-V2.5 and V2 models: pro, omni, flash)"),
  343. ("tencent-tokenhub", "Tencent TokenHub", "Tencent TokenHub (Hy4 preview via tokenhub.tencentmaas.com)"),
  344. ("tencent-tokenplan", "Tencent TokenPlan", "Tencent TokenPlan (Hy4 preview via api.lkeap.cloud.tencent.com, Anthropic Messages)"),
  345. ("nvidia", "NVIDIA NIM", "NVIDIA NIM (Nemotron models via build.nvidia.com or local NIM)"),
  346. ("huggingface", "Hugging Face", "Hugging Face Inference Providers"),
  347. ("gemini", "Google AI Studio", "Google AI Studio (Native Gemini API)"),
  348. ("vertex", "Google Vertex AI", "Google Vertex AI (Gemini via GCP; OAuth2 service account or ADC, GCP billing/quotas)"),
  349. ("deepseek", "DeepSeek", "DeepSeek (V3, R1, coder, direct API)"), ("xai", "xAI", "xAI Grok (Direct API)"),
  350. ("zai", "Z.AI / GLM", "Z.AI / GLM (Zhipu direct API)"),
  351. ("kimi-coding", "Kimi / Kimi Coding Plan", "Kimi Coding Plan (api.kimi.com & Moonshot API)"),
  352. ("kimi-coding-cn", "Kimi / Moonshot (China)", "Kimi / Moonshot China (Domestic direct API)"),
  353. ("stepfun", "StepFun Step Plan", "StepFun Step Plan (Agent / coding models via Step Plan API)"),
  354. ("minimax", "MiniMax", "MiniMax (Global direct API)"),
  355. ("minimax-oauth", "MiniMax (OAuth)", "MiniMax via OAuth browser login (Coding Plan, minimax.io)"),
  356. ("minimax-cn", "MiniMax (China)", "MiniMax China (Domestic direct API)"),
  357. ("ollama-cloud", "Ollama Cloud", "Ollama Cloud (Cloud-hosted open models, ollama.com)"),
  358. ("arcee", "Arcee AI", "Arcee AI (Trinity models, direct API)"),
  359. ("gmi", "GMI Cloud", "GMI Cloud (Multi-model direct API)"),
  360. ("kilocode", "Kilo Code", "Kilo Code (Kilo Gateway API)"),
  361. ("opencode-zen", "OpenCode Zen", "OpenCode Zen (Curated models, pay-as-you-go)"),
  362. ("opencode-go", "OpenCode Go", "OpenCode Go (Open models subscription)"),
  363. ("bedrock", "AWS Bedrock", "AWS Bedrock (Claude, Nova, Llama, DeepSeek; IAM or API key)"),
  364. ("azure-foundry", "Azure Foundry", "Azure Foundry (OpenAI-style or Anthropic-style endpoint, your Azure AI deployment)"),
  365. ("ai-gateway", "Vercel AI Gateway", "Vercel AI Gateway (Multi-model aggregator)"),
  366. ("qwen-oauth", "Qwen OAuth (Portal)", "Qwen OAuth (Reuses local Qwen CLI login)"),
  367. )]
  368. # Auto-extend CANONICAL_PROVIDERS with providers registered under plugins/model-providers/<name>/
  369. # so a new provider reaches the picker, /model and every downstream consumer without edits here.
  370. # Admission is by slug only: every in-tree non-api-key profile (OAuth, external-process, cloud
  371. # SDK) already owns a hand-written row above, so the old auth_type skip set never excluded an
  372. # in-tree provider — it only hid out-of-tree plugins. Visibility is gated downstream by
  373. # credentials, not here: ``models._provider_has_credentials`` / ``_lap_canonical_rows`` route
  374. # through ``auth.get_auth_status`` (external_process → the binary resolves; OAuth → auth.json /
  375. # credential-pool entry), so an admitted row reads authenticated=False until the user signs in.
  376. _canonical_slugs = {p.slug for p in CANONICAL_PROVIDERS}
  377. _BUILTIN_SLUGS = frozenset(_canonical_slugs)
  378. def _plugin_provider_enters_picker(pp) -> bool:
  379. """Picker admission for a plugin model-provider profile: any slug without a built-in row.
  380. Every profile is admitted, hidden (pre-release) ones included: ``CANONICAL_PROVIDERS`` is also
  381. the typed-path registry (``provider:model`` parsing, labels), so a signed-in user must still be
  382. able to name one. The pickers that list rows filter with ``providers.provider_listed``."""
  383. return pp.name not in _canonical_slugs
  384. def sync_plugin_provider_catalog() -> int:
  385. """Admit every registered plugin provider without a built-in row; return how many were added.
  386. Runs at import and again from ``providers._sync_auth_registry`` whenever a profile is registered
  387. after this module was imported. The import-time pass alone observes a *partial* registry: a
  388. plugin whose own imports pull ``hermes_cli.models`` in mid-``_discover_providers()``, or a
  389. profile registered later at runtime, would otherwise never reach the picker, ``hermes model``,
  390. ``/model`` or the Desktop ``model.options`` list until restart — the catalog twin of the auth
  391. registry window (#102123). Idempotent by slug; built-in rows are never rewritten. A row lands
  392. after its ``picker_after`` slug when that row exists, else at the end.
  393. """
  394. try:
  395. from providers import list_providers
  396. profiles = list_providers()
  397. except Exception:
  398. return 0
  399. pending = [pp for pp in profiles if _plugin_provider_enters_picker(pp)]
  400. added = 0
  401. while pending:
  402. # Rows anchored on a still-pending row wait for it, so a chain keeps its declared order.
  403. names = {pp.name for pp in pending}
  404. ready = [pp for pp in pending if pp.picker_after not in names] or pending
  405. for pp in ready:
  406. _admit_plugin_provider(pp)
  407. added += 1
  408. pending = [pp for pp in pending if pp not in ready]
  409. return added
  410. def _admit_plugin_provider(pp) -> None:
  411. """Add one plugin profile to the picker tables: row (at ``picker_after``), label, group and the
  412. aggregator set. Its catalog aliases are read per home (:class:`_CatalogAliases`)."""
  413. label = pp.display_name or pp.name
  414. entry = ProviderEntry(pp.name, label, pp.description or f"{label} (direct API)")
  415. slugs = [p.slug for p in CANONICAL_PROVIDERS]
  416. anchor = pp.picker_after
  417. CANONICAL_PROVIDERS.insert(slugs.index(anchor) + 1 if anchor in slugs else len(slugs), entry)
  418. _canonical_slugs.add(pp.name)
  419. _PROVIDER_LABELS[pp.name] = label
  420. if pp.picker_group:
  421. gid, group_label, group_desc = pp.picker_group
  422. members = PROVIDER_GROUPS.setdefault(gid, (group_label, group_desc, []))[2]
  423. if pp.name not in members:
  424. members.append(pp.name)
  425. _SLUG_TO_GROUP[pp.name] = gid
  426. if pp.aggregator:
  427. _AGGREGATOR_PROVIDERS.add(pp.name)
  428. _PROVIDER_LABELS: dict[str, str] = {p.slug: p.label for p in CANONICAL_PROVIDERS}
  429. _PROVIDER_LABELS["custom"] = "Custom endpoint" # special case: not a named provider
  430. def listed_canonical_providers() -> list[ProviderEntry]:
  431. """``CANONICAL_PROVIDERS`` minus pre-release profiles the user has not opted into: what a provider
  432. LIST offers. Typed paths (``provider:model``, labels, ``--provider``) keep the full table."""
  433. from hermes_cli import models # the binding every list consumer read before this filter existed
  434. from providers import unlisted_provider_names
  435. hidden = unlisted_provider_names()
  436. return [p for p in models.CANONICAL_PROVIDERS if p.slug not in hidden]
  437. # ---------------------------------------------------------------------------
  438. # Provider groups — DISPLAY ONLY. Vendors with several slugs (global API, China API, OAuth plan,
  439. # ...) fold under one top-level row in the INTERACTIVE PICKERS (``hermes model``, setup wizard,
  440. # Telegram ``/model``). They do NOT change CANONICAL_PROVIDERS, slug identity, ``--provider``,
  441. # ``/model <provider:model>`` or any typed path — every member slug stays individually addressable.
  442. # ``group_providers()`` is the single fold used by all three surfaces.
  443. # group_id -> (display_label, group_description shown on the collapsed row, [member_slug, ...])
  444. # Member order is the order shown inside the group submenu; member detail lives in ``tui_desc``.
  445. # ---------------------------------------------------------------------------
  446. PROVIDER_GROUPS: dict[str, tuple[str, str, list[str]]] = {
  447. "kimi": ("Kimi / Moonshot", "Coding Plan, Moonshot global & China endpoints", ["kimi-coding", "kimi-coding-cn"]),
  448. "minimax": ("MiniMax", "Global, OAuth Coding Plan & China endpoints", ["minimax", "minimax-oauth", "minimax-cn"]),
  449. "xai": ("xAI Grok", "Direct API or SuperGrok / Premium+ OAuth", ["xai", "xai-oauth"]),
  450. "google": ("Google Gemini", "Google AI Studio (API key)", ["gemini"]),
  451. "openai": ("OpenAI", "ChatGPT/Codex subscription or direct OpenAI API", ["openai-codex", "openai-api"]),
  452. "qwen": ("Qwen", "Qwen Cloud / DashScope, Coding Plan, Token Plan & Qwen CLI OAuth", ["alibaba", "alibaba-cn", "alibaba-coding-plan", "alibaba-coding-plan-cn", "alibaba-token-plan", "alibaba-token-plan-cn", "qwen-oauth"]),
  453. "opencode": ("OpenCode", "Zen pay-as-you-go or Go subscription", ["opencode-zen", "opencode-go"]),
  454. "tencent": ("Tencent Hy", "Hy4 / Hy3 via TokenHub & TokenPlan", ["tencent-tokenhub", "tencent-tokenplan"]),
  455. }
  456. # Reverse index: member slug -> group_id.
  457. _SLUG_TO_GROUP: dict[str, str] = {
  458. slug: gid for gid, (_label, _desc, members) in PROVIDER_GROUPS.items() for slug in members
  459. }
  460. def provider_group_for_slug(slug: str) -> str:
  461. """Return the group_id a provider slug belongs to, or "" if ungrouped."""
  462. return _SLUG_TO_GROUP.get(str(slug or "").strip().lower(), "")
  463. def group_providers(slugs):
  464. """Fold a flat ordered slug iterable into picker rows by provider group (DISPLAY ONLY).
  465. A group row appears at the position of its FIRST present member, in input order; later
  466. members fold into it. Member order inside a group follows ``PROVIDER_GROUPS`` declaration,
  467. restricted to the members present in ``slugs``.
  468. """
  469. present = set(slugs)
  470. group_members = {
  471. gid: [m for m in members if m in present]
  472. for gid, (_label, _desc, members) in PROVIDER_GROUPS.items()
  473. }
  474. rows = []
  475. seen: set[str] = set()
  476. emitted_groups: set[str] = set()
  477. for slug in slugs:
  478. s = str(slug or "").strip().lower()
  479. if not s or s in seen:
  480. continue
  481. seen.add(s)
  482. gid = _SLUG_TO_GROUP.get(s, "")
  483. if not gid:
  484. rows.append({"kind": "single", "slug": s})
  485. continue
  486. if gid in emitted_groups:
  487. continue # already folded at the first member's position
  488. emitted_groups.add(gid)
  489. members = group_members.get(gid) or [s]
  490. if len(members) <= 1:
  491. rows.append({"kind": "single", "slug": members[0]})
  492. else:
  493. label, desc, _ = PROVIDER_GROUPS[gid]
  494. rows.append({"kind": "group", "group_id": gid, "label": label,
  495. "description": desc, "members": list(members)})
  496. return rows
  497. class _CatalogAliases(dict):
  498. """``_PROVIDER_ALIASES``: the built-in alias table plus the ``catalog_aliases`` of the bound home's
  499. plugin profiles, resolved per read and never copied in: two served homes may give one alias to
  500. different providers. A built-in alias always wins; among plugins the first registered does."""
  501. _memo: tuple[tuple, dict[str, str]] = ((), {})
  502. def _plugin_aliases(self) -> dict[str, str]:
  503. from providers import bound_registry_key, list_providers
  504. token = bound_registry_key()
  505. if self._memo[0] == token:
  506. return self._memo[1]
  507. found: dict[str, str] = {}
  508. for pp in list_providers():
  509. if pp.catalog_aliases and pp.name not in _BUILTIN_SLUGS:
  510. for alias in pp.aliases:
  511. if not dict.__contains__(self, alias):
  512. found.setdefault(alias, pp.name)
  513. self._memo = (token, found)
  514. return found
  515. def __getitem__(self, key: str) -> str:
  516. if dict.__contains__(self, key):
  517. return dict.__getitem__(self, key)
  518. return self._plugin_aliases()[key]
  519. def get(self, key: str, default: Any = None) -> Any:
  520. if dict.__contains__(self, key):
  521. return dict.__getitem__(self, key)
  522. return self._plugin_aliases().get(key, default)
  523. def __contains__(self, key: object) -> bool:
  524. return dict.__contains__(self, key) or key in self._plugin_aliases()
  525. def items(self) -> list[tuple[str, str]]:
  526. return [*dict.items(self), *self._plugin_aliases().items()]
  527. def keys(self) -> list[str]:
  528. return [key for key, _ in self.items()]
  529. def values(self) -> list[str]:
  530. return [value for _, value in self.items()]
  531. def __iter__(self):
  532. return iter(self.keys())
  533. def __len__(self) -> int:
  534. return len(self.items())
  535. _PROVIDER_ALIASES = _CatalogAliases((
  536. ("glm", "zai"), ("z-ai", "zai"), ("z.ai", "zai"), ("zhipu", "zai"), ("google", "gemini"),
  537. ("google-gemini", "gemini"), ("google-ai-studio", "gemini"), ("google-vertex", "vertex"), ("vertex-ai", "vertex"),
  538. ("gcp-vertex", "vertex"), ("vertexai", "vertex"), ("kimi", "kimi-coding"), ("moonshot", "kimi-coding"),
  539. ("kimi-cn", "kimi-coding-cn"), ("moonshot-cn", "kimi-coding-cn"), ("step", "stepfun"),
  540. ("stepfun-coding-plan", "stepfun"), ("arcee-ai", "arcee"), ("arceeai", "arcee"), ("gmi-cloud", "gmi"),
  541. ("gmicloud", "gmi"), ("fireworks-ai", "fireworks"), ("fw", "fireworks"), ("actual-computer", "actual"),
  542. ("actualcomputer", "actual"), ("aci", "actual"), ("nebius", "nebius-token-factory"),
  543. ("nebius-tokenfactory", "nebius-token-factory"), ("nebius-tf", "nebius-token-factory"),
  544. ("token-factory", "nebius-token-factory"), ("tokenfactory", "nebius-token-factory"),
  545. ("minimax-china", "minimax-cn"), ("minimax_cn", "minimax-cn"), ("minimax-portal", "minimax-oauth"),
  546. ("minimax-global", "minimax-oauth"), ("minimax_oauth", "minimax-oauth"), ("claude", "anthropic"),
  547. ("claude-code", "anthropic"), ("deep-seek", "deepseek"), ("opencode", "opencode-zen"), ("zen", "opencode-zen"),
  548. ("go", "opencode-go"), ("opencode-go-sub", "opencode-go"), ("aigateway", "ai-gateway"), ("vercel", "ai-gateway"),
  549. ("vercel-ai-gateway", "ai-gateway"), ("kilo", "kilocode"), ("kilo-code", "kilocode"),
  550. ("kilo-gateway", "kilocode"), ("dashscope", "alibaba"), ("aliyun", "alibaba"), ("qwen", "alibaba"),
  551. ("alibaba-cloud", "alibaba"), ("qwen-portal", "qwen-oauth"), ("hf", "huggingface"),
  552. ("hugging-face", "huggingface"), ("huggingface-hub", "huggingface"), ("novita-ai", "novita"),
  553. ("novitaai", "novita"), ("mimo", "xiaomi"), ("xiaomi-mimo", "xiaomi"), ("tencent", "tencent-tokenhub"),
  554. ("tokenhub", "tencent-tokenhub"), ("tencent-cloud", "tencent-tokenhub"), ("tencentmaas", "tencent-tokenhub"),
  555. ("tokenplan", "tencent-tokenplan"), ("tencent-lkeap", "tencent-tokenplan"), ("aws", "bedrock"),
  556. ("aws-bedrock", "bedrock"), ("amazon-bedrock", "bedrock"), ("amazon", "bedrock"), ("grok", "xai"),
  557. ("grok-oauth", "xai-oauth"), ("xai-oauth", "xai-oauth"), ("x-ai-oauth", "xai-oauth"),
  558. ("xai-grok-oauth", "xai-oauth"), ("x-ai", "xai"), ("x.ai", "xai"), ("nim", "nvidia"), ("nvidia-nim", "nvidia"),
  559. ("build-nvidia", "nvidia"), ("nemotron", "nvidia"), ("lmstudio", "lmstudio"), ("lm-studio", "lmstudio"),
  560. ("lm_studio", "lmstudio"), ("chatgpt", "openai-codex"), ("chatgpt-codex", "openai-codex"),
  561. ("ollama", "custom"), # bare "ollama" = local; use "ollama-cloud" for cloud
  562. ("ollama_cloud", "ollama-cloud"),
  563. # Local OpenAI-compatible servers route through the generic "custom" provider
  564. # (parity with hermes_cli.auth and hermes_cli.providers). Issue #62213. The llamacpp
  565. # aliases stay unmapped: they are the managed local runtime's picker id, and the model
  566. # validator must reach its staged-library branch before the custom one.
  567. ("local", "custom"), ("vllm", "custom"),
  568. ))
  569. # Offline/fresh-install fallback for the model Hermes silently lands on when the user never picked
  570. # one (GUI onboarding confirm card, empty ``model.default``, provider-set-but-model-missing). The
  571. # AUTHORITATIVE source is the remote catalog manifest, which labels exactly one entry per provider
  572. # ``"default": true`` (get_default_model_from_cache) so the default rotates without a release; this
  573. # MUST match the labeled entry in website/static/api/model-catalog.json. Deliberately a capable
  574. # low-cost model rather than the curated lists' entry [0]: aggregator lists are ordered
  575. # most-capable-first, so [0] is the priciest Anthropic flagship.
  576. PREFERRED_SILENT_DEFAULT_MODEL = "z-ai/glm-5.3"
  577. # Providers whose *silent* auto-default goes through the cost-safe catalog-labeled default
  578. # (``get_preferred_silent_default_model``) instead of curated entry [0]. Metered aggregators order
  579. # best-first, so [0] is the priciest flagship; a profile that sets a provider with no model would
  580. # otherwise silently bill the most expensive model (863 Opus requests before one user noticed).
  581. # Network-free (cache-only) on purpose — this is the hot resolution path. The *interactive* default
  582. # (GUI onboarding / ``hermes model``) uses the tier-aware ``get_recommended_default_model`` in
  583. # hermes_cli/web_server.py + ``partition_nous_models_by_tier``, which may hit the Portal.
  584. _SILENT_DEFAULT_PROVIDERS: frozenset[str] = frozenset({"nous", "openrouter"})
  585. # Retired model IDs kept for /model auto-detect only — not shown in pickers. DeepSeek cut these
  586. # off; model_normalize remaps them on the wire.
  587. _PROVIDER_RETIRED_ALIASES: dict[str, tuple[str, ...]] = {
  588. "deepseek": ("deepseek-chat", "deepseek-reasoner"),
  589. }
  590. # Plugin profiles with ``aggregator=True`` join at sync time (``sync_plugin_provider_catalog``).
  591. _AGGREGATOR_PROVIDERS: set[str] = {"nous", "openrouter", "ai-gateway", "kilocode"}
  592. sync_plugin_provider_catalog() # every table it extends is defined above
  593. # Subscription/OAuth providers whose catalogs RE-EXPOSE other vendors' models; tried only as a last
  594. # resort for bare short-alias resolution (after every native-vendor catalog) so they never hijack
  595. # an alias from the model's native vendor. None currently defined.
  596. _BORROWED_MODEL_PROVIDERS: frozenset[str] = frozenset()
  597. # Providers whose live /v1/models is the authoritative catalog: the picker merges live-first (live
  598. # entries lead, curated-only append). Every OTHER provider keeps curated-first so a deliberately
  599. # surfaced newest model stays on top when the live API lags. Zen/Go re-expose dozens of vendors
  600. # and rotate them often, so their stale curated entries must not pollute the top.
  601. _LIVE_FIRST_PICKER_PROVIDERS: frozenset[str] = frozenset({"opencode-zen", "opencode-go", "meta-ai"})
  602. # Models supporting OpenAI Priority Processing (service_tier="priority"; see
  603. # openai.com/api-priority-processing). Pattern-based: any OpenAI flagship (gpt-*, o1*, o3*, o4*).
  604. # Non-OpenAI endpoints (OpenRouter/opencode-zen and other proxies) strip service_tier, so false
  605. # positives are harmless. Codex-series models are excluded — the Codex Responses API doesn't
  606. # expose service_tier.
  607. _OPENAI_FAST_MODE_PREFIXES: tuple[str, ...] = ("gpt-", "o1", "o3", "o4")
  608. # OpenAI Ultrafast (service_tier="ultrafast", 6x Standard): GPT-6 Astra and GPT-6.1 Sol
  609. # (developers.openai.com/api/docs/guides/ultrafast-mode, 2026-10-08).
  610. # Exact wire slugs, matched after stripping the vendor prefix and the Hermes-side ``-900k`` alias.
  611. _OPENAI_ULTRAFAST_MODELS: frozenset[str] = frozenset({"gpt-6-astra", "gpt-6.1-sol"})
  612. # Providers where models.dev is authoritative: the curated list is an offline fallback plus custom
  613. # additions the registry lacks, merged fresh-first (curated-only names appended) for both the CLI
  614. # and the gateway /model picker. DELIBERATELY EXCLUDED: "openrouter" (curated list is a hand-picked
  615. # agentic subset of 400+ models — merging would dump everything), "nous" (curated list + Portal
  616. # /models are the subscription-tier source of truth), and providers with dedicated live-endpoint
  617. # branches or a profile catalog hook (anthropic, ai-gateway, ollama-cloud, custom, stepfun, openai-codex).
  618. _MODELS_DEV_PREFERRED: frozenset[str] = frozenset({
  619. "opencode-go", "opencode-zen", "kilocode", "fireworks", "mistral", "togetherai", "cohere",
  620. "perplexity", "groq", "nvidia", "huggingface", "zai", "gemini", "google", "xai", "xai-oauth",
  621. })
  622. # Azure Foundry model families that require the Responses API: Azure rejects /chat/completions
  623. # against them with ``400 "The requested operation is unsupported."`` (seen on gpt-5.3-codex while
  624. # gpt-4o on the same endpoint worked). Broad enough for vendor-renamed deployments (gpt-5.x-codex,
  625. # o1-preview), tight enough to leave GPT-4 / 3.5 / Llama / Mistral / Grok on chat completions.
  626. _AZURE_FOUNDRY_RESPONSES_PREFIXES = ("codex", "gpt-5", "o1", "o3", "o4")