1. 访问 国产AI大模型 deepseek.com ,申请免费的  API 密钥
2. 使用下面源码,替换你申请的实际API 密钥,保存文件 deepseek_v3.py
from openai import OpenAI
text = input("请输入对话:\n")
print(" 正在AI对话... 请稍等.....")
client = OpenAI(api_key="sk-更换实际API 密钥", base_url="https://api.deepseek.com")
response = client.chat.completions.create(
    model="deepseek-chat",   
    messages=[
        {"role": "system", "content": "You are a helpful assistant"},
        {"role": "user", "content": text},
    ],
    stream=True  
)
print("AI回复:")
for chunk in response:
    if chunk.choices[0].delta.content:  
        print(chunk.choices[0].delta.content, end="", flush=True)  
print()  
3. 安装 OpenAI API 库 pip install openai -i https://pypi.tuna.tsinghua.edu.cn/simple
4. 参考视频 使用命令 运行代码  python.exe .\deepseek_v3.py
###【Python使用国产AI大模型DeepSeek-V3-使用OpenAI API实现逐行对话显示】 
