HazardInspector/千问API数据.txt

27 lines
940 B
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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")