Prompt cache works just for text

I experience an issue with prompt caching on Azure OpenAI where any request containing an image_url content block silently disables caching (cache_write_tokens=0), while text-only requests cache correctly.

I’ve used the raw OpenAI Python SDK (with_raw_response.create()) to bypass LangChain entirely and read usage.prompt_tokens_details directly. Each test sends two identical requests with the same prompt_cache_key and prompt_cache_options: {mode: “explicit”, ttl: “30m”}.

What I’ve tested :

  • cache_write_tokens=0 on Call 1 — Azure refuses to write to cache, not just to read
  • The block fires on the “type”: “image_url” / “type”: “input_image” content block type, regardless of image format (PNG/JPEG), encoding (base64/URL), size (1px to full photo), or API endpoint (Chat Completions vs Responses API)
  • Sending the identical base64 data as “type”: “text” (Test J) caches fine — confirming the gate is on content block type detection, not on the actual data

Is multimodal prompt / image caching disabled somehow at the deployment or subscription level? Documentation explicitly state images are cacheable. Is there a setting that needs to be enabled, or is there something I don’t understand?

Same here on Azure OpenAI, gpt-5.6-luna (DataZoneStandard), Chat Completions.

Minimal repro, same prompt_cache_key, prompt_cache_options: {mode: "explicit", ttl: "30m"}, breakpoint on the system text block:

Call prompt_tokens cached_tokens cache_write_tokens
system text + BP, question A 2958 0 2945
system text + BP, question B 2958 2945 0
same as above + one 512px image 3266 0 0
repeat of the image call 3266 0 0

Breakpoint, key and explicit mode work for text. Adding a single image_url block after the breakpoint stops all reads and writes for the whole request.

In implicit mode the image calls still don’t read the cached prefix, cache_write_tokens vanishes from the response, and an exact repeat reads 2816 tokens, rounded to 128-token blocks. Looks like image requests fall back to the legacy cache path, which only stores one entry point per request at the end of the prompt and ignores explicit breakpoints.

Cold-image tests for “same images, different follow-up prompt”:

Pattern Hits
images + prompt A, then images + prompt B, same key 0 of 5
~2k tokens stable text before the images, different prompt 0 of 2
explicit breakpoint after the images (on the last image, on a text block after it, or on the system block before) 0 of 3
exact repeat, or a request extending an earlier one hits
follow-up as conversation continuation (images + A + assistant answer + B) 3 of 3, ~5.9k tokens read

So with images, only a request whose full earlier request is a prefix of it ever hits. Explicit breakpoints are accepted without error but have no effect.

This is a really interesting finding. Based on the tests you’ve described, it looks less like a deployment/subscription setting and more like an Azure-side limitation or implementation difference in prompt caching for multimodal content.

The fact that the exact same base64 payload works when sent as type: "text" is particularly useful evidence. That seems to isolate the behaviour to how Azure handles the content block type, rather than the image itself.

A few things I’d be interested in checking:

  • Does this happen consistently across different Azure regions and model deployments?
  • Is the behaviour the same with the latest API version for the specific model?
  • What model/deployment are you using? Prompt caching support and behaviour can differ between model families and Azure OpenAI versions.
  • Does the cache work if the image is placed after a sufficiently large static text prefix, rather than being part of the beginning of the prompt?
  • Have you tested the same exact request against the OpenAI API directly, rather than Azure? That would be a useful control test to determine whether this is Azure-specific.
  • It would also be worth checking whether cache_read_tokens remains 0 on the second request, or whether there is some partial caching happening but cache_write_tokens is being reported differently.

The strongest part of your investigation, IMO, is the Test J result. If the payload is identical and only this changes:

type: "input_image" / image_url → type: "text"

and caching immediately starts working, that makes it much harder to explain as an image-size, encoding, URL, or payload issue.

If Azure documentation currently says multimodal inputs are cacheable, I would expect this to either work or be explicitly documented as an Azure-specific limitation. Silent fallback to cache_write_tokens=0 makes debugging particularly difficult.

I’d probably open a support ticket with Microsoft/Azure and include a minimal reproducible Python example + raw usage.prompt_tokens_details from both calls, along with the model deployment, API version, region, and exact content-block structure. Your controlled tests already make a pretty strong reproduction case.

It would also be great if someone from the Azure OpenAI team could clarify whether multimodal prompt caching is actually supported for this model/deployment combination, because the observed behaviour seems inconsistent with the general documentation around image caching.

  1. On production I have to stay on specific region, so even if it works on different one it doesn’t help. I always use the latest deployment of specific model. I’ve tested it on 5.5, Luna, Terra and Sol, same results. One interesting finding - prompt catching works fine for Claude models for my setup, so definitely something with OpenAI.
  2. As you can see in the last test, I’ve tested text first (about 6k tokens) and image then. Configuration with text first then image blocks even cache read (first I’ve sent text + image - no cache, then I’ve sent just text first (cached) then same text + image to read cache, and it doesn’t even read text from cache. Not even break mechanism before image is working here.
  3. No, I have to do it through Azure, so even if it’s working it’s not option for me.
  4. For Claude models same setup for cahce_write / cache_read works correctly. If it’s working correctly for text alone, I don’t think it will work different for image.

Hey @mathew3096 and @daniel25, thanks for sharing what you’ve tested.

Azure’s docs list images as cacheable. Since you’re both seeing this through Azure OpenAI, I’d recommend opening an Azure Support ticket so they can check the behavior on your deployments.

Include your reproduction code and usage results in the private ticket, along with the model version, region, and API version. The difference you found between explicit and implicit caching is especially useful to highlight.

-Sandra