I tried to integrate ChatGPT with a free-tier account, but I always receive the following error:
{“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”,”code”:”insufficient_quota”}}
HttpPost httpPost = new HttpPost("https://api.openai.com/v1/completions");
// Set headers
httpPost.setHeader("Content-Type", "application/json");
httpPost.setHeader("Authorization", "Bearer " + openaiApiKey);
// Create JSON payload
JsonObject json = new JsonObject();
json.addProperty("model", "gpt-3.5-turbo");
json.addProperty("prompt", prompt);
json.addProperty("max_tokens", 100);
StringEntity entity = new StringEntity(json.toString());
httpPost.setEntity(entity);
// Execute the request
try (CloseableHttpResponse response = httpClient.execute(httpPost)) {
String responseString = EntityUtils.toString(response.getEntity());
JsonObject responseJson = JsonParser.parseString(responseString).getAsJsonObject();
return responseJson.getAsJsonArray("choices").get(0).getAsJsonObject().get("text").getAsString().trim();
}
Error found:
{“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”,”code”:”insufficient_quota”}}
Does this mean that a free-tier account cannot be used for testing, and I need to upgrade to a paid plan to increase the limit for testing?