Unable to get API response inside VR headset with apk built with Unity

I’m building a Unity application in VR and I’m trying to integrate OpenAI to my existing project.
I tried integrating OpenAI API in a new VR project for testing and both Whisper and Chat API works.

But when I integrate OpenAI to my current project, when I call openai.CreateChatCompletion, it doesn’t give me any responses. Same goes with openai.CreateAudioTranscription which doesn’t give me any response from the await function.
The problem only occurs when I did the calls when I run directly on the headset with the VR application that I built through apk. With the same setup, everything works well on Unity Editor and I am able to get both responses without any problem.
I made sure that it’s using the exact same API key which I used on my test project which worked, and it’s hardcoded in new OpenAIApi declaration.

I tried various solutions like adding read/write permissions on AndroidManifest, as well as upgrading my Oculus Plugin, but none of them works.

For reference, my project is built using Unity 2019.4.22f1. And I have Playfab and Photon API calls integrated in my project.

What could have been the cause of the problem where I could not get any responses after integrating OpenAI to my project?

1 Like

Hi @Grand_A, any luck on this? I’m stuck on something similar myself.

I’m stuck on the exact same problem here, I would appreciate it if you guys find anything that helps.

  1. Set “Internet Access” to “Require” under Project Settings > Player > Configuration.
  2. In Project Settings > XR Plug-in Management > OpenXR, under OpenXR Feature Groups > Meta Quest Support, press the gear icon on the right and in the pop-up window, uncheck “Force Remove Internet”.

Can’t post the link where I originally found the answer here, but this is a generic problem of using UnityWebRequest with Oculus. The error you are probably getting is “cannot resolve destination host”, but you wouldn’t know without a VR debug console.

1 Like