Generative-ai-android json output

I wanted to ask about how we can get the output of the request in json format, where we can set it in google ai studio like this below



I’ve read some code in python that we could use "response_mime_type": "application/json" in the generation config.

model = genai.GenerativeModel("gemini-1.5-pro-latest",
                              generation_config={"response_mime_type": "application/json"})



But is it possible to do it in kotlin? because I didn’t saw any parameter available for it.



Is there any reccomendation what should I do? or should I just move out to rest api
Thanks in advance

1 Like

anyway, it is my first topic also my first post, be easy on me :blush:

There is currently a patch for the library (Add responseMimeType support by daymxn · Pull Request #133 · google-gemini/generative-ai-android · GitHub) that has been merged into main, but no release has yet been cut that includes this.

Sounds like it should be available in the library soon! (But not quite yet.) So keep an eye out for a new library version.

That is a good info to know. I think I will try it with rest api in the meantime while waiting for the next version release, thanks