我在OpenAI上创建了一个新账号,显示有5美元的免费额度,并用它进行测试,但它返回了429状态错误。我是否需要先付款才能测试,还是这是我的代码中的错误?
import OpenAI from "openai";import dotenv from "dotenv";import { Router } from "express";dotenv.config();const router = Router();const openAiClient = new OpenAI({ organization: "org-***", apiKey: "sk-proj-***",});router.get("/openai", async (req, res) => { const completeChat = await openAiClient.chat.completions.create({ model: "gpt-3.5-turbo", messages: [ { role: "user", content: "make a description of black jeans", }, ], }); console.log(completeChat); res.sendStatus(200);});export default router;
回答:
即使使用免费额度,OpenAI也要求您提供一个支付方式。这是为了防止滥用并确保服务的持续访问。如果您没有添加支付方式,API可能会限制您的访问,导致错误代码的出现。