I've been trying to make chatGPT, perhaps also Dall E into application where you would login with API key, but I have been stopped by this error.
E/API Error: 429
I/okhttp.OkHttpClient: Callback failure for call to https://api.openai.com/...
I/okhttp.OkHttpClient: java.io.IOException: Unexpected code Response{protocol=h2, code=429, message=, url=https://api.openai.com/v1/engines/davinci/completions/}
I/okhttp.OkHttpClient: at com.example.pocketgptd.LoginActivity$1.onResponse(LoginActivity.java:74)
Error only shows up when application is built, ran and you enter API key and press the designated button. which triggers function naOdziv(onResponse)
public void naOdziv(@NonNull Call call, @NonNull Response response) throws IOException {
try (ResponseBody ignored = response.body()) {
if (response.code() == 200 || response.code() == 201) {
if (znanAPIKey.isChecked()) {
SharedPreferences.Editor editor = preferences.edit();
editor.putString(API_KEY, daniAPIKey);
editor.apply();
}
Intent intent = new Intent(LoginStran.this, GlavnaStran.class);
intent.putExtra("api_key",apiKey);
startActivity(intent);
}
else {
Log.e("API Error",response.message() + " "+ response.code());
throw new IOException("Unexpected code " + response); //Line 74
}
}
}