Hello all,
I create a new account yesterday, and then create a secret API key. As I checked I have 5$ to use.
I assume that I can call api send a simple question and receive the answers.
But the answers always like this:
You exceeded your current quota, please check your plan and billing details
Does OpenAI change the policy recently? Or did I do something wrong?
Could some one help me on this topic? or confirm that can not use free account anymore?
My simple code java as below:
String apiKey = "mySecretKey";
String finalQuestion = "Who are you?";
String answers = "";
// Create HttpClient
HttpClient client = HttpClient.newHttpClient();
// Prepare the request
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://api.openai.com/v1/completions"))
.header("Content-Type", "application/json")
.header("Authorization", "Bearer " + apiKey)
.POST(HttpRequest.BodyPublishers.ofString("{\"model\":\"gpt-3.5-turbo\",\"prompt\":\"" + finalQuestion + "\",\"max_tokens\":150}"))
.build();
// Send the request and retrieve the response
try {
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println("Response Code: " + response.statusCode());
System.out.println("Response Body:\n" + response.body());
answers = response.body();
} catch (Exception e) {
e.printStackTrace();
}