openai-php / openai-php/client
[Bug]: Undefined array key "output" in D:\XXX\vendor\openai-php\client\src\Responses\Responses\CreateResponse.php on line 116
Open
Nobody has claimed this yet.
bug
Non-OpenAI Model
- Dominant language
- PHP
- Stars
- 5.8k
- Forks
- 679
- Avg merge
- 19m
- Merged PRs (30d)
- 2
Description
Description
PHP Warning: Undefined array key "output" in D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Responses\Responses\CreateResponse.php on line 116
PHP Fatal error: Uncaught TypeError: OpenAI\Actions\Responses\OutputObjects::parse(): Argument #1 ($outputItems) must be of type array, null given, called in D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Responses\Responses\CreateResponse.php on line 116 and defined in D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Actions\Responses\OutputObjects.php:45
Stack trace:
#0 D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Responses\Responses\CreateResponse.php(116): OpenAI\Actions\Responses\OutputObjects::parse()
#1 D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Resources\Responses.php(45): OpenAI\Responses\Responses\CreateResponse::from()
#2 D:\PhpProjects\Farasat\Server\openai_test1.php(26): OpenAI\Resources\Responses->create()
#3 {main}
thrown in D:\PhpProjects\Farasat\AppReq\proj_composer\vendor\openai-php\client\src\Actions\Responses\OutputObjects.php on line 45
Steps To Reproduce
my sample code is:
<?php
require_once(__DIR__ .'/../xxx/vendor/autoload.php');
$apiKey = 'sk-xxxxxxxxxxxxxxxxxxxxx';
$models=['gemini-2.0-flash','gpt-3.5-turbo','google/gemini-2.0-flash-exp:free','openai/gpt-4o-mini','gpt-4o'];
foreach($models as $model){
try{
$client = OpenAI::client($apiKey);
echo '<br/>'.$model.'<br/>';
$response = $client->responses()->create([
'model' => $model,
'input' => 'Hello!',
]);
$result = json_decode($response, true);
if($response!=null){
echo ' response is NOT null';
$var = print_r($response, true);
echo $var;
$var = print_r($result, true);
echo $var;
// echo $result['choices'][0]['message']['content'] ?? 'Error in response';
break;
}
else{
echo ' ------ response "'.$model.'" is null';
}
}
catch (Exception $e) {
echo $e->getMessage();
}
}
?>
OpenAI PHP Client Version
v0.18.0
PHP Version
8.5.1
Notes
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the sample request, then inspect CreateResponse.php at line 116 and OutputObjects.php at line 45 to compare the returned response shape with what the parser expects. Check each model in the example and verify that the affected response is handled without the undefined-key warning or TypeError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100