s for ClaudeMessagesRequest ***.***.***.str Input should be a valid string [type...
🚨 错误信息
48 validation errors for ClaudeMessagesRequest
***.***.***.str
Input should be a valid string [type=string_type, input_value=[{'signature': '', 'think...h', 'type': 'tool_use'}], input_type=list]
For further information visit https://***.dev/***/***/***
***.***.***.list[union[ClaudeContentBlockText,ClaudeContentBlockImage,ClaudeContentBlockToolUse,ClaudeContentBlockToolResult]].***.***.type
Input should be 'text' [type=literal_error, input_value='thinking', input_type=str]
For further information visit https://***.dev/***/***/***
***.***.***.list[union[ClaudeContentBlockText,ClaudeContentBlockImage,ClaudeContentBlockToolUse,ClaudeContentBlockToolResult]].***.***.text
🤖 AI解决方案
报错分析报告
1.错误翻译
原文:Input should be a valid string [type=string_type, input_value=[{'signature': '', 'think...h', 'type': 'tool_use'}], input_type=list]
译文:输入应为有效字符串(当前传入列表类型值)原文:Input should be 'text' [type=literal_error, input_value='thinking', input_type=str]
译文:输入应为'text'(当前传入值为'thinking')
2.原因分析
ClaudeMessagesRequest 请求参数违反验证规则 1. 某字符串字段(
..*.str)误传列表类型(含tool_use等内容块) 2. 内容块
type字段值应为'text',实际传入'thinking' 3. 内容块
text字段缺失或格式错误(未完整显示) 3.解决方案
python
修复后的请求构造示例(以Python为例)
from dmxfi import ClaudeMessagesRequest, ClaudeContentBlockText1. 确保字符串字段传字符串而非列表
correct_str_field = "your_valid_string_here" # 替换原列表值2. 修正内容块type为'text',使用正确类型
content_blocks = [
ClaudeContentBlockText(
type="text", # 必须为'text'(原错误用'thinking')
text="你的文本内容"
),
# 如需tool_use块,单独构造对应类型(不混用字符串字段)
# ClaudeContentBlockToolUse(type="tool_use", ...)
]3. 构造合法请求
request = ClaudeMessagesRequest(
# 字符串字段用correct_str_field
your_str_field=correct_str_field,
content=content_blocks # 用合规的内容块列表
)
4.️ 预防措施
validate_request方法,或Postman模拟请求前检查Schema ---
注:请补充完整第三个错误细节(.text后缀内容)以获取更精准分析。