This is a server example to make API call to Google Gemini using OkHttpUtils2 and Json libraries.
Get API Key: https://aistudio.google.com/api-keys
Learn more: https://ai.google.dev/gemini-api/docs/quickstart#java
This example is still not perfect. Welcome to collaborate.
GitHub: https://github.com/pyhoon/Gemini_Server
This project is very challenging!
Gemini itself was not really helpful.
After hours and days of vibe coding, solving problems due to my lack of understanding in Server Sent Events (SSE), making countless trials and errors on different combinations of http headers, finally I got a working project with the help of DeepSeek and old school google search.
Adding event to SSE: https://medium.com/ @thiagosalvatore/the-line-break-problem-when-using-server-sent-events-sse-1159632d09a0
For B4J UI app without "streaming", check: https://www.b4x.com/android/forum/threads/gemini-ai-example-using-rest-api-ui.169487/