Scrivio Interview library
CodingFoundations6 min read · updated 12 November 2026

Send a photo of a receipt plus a question to a vision-capable model with Spring AI ChatClient, and transcribe a customer voicemail to text. Which APIs do you use?

For the receipt, we attach the image to the user message: chatClient.prompt().user(u -> u.text("What is the total?").media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("receipt.png"))).call().content(), and the chat model must support image input. For the voicemail, we use a transcription model such as OpenAI's: transcriptionModel.call(new AudioTranscriptionPrompt(audioResource)).getResult().getOutput() returns the text. Speech models do the reverse for some providers, and images and recordings are personal data, so retention, consent and provider terms come first.

Why this question is asked

Many real business inputs are not text: photos of receipts and damaged parcels, scanned forms, voicemails from customers. Modern models can read images and transcribe speech, and Spring AI exposes both through familiar APIs. Interviewers ask this question to check that we know where media goes in a ChatClient call, that transcription is a separate kind of model, and that we think about limits and privacy. In this answer, we will recap multimodal models, send a receipt photo with a question, look at URLs and limits, transcribe a voicemail, touch on text to speech, and finish with data protection.

1A Quick Recap of Multimodal Models

A multimodal model accepts more than one kind of input, for example text and images in the same message. Not every chat model can do this: vision-capable models can, text-only models will reject the image or ignore it. So the first check is in the provider's documentation for the exact model we configure.

Speech is usually handled by different models. A transcription model, also called speech to text, takes audio and returns text. A speech model, text to speech, does the opposite. In Spring AI these are separate model types with their own interfaces, not options of the chat model.

Which Spring AI model handles which input
TaskModel typeInputOutput
Question about a photoChatModel (vision-capable)text plus image mediatext
Voicemail to texttranscription modelaudio resourcetext
Text to audiospeech modeltextaudio bytes

2Sending a Receipt Photo With a Question

In ChatClient, media belongs to the user message. The user spec has a media() method that takes a MIME type and a resource. Spring AI encodes the image and sends it in the format the provider expects.

Java
String total = chatClient.prompt()
.user(u -> u.text("What is the total amount on this receipt? Answer with the number only.")
.media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("receipt.png")))
.call()
.content();
System.out.println(total); // 47.80

Notice that we still write a clear text instruction. The image alone does not say what we want; the question tells the model to read the total and answer with only the number, which makes the result easy to parse. The MIME type must match the file: IMAGE_JPEG for a JPEG photo from a phone, IMAGE_PNG for a PNG.

For a structured answer, such as merchant, date, total and currency, we can combine the image with entity(Receipt.class) exactly as we would for text input.

3Passing a URL and Respecting Limits

Some providers accept an image URL instead of the bytes. Then the provider downloads the image itself, which keeps our request small. Spring AI's Media type can carry a URL for those providers. The URL must be reachable by the provider, so a link to an internal file server will not work, and a signed short-lived URL is safer than a public one.

Limits differ per provider and model: maximum file size, maximum pixel dimensions, number of images per request, and accepted formats (PNG and JPEG are almost always supported, HEIC from iPhones often is not). Large images are also billed as many input tokens. For receipts, resizing a 4,000-pixel phone photo to about 1,500 pixels on the long side usually keeps the text readable while cutting size and cost, and converting unsupported formats on upload avoids errors later.

4Transcribing a Customer Voicemail

For audio we use a transcription model. With the OpenAI starter, Spring AI auto-configures an OpenAI transcription model that we can inject, and we call it with an AudioTranscriptionPrompt wrapping the audio resource. Class names have changed between versions (for example OpenAiAudioTranscriptionModel), so check your version.

Java
@Service
class VoicemailService {
private final OpenAiAudioTranscriptionModel transcriptionModel;
VoicemailService(OpenAiAudioTranscriptionModel transcriptionModel) { this.transcriptionModel = transcriptionModel; }
String transcribe(Resource audio) {
var options = OpenAiAudioTranscriptionOptions.builder()
.language("en") // helps accuracy when we know the language
.temperature(0f)
.build();
AudioTranscriptionResponse response =
transcriptionModel.call(new AudioTranscriptionPrompt(audio, options));
return response.getResult().getOutput();
}
}
// transcribe(new FileSystemResource("vm-2026-11-05-0912.mp3"))
// "Hi, this is Maria Lopez, my order 4711 arrived damaged, please call me back.
Step throughVoicemail to an action
  1. Store the recordingaccess-controlled, with retention
  2. Transcribetranscription model
  3. Extract intent and order numberchat model, structured output
  4. Create or update the ticket
  5. Delete audio after retention period

5 steps in order. Play them, or step through them one at a time.

Notice the shape of the result: getResult() gives the first transcription, and getOutput() the text. Audio files have size limits too (some providers cap a single upload at around 25 MB), so long recordings are split into segments before transcription.

5Text to Speech

Some providers also offer speech models that turn text into audio, for example to read a confirmation back over the phone. In Spring AI that is a separate speech model class with options for voice, format and speed. Names have changed between versions, so check your version. As with transcription, it is a different model and a different price list from chat.

6Treat Images and Audio as Personal Data

A receipt shows where someone shopped and sometimes part of their card number. A voicemail contains a voice, a name and often a phone number. Before sending either to a provider, we check three things. Consent and purpose: did the user agree to their content being processed this way, and do we only use it for that purpose. Provider terms: whether the provider stores inputs, for how long, and whether it may use them for training, and whether our contract turns that off. Retention on our side: how long we keep the original files and the transcripts, and who can access them. Where policy requires it, we redact before sending, for example cropping the card number area, and we keep the originals in storage with access control and an expiry rule.

7Follow-up questions

How would you validate the extracted total?

Never trust a single read. Ask for structured output with the line items, subtotal, tax and total, then check in code that the line items add up to the subtotal and subtotal plus tax equals the total, within a cent. Check that the currency and date are plausible. If the numbers do not add up or the model reports low confidence, send the receipt to a person, and for expense claims compare the total with the amount the user typed. Track how often validation fails per model.

What if the model is not vision-capable?

The call fails or the image is ignored, depending on the provider. We configure a vision-capable model for this client, or use a dedicated OCR service first and send its text to any chat model.

Can I stream responses with images in the prompt?

Yes. Media is part of the prompt, so stream() works the same way as call(); only the input differs.

8Conclusion

In this answer, we sent a receipt image to a vision-capable chat model by adding media to the user message, saw that URLs work for some providers and that size and format limits differ, and transcribed a voicemail with a transcription model and AudioTranscriptionPrompt. Speech models cover text to speech for some providers. Because images and audio are personal data, consent, provider terms and retention must be settled before anything is sent.

What to say in the interviewAbout 70 seconds aloud

Open with

For the receipt I use a vision-capable chat model and attach the image to the user message: chatClient.prompt().user(u -> u.text("What is the total?").media(MimeTypeUtils.IMAGE_PNG, new ClassPathResource("receipt.png"))).call().content(). The MIME type must match the file, and I still write a precise instruction, or use entity with a Receipt record for structured fields.

Then, if they want more

Some providers accept an image URL instead of bytes, but size limits, dimensions and accepted formats differ, so I resize photos and convert formats on upload.

For the voicemail I use a transcription model, not the chat model: with OpenAI, the transcription model's call with a new AudioTranscriptionPrompt of the audio resource, then getResult().getOutput() gives the text, and I can set the language in the options. Class names have moved between versions, so I would check. Some providers also have speech models for text to speech.

Then I would validate the total by checking that the line items add up, and send doubtful cases to a person. Finally, images and recordings are personal data, so I check consent, the provider's retention and training terms, and our own retention before sending anything.

About this answer

Last updated
12 November 2026
Checked
Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
Where the question comes from
Written by Scrivio for practice. It is not taken from an interview.
Official documentation
Spring AI reference
Report an issue with this answer

Copy the line below and send it to the author with what you found. It carries the address of this page.

Issue with "Send a photo of a receipt plus a question to a vision-capable model with Spring AI...": https://scrivio-interview-library.netlify.app/spring-boot/spring-ai/45bee88644/