Skip to content

Error when listing available models #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
simohammedhttp opened this issue Nov 8, 2023 · 1 comment
Closed

Error when listing available models #246

simohammedhttp opened this issue Nov 8, 2023 · 1 comment

Comments

@simohammedhttp
Copy link

Hi,

I tried this code in the docs:

$response = $client->models()->list();
$response->object;
foreach ($response->data as $result) {
    $result->id;
    $result->object;
}
$response->toArray();

I got this error:

Warning: Undefined array key "permission" in C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\RetrieveResponse.php on line 51

Fatal error: Uncaught TypeError: array_map(): Argument #2 ($array) must be of type array, null given in C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\RetrieveResponse.php:49 Stack trace: #0 C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\RetrieveResponse.php(49): array_map(Object(Closure), NULL) #1 C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\ListResponse.php(44): OpenAI\Responses\Models\RetrieveResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation)) #2 [internal function]: OpenAI\Responses\Models\ListResponse::OpenAI\Responses\Models{closure}(Array) #3 C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\ListResponse.php(44): array_map(Object(Closure), Array) #4 C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Resources\Models.php(30): OpenAI\Responses\Models\ListResponse::from(Array, Object(OpenAI\Responses\Meta\MetaInformation)) #5 C:\xampp\htdocs\myproject\openai-test.php(37): OpenAI\Resources\Models->list() #6 {main} thrown in C:\xampp\htdocs\myproject\OpenAI\vendor\openai-php\client\src\Responses\Models\RetrieveResponse.php on line 49

@gehrisandro
Copy link
Collaborator

Hi @simohammedhttp

You are using an old version of the client. This issue has already been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants