DeepSeek-百炼
其他 官方文档
通过百炼白嫖DeepSeek-R1满血版,100wtoken
基本说明:
接口地址:https://dashscope.aliyuncs.com/compatible-mode/v1
返回格式:json
请求方式:post
请求示例:https://dashscope.aliyuncs.com/compatible-mode/v1
请求参数说明:
名称 类型 必填 说明
- - - -
返回参数说明:
名称 类型 说明
- - -
JSON返回示例:
{}
服务级错误码参照
错误码 说明
- -
完整教学代码示例
import os from openai import OpenAI client = OpenAI( # 若没有配置环境变量,请用百炼API Key将下行替换为:api_key="sk-xxx", api_key=os.getenv("DASHSCOPE_API_KEY"), # 如何获取API Key:https://help.aliyun.com/zh/model-studio/developer-reference/get-api-key base_url="https://dashscope.aliyuncs.com/compatible-mode/v1" ) completion = client.chat.completions.create( model="deepseek-r1", # 此处以 deepseek-r1 为例,可按需更换模型名称。 messages=[ {'role': 'user', 'content': '9.9和9.11谁大'} ] ) # 通过reasoning_content字段打印思考过程 print("思考过程:") print(completion.choices[0].message.reasoning_content) # 通过content字段打印最终答案 print("最终答案:") print(completion.choices[0].message.content)