openai-php / openai-php/client

[Bug]: Warning: undefined array key 'id' using chat()

Open
#568 4 comments 2 reactions 0 assignees View on GitHub

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

Another error with using the client to interact with Gemini - once again, Google doesn't provide a field (id) that the client expects to be present in the response.

Steps To Reproduce
return $client->chat()->create([
            'model' => 'gemini-2.0-flash',
            'messages' => [
                ['role' => 'user', 'content' => $text],
            ],
        ]);
OpenAI PHP Client Version

v0.10.3

PHP Version

8.4

Notes

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the chat()->create() entry point and trace how the Gemini response is processed after the request in the reproduction. Check where the response's id field is accessed, then run the reported example against Gemini to verify the warning is gone and the returned chat result remains usable.

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
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.