Appearance
Claude Code 使用 DeepSeek Anthropic 兼容端点时无法发送图片
问题
在 Claude Code 中配置 DeepSeek 的 Anthropic 兼容端点(https://api.deepseek.com)后,附加图片发送时报 400 错误:
API Error: 400 {"error":{"message":"Failed to deserialize the JSON body into the target type: messages[66].content: unknown variant `image`, expected one of `text`, `tool_use`, `tool_result`, `thinking`"}}解决方案
根本原因:DeepSeek 的 Anthropic 兼容 API 目前不支持 image 类型的 content block,仅支持 text、tool_use、tool_result、thinking。
临时解决方案:
- 避免在 Claude Code 中通过 DeepSeek 兼容端点发送图片,改用文字描述图片内容
- 如果需要图像理解,切换回原生 Anthropic API(
claude.ai账号或官方 API Key) - 使用 DeepSeek 的原生 OpenAI 兼容端点(
/v1/chat/completions)并搭配支持图片的客户端
DeepSeek 官方 API(非 Anthropic 兼容模式)本身支持 Vision 功能,问题仅出现在 Anthropic 格式兼容层。