Hi guys,
I am building a Q&A app in Android Studio without any hands-on developer experience (more like a hobby project) but with the help of ChatGPT I feel like I am getting a hang of it, bit by bit.
After re-reading the documentation multiple times and trying to find a solution by myself I am ready to share my struggle.
I am trying to receive a response from a send text while authenticating with the API, but with my current endpoint “https://api.openai.com/v1/completions/”, I am getting “Failed with code 404” response. I’ve tried different endpoints from the documentation but without success.
I would really appreciate your advice on my code:
private static final String API_KEY = “Authorization: Bearer my valid API key”;
private ApiClient apiClient = new ApiClient();
private Retrofit retrofit = apiClient.getClient(“https://api.openai.com/v1/completions/” +
“\n”, API_KEY);
private OpenAiApi openAiApi = retrofit.create(OpenAiApi.class);public void button(View v) { EditText t = findViewById(R.id.source); final String input = t.getText().toString(); Log.d("info", input); Call<OpenAiResponse> call = openAiApi.generateResponse("text-davinci-003", input, 200); call.enqueue(new Callback<OpenAiResponse>() { @Override public void onResponse(Call<OpenAiResponse> call, Response<OpenAiResponse> response) { if (response.isSuccessful()) { Log.d("API Response", "onResponse: Success"); if (response.body() != null) { Log.d("API Response", "onResponse: Body: " + response.body().toString()); } } else { Log.d("API Response", "onResponse: Failed with code " + response.code());