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

API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}

Open Lyken17 opened this issue 8 months ago • 21 comments

What version of Kimi Code CLI is running?

kimi, version 1.14.0

Which open platform/subscription were you using?

Kimi Code

Which model were you using?

kimi-for-coding

What platform is your computer?

Darwin 25.2.0 arm64 arm

What issue are you seeing?

QQ

What steps can reproduce the bug?

with kimi-cli, current every works smoothly, but when switching to claude code (endpoint set to kimi), it only works for daily chats. When toolcall are involved, it returns API-400 err

➜  v2-dev git:(main) claude -p "how are you"
I'm doing well, thanks for asking. Ready to help you with whatever you're working on. How can I assist you today?
➜  v2-dev git:(main) claude -p "list the files"
API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}

What is the expected behavior?

No response

Additional information

No response


Solution

Thx for @carl10086 clues. Here is the workaround

in your ~/.zshrc or ~/.bashrc

export ANTHROPIC_AUTH_TOKEN=<token>
export ANTHROPIC_BASE_URL=https://api.kimi.com/coding/
export ANTHROPIC_MODEL=claude-haiku-4-5-20251001
export ANTHROPIC_DEFAULT_HAIKU_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_SONNET_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_OPUS_MODEL=kimi-k2.5
alias ccd="claude --dangerously-skip-permissions"

Lyken17 avatar Mar 05 '26 03:03 Lyken17

similar issue has also been observed in https://github.com/MoonshotAI/kimi-cli/issues/778

I tested opencode and it works as usual, so this should be specific bug related to claude and https://api.kimi.com/coding/

Lyken17 avatar Mar 05 '26 03:03 Lyken17

I have the same problem when using cluade code It occurs from this morning.

jichaofdu avatar Mar 05 '26 03:03 jichaofdu

I restart vscode for its aotoupdate, and then i have same problem.

ShiliangLuo avatar Mar 05 '26 03:03 ShiliangLuo

+1

quansang avatar Mar 05 '26 04:03 quansang

the error occurs as soon as a SKILL is loaded, seemed to be an issue with Claude Code's agent ability.

xraywu avatar Mar 05 '26 04:03 xraywu

I suspect the CC client switched to the latest model, which is causing the 400 error. When I use ⁠/model to switch back to the older 4.5 version, it seems to work fine.

  /model to try Opus 4.6

❯ /model
  ⎿  Set model to Default (claude-sonnet-4-6)

❯ /gc
  ⎿  API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}

❯ /model
  ⎿  Set model to haiku (claude-haiku-4-5-20251001)

❯ /gc

⏺ Bash(git status)
  ⎿  On branch main
     Your branch is up to date with 'origin/main'.
     … +17 lines (ctrl+o to expand)

⏺ Bash(git diff --stat HEAD)
  ⎿   pyproject.toml     |  1 +
      src/dm_cc/agent.py | 38 ++++++++++++++++++++-----------
      src/dm_cc/cli.py   | 22 ++++++++++++++----
     … +2 lines (ctrl+o to expand)
  ⎿  Interrupted · What should Claude do instead?

carl10086 avatar Mar 05 '26 04:03 carl10086

I suspect the CC client switched to the latest model, which is causing the 400 error. When I use ⁠/model to switch back to the older 4.5 version, it seems to work fine.

/model to try Opus 4.6

❯ /model ⎿ Set model to Default (claude-sonnet-4-6)

❯ /gc ⎿  API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}

❯ /model ⎿ Set model to haiku (claude-haiku-4-5-20251001)

❯ /gc

⏺ Bash(git status) ⎿  On branch main Your branch is up to date with 'origin/main'. … +17 lines (ctrl+o to expand)

⏺ Bash(git diff --stat HEAD) ⎿   pyproject.toml | 1 + src/dm_cc/agent.py | 38 ++++++++++++++++++++----------- src/dm_cc/cli.py | 22 ++++++++++++++---- … +2 lines (ctrl+o to expand) ⎿  Interrupted · What should Claude do instead?

Thanks I can confirm the issue and this could temperarily resolve the issue

xraywu avatar Mar 05 '26 05:03 xraywu

the same error

issakk avatar Mar 05 '26 08:03 issakk

I suspect the CC client switched to the latest model, which is causing the 400 error. When I use ⁠/model to switch back to the older 4.5 version, it seems to work fine. /model to try Opus 4.6 ❯ /model ⎿ Set model to Default (claude-sonnet-4-6) ❯ /gc ⎿  API Error: 400 {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"} ❯ /model ⎿ Set model to haiku (claude-haiku-4-5-20251001) ❯ /gc ⏺ Bash(git status) ⎿  On branch main Your branch is up to date with 'origin/main'. … +17 lines (ctrl+o to expand) ⏺ Bash(git diff --stat HEAD) ⎿   pyproject.toml | 1 + src/dm_cc/agent.py | 38 ++++++++++++++++++++----------- src/dm_cc/cli.py | 22 ++++++++++++++---- … +2 lines (ctrl+o to expand) ⎿  Interrupted · What should Claude do instead?

Thanks I can confirm the issue and this could temperarily resolve the issue

Switch to haiku do not solve this issue for me. claude code v2.1.69, Fedora 43

huhanwj avatar Mar 05 '26 09:03 huhanwj

Downgrading to Claude Code v2.1.68 works

issakk avatar Mar 05 '26 10:03 issakk

Downgrading to Claude Code v2.1.68 works

Indeed useful

huhanwj avatar Mar 05 '26 11:03 huhanwj

The same error,switch to haiku fixed.

anofinda avatar Mar 05 '26 13:03 anofinda

Downgrading to Claude Code v2.1.68 works

Indeed useful

It works

ShiliangLuo avatar Mar 06 '26 01:03 ShiliangLuo

Thx for @carl10086 clues. Here is the more general workaround

in your ~/.zshrc or ~/.bashrc

export ANTHROPIC_AUTH_TOKEN=<token>
export ANTHROPIC_BASE_URL=https://api.kimi.com/coding/
export ANTHROPIC_MODEL=claude-haiku-4-5-20251001
export ANTHROPIC_DEFAULT_HAIKU_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_SONNET_MODEL=kimi-k2.5
export ANTHROPIC_DEFAULT_OPUS_MODEL=kimi-k2.5
alias ccd="claude --dangerously-skip-permissions"

Lyken17 avatar Mar 06 '26 01:03 Lyken17

meanwhile, let's wait kimi team to fix their inference endpoint.

Lyken17 avatar Mar 06 '26 01:03 Lyken17

The same error,switch to haiku fixed.

DenisZheng avatar Mar 06 '26 06:03 DenisZheng

The same error,switch to haiku fixed.

DenisZheng avatar Mar 06 '26 06:03 DenisZheng

I tried claude code v2.1.70 this morning and it seems to be fixed without the need of changing model settings

huhanwj avatar Mar 06 '26 06:03 huhanwj

Can confirm, let Claude update (run once -> then close run again - issue gone)

Megachill avatar Mar 06 '26 08:03 Megachill

I have the same problem when using cluade code on Vs Code I use it for reading PDF

mom145015 avatar Apr 07 '26 02:04 mom145015