admin管理员组文章数量:1026989
(357条消息) ChatGPT API调用python和脚本实现_AI架构师易筋的博客-CSDN博客
(357条消息) NLP | 打造一个‘OpenAI智能’机器人,只需要五分钟_夏天|여름이다的博客-CSDN博客
(357条消息) ChatGPT官方API可以抢先体验了_Coding的叶子的博客-CSDN博客
这个是我参考的博客
1.在你有openai账号的的前提下(没有也有很多办法注册和在某宝购买),去到这个网站去注册api-key:
,在https://beta.openai/account/api-keys申请你的api keys
代码:
import openai
openai.api_key = "sk-xxxxxxxxxxxxxxxxxxx"#这里是你的api-key
def askChatGPT(question):
prompt = question
model_engine = "text-davinci-003"
completions = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
message = completions.choices[0].text
print(message)
askChatGPT("what is love")
(357条消息) ChatGPT API调用python和脚本实现_AI架构师易筋的博客-CSDN博客
(357条消息) NLP | 打造一个‘OpenAI智能’机器人,只需要五分钟_夏天|여름이다的博客-CSDN博客
(357条消息) ChatGPT官方API可以抢先体验了_Coding的叶子的博客-CSDN博客
这个是我参考的博客
1.在你有openai账号的的前提下(没有也有很多办法注册和在某宝购买),去到这个网站去注册api-key:
,在https://beta.openai/account/api-keys申请你的api keys
代码:
import openai
openai.api_key = "sk-xxxxxxxxxxxxxxxxxxx"#这里是你的api-key
def askChatGPT(question):
prompt = question
model_engine = "text-davinci-003"
completions = openai.Completion.create(
engine=model_engine,
prompt=prompt,
max_tokens=1024,
n=1,
stop=None,
temperature=0.5,
)
message = completions.choices[0].text
print(message)
askChatGPT("what is love")
版权声明:本文标题:python调用chatgpt的API 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/jiaocheng/1724527350a478647.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论