Skip to content

feat: add OpenAI compatibility support for Google Gemini #502

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

Conversation

TyperEJ
Copy link
Contributor

@TyperEJ TyperEJ commented Nov 21, 2024

What:

  • Bug Fix
  • New Feature

Description:

According to the Google Gemini OpenAI compatibility documentation, OpenAI's official Python and Node.js SDKs are supported for compatibility.

Hope that the PHP version can also be updated to reflect this compatibility :)

Related:

https://ai.google.dev/gemini-api/docs/openai

fixes: #526

@slavkof
Copy link

slavkof commented Jan 27, 2025

Any chance to get this rolling? :)

@npotier
Copy link

npotier commented Feb 19, 2025

Hello. Thank you for this PR

any news on it ?

@ghostza1209
Copy link

hello. any plan to merge this PR?

@ghostza1209
Copy link

ghostza1209 commented Mar 4, 2025

hello. any plan to merge this PR?

btw, here's my temporary fixed.
#526 (comment)

@Capevace
Copy link

Would be great to merge this, as this bug currently completely prevents using Gemini models with the SDK! :)

@iBotPeaches
Copy link
Collaborator

Sorry for delay on this. At the moment there are conflicts, so those would need to be resolved so we can confirm if CI passes, then I can take a look and review this.

@iBotPeaches iBotPeaches marked this pull request as draft April 8, 2025 23:44
@TyperEJ TyperEJ marked this pull request as ready for review April 9, 2025 03:32
@iBotPeaches
Copy link
Collaborator

It looks good!

Just a thought about 1 thing. If we have people depending on this package and the id property is now nullable - it may be a mini breaking change for them as their static analysis will force them to defend against something that isn't nullable for at least OpenAI.

Do we think thats alright? My only other thought is to dynamically create some random index since it seems Gemini does not if we don't have one in the response. The downside to that is folks may store an ID thinking its from Gemini and its instead some made up value.

Copy link
Collaborator

@iBotPeaches iBotPeaches left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think nullable is right call vs a fake index. It reflects how the official SDKs degrade

@iBotPeaches iBotPeaches added the Non-OpenAI Model Not an OpenAI Model. label Apr 10, 2025
@iBotPeaches iBotPeaches changed the title feat: add openai compatibility support for google gemini feat: add OpenAI compatibility support for Google Gemini Apr 10, 2025
@iBotPeaches iBotPeaches merged commit 6403060 into openai-php:main Apr 10, 2025
10 checks passed
@iBotPeaches
Copy link
Collaborator

thanks!

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

Successfully merging this pull request may close these issues.

[Bug]: Undefined array key "index"
6 participants