Calling AI Tools from Java
summary
Demos use Java 11+ HTTP client, Apache HTTP client and Spring HTTP-exchange interfaces to call OpenAI, Claude, Gemini, Mistral and local Olama; JSON maps to records and sealed interfaces with compact constructors for validation. Image generation returns base64 saved to files, text-to-MP3 is shown, and a full book is submitted to Gemini as 880,000 tokens and summarized successfully against a 1,000,000-token context window. Pricing, streaming defaults, multipart upload quirks and LangChain-for-J / Spring AI tooling are demonstrated and work end-to-end.
AI-written summary · about
