status_code=400, Function tools with reasoning_effort are not supported for gpt-...

2026年07月08日 10:00 38.33 秒 success

错误信息

status_code=400, Function tools with reasoning_effort are not supported for gpt-5.5 in /v1/chat/completions. Please use /v1/responses instead.

AI 解决方案

🔍 报错分析

1. 🌐 错误翻译


原文:Function tools with reasoning_effort are not supported for gpt-5.5 in /v1/chat/completions. Please use /v1/responses instead.
译文:在/v1/chat/completions接口中,gpt-5.5不支持带有reasoning_effort参数的函数工具调用,请改用/v1/responses接口。

2. 🎯 原因分析


该错误的核心原因是API接口与模型版本不兼容
  • 你正在使用/v1/chat/completions接口调用GPT-5.5模型

  • 但同时尝试传入了reasoning_effort参数用于函数工具调用

  • GPT-5.5在该接口下不支持这种参数组合,需要切换到官方指定的/v1/responses接口
  • 3. 💡 解决方案


    将API调用从/v1/chat/completions迁移到/v1/responses,并调整参数结构:

    // ❌ 错误调用方式 - /v1/chat/completions
    const wrongResponse = await openai.chat.completions.create({
      model: 'gpt-5.5',
      messages: [{ role: 'user', content: '...' }],
      tools: [yourFunctionTools],
      reasoning_effort: 'high' // 不被支持的参数
    });
    
    // ✅ 正确调用方式 - /v1/responses
    const correctResponse = await openai.responses.create({
      model: 'gpt-5.5',
      input: '...', // 用户输入内容
      tools: [yourFunctionTools],
      reasoning: {
        effort: 'high' // 正确的参数路径
      }
    });
    

    4. 🛡️ 预防措施


  • 接口匹配检查:使用新模型前务必查阅官方文档,确认模型与API接口的兼容性,特别是GPT-5系列模型必须使用/v1/responses接口

  • 参数结构适配:不同接口的参数结构差异较大,/v1/responses接口中reasoning_effort参数的路径为reasoning.effort,而不再是顶层参数

  • 使用版本检测工具:在代码中添加模型版本检测,自动选择对应的API接口,避免硬编码接口路径