[Bug]: Warning: undefined array key 'id' using chat()
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
I wonder whether marking these fields as nullable is a long term solution. It's clear that LLM providers are:
- eager to provide support for the OpenAI API
- unwilling to present the same interfaces for responses as OpenAI does
It's clear OpenAI never intended the id field of all things to be null. Providing support for Gemini (and other providers) degrades the type safety of the responses, yet clearly is a business need we need to support. Maybe we need a better way to support these third-party LLM providers. Something like a 'GoogleResponse' class whose interface we can change as Google's OpenAI API implementation does.
I have been debating this exact problem and haven't really come up with a good solution, but I do like the different response class. My grip is kinda with Google.
There is like 10+ "drop-in" replacements for AWS S3 and they all have near perfect parity with S3. I haven't had a single issue with Wasabi or MinIO with my existing AWS/S3 PHP library. I don't understand how these other models can provide an OpenAI compatibility layer and then not match it.
I was even brainstorming a dumb poly-fill that was like "google_fake_uuid_do_not_use_{uuid}"
Any update here?
Maybe this has already been solved? See https://github.com/LLPhant/LLPhant/pull/359