openai-php / laravel

⚡️ OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with OpenAI API

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug]: Meta information not included in CreateResponse

birdhouses opened this issue · comments

The meta information is not on the CreateResponse object. I could not find how to obtain the metainformation on a ChatCompletion response in the documentation.

Getting the metainformation only works for legacy completions, not for Chat

$client = \OpenAI::client(env('OPENAI_API_KEY'));


$response = $client->chat()->create([
                    'model' => $model,
                    'temperature' => 0,
                    'top_p' => 0,
                    'messages' => [
                        [
                            "role" => "user",
                            "content" => $generatedPrompt->prompt
                        ]
                    ],
                ]);

Log::info(json_encode($response->meta()));

Call to undefined method OpenAI\Responses\Chat\CreateResponse::meta() {"userId":1,"exception":"[object] (Error(code: 0): Call to undefined method OpenAI\\Responses\\Chat\\CreateResponse::meta()

        "openai-php/laravel": "^0.6.3",
        "php": "^8.1",

Hi @birdhouses

Please upgrade to the latest version, it is available there.