-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Does not support google gemini #1252
Comments
Let's see how it goes for you 😇 |
I wanted to try it out as well. I’m just waiting for the branch to open. 👍 |
@KotlinFactory , @ziodave, @youngmoneee the truth of the matter is, Google Gemini API does NOT provide Java Client. The other option is to try to build a low-level Spring AI Gemini client on top of the REST API, as we've done for many other providers including the , now deprecated, Google Vertex PaLM2 Honestly Google's Dev docs and API management is amongst the most confusing out there. Would appreciate if you can point me to reliable doc and code sources. |
@tzolov in situations where Google’s APIs and models frequently change or get deprecated, how about creating an adapter interface like GoogleAiApi and simply swapping out the implementation when needed? This approach could allow us to call methods from various implementations like Similarly, Hugging Face supports multiple implementations through a unified interface, and it seems to work well without major issues. Maybe we could take a similar approach? |
I totally agree with you, that google tends to provide horrible documentation for their APIs. |
@KotlinFactory, I'm not sure the REST API reference doc event exists: https://ai.google.dev/api ? |
Hey @tzolov it surely does. I build my own gemini client a few month ago I believe. It was based on this incomplete documentation from their side.
|
@KotlinFactory so, can you point me to this "incomplete" Google Gemini REST API documentation? My point is that, if a billions worth company, with zillions employees can't put their ** together to add a simple API doc, why should anyone take this API seriously? |
@KotlinFactory, |
@tzolov Yeah I've heard about and seen the poor documentation of google APIs in various instances. Its really annoying. ![]() Yes, I would love l be contributing some gemini client to Spring AI. Just one question, how feature complete does it need to be considered. I've already some simple Java based Rest client for the GeminiAPI. |
I will try ask them for an openapi spec. Perhaps they will respond. |
I will join when the branch opens. |
Thanks for digging further @KotlinFactory I found this Apparently, unlike Vertex AI, no If I understand correct the primary reason for someone to consider Otherwise, you can use any of the available models (including 1.5 pro & flash) with the Spring AI Vertex Gemini Chat model. |
Yeah thats the primary concern. I dont beliebe users should be forced to use GCP just to use gemini. There is also some response from their side. It appears like we can obtain an openapi spec given the instructions. |
@tzolov Perhaps it would be an idea to reuse some parts of the vertex.ai module? I think except for authentication its basically identical. |
Given the enterprise customer base we focus on, I don't see us having bandwidth to devote to this in the short term. Is'nt it really more of an issue using an API key than 'using GCP' @KotlinFactory (neat handle name btw) |
They have REST API defined here |
@KotlinFactory theoratically the vertex.ai module can be re-used and modify to alternate the REST call to the Gemini endpoint instead of going through GCP. However, the issue is that Google haven't release a SDK for Java yet (There is only Android SDK and it's only used for prototyping purpose ) and the vertex.ai library from Google that Spring AI is using does not support Gemini without GCP REST call. To make the change, Spring AI needs to re-implement this using classes in that module and I think it's not beneficial, this should be handled by Google instead. Related issue #626 |
Here you can find Google Generative Language API OpenAPI Specification (Revision 20241016): Some work had to be done to be able to generate open api specification from google discovery specification. You can find here how to do this: I tested this endpoint: "/v1beta/models/{model}:generateContent" it works fine. |
Revising this topic again. Mariusz has made an implementation and has previously contributed to Spring AI. See https://github.com/didalgolab/spring-ai-gemini @didalgolab is this something that you would like to contribute to Spring AI? |
Love to have this. |
@markpollack Thanks for the mention. It is a bit basic implementation, suiting my needs but not updated for a while. However, if there's actual interest in this, I can consider refining it and turning it into a contribution. |
Just a heads up: You can connect Spring AI to model brokers like openrouter.ai and utilize their OpenAI compatible API. That way I got Google Gemini to work using the Spring AI OpenAPI starter. There's just a (very) small configuration fix needed: #1522 (comment) |
Google has also an experimental OpenAI-compatible REST API: https://ai.google.dev/gemini-api/docs/openai. |
Google Gemini Pro 1.5 (especially the new experimental version) is one of the top models in the the LLM leaderboard, showcasing its exceptional capabilities and potential.
The model performs well especially in non-english languages such as German or English.
However currently, Spring AI only supports accessing Google Gemini through Google Vertex AI. This requires users to manage authentication through Google Cloud and prevents the use of the standalone Gemini API.
Another user also brought this up in #1247
This leads to:
High friction and decreased Adoption: There is a reason Google released AI Studio. Forcing users through Vertex AI creates unnecessary friction and complexity, especially for those unfamiliar with Google Cloud. This is a significant turnoff for developers evaluating Spring AI, potentially leading them to abandon the framework altogether in favor of alternatives that offer a more straightforward integration with the standalone Gemini API.
Cumbersome prototyping: The standalone API allows for rapid prototyping and testing of ideas without the need for complex infrastructure setup. This is particularly valuable for new developers who want to quickly explore the capabilities of Gemini and Spring AI without getting bogged down in configuration and deployment hurdles.
The lack of support for the standalone Gemini API in Spring AI is a significant limitation and forces users to either abandon Spring AI or refactor their codebase to use the Google Cloud SDK directly.
Expected behavior
Spring AI should provide support for the standalone Google Gemini API, similar to how other language models are integrated. This would include:
Configuration options for specifying API keys and endpoints.
Abstractions similar to existing language model integrations to streamline usage and maintain consistency.
Documentation outlining how to configure and use the standalone Gemini API within the Spring AI framework.
Additional context
In the ReadMe of the project the relatively minor role of Java in the AI landscape is acknowledged.
Tools like LangChain have gained immense popularity by focusing on developer-friendliness and providing a smooth onboarding experience.
By removing barriers to entry and simplifying integrations, like enabling access to the standalone Google Gemini API, Spring AI can attract a wider audience and solidify its position as a leading framework for AI development (not just) in Java/ the JVM space.
The text was updated successfully, but these errors were encountered: