-
Notifications
You must be signed in to change notification settings - Fork 189
Open
Description
官方示例
import os
from openai import OpenAI
client = OpenAI(
# 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx",
api_key="123",
base_url="http://localhost:9090/v1",
)
completion = client.chat.completions.create(
# 模型列表:https://help.aliyun.com/zh/model-studio/getting-started/models
model="qwen-plus",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "你是谁?"},
],
# Qwen3模型通过enable_thinking参数控制思考过程(开源版默认True,商业版默认False)
# 使用Qwen3开源版模型时,若未启用流式输出,请将下行取消注释,否则会报错
extra_body={"enable_thinking": False},
)
print(completion.model_dump_json())按照如上例子给自建服务发请求,得到如下报错
openai.InternalServerError: Error code: 500 - {'error': 'Post "https://dashscope.aliyuncs.com/compatible-mode/v1/chat/completions": HTTP error: 400 Bad Request, body: {"error":{"code":"invalid_parameter_error","param":null,"message":"parameter.enable_thinking must be set to false for non-streaming calls","type":"invalid_request_error"},"id":"chatcmpl-6d65201b-cad4-93bd-a49e-181cc76aa757","request_id":"6d65201b-cad4-93bd-a49e-181cc76aa757"}'}
但是改为官方base_url,就不会有这样的报错
这是为什么?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels