MoonshotAI / MoonshotAI/kimi-code

API 网关对 PDF document 块一律返回无具体原因的 400,且污染会话导致后续所有请求失败

Open
#2,378 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
7.5k
Forks
1.2k
Avg merge
11h 53m
Merged PRs (30d)
350

Description

What version of Kimi Code is running?

k3、k3-256k 均复现

Which open platform/subscription were you using?

Claude Code CLI 2.1.220(Windows 11)

Which model were you using?

k3、k3-256k

What platform is your computer?

Windows 11 25H2

What issue are you seeing?

通过 https://api.kimi.com/coding/v1/messages 使用 Claude Code 时,只要请求中包含 Anthropic 标准格式的 PDF document 内容块,网关即返回: {"error":{"type":"invalid_request_error","message":"Invalid request Error"},"type":"error"}

错误信息没有任何可操作的具体原因。更严重的是:Claude Code 每轮请求都会重发完整会话历史,一旦历史中包含 PDF块,之后所有请求(包括纯文本提问)都会持续 400,会话完全不可用,只能清空重来,已消耗的上下文和费用无法恢复

What steps can reproduce the bug?

600 字节的合法单页 PDF 也会失败 —— 与文件大小无关

curl -X POST "https://api.kimi.com/coding/v1/messages"
-H "content-type: application/json"
-H "Authorization: Bearer "
-H "anthropic-version: 2023-06-01"
-H "anthropic-beta: pdfs-2024-09-25"
-d '{"model":"k3","max_tokens":50,"messages":[{"role":"user","content":[
{"type":"document","source":{"type":"base64","media_type":"application/pdf","data":"<600字节PDF的base64>"}},
{"type":"text","text":"概括"}]}]}'

→ 400 Invalid request Error

What is the expected behavior?

返回 API Error: 400 Invalid request Error

Additional information

诉求

  1. 在官方文档 (https://www.kimi.com/coding/docs/)中明确标注不支持 PDF document 块(目前只写了"k3-256k 不支持视频输入"),或实现对 PDF输入的支持;
  2. 400 错误返回具体原因(如 PDF document blocks are not supported),而不是笼统的 "Invalid request Error",方便客户端识别和降级;
  3. 如有可能,对因此被污染的会话所产生的费用/额度予以补偿。

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the request against https://api.kimi.com/coding/v1/messages with the supplied curl example, then review the official documentation at https://www.kimi.com/coding/docs/. Confirm the supported behavior for PDF document blocks and define completion as either documented PDF rejection or support, with a specific actionable 400 error that does not leave later requests unusable.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, backend, documentation
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.