- Issue created by @sepa_cleversoft
- 🇩🇪Germany marcus_johansson
Hi sepa_cleversoft.
Could you try this file (but change the OpenAI key to your key). Please verify it for yourself of course, don't trust me before uploading it :)
But this is a plain vanilla curl call to OpenAI models listing. Just save it in a file and visit it or do `php filename.php`
// Your OpenAI API key $apiKey = 'YOUR_OPENAI_API_KEY'; // Initialize cURL $ch = curl_init(); // Set cURL options curl_setopt($ch, CURLOPT_URL, 'https://api.openai.com/v1/models'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Authorization: Bearer ' . $apiKey, 'Content-Type: application/json' ]); // Execute the request $response = curl_exec($ch); // Check for errors if (curl_errno($ch)) { echo 'Error:' . curl_error($ch); } else { // Decode and print the response $models = json_decode($response, true); print_r($models); } // Close the cURL session curl_close($ch);
If you see error with the same error, it is something with the host and you should reach out to them, if not its seems like some module is using the AuthenticationSubscriber wrongly (or we have a bug).
OAuth, JWT, Custom Authentication are some modules using this subscriber.
- 🇩🇪Germany marcus_johansson
Oh, and replace `YOUR_OPENAI_API_KEY` with your actual key of course :)
- 🇮🇹Italy sepa_cleversoft
With your code I get the list of available models. Indeed, I was able also to run openai module without errors. Thank you for your support.
- 🇩🇪Germany marcus_johansson
So, is this solved or did you mean the OpenAI module worked, but not the AI module + OpenAI provider?
- 🇮🇹Italy sepa_cleversoft
No, it's not solved. The code you provided worked well, so the problem for me is related to the module or something related. Maybe also the module key can be involved? How can I debug the error better?
- 🇩🇪Germany marcus_johansson
Three things I can think of right of the bat that would give more info on this:
Would it be possible for you to set it up locally and see if you can replicate the issue? Is there anything in the log messages? Where is it trying to redirect to?
- 🇮🇹Italy sepa_cleversoft
I found the issue. Was not directly related to ai module, but instead was a different module (services_api_key_auth) that was broking the website. Uninstalled it, it worked well.
Maybe can be useful for someone else, for me the issue is closed. Thank you.
- Status changed to Closed: works as designed
about 2 months ago 4:10am 18 September 2024 - 🇩🇪Germany marcus_johansson
Great to hear that you found it. Closed the ticket.