Skip to content

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.

Error output
获取模型列表失败
English translation

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.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

ToolClaude Code / Codex
VersionUnknown
PlatformsWindowsmacOS
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`.

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.