I've been this error since yesterday. Whenever it goes through onResponse it always goes to !response.isSuccessful and i don't know what i have been doing wrong.
OkHttpClient client = new OkHttpClient();
Log.d("API Key", "Before: " + getAPIKey());
JSONObject json = new JSONObject();
try {
json.put("prompt", mInput.getText().toString());
json.put("model", "text-davinci-002");
json.put("temperature", 0.5);
json.put("max_tokens", 2048);
} catch (JSONException e) {
e.printStackTrace();
Log.d("API JSON"," Error "+ e);
}
RequestBody body = RequestBody.create(json.toString(), MediaType.parse("application/json; charset=utf-8"));
Request request = new Request.Builder()
.url("https://api.openai.com/v1/engines/davinci/completions")
.addHeader("Authorization", "Bearer " + getAPIKey())
.addHeader("Content-Type", "application/json")
.post(body)
.build();
Log.d("API Key", "After: " + getAPIKey());
client.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
e.printStackTrace();
Log.d("API onFailure"," Error "+ e);
}