Qwen3.5-27B api_key="sk-c7ffed1b32794284a5d21b046d7d0008" base_url="https://dashscope.aliyuncs.com/compatible-mode/v1" import os from openai import OpenAI try: client = OpenAI( # 若没有配置环境变量,请用阿里云百炼API Key将下行替换为: api_key="sk-xxx", api_key=os.getenv("DASHSCOPE_API_KEY"), base_url="https://dashscope.aliyuncs.com/compatible-mode/v1", ) completion = client.chat.completions.create( model="qwen3.5-27b", # 模型列表: https://help.aliyun.com/model-studio/getting-started/models messages=[ {'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': '你是谁?'} ] ) print(completion.choices[0].message.content) except Exception as e: print(f"错误信息:{e}") print("请参考文档:https://help.aliyun.com/model-studio/developer-reference/error-code")