Report === --- User-Friendly Information --- Message: 自定义模型 custom-local:gpt-6-a...

2026年09月08日 15:13 35.16 秒 success

错误信息

=== Error Report === --- User-Friendly Information --- Message: 自定义模型 custom-local:gpt-6-astra 错误,请切换模型或重试。 --- Technical Details --- Error Code: 10000 Request ID: fbc78ab9b8404190b5d178d259a8bb7e Trace ID: fbc78ab9b8404190b5d178d259a8bb7e Timestamp: 2026/09/08 15:12:33 (UTC+8) Server Detail: {"code":-32603,"message":"Internal error","data":{"message":"Function tools with reasoning_effort are not supported for gpt-6-astra in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'.","type":"invalid_request_error","param":"reasoning_effort","code":0,"details":"400 Function tools with reasoning_effort are not supported for gpt-6-astra in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'. (04ec66b2c985409eadd75a7d1888a816/91863208-0ff0-48c5-ac3d-fca5c87bc953)","statusCode":400,"category":"internal"}} App Version: 5.5.3 User ID: 94e5c5c4-e44f-411d-b6ce-ceb01880297f

AI 解决方案

1. 🌐 错误翻译

原文:Function tools with reasoning_effort are not supported for gpt-6-astra in /v1/chat/completions. To use function tools, use /v1/responses or set reasoning_effort to 'none'.
译文:在/v1/chat/completions接口中,gpt-6-astra模型不支持同时使用函数工具和reasoning_effort参数。如需使用函数工具,请改用/v1/responses接口,或将reasoning_effort参数设置为'none'。

2. 🎯 原因分析

根本原因:在调用/v1/chat/completions接口时,针对gpt-6-astra自定义模型,代码同时配置了函数工具(Function Tools)和reasoning_effort参数,而该模型不支持这两个功能的并发使用,触发了API的参数校验错误。

错误位置:API请求的参数配置阶段,具体是reasoning_effort参数与函数工具的配置冲突。

3. 💡 解决方案

根据错误提示,有两种修复方式,任选其一即可。以下以Python代码示例说明:

方案一:将reasoning_effort设置为'none'(保留函数工具和/v1/chat/completions接口)

import requests
import json

# API基础配置
API_URL = "https://api.dmxapi.com/v1/chat/completions"
MODEL = "custom-local:gpt-6-astra"
API_KEY = "your_api_key_here"  # 替换为实际API Key

# 请求头
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# 请求参数 - 关键修改:将reasoning_effort设为'none'
data = {
    "model": MODEL,
    "messages": [
        {"role": "user", "content": "帮我查询今天的天气"}
    ],
    "reasoning_effort": "none",  # 修改此处为'none',解决冲突
    "tools": [  # 保留函数工具配置
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "获取天气信息"
            }
        }
    ]
}

# 发送请求
response = requests.post(API_URL, headers=headers, json=data)
print(response.json())

方案二:改用/v1/responses接口(同时保留函数工具和reasoning_effort参数)

import requests
import json

# API基础配置(更换接口地址)
API_URL = "https://api.dmxapi.com/v1/responses"  # 改为/v1/responses接口
MODEL = "custom-local:gpt-6-astra"
API_KEY = "your_api_key_here"  # 替换为实际API Key

# 请求头
headers = {
    "Authorization": f"Bearer {API_KEY}",
    "Content-Type": "application/json"
}

# 请求参数 - 切换接口后,可保留原参数配置
data = {
    "model": MODEL,
    "input": "帮我查询今天的天气",  # /v1/responses接口使用input字段
    "reasoning_effort": "high",  # 可保留该参数
    "tools": [  # 保留函数工具配置
        {
            "type": "function",
            "function": {
                "name": "get_weather",
                "description": "获取天气信息"
            }
        }
    ]
}

# 发送请求
response = requests.post(API_URL, headers=headers, json=data)
print(response.json())

4. 🛡️ 预防措施

  • 参数兼容性前置校验:在调用模型接口前,先通过官方文档确认目标模型支持的参数组合,避免在代码中硬编码不兼容的参数搭配,尤其是在使用新模型或自定义模型时,需优先检查其功能支持清单。

  • 接口适配动态配置:若项目中涉及多模型调用,建议将接口路径、参数校验规则等适配逻辑封装为配置层,针对不同模型自动切换兼容的接口和参数,减少因模型特性差异导致的参数冲突错误。

  • 使用API参数校验工具:可借助API客户端工具(如Postman)或代码中的参数校验库,在发送请求前模拟校验参数组合,提前发现不符合接口规范的配置,降低运行时报错概率。