admin管理员组

文章数量:1530030

废话不多说,直接上代码,看怎么自定义key和域名

安装openai的python库

pip install openai  

运行以下代码

import os
import openai

# 域名和api_secret_key都可以从公众号“小一机器人”获取,优质稳定的api
openai.api_key = "您的api_secret_key"
openai.api_base = "http://flag.smarttrot/index.php/api/v1"

chat_completion = openai.ChatCompletion.create(
    model="gpt-3.5-turbo",
    messages=[{ "role": "user", "content": "Hello world" }]
)
print(chat_completion.choices[0].message.content) 

正常运行打印如下

Hello there! How can I assist you today ? 

 

本文标签: 接口自定义域名PythonopenAI