快速开始

获取 key 的方式

  • 第一步:注册账号:去 DevAGI 官方注册账号

    https://devcto.com

  • 第二步:点击应用中心,然后复制 key

    Picture of the author

编写代码

在项目文件夹下,安装项目依赖的包

# 下载 openai 包
pip install openai

新建 index.py 文件

from openai import OpenAI

client = OpenAI(
    api_key = "自己的API key",
    base_url = "https://api.fe8.cn/v1"
)

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": "讲个笑话",
        }
    ],
    model="gpt-3.5-turbo", #此处更换其它模型,请参考模型列表 eg: google/gemma-7b-it
)
print(chat_completion.choices[0].message.content)

视频教程 👇🏻👇🏻👇🏻


西鲸AI

Was this page helpful?