node.jsexpressopenai-api

Why Api of New account on OpenAI not Working?


I created new account on Open AI and it shows free $5 limit and using it for testing but it is respponding with 429 status error do I have to pay first to test or is it error from my code?

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;

Solution

  • OpenAI requires a payment method to be on file even when using free credits. This is a common practice to prevent abuse and ensure uninterrupted access to the service. If you haven't added a payment method, the API may restrict your access, resulting in error codes.