API Error: usage quota exceeded

I’m using the free tier api(5$ limit) and it it not used for a single time, when running my app it gives this error even though I have quota.
OpenAI API response: {
error: {
message: ‘You exceeded your current quota, please check
your plan and billing details. For more information on this
error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.’,
type: ‘insufficient_quota’,
param: null,
code: ‘insufficient_quota’
}
}


My code:
import { OpenAIApi, Configuration } from “openai-edge”;

const config = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});

const openai = new OpenAIApi(config);

export async function getEmbeddings(text: string) {
try {
const response = await openai.createEmbedding({
model: “text-embedding-ada-002”,
input: text.replace(/\n/g, " "),
});

const result = await response.json();

console.log("OpenAI API response:", result);

// Check if result.data is defined and has at least one element
if (!result.data || result.data.length === 0) {
  throw new Error("No embeddings returned from OpenAI API");
}

return result.data[0].embedding as number[];

} catch (error: any) {
if (error.code === ‘insufficient_quota’) {
console.error(‘Quota exceeded. Please check your plan and billing details.’);
// Optionally, notify the user or admin
} else {
console.error(‘Error calling OpenAI embeddings API:’, error.message);
}
throw error; // Re-throw the error after logging
}
}

The issue seems to be a ‘quota’ limit. Check your settings to see if there is any limits set, and ensure the model you are trying to access shows up on the list.

Click the gear icon in the top right, then the ‘Limits’ tab.

Edit: Try again, there was an issue that was apparently just fixed.

Hi there and welcome to the Forum!

It looks like you have not added any funds to your account. In order to start using the API, you need to add a minimum of USD 5 of your own funds. OpenAI no longer provides free credits.