【大模型AIGC系列课程 1-2】创建并部署自己的ChatGPT机器人

OpenAI API 调用

获取 openai api api-key

https://platform.openai.com/account/api-keys

利用 python requests 请求 openai

参考 openai 接口说明:https://platform.openai.com/docs/api-reference/chat/create

import json  # 导入json包
import requests  # 导入requests包

url = 'https://api.openai.com/v1/chat/completions'  # 你的API URL
api_key = 'xxx'  # 你的API KEY
headers = {
   
    
    
   

猜你喜欢

转载自blog.csdn.net/u011239443/article/details/132420584
今日推荐