Expand description
AI-13 (#201): Gateway-side image URL fetcher.
When a client sends a multimodal request with a remote image URL
(the OpenAI image_url.url convention) and the target provider
adapter requires base64 image data (Anthropic, Gemini), the
gateway fetches the image, converts it to base64, and fills the
data_b64 + media_type fields on ContentPart::Image. The
OpenAI adapter continues to pass the remote URL through unchanged.
The fetcher is async and runs in serve_ai after guardrails and
before adapter.build_request. It is opt-in per route via the
ai.image_fetch config block; when disabled, remote URLs are
dropped by the Anthropic/Gemini adapters as before (preserving
backward compatibility).
Structs§
- Image
Fetch Config - Configuration for the image fetcher.
Functions§
- fetch_
remote_ images - Fetch remote image URLs in a
ChatRequestand filldata_b64+media_typeon eachContentPart::Imagethat has a remote URL but no base64 data. Images that already havedata_b64(fromdata:URIs) are left unchanged. Theurlfield is preserved so the OpenAI adapter can still pass it through. - has_
remote_ images - Check if a
ChatRequesthas any remote image URLs that would need fetching. Used to skip the fetcher entirely when not needed.