How can I use Gemini AI API in Java/SpringBoot? Can I use VertexAI?

Hello Team,

There is no Java SDK for Gemini AI as far as I know. Is it okay to use VertexAI? or should I change to another framework/ Language? If there are other resources related to Java, kindly share.

Is it okay if our entire app depends on Gemini AI?

Thanks

1 Like

Hey there and welcome to the community!

Yep! That’s in a way, the intention of this competition :slight_smile:.

VertexAI is merely a means of distribution. You are perfectly fine to use VertexAI, so long as your app’s main focus is on the Gemini API.

As for “no Java SDK”, don’t fret.

You can use the Gemini API in any programming language you’d like using the REST API. A getting started guide can be found here:

REST APIs are basically ways to interact with the API directly via http requests and whatnot. It’s basically what all your SDKs are doing under the hood.

I program in Rust, so, like you, I have to use the REST API if I want to make any kind of calls to Gemini using my language of choice. It takes a little extra elbow grease, but it won’t take you too long once you realize how easy it actually is.

1 Like

Thanks a lot.
I ran a couple of prompts, the model response has this warning icon on top. What does this mean?

Can someone explain or tell where to find related info?

This sounds like a new question? Perhaps raise this in a new post.

You can click on the red triangle to get more details of what the error was.

All this is is a warning from the safety filters. It triggered a flag, but not bad enough that it prevented the completion.

This happens every once in a while. You can adjust the safety settings to your right in AI Studio:

And tweak them as necessary:

The triangle flag is just there to let you know how “safe” the filter determines it is. It will appear even for a “low” danger flag.

@afirstenberg This kind of follow-up is fine to leave in the same thread imo since it’s from the OP and it’s (in a way) tied to what they were doing. It’s also a quick answer.

It’s when users try to post on threads like announcement threads to ask questions, or when a non-OP tries to ask a different question is where I would mostly try to snip it onto its own topic. It’s all good though!

1 Like

I’ve started creating a Java API here: gemini-api

It’s also published on maven central, in case others would like to re-use it.

2 Likes