代理类客户端(Cline、Roo、Open Interpreter)全靠工具调用驱动。失败通常是模型不支持、参数不合法、消息序列不对这三类。
curl https://hardysapi.com/v1/chat/completions \ -H "Authorization: Bearer sk-你的密钥" \ -H "Content-Type: application/json" \ -d '{"model":"claude-sonnet-4-5","messages":[{"role":"user","content":"北京天气"}], "tools":[{"type":"function","function":{"name":"get_weather","description":"查天气", "parameters":{"type":"object","properties":{"city":{"type":"string"}},"required":["city"]}}}]}'
返回里出现 tool_calls 数组,说明该模型与链路支持工具调用;返回纯文本则是不支持。
strict: true 要求模型严格遵守 JSON Schema,兼容层实现程度不一。报 400 时先去掉 strict,
改用提示词约束格式,再在代码里校验 JSON。
claude-sonnet-4-5、gpt-5.5 这类完整支持的模型;该模型大概率不支持工具调用,换用完整支持 function calling 的模型,如 claude-sonnet-4-5、gpt-5.5。
messages 里 tool 消息没有对应的 assistant tool_calls,或顺序被打乱;按「assistant(tool_calls) → tool 结果」成对出现即可。