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

SEO教程2025-06-2438
    正在检查是否收录...

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 = { 

apiopenaiurlchatai apijsoncodepythoncreatedoc