Failed to fetch the model list - cc-switch
Quick fix
Upgrade cc-switch and add a model row before fetching the list. If it still fails, verify /v1/models permissions with curl.
Symptom
Section titled “Symptom”获取模型列表失败Failed to fetch the model list
cc-switch's 获取模型列表 (fetch model list) requests `{Base URL}/v1/models` over the OpenAI-compatible protocol, sending `Authorization: Bearer <API Key>`. Any 401/403 from that endpoint makes the front end show that the API key is invalid or unauthorised, or that fetching the model list failed. That does not necessarily mean the key is dead: some providers serve the chat endpoint fine while the model list endpoint is closed or unauthorised, and the API key may have picked up a stray space, newline, or a `Bearer ` prefix when pasted.
There are several variants. In early versions, adding codex as a provider and fetching the model list reported that the API key must be filled in first — fixed in v3.15.0. "Fetched successfully but nothing shows" usually means you did not click 添加模型 (add model) first, so the fetched models have no row to attach to. A generated catalogue not showing in the Codex Desktop model picker is tracked in #4420 and relates to official login state. Separately, users report that after editing a Codex provider's `base_url`, `provider_endpoints.url` is not updated to match, so the model list still requests the old address.
Upgrade cc-switch to v3.15.0 or newer. If the problem is the Codex Desktop model picker not showing, follow the official-login-state notes in #4420.
In the provider form, click 添加模型 (add model) to create a row first, then click 获取模型列表 (fetch model list), so the fetched models attach to that row's dropdown.
Check the API key field for a leading or trailing space, a newline, or a whole `Bearer xxx` string pasted in. Only the bare key belongs here.
Verify the key's permissions against the model list endpoint by hand, for example: `curl -H "Authorization: Bearer YOUR_KEY" https://api.deepseek.com/v1/models`. A 401/403 from curl means that key has no access to `/v1/models`, or the provider does not expose it — ask the provider. You can enter model names by hand and keep working in the meantime.
If curl returns the model list fine but cc-switch still fails, check whether you edited the Codex provider's `base_url` while `provider_endpoints.url` still holds the old address. Set `provider_endpoints.url` to match `base_url` and retry.
Affected Versions
Section titled “Affected Versions”Source Issues
Section titled “Source Issues”This page is distilled from 21 real issues
- #2274各家codeplan多模型切换的支持
- #2325Claude桌面端无法检测模型列表
- #2404获取模型列表失败
- #2672curl 可以正常工作,ccswitch测试模型始终404
- #2685claude code
- #2687添加 codex作为Claude Code供应商后,选择获取模型列表,提示:请先填写 API Key
- #3035GLM模型5小时余量与7天余量展示数据相反
- #3800配置面板抖动
- #4364claude显示网络问题,同时CCswitch关于页面获取模型更新显示未知
- #4543获取模型列表失败
- #4552获取模型列表成功之后为什么不显示获取到的模型列表呢?
- #4790如何获取模型列表
- #4904获取模型列表失败
- #5066codex模型只显示自定义,看不到模型列表
- #5072获取模型、检测连通性提示错误,但是实际是通
- #5099Codex provider 编辑 base_url 后 provider_endpoints.url 未同步更新,导致模型列表/测试仍请求旧地址
- #5507与BUG共存,不要作完美主义
- #5726Codex桌面版更新后模型不可选
- #6184开启本地路由后,模型列表与供应商模型列表不一致
- #6295Correct configuration for the Grok build
- #6349模型供应商名称疯狂闪烁
- Why does the same key fetch the model list for someone else but fail for me?
- The API key field on your machine may have picked up a space, newline, or `Bearer ` prefix. Proxy software, your network, or the provider's permissions on `/v1/models` can also differ. Verify locally first with `curl -H "Authorization: Bearer YOUR_KEY" {Base URL}/v1/models`.
- It says the API key must be filled in first. What now?
- That was fixed in v3.15.0 — upgrade cc-switch. If it still happens after upgrading, add the latest version number, reproduction steps, and relevant logs.
- The fetch succeeds but nothing is shown. Why?
- Click 添加模型 (add model) to create a row first, then 获取模型列表 (fetch model list). Fetched models attach to an existing model entry for you to choose from; with no row, the fetch has nowhere to land and looks like a silent success.
- curl returns fine, but the cc-switch model test keeps 404-ing or failing. Why?
- Users report this as an old-version problem; try 3.13.0 or upgrade to a newer release. Also, if you edited the Codex provider's `base_url`, check whether `provider_endpoints.url` still points at the old address.
- Does a failed model list fetch stop me using the provider?
- Not necessarily. Some providers simply do not expose the model list endpoint, or your key lacks access to it, while the chat endpoint works. Enter the model name by hand and carry on.
- Claude Desktop cannot detect the model list in developer mode. Is that a cc-switch problem?
- Per the discussion in the issue, Claude Desktop developer mode offers no custom model name input, and the model list and component display are controlled by Desktop itself. cc-switch local routing can handle API requests already sent and do model mapping, but it cannot change the Claude Desktop model picker UI or its hard-coded validation.
- The Codex Desktop model list is empty and unselectable after an update. What now?
- Follow the official-login-state notes in #4420. If that does not help, reopen the issue with your Codex Desktop version and the output of `codex debug models`.
Related problems
Section titled “Related problems”This is an unofficial community wiki with no affiliation to the cc-switch authors or the project itself. Its content is compiled from the project's public GitHub issues. This site distributes no software.