java.net.http.HttpClient) or an official/community Java SDKSend a JSON body with a list of role-tagged messages (system, user, assistant) → get back a JSON response containing the generated text → parse it (Ch.11's JSON techniques) to extract the answer.
Send text to a speech endpoint → receive an audio file back (e.g. MP3 bytes) → play it or save it with Java I/O.
Send an audio file to a transcription endpoint → receive the transcribed text in the JSON response.
Send a text prompt describing the desired image → the API responds with a URL or base64 data for the generated image, which you download/decode with standard Java I/O.
Similar request/response pattern for emerging video-generation endpoints — typically returns a job ID you poll until the video is ready to download.
Before displaying AI-generated or user-submitted content, many apps send it through a moderation endpoint that flags unsafe categories (violence, hate, self-harm, etc.) so the application can filter or block it.
A recurring design pattern: wrap repetitive HTTP + JSON boilerplate (auth headers, request building, response parsing) into a small reusable utility class with static helper methods — e.g. OpenAIUtilities.chat(prompt) — so the rest of the app's code stays clean and focused on business logic.