openai-php / client

⚡️ OpenAI PHP is a supercharged community-maintained PHP API client that allows you to interact with OpenAI API.
MIT License
4.6k stars 468 forks source link

Undefined array key "permission" #232

Closed ryanatearth closed 8 months ago

ryanatearth commented 8 months ago

I just am starting out using the PHP client to access the OpenAI API. And just in my first attempt to get something basic back, getting errors. I am just trying to do a basic test to get all models, as in the example given in the documentation.

$client = OpenAI::client(OPENAI_API_KEY);
$resp = $client->models()->list();
foreach($resp['data'] as $result){
  print "ID: " . $result->id . "\n";
}

These are the errors/warnings I am getting in my logs:

[05-Nov-2023 03:44:32 UTC] PHP Warning:  Undefined array key "permission" in /.../vendor/openai-php/client/src/Responses/Models/RetrieveResponse.php on line 51
[05-Nov-2023 03:44:32 UTC] PHP Fatal error:  Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in /.../vendor/openai-php/client/src/Responses/Models/RetrieveResponse.php:51

Seems like this should be very basic. Has something changed within the permission structure, am I not passing in some configuration, or am I missing something else?

Thanks in advance for your help.

shcherbanich commented 8 months ago

This PR fixes a bug, I'm waiting for a review. It seems that the OpenAI API is no longer returning this data for some reason. https://github.com/openai-php/client/pull/233

ryanatearth commented 8 months ago

Great, thanks!

gehrisandro commented 8 months ago

A fix is released soo https://github.com/openai-php/client/pull/235