kimi-cli icon indicating copy to clipboard operation
kimi-cli copied to clipboard

Failed to get models: 401, message='Unauthorized', url='https://api.kimi.com/coding/v1/models'

Open albertwyjoy-bit opened this issue 9 months ago • 20 comments

What version of Kimi Code CLI is running?

kimi, version 1.10.0

Which open platform/subscription were you using?

Kimi Code

Which model were you using?

kimi-for-coding

What platform is your computer?

macOS 11.7.1 x86_64

What issue are you seeing?

Select a platform (↑↓ navigate, Enter select, Ctrl+C cancel):

  1. Kimi Code 2. Moonshot AI Open Platform (moonshot.cn) 3. Moonshot AI Open Platform (moonshot.ai) Please visit the following URL to finish authorization. Verification URL: https://www.kimi.com/code/authorize_device?user_code=XXXXXX Failed to get models: 401, message='Unauthorized', url='https://api.kimi.com/coding/v1/models'

What steps can reproduce the bug?

/login

What is the expected behavior?

No response

Additional information

No response

albertwyjoy-bit avatar Feb 10 '26 03:02 albertwyjoy-bit

same, getting this now

Teylersf avatar Feb 10 '26 03:02 Teylersf

我还以为怎么了,我也遇到这种问题了,什么时候能解决呢?


I thought something was wrong. I also encountered this problem. When will it be solved?

jxhhdx avatar Feb 10 '26 03:02 jxhhdx

遇到了相同问题,怎么解决?


Encountered the same problem, how to solve it?

cliu2333-shipship avatar Feb 10 '26 03:02 cliu2333-shipship

遇到了相同问题!就今天


Encountered the same problem! Just today

CR-c avatar Feb 10 '26 03:02 CR-c

same +1

maxwellTURE avatar Feb 10 '26 04:02 maxwellTURE

same + 10086

Wolido avatar Feb 10 '26 04:02 Wolido

I’ve encountered the same issue as well.

LeoGZ avatar Feb 10 '26 04:02 LeoGZ

I've encontered same error here, even tried to re-authenticate though it returns the same error, from cli and from vs code plugin trying to log back in again.

diegomgarcia avatar Feb 10 '26 04:02 diegomgarcia

尝试手动填写coding的apikey,oauth后端可能暂时有点问题


Try to manually fill in the coding apikey. There may be a temporary problem with the oauth backend

xiaoju111a avatar Feb 10 '26 04:02 xiaoju111a

Encountered same problem

Billiardozan avatar Feb 10 '26 04:02 Billiardozan

fill the apikey manually not work, i still can't get the models

IfarraSpentera avatar Feb 10 '26 04:02 IfarraSpentera

怎么解决啊遇到相同问题了


How to solve it? I encountered the same problem.

yinanchen1998 avatar Feb 10 '26 04:02 yinanchen1998

尝试手动填写coding的apikey,oauth后端可能暂时有点问题

Try to manually fill in the coding apikey. There may be a temporary problem with the oauth backend

tried that as well, same error:

Enter your API key: ************************************************************
************
Failed to get models: 401, message='Unauthorized', url='https://api.moonshot.ai/v
1/models'

diegomgarcia avatar Feb 10 '26 04:02 diegomgarcia

Adding my detailed reproduction case - this appears to be the same issue with additional troubleshooting context.

My Environment

  • OS: Windows 11 (PowerShell)
  • CLI: 1.10.0 (also tested 1.9.0 - same failure)
  • Install: UV (uv tool install)
  • API Key: Valid and Enabled (Moderato plan, K2.5 access)

Critical Finding

API key works perfectly via direct API call:

curl.exe -H "Authorization: Bearer sk-..." https://api.kimi.com/coding/v1/models
# Returns: {"data":[{"id":"kimi-for-coding"...}]} ✅

But CLI fails to use it:

$env:KIMI_API_KEY="sk-..."
kimi
# Shows: API Key: ****** (from KIMI_API_KEY)
# Shows: Model: not set, send /login to login ❌

Symptoms

  • /model → No models configured, send "/login" to login
  • /login (Option 1) → 401 Unauthorized
  • /login (Options 2/3) → loops back to login requirement
  • kimi web → LLM is not set
  • --model flag ignored

Troubleshooting Attempted

  • [x] Env vars only
  • [x] Config file only (~/.kimi/config.toml)
  • [x] Both combined
  • [x] Version downgrade to 1.9.0 (uv tool install --force)
  • [x] Complete purge (rm -rf ~/.kimi, uv cache clean)
  • [x] Different KIMI_BASE_URL values
  • [x] Explicit model IDs (kimi-k2-5, kimi-for-coding)

Root Cause Hypothesis

Circular dependency in auth initialization:

  1. CLI detects API key (shows API Key: ******)
  2. Model discovery fails silently (empty list)
  3. CLI demands /login despite having valid key
  4. Login fails or doesn't populate models
  5. Loop continues

Not version-specific (both 1.9.0 and 1.10.0 broken) → suggests server-side change in last 6-12 hours broke backward compatibility.

Workaround Status

None found - complete blocker. Using web interface temporarily.

tears-mysthrala avatar Feb 10 '26 04:02 tears-mysthrala

我在差不多20分钟前windows上遇到了同样的问题,这是我的问题还是kimi的问题?


I had the same problem on windows almost 20 minutes ago, is this my problem or kimi's problem?

3126383362 avatar Feb 10 '26 04:02 3126383362

试过了笔记本和台式机,VS Code的Kimi Code插件和Terminal环境都一样的问题,而且试过了API Key,也是一样的。典型的服务器端回报出错或者掉包。这么大面积掉包的可能性比较大吧?是不是有服务器需要重启了?【狗头】


I have tried laptops and desktops, and the Kimi Code plug-in and Terminal environment of VS Code have the same problem. I have also tried the API Key, and it is the same. Typical server side reports errors or packet drops. Is it more likely that the package will be dropped on such a large scale? Does any server need to be restarted? 【Dog Head】

msz006c1 avatar Feb 10 '26 04:02 msz006c1

试过了笔记本和台式机,VS Code的Kimi Code插件和Terminal环境都一样的问题,而且试过了API Key,也是一样的。典型的服务器端回报出错或者掉包。这么大面积掉包的可能性比较大吧?是不是有服务器需要重启了?【狗头】

I have tried laptops and desktops, and the Kimi Code plug-in and Terminal environment of VS Code have the same problem. I have also tried the API Key, and it is the same. Typical server side reports errors or packet drops. Is it more likely that the package will be dropped on such a large scale? Does any server need to be restarted? 【Dog Head】

已经恢复了

xiaoju111a avatar Feb 10 '26 04:02 xiaoju111a

尝试手动填写coding的apikey,oauth后端可能暂时有点问题 Try to manually fill in the coding apikey. There may be a temporary problem with the oauth backend

tried that as well, same error:

Enter your API key: ************************************************************
************
Failed to get models: 401, message='Unauthorized', url='https://api.moonshot.ai/v
1/models'

has fixed.

xiaoju111a avatar Feb 10 '26 04:02 xiaoju111a

yup it works

IfarraSpentera avatar Feb 10 '26 04:02 IfarraSpentera

同样的问题,2026.03.06仍然存在,vs code里cline用kimi2.5返回401

Image

ImmunoYangRock avatar Mar 06 '26 13:03 ImmunoYangRock