Skip to content

fix(async): move remote image fetches off the event loop for Snowflake, Bedrock invoke Claude, Mantle and Gemini - #39839

Merged
mateo-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_async_remote_image_fetch
Sep 7, 2026
Merged

mateo-berri merged 10 commits into
litellm_internal_stagingfrom
litellm_async_remote_image_fetch

Conversation

@mateo-berri

@mateo-berri mateo-berri commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Snowflake Cortex Claude, Bedrock invoke Claude, Gemini AI Studio and Vertex AI Gemini fetched remote image URLs synchronously
  • On the proxy that download ran on the event loop or a shared executor thread
  • One slow image host stalled health probes and unrelated requests on that worker
  • The SSRF check's DNS lookup, request signing and pre-call logging also ran on the event loop around the async fetch
  • Black Forest Labs image edits given an image URL through the Python SDK downloaded it on the event loop too
  • A fetch the URL policy blocked answered the caller with the resolved private IP, and a host that did not resolve was retried three times before failing

How it solves it:

  • New shared async walker inlines remote images and files before the transform runs
  • The shared HTTP handler now awaits async_transform_request for configs that opt in
  • Snowflake Claude, Bedrock invoke Claude and Mantle opt in; Gemini AI Studio and Vertex AI Gemini inline in their async body builder, Vertex AI only for the URLs Google cannot fetch itself (http://, or https with no known mime type)
  • Per-provider regression tests fail if the sync fetcher runs on the async path
  • At most 20 downloads run at once per request, so one request cannot hog the worker's connection pool, and one failed download cancels the rest of that request's downloads
  • Native Anthropic document and image blocks with url sources go through the same walker, so the async path leaves nothing for the sync converter
  • DNS resolution for the SSRF check, request signing and pre-call logging run in a thread; a blocked address fails the fetch on the first attempt instead of being retried
  • Every URL the SSRF check rejects, whether the policy blocked it or the host did not resolve, answers with the same fixed 400 on the first attempt (the proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and user_url_allowed_hosts), so the error text does not tell a caller which internal hostnames exist; the real verdict goes to the proxy log at warning level. Two callers outside this graph still forward the verdict (auth_utils, langfuse_endpoints), tracked in LIT-7045
  • Image edit configs get an async_transform_image_edit_request hook that the async handler awaits; Black Forest Labs uses it to download a URL image and mask with the async fetcher before its sync transform runs

User Flow

Before: a developer whose app sends chat completions with remote image URLs to a Snowflake Cortex Claude, Bedrock invoke Claude, Gemini or Vertex AI Gemini deployment stalls everyone else on the same proxy workers while the images download

  1. The proxy admin runs a two-worker proxy with gemini-flash (gemini/gemini-3.8-flash), vertex-gemini (vertex_ai/gemini-3.8-flash), bedrock-claude (bedrock/invoke/us.anthropic.claude-sonnet-5), bedrock-mantle (bedrock/mantle/anthropic.claude-sonnet-5) and snowflake-claude (snowflake/claude-sonnet-4-6) deployments
  2. The developer's app sends four POST https://litellm-domain/v1/chat/completions requests to gemini-flash at once, each with an image_url part whose host takes 8 seconds to serve the image
  3. While those downloads run, GET https://litellm-domain/health/liveliness hangs for 15.8 seconds instead of milliseconds, and every other request on those workers waits the same way
  4. The four requests come back 200 with "content": "Green" after 19.0, 19.0, 21.2 and 22.1 seconds, because each worker downloads its images one after another
  5. Sixty of those image requests sent at once to bedrock-claude come back in two waves (44 after 10.1 to 11.2 seconds, 16 after 17.8 to 23.2 seconds); sixty sent to snowflake-claude come back in two waves the same way (40 after 9.3 to 9.8 seconds, 20 after 16.6 to 16.9 seconds), and a text-only POST https://litellm-domain/v1/chat/completions to gemini-flash sent 1.5 seconds into the Bedrock fan-out waits 8.3 seconds for a free executor thread (0.7 seconds during the Snowflake fan-out, which left four threads free)
  6. The same four slow-image requests sent as POST https://litellm-domain/v1/responses (input_image), POST https://litellm-domain/v1/messages (image with a url source) or streaming POST https://litellm-domain/v1/chat/completions to gemini-flash hang GET https://litellm-domain/health/liveliness for 8.1, 7.5 and 15.5 seconds and come back after 11.6 to 26.1, 9.7 to 26.6 and 17.8 to 22.2 seconds
  7. Four of them sent to vertex-gemini with an http:// image hang GET https://litellm-domain/health/liveliness for 16.1 seconds and come back after 19.6, 20.2, 20.4 and 21.9 seconds
  8. One POST https://litellm-domain/v1/chat/completions to gemini-flash carrying 25 distinct images from a host that takes 2 seconds per image comes back after 55.0 seconds, because the images download one after another
  9. One slow-image request to bedrock-mantle comes back 200 after 10.0 seconds; four POST https://litellm-domain/v1/messages requests to bedrock-claude with a url image source come back 400 in 1.6 seconds because Bedrock rejects url sources itself ("URL content sources are not yet supported for this model")
  10. An image_url pointing at a blocked private address comes back 400 "Unable to fetch image from URL after 3 attempts" on every deployment
  11. An image_url on a host that does not resolve is looked up three times before the same "after 3 attempts" 400 comes back
  12. A multipart POST https://litellm-domain/v1/images/edits to openai-image-edit (openai/gpt-image-2) with a PNG upload comes back 200 with the edited image (b64_json) and 226 usage tokens after 11.9 seconds
  13. Four streaming slow-image requests to bedrock-claude and two to bedrock-mantle stream "Green" back after 9.9 to 10.3 and 9.8 to 10.8 seconds, and four to snowflake-claude get the stand-in's 401 after 8.2 to 8.5 seconds once the image is downloaded and inlined; GET https://litellm-domain/health/liveliness stays at 131, 94 and 111 milliseconds at worst, because these streaming downloads queue on executor threads rather than the loop and four at a time never fill the pool (step 5 does)

After: the same requests come back with the same answers, and the rest of the traffic on those workers keeps flowing while the images download

  1. The proxy admin runs the same two-worker proxy with the same five deployments
  2. The developer's app sends the same four POST https://litellm-domain/v1/chat/completions requests to gemini-flash with the same slow image_url
  3. GET https://litellm-domain/health/liveliness answers within 1.2 seconds for the whole download instead of hanging for 15.8 (the box sat above load 20 during this leg; every other leg below keeps it under half a second)
  4. The four requests come back 200 with "content": "Green" together after 14.5 to 15.6 seconds, because the downloads now run side by side
  5. Sixty image requests at once to bedrock-claude all come back 200 in one wave (9.7 to 11.8 seconds); sixty to snowflake-claude finish in one wave too (8.5 to 9.8 seconds), and the text-only gemini-flash request sent 1.5 seconds into that fan-out answers in 0.7 seconds (1.0 seconds during the Snowflake fan-out)
  6. The same four slow-image requests as POST https://litellm-domain/v1/responses, POST https://litellm-domain/v1/messages or streaming POST https://litellm-domain/v1/chat/completions to gemini-flash leave GET https://litellm-domain/health/liveliness at milliseconds (82, 106 and 429 milliseconds at worst) and come back after 9.8 to 10.5, 9.6 to 10.5 and 9.5 to 12.2 seconds
  7. Four sent to vertex-gemini with an http:// image leave GET https://litellm-domain/health/liveliness at 87 milliseconds at worst and come back after 10.2 to 10.6 seconds
  8. The same 25-image request comes back after 7.3 seconds, because the images download 20 at a time
  9. The bedrock-mantle request comes back 200 after 10.8 seconds, and the four POST https://litellm-domain/v1/messages requests to bedrock-claude still come back 400 from Bedrock in 1.4 to 2.1 seconds: that route hands url sources to Bedrock untouched, before and after
  10. The blocked private address comes back 400 on the first attempt with "The proxy could not resolve this host or its URL policy rejected it" and the user_url_allowed_hosts hint, with no resolved IP or DNS detail in the response, on every deployment
  11. The host that does not resolve comes back 400 on the first attempt with the same message, so a caller cannot use the error text to learn which internal hostnames resolve
  12. The same multipart POST https://litellm-domain/v1/images/edits comes back 200 with the edited image and the same 226 usage tokens after 11.5 seconds: the shared async_transform_image_edit_request default the async handler now awaits hands OpenAI the same request, and OpenAI's answer is unchanged
  13. The same streaming requests come back the same way: bedrock-claude after 10.7 to 11.1 seconds, bedrock-mantle after 10.4 to 10.5 seconds and snowflake-claude with the stand-in's 401 after 9.9 to 10.9 seconds, with GET https://litellm-domain/health/liveliness at 141, 168 and 173 milliseconds at worst; their downloads now run on the loop's async client instead of executor threads, which is why sixty of them no longer form waves (step 5)

Relevant issues

Follow-up to the unresolved review thread on #39453

Linear ticket

Resolves LIT-6923

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/test_litellm/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • I have received a Greptile Confidence Score of at least 4/5 before requesting a maintainer review (Greptile reviews automatically once the PR is opened; only comment @greptileai to re-request a review after pushing changes)

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Shared setup for both legs: one proxy process per leg booted with --num_workers 2 (two uvicorn workers), no database, real Gemini, Vertex AI and Bedrock calls costing real money. No Snowflake Cortex credentials are available, so a local stand-in takes the Snowflake requests: it dumps every request body, logs the content sources it receives and answers 401, which still shows the image was downloaded and inlined before the request left the proxy. Every image URL carries a cache-busting query string (?delay=8&label=<leg>&n=<case-request>), so the proxy's image cache never short-circuits a download. The box ran at load 17 to 26 on 18 cores with swap full for the whole run (about twenty other agents on it), so absolute timings are inflated on both sides; the shapes (probe stalls, waves, serial vs parallel downloads) are the evidence

config.yaml
model_list:
  - model_name: gemini-flash
    litellm_params:
      model: gemini/gemini-3.8-flash
      api_key: os.environ/GEMINI_API_KEY
  - model_name: vertex-gemini
    litellm_params:
      model: vertex_ai/gemini-3.8-flash
      vertex_project: os.environ/VERTEXAI_PROJECT
      vertex_location: global
  - model_name: bedrock-claude
    litellm_params:
      model: bedrock/invoke/us.anthropic.claude-sonnet-5
      aws_access_key_id: os.environ/AWS_LIT6341_QA_ACCESS_KEY_ID
      aws_secret_access_key: os.environ/AWS_LIT6341_QA_SECRET_ACCESS_KEY
      aws_region_name: us-east-1
  - model_name: bedrock-mantle
    litellm_params:
      model: bedrock/mantle/anthropic.claude-sonnet-5
      aws_access_key_id: os.environ/AWS_LIT6341_QA_ACCESS_KEY_ID
      aws_secret_access_key: os.environ/AWS_LIT6341_QA_SECRET_ACCESS_KEY
      aws_region_name: us-east-1
  - model_name: snowflake-claude
    litellm_params:
      model: snowflake/claude-sonnet-4-6
      api_key: dummy-snowflake-token
      api_base: http://127.0.0.1:33721/snowflake
  - model_name: openai-image-edit
    litellm_params:
      model: openai/gpt-image-2
      api_key: os.environ/OPENAI_API_KEY

general_settings:
  master_key: sk-lit6923
  user_url_allowed_hosts: ["127.0.0.1:33721"]

litellm_settings:
  drop_params: true

router_settings:
  disable_cooldowns: true
slow_image_server.py (GET sleeps `delay` seconds, then serves a 1x1 PNG; POST dumps the body, logs the Anthropic content sources and answers 401)
import base64, json, sys, time
from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer
from pathlib import Path
from urllib.parse import parse_qs, urlparse

DUMP_ROOT = Path(__file__).resolve().parent / "sink-bodies"

PNG = base64.b64decode(
    "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNk+M9QDwADhgGAWjR9awAAAABJRU5ErkJggg=="
)


class Handler(BaseHTTPRequestHandler):
    def log(self, msg):
        sys.stdout.write(f"{time.strftime('%H:%M:%S')} {msg}\n")
        sys.stdout.flush()

    def do_GET(self):
        url = urlparse(self.path)
        if url.path == "/dump":
            Handler.dump_dir = DUMP_ROOT / parse_qs(url.query)["dir"][0]
            Handler.dump_dir.mkdir(parents=True, exist_ok=True)
            Handler.dump_count = 0
            self.send_response(204)
            self.end_headers()
            self.log(f"dumping POST bodies to {Handler.dump_dir}")
            return
        delay = float(parse_qs(url.query).get("delay", ["0"])[0])
        self.log(f"GET {self.path} start (sleep {delay}s)")
        time.sleep(delay)
        self.send_response(200)
        self.send_header("Content-Type", "image/png")
        self.send_header("Content-Length", str(len(PNG)))
        self.end_headers()
        self.wfile.write(PNG)
        self.log(f"GET {self.path} done")

    dump_dir = None
    dump_count = 0

    def do_POST(self):
        body = self.rfile.read(int(self.headers.get("Content-Length", "0")))
        if Handler.dump_dir is not None:
            Handler.dump_count += 1
            (Handler.dump_dir / f"{Handler.dump_count:03d}.json").write_bytes(body)
        sources = []
        try:
            for m in json.loads(body).get("messages", []):
                for block in m.get("content", []) if isinstance(m.get("content"), list) else []:
                    src = block.get("source") if isinstance(block, dict) else None
                    if src:
                        sources.append(f"{block.get('type')}:{src.get('type')}:{(src.get('url') or src.get('data') or '')[:24]}")
        except Exception as e:
            sources.append(f"unparseable:{e}")
        self.log(f"POST {self.path} sources={sources}")
        payload = json.dumps({"message": "invalid token (sink)"}).encode()
        self.send_response(401)
        self.send_header("Content-Type", "application/json")
        self.send_header("Content-Length", str(len(payload)))
        self.end_headers()
        self.wfile.write(payload)

    def log_message(self, *args):
        pass


ThreadingHTTPServer(("127.0.0.1", int(sys.argv[1])), Handler).serve_forever()
legs2.sh (the fourteen cases and their request bodies)
#!/bin/zsh
# usage: legs2.sh <proxy port> <img port> <label>
P=$1; IMG=$2; LABEL=$3; S=${0:A:h}
KEY=sk-lit6923
OUT="$S/legs2-$LABEL"; rm -rf "$OUT"; mkdir -p "$OUT"
rm -rf "$S/sink-bodies/$LABEL"; curl -s -o /dev/null "http://127.0.0.1:$IMG/dump?dir=$LABEL"
IMGBASE="http://127.0.0.1:$IMG/slow.png?delay=8&label=$LABEL"
chat_body() { printf '{"model":"%s","max_tokens":200,"messages":[{"role":"user","content":[{"type":"text","text":"One word: what color is this image?"},{"type":"image_url","image_url":{"url":"%s"}}]}]}' "$1" "$IMGBASE&n=$2"; }
responses_body() { printf '{"model":"%s","max_output_tokens":200,"input":[{"role":"user","content":[{"type":"input_text","text":"One word: what color is this image?"},{"type":"input_image","image_url":"%s"}]}]}' "$1" "$IMGBASE&n=$2"; }
messages_body() { printf '{"model":"%s","max_tokens":200,"messages":[{"role":"user","content":[{"type":"text","text":"One word: what color is this image?"},{"type":"image","source":{"type":"url","url":"%s"}}]}]}' "$1" "$IMGBASE&n=$2"; }
post() { curl -s -o "$3" -w '%{http_code} %{time_total}s\n' "http://127.0.0.1:$P$1" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d "$2"; }
probe_loop() { for i in {1..14}; do curl -s -o /dev/null -w "liveliness %{http_code} %{time_total}s\n" "http://127.0.0.1:$P/health/liveliness"; sleep 0.5; done; }
summary() { sort "$1" | uniq -c | tr -s ' ' | tr '\n' ';'; }

probed_fanout() {
  ROUTE=$1; KIND=$2; N=$3; TAG=$4; M=${5:-gemini-flash}
  echo "### Leg $TAG ($LABEL): $N concurrent slow-image requests to POST $ROUTE for $M while probing GET /health/liveliness"
  for i in $(seq 1 $N); do post "$ROUTE" "$(${KIND}_body $M $TAG-$i)" "$OUT/$TAG-$i.json" >> "$OUT/$TAG.status" & done
  sleep 0.3
  probe_loop | tee "$OUT/probes-$TAG.txt"
  wait
  echo "$M $ROUTE statuses: $(summary $OUT/$TAG.status)"
  python3 "$S/summ.py" "$KIND" "$OUT"/$TAG-*.json
}

stream_body() { printf '{"model":"%s","max_tokens":200,"stream":true,"messages":[{"role":"user","content":[{"type":"text","text":"One word: what color is this image?"},{"type":"image_url","image_url":{"url":"%s"}}]}]}' "$1" "$IMGBASE&n=$2"; }

probed_stream_fanout() {
  N=$1; TAG=$2; M=${3:-gemini-flash}
  echo "### Leg $TAG ($LABEL): $N concurrent slow-image streaming requests to POST /v1/chat/completions for $M while probing GET /health/liveliness"
  for i in $(seq 1 $N); do post /v1/chat/completions "$(stream_body $M $TAG-$i)" "$OUT/$TAG-$i.sse" >> "$OUT/$TAG.status" & done
  sleep 0.3
  probe_loop | tee "$OUT/probes-$TAG.txt"
  wait
  echo "$M streaming statuses: $(summary $OUT/$TAG.status)"
  for f in "$OUT"/$TAG-*.sse; do echo "${f:t}: $(grep -c '^data:' $f) data lines, content=$(python3 "$S/summ_stream.py" $f)"; done
}

single() {
  M=$1; TAG=$2
  echo "### Leg $TAG ($LABEL): one slow-image POST /v1/chat/completions request to $M"
  post /v1/chat/completions "$(chat_body $M $TAG-1)" "$OUT/$TAG-1.json" | tee "$OUT/$TAG.status"
  python3 "$S/summ.py" chat "$OUT/$TAG-1.json"
}

fanout() {
  M=$1; N=$2; TAG=$3
  echo "### Leg $TAG ($LABEL): $N concurrent slow-image requests to POST /v1/chat/completions for $M, then a text-only gemini-flash request 1.5s later"
  for i in $(seq 1 $N); do post /v1/chat/completions "$(chat_body $M $TAG-$i)" "$OUT/$M-$i.json" >> "$OUT/$M.status" & done
  sleep 1.5
  curl -s -o "$OUT/text-during-$M.json" -w "text-only gemini-flash during $M fan-out: %{http_code} %{time_total}s\n" "http://127.0.0.1:$P/v1/chat/completions" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d '{"model":"gemini-flash","max_tokens":5,"messages":[{"role":"user","content":"say hi"}]}' &
  curl -s -o /dev/null -w "liveliness during $M fan-out: %{http_code} %{time_total}s\n" "http://127.0.0.1:$P/health/liveliness" &
  wait
  echo "$M fan-out statuses: $(summary $OUT/$M.status)"
  python3 "$S/summ.py" chat "$OUT/$M-1.json" "$OUT/$M-$N.json"
}

many_images_body() { python3 -c '
import json, sys
base, n = sys.argv[1], int(sys.argv[2])
parts = [{"type": "text", "text": "One word: what color are these images?"}] + [{"type": "image_url", "image_url": {"url": f"{base}&n=F-{i}"}} for i in range(n)]
print(json.dumps({"model": "gemini-flash", "max_tokens": 200, "messages": [{"role": "user", "content": parts}]}))
' "http://127.0.0.1:$IMG/slow.png?delay=2&label=$LABEL" "$1"; }

many_images() {
  N=$1; TAG=$2
  echo "### Leg $TAG ($LABEL): one POST /v1/chat/completions to gemini-flash carrying $N distinct slow images (2s each) while probing GET /health/liveliness"
  post /v1/chat/completions "$(many_images_body $N)" "$OUT/$TAG.json" > "$OUT/$TAG.status" &
  sleep 0.3
  probe_loop | tee "$OUT/probes-$TAG.txt"
  wait
  echo "gemini-flash $N-image request: $(cat $OUT/$TAG.status)"
  python3 "$S/summ.py" chat "$OUT/$TAG.json"
}


image_edit() {
  TAG=$1
  echo "### Leg $TAG ($LABEL): one multipart POST /v1/images/edits to openai-image-edit (openai/gpt-image-2) with a 64x64 PNG upload"
  curl -s -o "$OUT/$TAG-1.json" -w '%{http_code} %{time_total}s\n' "http://127.0.0.1:$P/v1/images/edits" -H "Authorization: Bearer $KEY" -F model=openai-image-edit -F prompt="Add a small red dot in the center" -F image=@"$S/edit-input.png" -F size=1024x1024 -F quality=low | tee "$OUT/$TAG.status"
  python3 -c '
import json, sys
j = json.load(open(sys.argv[1]))
if "data" in j:
    d = j["data"][0]
    print("data[0] keys:", sorted(d.keys()), "| b64_json bytes:", len(d.get("b64_json") or ""), "| usage:", j.get("usage"))
else:
    print("error:", str(j.get("error", j))[:200])
' "$OUT/$TAG-1.json"
}

probed_fanout /v1/chat/completions chat 4 A
fanout bedrock-claude 60 B
fanout snowflake-claude 60 C
probed_fanout /v1/responses responses 4 D
probed_fanout /v1/messages messages 4 E
many_images 25 F
probed_stream_fanout 4 G
probed_fanout /v1/chat/completions chat 4 H vertex-gemini
probed_fanout /v1/messages messages 4 I bedrock-claude
single bedrock-mantle J
image_edit K
probed_stream_fanout 4 L bedrock-claude
probed_stream_fanout 2 M bedrock-mantle
probed_stream_fanout 4 N snowflake-claude
echo "### sink saw (last 3 POST lines):"; grep POST ~/.claude/detached/lit6923-img5.log | tail -3
echo "### sink bodies ($LABEL): $(ls $S/sink-bodies/$LABEL | wc -l | tr -d ' ') Snowflake request bodies, $(md5 -q $S/sink-bodies/$LABEL/*.json | sort -u | wc -l | tr -d ' ') distinct md5: $(md5 -q $S/sink-bodies/$LABEL/*.json | sort -u | tr '\n' ' ')"

Boot commands:

python3 slow_image_server.py 33721
python litellm/proxy/proxy_cli.py --config config.yaml --port 27860 --num_workers 2   # Before leg, checkout at 29ac88ebc6
python litellm/proxy/proxy_cli.py --config config.yaml --port 40862 --num_workers 2   # After leg, checkout at 59e000de8e

Before (29ac88e)

Leg A: four slow-image POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg A block)

  2. Observed:

    liveliness 200 0.028173s
    liveliness 200 0.410621s
    liveliness 200 15.844042s
    liveliness 200 0.075716s
    liveliness 200 2.449536s
    liveliness 200 0.103448s
    liveliness 200 0.003167s
    liveliness 200 0.037354s
    liveliness 200 0.000933s
    liveliness 200 0.125150s
    liveliness 200 0.001344s
    liveliness 200 0.054094s
    liveliness 200 0.003339s
    liveliness 200 0.035408s
    gemini-flash /v1/chat/completions statuses:  1 200 19.018074s; 1 200 19.024957s; 1 200 21.243571s; 1 200 22.124741s;
    A-1.json: 'Green'
    A-2.json: 'Green'
    A-3.json: 'Green'
    A-4.json: 'Green'
    

Leg B: sixty slow-image POST /v1/chat/completions requests to bedrock-claude, then a text-only gemini-flash request 1.5s later

  1. ./legs2.sh 27860 33721 before (this case is its Leg B block)

  2. Observed:

    liveliness during bedrock-claude fan-out: 200 0.005974s
    text-only gemini-flash during bedrock-claude fan-out: 200 8.326545s
    bedrock-claude fan-out statuses:  1 200 10.057789s; 1 200 10.171649s; 1 200 10.181965s; 1 200 10.182413s; 1 200 10.190685s; 1 200 10.199946s; 1 200 10.239270s; 1 200 10.247684s; 1 200 10.250883s; 1 200 10.261392s; 1 200 10.292393s; 1 200 10.293122s; 1 200 10.308770s; 1 200 10.316842s; 1 200 10.323929s; 1 200 10.330383s; 1 200 10.332194s; 1 200 10.336476s; 1 200 10.339445s; 1 200 10.355821s; 1 200 10.384758s; 1 200 10.408477s; 1 200 10.439144s; 1 200 10.454099s; 1 200 10.456775s; 1 200 10.463339s; 1 200 10.466919s; 1 200 10.510786s; 1 200 10.530796s; 1 200 10.531463s; 1 200 10.548740s; 1 200 10.550126s; 1 200 10.556436s; 1 200 10.561181s; 1 200 10.598819s; 1 200 10.599301s; 1 200 10.605330s; 1 200 10.633239s; 1 200 10.678077s; 1 200 10.821419s; 1 200 10.823098s; 1 200 10.929305s; 1 200 11.141144s; 1 200 11.190334s; 1 200 17.781713s; 1 200 17.808758s; 1 200 17.811938s; 1 200 17.816808s; 1 200 17.866735s; 1 200 17.869487s; 1 200 17.886117s; 1 200 17.925944s; 1 200 17.926405s; 1 200 17.967898s; 1 200 17.994850s; 1 200 18.003046s; 1 200 18.038662s; 1 200 18.087795s; 1 200 18.233468s; 1 200 23.181707s;
    bedrock-claude-1.json: 'Green'
    bedrock-claude-60.json: 'Light green (or pale yellow-green)'
    

Leg C: sixty slow-image POST /v1/chat/completions requests to snowflake-claude, then a text-only gemini-flash request 1.5s later

  1. ./legs2.sh 27860 33721 before (this case is its Leg C block)

  2. Observed:

    liveliness during snowflake-claude fan-out: 200 0.017875s
    text-only gemini-flash during snowflake-claude fan-out: 200 0.691714s
    snowflake-claude fan-out statuses:  1 401 16.600337s; 1 401 16.664819s; 1 401 16.677705s; 1 401 16.683559s; 1 401 16.736300s; 1 401 16.756485s; 1 401 16.763081s; 1 401 16.774895s; 1 401 16.813424s; 1 401 16.813494s; 1 401 16.823661s; 1 401 16.824849s; 1 401 16.830573s; 1 401 16.830582s; 1 401 16.855055s; 1 401 16.902046s; 1 401 16.903496s; 1 401 16.910629s; 1 401 16.912964s; 1 401 16.922557s; 1 401 9.338317s; 1 401 9.347142s; 1 401 9.381436s; 1 401 9.383759s; 1 401 9.384433s; 1 401 9.392201s; 1 401 9.392997s; 1 401 9.397101s; 1 401 9.406563s; 1 401 9.428680s; 1 401 9.462587s; 1 401 9.478250s; 1 401 9.482409s; 1 401 9.497745s; 1 401 9.498182s; 1 401 9.498610s; 1 401 9.499172s; 1 401 9.502040s; 1 401 9.505005s; 1 401 9.527294s; 1 401 9.538405s; 1 401 9.545280s; 1 401 9.582030s; 1 401 9.584397s; 1 401 9.584540s; 1 401 9.586460s; 1 401 9.600019s; 1 401 9.618032s; 1 401 9.619211s; 1 401 9.658011s; 1 401 9.700470s; 1 401 9.724321s; 1 401 9.725555s; 1 401 9.745353s; 1 401 9.768114s; 1 401 9.775182s; 1 401 9.780076s; 1 401 9.798909s; 1 401 9.800759s; 1 401 9.821151s;
    snowflake-claude-1.json: {"error": {"message": "litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}. Received Model Group=snowflake-claude\nAvailable Model Group Fallbacks=None", "type": 
    snowflake-claude-60.json: {"error": {"message": "litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}. Received Model Group=snowflake-claude\nAvailable Model Group Fallbacks=None", "type":
    

Leg D: four slow-image POST /v1/responses requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg D block)

  2. Observed:

    liveliness 200 0.023551s
    liveliness 200 8.074444s
    liveliness 200 0.007715s
    liveliness 200 0.032338s
    liveliness 200 0.021511s
    liveliness 200 0.004193s
    liveliness 200 0.064014s
    liveliness 200 0.009584s
    liveliness 200 0.027752s
    liveliness 200 0.063069s
    liveliness 200 0.023015s
    liveliness 200 0.020195s
    liveliness 200 0.007075s
    liveliness 200 0.029575s
    gemini-flash /v1/responses statuses:  1 200 11.555699s; 1 200 25.807477s; 1 200 25.873586s; 1 200 26.064079s;
    D-1.json: ['Green']
    D-2.json: ['Green']
    D-3.json: ['Green']
    D-4.json: ['Green']
    

Leg E: four slow-image POST /v1/messages requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg E block)

  2. Observed:

    liveliness 200 0.014578s
    liveliness 200 7.489103s
    liveliness 200 0.012780s
    liveliness 200 0.056922s
    liveliness 200 0.066001s
    liveliness 200 0.095501s
    liveliness 200 0.059967s
    liveliness 200 0.006522s
    liveliness 200 0.115628s
    liveliness 200 0.004222s
    liveliness 200 0.016899s
    liveliness 200 0.023660s
    liveliness 200 0.130916s
    liveliness 200 0.012927s
    gemini-flash /v1/messages statuses:  1 200 24.945825s; 1 200 26.460071s; 1 200 26.559774s; 1 200 9.706392s;
    E-1.json: ['Green']
    E-2.json: ['Green']
    E-3.json: ['Green']
    E-4.json: ['Green']
    

Leg F: one POST /v1/chat/completions to gemini-flash carrying 25 distinct slow images (2s each) while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg F block)

  2. Observed:

    liveliness 200 0.017853s
    liveliness 200 0.003232s
    liveliness 200 0.037628s
    liveliness 200 0.024338s
    liveliness 200 0.002947s
    liveliness 200 0.024507s
    liveliness 200 0.043647s
    liveliness 200 0.012306s
    liveliness 200 0.123890s
    liveliness 200 0.022879s
    liveliness 200 0.045612s
    liveliness 200 0.008307s
    liveliness 200 0.081969s
    liveliness 200 0.012621s
    gemini-flash 25-image request: 200 55.027445s
    F.json: 'Green'
    

Leg G: four slow-image streaming POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg G block)

  2. Observed:

    liveliness 200 0.087298s
    liveliness 200 15.463339s
    liveliness 200 0.015557s
    liveliness 200 0.011075s
    liveliness 200 0.001576s
    liveliness 200 0.007771s
    liveliness 200 0.015580s
    liveliness 200 0.022132s
    liveliness 200 0.002108s
    liveliness 200 0.053563s
    liveliness 200 0.004373s
    liveliness 200 0.038301s
    liveliness 200 0.013461s
    liveliness 200 0.024303s
    gemini-flash streaming statuses:  1 200 17.811358s; 1 200 18.621354s; 1 200 21.046239s; 1 200 22.157824s;
    G-1.sse: 4 data lines, content='Green'
    G-2.sse: 4 data lines, content='Green'
    G-3.sse: 4 data lines, content='Green'
    G-4.sse: 4 data lines, content='Green'
    

Leg H: four slow-image POST /v1/chat/completions requests to vertex-gemini (http:// image) while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg H block)

  2. Observed:

    liveliness 200 0.059530s
    liveliness 200 16.107027s
    liveliness 200 0.001947s
    liveliness 200 0.093177s
    liveliness 200 0.031965s
    liveliness 200 0.008541s
    liveliness 200 0.013077s
    liveliness 200 0.001574s
    liveliness 200 0.002148s
    liveliness 200 0.044215s
    liveliness 200 0.016169s
    liveliness 200 0.018522s
    liveliness 200 0.001409s
    liveliness 200 0.020926s
    vertex-gemini /v1/chat/completions statuses:  1 200 19.563894s; 1 200 20.152004s; 1 200 20.446966s; 1 200 21.862848s;
    H-1.json: 'Green'
    H-2.json: 'Green'
    H-3.json: 'Green'
    H-4.json: 'Green'
    

Leg I: four slow-image POST /v1/messages requests to bedrock-claude while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg I block)

  2. Observed:

    liveliness 200 0.010630s
    liveliness 200 0.027212s
    liveliness 200 0.006695s
    liveliness 200 0.023165s
    liveliness 200 0.011497s
    liveliness 200 0.112291s
    liveliness 200 0.028831s
    liveliness 200 0.005588s
    liveliness 200 0.019265s
    liveliness 200 0.002974s
    liveliness 200 0.015932s
    liveliness 200 0.003640s
    liveliness 200 0.032093s
    liveliness 200 0.011092s
    bedrock-claude /v1/messages statuses:  1 400 1.642315s; 1 400 1.651810s; 1 400 1.652776s; 1 400 1.657673s;
    I-1.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-2.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-3.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-4.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    

Leg J: one slow-image POST /v1/chat/completions request to bedrock-mantle

  1. ./legs2.sh 27860 33721 before (this case is its Leg J block)

  2. Observed:

    200 9.951565s
    J-1.json: 'Green'
    

Leg K: one multipart POST /v1/images/edits to openai-image-edit (openai/gpt-image-2) with a 64x64 PNG upload

  1. ./legs2.sh 27860 33721 before (this case is its Leg K block)

  2. Observed:

    200 11.858751s
    data[0] keys: ['b64_json', 'revised_prompt', 'url'] | b64_json bytes: 1076752 | usage: {'total_tokens': 226, 'input_tokens': 30, 'input_tokens_details': {'image_tokens': 16, 'text_tokens': 14}, 'output_tokens': 196, 'output_tokens_details': {'image_tokens': 196, 'text_tokens': 0}}
    

Leg L: four slow-image streaming POST /v1/chat/completions requests to bedrock-claude while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg L block)

  2. Observed:

    liveliness 200 0.008131s
    liveliness 200 0.074661s
    liveliness 200 0.002029s
    liveliness 200 0.019902s
    liveliness 200 0.011479s
    liveliness 200 0.131295s
    liveliness 200 0.001874s
    liveliness 200 0.049633s
    liveliness 200 0.001803s
    liveliness 200 0.066251s
    liveliness 200 0.037392s
    liveliness 200 0.017065s
    liveliness 200 0.001664s
    liveliness 200 0.017111s
    bedrock-claude streaming statuses:  1 200 10.105726s; 1 200 10.236128s; 1 200 10.297134s; 1 200 9.863158s;
    L-1.sse: 3 data lines, content='Green'
    L-2.sse: 3 data lines, content='Green'
    L-3.sse: 7 data lines, content='Light green (pale yellow-green).'
    L-4.sse: 3 data lines, content='Green'
    

Leg M: two slow-image streaming POST /v1/chat/completions requests to bedrock-mantle while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg M block)

  2. Observed:

    liveliness 200 0.028569s
    liveliness 200 0.027633s
    liveliness 200 0.025094s
    liveliness 200 0.094139s
    liveliness 200 0.001603s
    liveliness 200 0.084223s
    liveliness 200 0.002197s
    liveliness 200 0.010986s
    liveliness 200 0.001537s
    liveliness 200 0.023800s
    liveliness 200 0.001868s
    liveliness 200 0.060515s
    liveliness 200 0.012578s
    liveliness 200 0.001839s
    bedrock-mantle streaming statuses:  1 200 10.829667s; 1 200 9.787816s;
    M-1.sse: 3 data lines, content='Yellow'
    M-2.sse: 3 data lines, content='Green'
    

Leg N: four slow-image streaming POST /v1/chat/completions requests to snowflake-claude while probing GET /health/liveliness

  1. ./legs2.sh 27860 33721 before (this case is its Leg N block)

  2. Observed:

    liveliness 200 0.005367s
    liveliness 200 0.004807s
    liveliness 200 0.110980s
    liveliness 200 0.001887s
    liveliness 200 0.040687s
    liveliness 200 0.002478s
    liveliness 200 0.004337s
    liveliness 200 0.002181s
    liveliness 200 0.016603s
    liveliness 200 0.001846s
    liveliness 200 0.041564s
    liveliness 200 0.001350s
    liveliness 200 0.006812s
    liveliness 200 0.009311s
    snowflake-claude streaming statuses:  1 401 8.208684s; 1 401 8.235754s; 1 401 8.514115s; 1 401 8.526401s;
    N-1.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-2.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-3.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-4.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    
  3. The Snowflake stand-in logged what the proxy sent it, image already inlined as base64, and dumped every request body from Legs C and N; the md5 set is what the byte-for-byte comparison below uses:

    00:46:01 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    00:46:01 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    00:46:01 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    ### sink bodies (before): 64 Snowflake request bodies, 2 distinct md5: 3fa89044cf314831a5112345c9659ca0 4aa896f8c3ad70b4c208a76a21b16d1a
    

After (59e000d)

Leg A: four slow-image POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg A block)

  2. Observed:

    liveliness 200 0.501437s
    liveliness 200 0.010079s
    liveliness 200 1.158359s
    liveliness 200 0.542149s
    liveliness 200 0.011563s
    liveliness 200 0.001207s
    liveliness 200 0.011217s
    liveliness 200 0.015655s
    liveliness 200 0.002062s
    liveliness 200 0.019021s
    liveliness 200 0.035424s
    liveliness 200 0.011285s
    liveliness 200 0.002853s
    liveliness 200 0.001621s
    gemini-flash /v1/chat/completions statuses:  1 200 14.477364s; 1 200 14.632350s; 1 200 14.809199s; 1 200 15.582312s;
    A-1.json: 'Green'
    A-2.json: 'Green'
    A-3.json: 'Green'
    A-4.json: 'Green'
    

Leg B: sixty slow-image POST /v1/chat/completions requests to bedrock-claude, then a text-only gemini-flash request 1.5s later

  1. ./legs2.sh 40862 33721 after (this case is its Leg B block)

  2. Observed:

    liveliness during bedrock-claude fan-out: 200 0.036534s
    text-only gemini-flash during bedrock-claude fan-out: 200 0.719962s
    bedrock-claude fan-out statuses:  1 200 10.016886s; 1 200 10.026277s; 1 200 10.030642s; 1 200 10.032396s; 1 200 10.055540s; 1 200 10.062012s; 1 200 10.067923s; 1 200 10.097481s; 1 200 10.099617s; 1 200 10.105019s; 1 200 10.110740s; 1 200 10.111667s; 1 200 10.154957s; 1 200 10.192878s; 1 200 10.199646s; 1 200 10.207299s; 1 200 10.215083s; 1 200 10.233090s; 1 200 10.237775s; 1 200 10.248531s; 1 200 10.301148s; 1 200 10.311677s; 1 200 10.312759s; 1 200 10.326560s; 1 200 10.336491s; 1 200 10.398379s; 1 200 10.434263s; 1 200 10.463480s; 1 200 10.477212s; 1 200 10.477372s; 1 200 10.497488s; 1 200 10.520453s; 1 200 10.617726s; 1 200 10.627198s; 1 200 10.665527s; 1 200 10.712409s; 1 200 10.728540s; 1 200 10.769741s; 1 200 10.801855s; 1 200 10.926483s; 1 200 11.021059s; 1 200 11.447064s; 1 200 11.539722s; 1 200 11.735918s; 1 200 11.803694s; 1 200 9.681634s; 1 200 9.747272s; 1 200 9.844002s; 1 200 9.846286s; 1 200 9.865999s; 1 200 9.880651s; 1 200 9.883280s; 1 200 9.894377s; 1 200 9.912028s; 1 200 9.913623s; 1 200 9.936763s; 1 200 9.960131s; 1 200 9.963382s; 1 200 9.977339s; 1 200 9.985534s;
    bedrock-claude-1.json: 'Light green'
    bedrock-claude-60.json: 'Green'
    

Leg C: sixty slow-image POST /v1/chat/completions requests to snowflake-claude, then a text-only gemini-flash request 1.5s later

  1. ./legs2.sh 40862 33721 after (this case is its Leg C block)

  2. Observed:

    liveliness during snowflake-claude fan-out: 200 0.071397s
    text-only gemini-flash during snowflake-claude fan-out: 200 0.993454s
    snowflake-claude fan-out statuses:  1 401 8.454158s; 1 401 8.480353s; 1 401 8.490546s; 1 401 8.498134s; 1 401 8.547810s; 1 401 8.554575s; 1 401 8.569055s; 1 401 8.576450s; 1 401 8.579719s; 1 401 8.586909s; 1 401 8.622640s; 1 401 8.637351s; 1 401 8.655817s; 1 401 8.674557s; 1 401 8.678704s; 1 401 8.681035s; 1 401 8.684314s; 1 401 8.686708s; 1 401 8.697792s; 1 401 8.703641s; 1 401 8.709616s; 1 401 8.712062s; 1 401 8.721200s; 1 401 8.738682s; 1 401 8.744853s; 1 401 8.752777s; 1 401 8.755843s; 1 401 8.756788s; 1 401 8.763417s; 1 401 8.766982s; 1 401 8.772171s; 1 401 8.772957s; 1 401 8.773156s; 1 401 8.784313s; 1 401 8.812645s; 1 401 8.826817s; 1 401 8.833262s; 1 401 8.836504s; 1 401 8.841869s; 1 401 8.850647s; 1 401 8.878649s; 1 401 8.891125s; 1 401 8.927969s; 1 401 8.966787s; 1 401 8.972821s; 1 401 8.987093s; 1 401 9.030853s; 1 401 9.051213s; 1 401 9.099971s; 1 401 9.148085s; 1 401 9.214088s; 1 401 9.218233s; 1 401 9.242733s; 1 401 9.338477s; 1 401 9.368351s; 1 401 9.390322s; 1 401 9.416463s; 1 401 9.464186s; 1 401 9.655297s; 1 401 9.831206s;
    snowflake-claude-1.json: {"error": {"message": "litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}. Received Model Group=snowflake-claude\nAvailable Model Group Fallbacks=None", "type": 
    snowflake-claude-60.json: {"error": {"message": "litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}. Received Model Group=snowflake-claude\nAvailable Model Group Fallbacks=None", "type":
    

Leg D: four slow-image POST /v1/responses requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg D block)

  2. Observed:

    liveliness 200 0.018948s
    liveliness 200 0.008299s
    liveliness 200 0.001059s
    liveliness 200 0.003126s
    liveliness 200 0.001767s
    liveliness 200 0.003487s
    liveliness 200 0.005026s
    liveliness 200 0.081797s
    liveliness 200 0.001289s
    liveliness 200 0.009036s
    liveliness 200 0.014406s
    liveliness 200 0.003371s
    liveliness 200 0.003755s
    liveliness 200 0.004115s
    gemini-flash /v1/responses statuses:  1 200 10.164690s; 1 200 10.503632s; 1 200 9.818102s; 1 200 9.865724s;
    D-1.json: ['Green']
    D-2.json: ['Green']
    D-3.json: ['Green']
    D-4.json: ['Green']
    

Leg E: four slow-image POST /v1/messages requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg E block)

  2. Observed:

    liveliness 200 0.001673s
    liveliness 200 0.001083s
    liveliness 200 0.002249s
    liveliness 200 0.002328s
    liveliness 200 0.001051s
    liveliness 200 0.001429s
    liveliness 200 0.074385s
    liveliness 200 0.002647s
    liveliness 200 0.007770s
    liveliness 200 0.004105s
    liveliness 200 0.003093s
    liveliness 200 0.069210s
    liveliness 200 0.102740s
    liveliness 200 0.105743s
    gemini-flash /v1/messages statuses:  1 200 10.518854s; 1 200 9.585577s; 1 200 9.603204s; 1 200 9.817920s;
    E-1.json: ['Green']
    E-2.json: ['Green']
    E-3.json: ['Green']
    E-4.json: ['Green']
    

Leg F: one POST /v1/chat/completions to gemini-flash carrying 25 distinct slow images (2s each) while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg F block)

  2. Observed:

    liveliness 200 0.063318s
    liveliness 200 0.008675s
    liveliness 200 0.015382s
    liveliness 200 0.001342s
    liveliness 200 0.016813s
    liveliness 200 0.022303s
    liveliness 200 0.003123s
    liveliness 200 0.033140s
    liveliness 200 0.005081s
    liveliness 200 0.102215s
    liveliness 200 0.020878s
    liveliness 200 0.001397s
    liveliness 200 0.001447s
    liveliness 200 0.003602s
    gemini-flash 25-image request: 200 7.257004s
    F.json: 'Green'
    

Leg G: four slow-image streaming POST /v1/chat/completions requests to gemini-flash while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg G block)

  2. Observed:

    liveliness 200 0.001539s
    liveliness 200 0.009175s
    liveliness 200 0.007761s
    liveliness 200 0.005762s
    liveliness 200 0.046664s
    liveliness 200 0.002070s
    liveliness 200 0.429205s
    liveliness 200 0.010919s
    liveliness 200 0.006914s
    liveliness 200 0.049944s
    liveliness 200 0.002389s
    liveliness 200 0.024479s
    liveliness 200 0.044914s
    liveliness 200 0.001679s
    gemini-flash streaming statuses:  1 200 12.198774s; 1 200 9.512559s; 1 200 9.540434s; 1 200 9.648360s;
    G-1.sse: 4 data lines, content='Green'
    G-2.sse: 4 data lines, content='Green'
    G-3.sse: 4 data lines, content='Green'
    G-4.sse: 4 data lines, content='Green'
    

Leg H: four slow-image POST /v1/chat/completions requests to vertex-gemini (http:// image) while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg H block)

  2. Observed:

    liveliness 200 0.041000s
    liveliness 200 0.047122s
    liveliness 200 0.069557s
    liveliness 200 0.087121s
    liveliness 200 0.002333s
    liveliness 200 0.044270s
    liveliness 200 0.036427s
    liveliness 200 0.001882s
    liveliness 200 0.076036s
    liveliness 200 0.033180s
    liveliness 200 0.013576s
    liveliness 200 0.028294s
    liveliness 200 0.034547s
    liveliness 200 0.045799s
    vertex-gemini /v1/chat/completions statuses:  1 200 10.164444s; 1 200 10.301205s; 1 200 10.337708s; 1 200 10.577598s;
    H-1.json: 'Green'
    H-2.json: 'Green'
    H-3.json: 'Green'
    H-4.json: 'Green'
    

Leg I: four slow-image POST /v1/messages requests to bedrock-claude while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg I block)

  2. Observed:

    liveliness 200 0.018292s
    liveliness 200 0.023035s
    liveliness 200 0.005147s
    liveliness 200 0.036767s
    liveliness 200 0.004073s
    liveliness 200 0.010990s
    liveliness 200 0.063364s
    liveliness 200 0.027420s
    liveliness 200 0.009023s
    liveliness 200 0.013779s
    liveliness 200 0.015440s
    liveliness 200 0.166453s
    liveliness 200 0.008016s
    liveliness 200 0.029515s
    bedrock-claude /v1/messages statuses:  1 400 1.414902s; 1 400 1.599636s; 1 400 1.997423s; 1 400 2.079124s;
    I-1.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-2.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-3.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    I-4.json: {"type": "error", "error": {"type": "invalid_request_error", "message": "litellm.BadRequestError: BedrockException - {\"message\":\"URL content sources are not yet supported for this model\"}. Receive
    

Leg J: one slow-image POST /v1/chat/completions request to bedrock-mantle

  1. ./legs2.sh 40862 33721 after (this case is its Leg J block)

  2. Observed:

    200 10.791926s
    J-1.json: 'Yellow'
    

Leg K: one multipart POST /v1/images/edits to openai-image-edit (openai/gpt-image-2) with a 64x64 PNG upload

  1. ./legs2.sh 40862 33721 after (this case is its Leg K block)

  2. Observed:

    200 11.456388s
    data[0] keys: ['b64_json', 'revised_prompt', 'url'] | b64_json bytes: 1079708 | usage: {'total_tokens': 226, 'input_tokens': 30, 'input_tokens_details': {'image_tokens': 16, 'text_tokens': 14}, 'output_tokens': 196, 'output_tokens_details': {'image_tokens': 196, 'text_tokens': 0}}
    

Leg L: four slow-image streaming POST /v1/chat/completions requests to bedrock-claude while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg L block)

  2. Observed:

    liveliness 200 0.141223s
    liveliness 200 0.053637s
    liveliness 200 0.103270s
    liveliness 200 0.006835s
    liveliness 200 0.072808s
    liveliness 200 0.046978s
    liveliness 200 0.009504s
    liveliness 200 0.002858s
    liveliness 200 0.014867s
    liveliness 200 0.022449s
    liveliness 200 0.059872s
    liveliness 200 0.121233s
    liveliness 200 0.081259s
    liveliness 200 0.051974s
    bedrock-claude streaming statuses:  1 200 10.660733s; 1 200 11.046837s; 1 200 11.077182s; 1 200 11.093714s;
    L-1.sse: 4 data lines, content='Light green'
    L-2.sse: 3 data lines, content='Green'
    L-3.sse: 3 data lines, content='Green'
    L-4.sse: 4 data lines, content='Yellow'
    

Leg M: two slow-image streaming POST /v1/chat/completions requests to bedrock-mantle while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg M block)

  2. Observed:

    liveliness 200 0.087269s
    liveliness 200 0.110248s
    liveliness 200 0.007292s
    liveliness 200 0.167550s
    liveliness 200 0.105137s
    liveliness 200 0.007502s
    liveliness 200 0.023945s
    liveliness 200 0.006442s
    liveliness 200 0.029443s
    liveliness 200 0.005037s
    liveliness 200 0.019705s
    liveliness 200 0.022381s
    liveliness 200 0.061734s
    liveliness 200 0.019024s
    bedrock-mantle streaming statuses:  1 200 10.367191s; 1 200 10.465278s;
    M-1.sse: 4 data lines, content='Light green'
    M-2.sse: 3 data lines, content='Green'
    

Leg N: four slow-image streaming POST /v1/chat/completions requests to snowflake-claude while probing GET /health/liveliness

  1. ./legs2.sh 40862 33721 after (this case is its Leg N block)

  2. Observed:

    liveliness 200 0.013795s
    liveliness 200 0.039336s
    liveliness 200 0.004879s
    liveliness 200 0.017927s
    liveliness 200 0.002537s
    liveliness 200 0.033087s
    liveliness 200 0.001915s
    liveliness 200 0.026295s
    liveliness 200 0.008804s
    liveliness 200 0.032482s
    liveliness 200 0.036720s
    liveliness 200 0.004367s
    liveliness 200 0.173206s
    liveliness 200 0.027331s
    snowflake-claude streaming statuses:  1 401 10.600001s; 1 401 10.838317s; 1 401 10.885136s; 1 401 9.897071s;
    N-1.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-2.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-3.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    N-4.sse: 0 data lines, content='<no SSE data; body starts: {"error":{"message":"litellm.AuthenticationError: SnowflakeException - {\"message\": \"invalid token (sink)\"}>'
    
  3. The Snowflake stand-in logged what the proxy sent it, image already inlined as base64, and dumped every request body from Legs C and N; the md5 set is what the byte-for-byte comparison below uses:

    01:09:34 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    01:09:34 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    01:09:35 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']
    ### sink bodies (after): 64 Snowflake request bodies, 2 distinct md5: 3fa89044cf314831a5112345c9659ca0 4aa896f8c3ad70b4c208a76a21b16d1a
    

Observations from the run:

  • Legs B and C Before: the sixty requests finish in two waves one image download apart (44 then 16 on Bedrock, 40 then 20 on Snowflake: the executor pool is 22 threads per worker on 18 cores, two workers); After: one wave each
  • Leg B After: the 9.7 to 11.8 second spread is Bedrock's own latency at sixty concurrent calls; the image download is the same 8 seconds for every request
  • Legs C and N: the Snowflake stand-in answers 401 on purpose; the sixty Leg C bodies hash to one md5 (4aa896f8c3ad70b4c208a76a21b16d1a) and the four streaming Leg N bodies to another (3fa89044cf314831a5112345c9659ca0), and both md5s are identical Before and After, so the bytes Snowflake receives are unchanged
  • Leg A Before: two requests finished at 19.0s and the other two queued behind their downloads until 21.2s and 22.1s; After: the 1.2 second worst probe is box load (load 20 plus on 18 cores during that leg), every other After leg keeps the probes under 0.5 seconds
  • Leg H Before: the http:// image on Vertex AI went through the sync fetcher inside the async body builder and stalled the loop for 16.1 seconds; After: the walker inlines it and the probes stay at milliseconds
  • Leg I: Bedrock invoke Claude through the native /v1/messages route never downloads anything on either side; it passes url sources to Bedrock, which rejects them in under a second. This PR does not touch that route
  • Leg J: Mantle downloads and then dispatches on both sides (its sync transform already ran on the executor); Claude's wording for the same yellow-green pixel varies run to run ("Green" Before, "Yellow" After; Legs B and L show both words on each side)
  • Leg K: the multipart upload never touches the URL fetcher; it proves the shared async_transform_image_edit_request default every image-edit provider now runs through, live against OpenAI, with the same 226 usage tokens on both sides
  • Legs L, M and N: the streaming paths of the three opted-in providers answer the same on both sides. Before, four streaming downloads at a time sat on executor threads and never filled the pool, so no stall shows at four (Leg B shows the pool filling at sixty); After, they run on the loop's async client like the non-streaming path
  • The first After run of this round lost one of the two uvicorn workers to a kernel memory-pressure kill on the shared box in the middle of Leg A (curl status 000 for one request, Child process [13663] died in the proxy log, a memorystatus kill storm in the system log at the same second, no Python crash report). The After leg was re-run in full once the box recovered, on the same proxy process with its replacement worker, and that run is the one above

Dependents check at this tip (lprr_delta3.sh, same two proxies): a blocked private address and a host that does not resolve both fail on the first attempt with the same fixed message instead of "after 3 attempts", with the same 400; Vertex AI still hands gs:// URIs and mime-hinted https URLs to Google unchanged (Google's robots.txt rejection is identical on both sides), and only downloads the extensionless https and http:// cases itself. Empty or cut-off answers on the 20-token probes are Gemini 3.8 flash spending the budget on reasoning, not a proxy difference: the same extensionless request with max_tokens: 200 answers "Puppy" before and "Dog" after

lprr_delta3.sh and both logs
#!/bin/zsh
# usage: lprr_delta3.sh <proxy port> <label>   (blocked-address image URLs and Vertex AI pass-through shapes)
P=$1; LABEL=$2; KEY="$(grep -E '^\s*master_key:' "$(dirname "$0")/config.yaml" | awk '{print $2}')"
BLOCKED="http://10.0.0.8/private.png?label=lprr3-$LABEL"
PICSUM="https://picsum.photos/id/237/200/200"
GS="gs://cloud-samples-data/generative-ai/image/scones.jpg"
img_body() { printf '{"model":"%s","max_tokens":20,"messages":[{"role":"user","content":[{"type":"text","text":"One word: what is in this image?"},{"type":"image_url","image_url":{"url":"%s"%s}}]}]}' "$1" "$2" "$3"; }
doc_body() { printf '{"model":"%s","max_tokens":20,"messages":[{"role":"user","content":[{"type":"text","text":"One word: what is this?"},{"type":"document","source":{"type":"url","url":"%s"}}]}]}' "$1" "$2"; }
run() { echo "## $LABEL $1 $2"; curl -s -m 120 -w '\nHTTP %{http_code} %{time_total}s\n' "http://127.0.0.1:$P/v1/chat/completions" -H "Authorization: Bearer $KEY" -H 'Content-Type: application/json' -d "$3" | python3 -c '
import sys,json
raw=sys.stdin.read(); body,_,tail=raw.rpartition("\nHTTP ")
try:
    j=json.loads(body)
    print(j["choices"][0]["message"]["content"][:160] if "choices" in j else ("error: "+str(j.get("error",{}).get("message",j))[:260]))
except Exception: print(body[:260])
print("HTTP "+tail.strip())'; }
for M in gemini-flash vertex-gemini bedrock-claude snowflake-claude bedrock-mantle; do run blocked-image $M "$(img_body $M "$BLOCKED" "")"; done
run blocked-document bedrock-claude "$(doc_body bedrock-claude "$BLOCKED")"
run unresolvable-image gemini-flash "$(img_body gemini-flash "http://image-host-that-does-not-exist.invalid/cat.png?label=lprr3-$LABEL" "")"
run unresolvable-image bedrock-claude "$(img_body bedrock-claude "http://image-host-that-does-not-exist.invalid/cat.png?label=lprr3-$LABEL" "")"
run https-extensionless vertex-gemini "$(img_body vertex-gemini "$PICSUM" "")"
run https-extensionless-format vertex-gemini "$(img_body vertex-gemini "$PICSUM" ',"format":"image/jpeg"')"
run gs-uri vertex-gemini "$(img_body vertex-gemini "$GS" "")"
run https-extensionless gemini-flash "$(img_body gemini-flash "$PICSUM" "")"
echo "sink last: $(grep -E 'GET|POST' ~/.claude/detached/lit6923-img5.log | tail -1 | cut -c1-120)"

Before (29ac88e):

## before blocked-image gemini-flash
error: litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before. Received Model Group=gemini-flash
Available Model Group Fallbacks=None
HTTP 400 2.259560s
## before blocked-image vertex-gemini
error: litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before. Received Model Group=vertex-gemini
Available Model Group Fallbacks=None
HTTP 400 0.198713s
## before blocked-image bedrock-claude
error: litellm.BadRequestError: BedrockException - litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before
Received Messages=[{'role': 'user', 'content': [{'type': 'text', 'text': 'One word: 
HTTP 400 0.133009s
## before blocked-image snowflake-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before. Received Model Group=snowflake-claude
Available Model Group Fallbacks=None
HTTP 400 0.067934s
## before blocked-image bedrock-mantle
error: litellm.BadRequestError: BedrockException - litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before
Received Messages=[{'role': 'user', 'content': [{'type': 'text', 'text': 'One word: 
HTTP 400 0.037435s
## before blocked-document bedrock-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://REDACTED/private.png?label=lprr3-before. Received Model Group=bedrock-claude
Available Model Group Fallbacks=None
HTTP 400 0.157440s
## before unresolvable-image gemini-flash
error: litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://image-host-that-does-not-exist.invalid/cat.png?label=lprr3-before. Received Model Group=gemini-flash
Available Model Group Fallbacks=None
HTTP 400 0.075476s
## before unresolvable-image bedrock-claude
error: litellm.BadRequestError: BedrockException - litellm.BadRequestError: Error: Unable to fetch image from URL after 3 attempts. url=http://image-host-that-does-not-exist.invalid/cat.png?label=lprr3-before
Received Messages=[{'role': 'user', 'content': [{'type': '
HTTP 400 0.082657s
## before https-extensionless vertex-gemini
{"id":"eMmbar_uNoWJ6tkPlZeUuA4","created":1788594552,"model":"vertex-gemini","object":"chat.completion","choices":[],"usage":{"completion_tokens":17,"prompt_tokens":1098,"total_tokens":1115,"completion_tokens_details":{"reasoning_tokens":17,"text_tokens":0},"p
HTTP 200 2.513520s
## before https-extensionless-format vertex-gemini
error: litellm.BadRequestError: Vertex_aiException BadRequestError - {
  "error": {
    "code": 400,
    "message": "Cannot fetch content from the provided URL. The URL is blocked by robots.txt rules. Please confirm the URL is allowed to be crawled.",
    "status": "
HTTP 400 0.527984s
## before gs-uri vertex-gemini
S
HTTP 200 1.406916s
## before https-extensionless gemini-flash
pu
HTTP 200 0.977217s
sink last: 00:49:07 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']

After (59e000d):

## after blocked-image gemini-flash
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.207561s
## after blocked-image vertex-gemini
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.019253s
## after blocked-image bedrock-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.021194s
## after blocked-image snowflake-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.038737s
## after blocked-image bedrock-mantle
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.195217s
## after blocked-document bedrock-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://REDACTED/private.png?label=lprr3-
HTTP 400 0.018438s
## after unresolvable-image gemini-flash
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://image-host-that-does-not-exist.in
HTTP 400 0.023163s
## after unresolvable-image bedrock-claude
error: litellm.BadRequestError: Error: Unable to fetch image from URL. The proxy could not resolve this host or its URL policy rejected it; an admin can check the proxy log and `user_url_allowed_hosts` in general_settings. url=http://image-host-that-does-not-exist.in
HTTP 400 0.016752s
## after https-extensionless vertex-gemini
{"id":"f8mbavfGDISRq8YP1aniyQw","created":1788594558,"model":"vertex-gemini","object":"chat.completion","choices":[],"usage":{"completion_tokens":16,"prompt_tokens":1098,"total_tokens":1114,"completion_tokens_details":{"reasoning_tokens":16,"text_tokens":0},"p
HTTP 200 1.954165s
## after https-extensionless-format vertex-gemini
error: litellm.BadRequestError: Vertex_aiException BadRequestError - {
  "error": {
    "code": 400,
    "message": "Cannot fetch content from the provided URL. The URL is blocked by robots.txt rules. Please confirm the URL is allowed to be crawled.",
    "status": "
HTTP 400 0.640704s
## after gs-uri vertex-gemini
{"id":"gcmbap3hKKCeq8YPqMG48Qc","created":1788594561,"model":"vertex-gemini","object":"chat.completion","choices":[],"usage":{"completion_tokens":17,"prompt_tokens":1089,"total_tokens":1106,"completion_tokens_details":{"reasoning_tokens":17,"text_tokens":0},"p
HTTP 200 1.754124s
## after https-extensionless gemini-flash
Pupp
HTTP 200 1.590143s
sink last: 00:49:07 POST /snowflake/api/v2/cortex/v1/messages sources=['image:base64:iVBORw0KGgoAAAANSUhEUgAA']

CI: the CircleCI pipelines at 5c8016e (89161) and 3920cf4 (89180) passed in full (43 of 43 jobs at 3920cf4); the two reds seen at earlier tips were staging breakages folded in by the staging merge: the integrations GitHub Actions job (LIT-7021, #39848) and proxy_store_model_in_db_tests (LIT-6949, #39842). The pipeline at 59e000d (89185) passed in full as well (43 of 43 jobs)

Type

🐛 Bug Fix

Caveats (if any)

Medium

  • The Snowflake leg only proves the proxy against a local sink that answers 401: there are no Snowflake Cortex credentials to run a live call, so the evidence that the transformed body still works is the byte-identical before and after request bodies the sink recorded plus the unit tests that drive SnowflakeCortexClaudeConfig through the async transform

Low

  • Anthropic direct http:// images, every remote image on Vertex AI Anthropic (force_base64), Ollama images and HF tokenizer fetches still download on the executor thread; those paths never blocked the loop and moving them means restructuring the Anthropic handler and the Ollama prompt factory, tracked in LIT-7028
  • The Black Forest Labs URL download only has unit-test proof: the proxy's /v1/images/edits route hands the transform uploaded bytes, so the on-loop download was reachable only from Python SDK callers passing an image URL, and there is no Black Forest Labs key to run a live edit against. Leg K proves the shared async_transform_image_edit_request default that every image-edit provider now runs through, live against OpenAI
  • The cheap string shaping in transform_request still runs on the loop inside async_transform_request; only the downloads, the SSRF DNS lookup, signing and pre-call logging leave it, and a thread hop for the string work would cost more than it saves
  • The SSRF DNS lookup, signing and pre-call logging take a default-executor slot after the async transform, so while the providers still on the sync fetcher (LIT-7028) saturate the pool, a Bedrock invoke or Snowflake request waits for a slot a second time; each hold is milliseconds where the download used to hold one for the whole fetch
  • The shared async_transform_image_edit_request default calls the sync transform_image_edit_request on the loop with no thread hop; only the Black Forest Labs override downloads off it, and Leg K is a no-regression check for OpenAI edits, not proof of an off-loop transform
  • OpenAI-compatible providers on the shared handler keep their sync transform on the executor thread; their existing async_transform_request override is only used by the OpenAI SDK handler and is deliberately not switched on here
  • Bedrock invoke Claude through the native /v1/messages route passes url image sources straight to Bedrock, which rejects them with a 400, before and after this PR
  • Gemini AI Studio Files API refs (generativelanguage.googleapis.com/v1beta/files/...) pass through unfetched, as before; other AI Studio file_id URLs that fail to download now return 400 naming the URL and status instead of passing through to Google
  • Mantle async requests now inline https images as base64 like the sync path already did
  • The Snowflake dispatch now honors a caller-supplied HTTP client instead of always building its own
  • Downloads beyond 20 distinct URLs in one request run in waves of 20; the cap is a constant, not a config knob, and there is still no per-fetch timeout or byte cap (LIT-6924); up to 20 raw downloads buffer at once before they land in the body as base64, where the sync path held every inlined image in the body too
  • A url-sourced document block whose URL ends in .pdf is sent as application/pdf whatever the host's content type, as the deleted converter did; url-sourced image blocks, which no path converted before, are now inlined too

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

  • 59e000d passes /live-pr-risk

@mateo-berri
mateo-berri requested a review from a team September 5, 2026 00:59
@codspeed

codspeed Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 31 untouched benchmarks


Comparing litellm_async_remote_image_fetch (59e000d) with litellm_internal_staging (29ac88e)

Open in CodSpeed

@greptile-apps

greptile-apps Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR moves remote-media processing off async request event loops while preserving provider-specific payload behavior.

  • Adds bounded concurrent remote image and file inlining for supported message shapes.
  • Enables async transforms for Snowflake Claude, Bedrock Invoke Claude, Mantle, Gemini, and Vertex Gemini.
  • Moves SSRF DNS validation, request signing, and pre-call logging off the event loop.
  • Adds async image-edit transformation support, including URL-based Black Forest Labs inputs.
  • Normalizes rejected or unresolvable URL errors and prevents retrying policy failures.
  • Adds regression coverage for async fetching, provider payloads, concurrency, cancellation, and URL validation behavior.

Confidence Score: 5/5

The PR appears safe to merge because no actionable new issue or outstanding previous finding remains.

There are no changes after the previous review SHA, all earlier findings are resolved, and the current diff preserves Gemini Files API pass-through while adding tested asynchronous media processing. The DNS-guidance thread was manually resolved without explanation; the two rule-related false positives were conceded, and the remaining compatibility thread was resolved.

Important Files Changed

Filename Overview
litellm/litellm_core_utils/prompt_templates/image_handling.py Adds bounded asynchronous remote-media discovery, fetching, cancellation, deduplication, and immutable message reconstruction.
litellm/litellm_core_utils/url_utils.py Moves DNS-backed URL validation to a worker thread for asynchronous safe fetches.
litellm/llms/custom_httpx/llm_http_handler.py Dispatches opted-in async provider transforms and moves signing and pre-call logging off the event loop.
litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py Routes Bedrock Invoke Claude remote media through the shared async inlining path before synchronous payload shaping.
litellm/llms/bedrock/chat/mantle/transformation.py Uses shared asynchronous media inlining while retaining Mantle-specific request restoration.
litellm/llms/gemini/chat/transformation.py Preserves Gemini Files API references instead of attempting to download them.
litellm/llms/vertex_ai/gemini/transformation.py Asynchronously inlines media only where required while preserving Gemini Files API, GCS, and MIME-hinted pass-through behavior.
litellm/llms/snowflake/chat/transformation.py Enables shared asynchronous media inlining for Snowflake Claude requests.
litellm/llms/black_forest_labs/image_edit/transformation.py Downloads URL-based image and mask inputs asynchronously before applying the existing image-edit transform.
litellm/llms/base_llm/image_edit/transformation.py Adds a default asynchronous image-edit transform hook that preserves existing provider behavior.
litellm/main.py Honors an injected Snowflake HTTP client while retaining the existing fallback client lifecycle.
tests/test_litellm/litellm_core_utils/test_image_handling.py Covers remote-media shapes, concurrency limits, deduplication, cancellation, immutability, and SSRF failure behavior.

Reviews (8): Last reviewed commit: "Merge remote-tracking branch 'origin/lit..." | Re-trigger Greptile

)
if not remote_urls:
return messages
data_urls: Final = await asyncio.gather(*(async_convert_url_to_base64(url) for url in remote_urls))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Low: Unbounded concurrent media downloads

An authenticated caller can include an arbitrary number of unique remote media parts, causing gather to start all downloads concurrently and retain every base64 result. The per-file size limit does not cap aggregate memory or connection usage, so a small request containing many URLs can exhaust a proxy worker. Use a bounded worker pool or semaphore, enforce a maximum URL count and aggregate byte limit, and cancel remaining downloads when one fails.

@veria-ai

veria-ai Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

This pull request moves remote image fetching off the event loop for Snowflake, Bedrock Claude invocation, Mantle, and Gemini integrations. It also updates shared media handling and Gemini request transformation behavior.

Two security issues remain open after one was addressed. Gemini file references can bypass tenant ownership controls, allowing an authenticated caller who knows another tenant’s file URI to expose that file through the shared Gemini credentials. Remote media downloads also lack concurrency and aggregate resource limits, which could allow authenticated callers to exhaust proxy worker resources.

Open issues (2)

Fixed/addressed: 1 · PR risk: 7/10

@codecov

codecov Bot commented Sep 5, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.03846% with 2 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
...ellm_core_utils/prompt_templates/image_handling.py 99.20% 1 Missing ⚠️
litellm/llms/custom_httpx/llm_http_handler.py 95.23% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

Gemini AI Studio file URIs under generativelanguage.googleapis.com/v1beta/files/
answer 403 when fetched and must pass through as file_data.file_uri, which the
sync transform already did. Give the shared walker a skip_url_prefixes parameter,
pass that prefix from the Gemini body builder, and skip it in the AI Studio
message transform for both image_url and file parts

if _openai_messages_may_need_sync_gcs_metadata_fetch(messages):
inlined_messages: Final = (
await async_inline_remote_media(messages, skip_url_prefixes=(GEMINI_FILES_API_URI_PREFIX,))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Medium: Gemini file references bypass tenant ownership

This exemption, together with the new checks in litellm/llms/gemini/chat/transformation.py, forwards any caller-supplied Gemini Files API URI under the proxy's shared Gemini credentials. An authenticated user who obtains another tenant's file URI can reference it in a completion and ask the model to return its contents; validate the file against a proxy-managed owner/team record before forwarding it, or reject raw Files API URIs from untrusted requests.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Raw Gemini Files API URIs already passed through unchanged at the merge base. This PR keeps that. Ownership checks belong in the managed files layer.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the detail. I can't automatically confirm this is safe to dismiss, so I'm leaving the thread open for a maintainer to make the call.

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Document URLs still block the event loop
    • Extended async_inline_remote_media to also recognize native Anthropic image and document blocks with source.type=url so URL fetches always run on the async client instead of falling through to the sync converter or being forwarded to the provider.

Create PR

Or push these changes by commenting:

@cursor push af7ca373d1
Preview (af7ca373d1)
diff --git a/litellm/litellm_core_utils/prompt_templates/image_handling.py b/litellm/litellm_core_utils/prompt_templates/image_handling.py
--- a/litellm/litellm_core_utils/prompt_templates/image_handling.py
+++ b/litellm/litellm_core_utils/prompt_templates/image_handling.py
@@ -149,6 +149,15 @@
     url: str
 
 
+@dataclass(frozen=True, slots=True)
+class _RemoteAnthropicSource:
+    part: Mapping[str, object]
+    url: str
+
+
+_ANTHROPIC_MEDIA_BLOCK_TYPES: Final = frozenset({"image", "document"})
+
+
 def _as_mapping(value: object) -> Mapping[str, object] | None:
     return value if isinstance(value, Mapping) else None  # pyright: ignore[reportUnknownVariableType]  # fields are parsed one by one
 
@@ -157,18 +166,27 @@
     return candidate if isinstance(candidate, str) and candidate.startswith(_REMOTE_URL_PREFIXES) else None
 
 
-def _parse_remote_part(part: object) -> _RemoteImage | _RemoteFile | None:
+def _parse_remote_part(part: object) -> _RemoteImage | _RemoteFile | _RemoteAnthropicSource | None:
     fields: Final = _as_mapping(part)
     if fields is None:
         return None
-    if fields.get("type") == "image_url":
+    part_type: Final = fields.get("type")
+    if part_type == "image_url":
         image_url: Final = fields.get("image_url")
         image_url_fields: Final = _as_mapping(image_url)
         url: Final = _remote_url(image_url_fields.get("url") if image_url_fields is not None else image_url)
         return _RemoteImage(fields, image_url_fields, url) if url is not None else None
-    file: Final = _as_mapping(fields.get("file")) if fields.get("type") == "file" else None
-    file_url: Final = _remote_url(file.get("file_id")) if file is not None else None
-    return _RemoteFile(fields, file, file_url) if file is not None and file_url is not None else None
+    if part_type == "file":
+        file: Final = _as_mapping(fields.get("file"))
+        file_url: Final = _remote_url(file.get("file_id")) if file is not None else None
+        return _RemoteFile(fields, file, file_url) if file is not None and file_url is not None else None
+    if part_type in _ANTHROPIC_MEDIA_BLOCK_TYPES:
+        source: Final = _as_mapping(fields.get("source"))
+        source_url: Final = (
+            _remote_url(source.get("url")) if source is not None and source.get("type") == "url" else None
+        )
+        return _RemoteAnthropicSource(fields, source_url) if source_url is not None else None
+    return None
 
 
 _PDF_FORMAT: Final = MappingProxyType({"format": "application/pdf"})
@@ -187,12 +205,19 @@
     return {**kept, **_inferred_format(file, url), "file_data": data_url}  # mutable-ok: json-serialized part
 
 
-def _inline(remote: _RemoteImage | _RemoteFile, data_url: str) -> Mapping[str, object]:
+def _inlined_anthropic_source(data_url: str) -> Mapping[str, object]:
+    media_type, _, data = data_url.removeprefix("data:").partition(";base64,")
+    return {"type": "base64", "media_type": media_type, "data": data}  # mutable-ok: json-serialized source block
+
+
+def _inline(remote: _RemoteImage | _RemoteFile | _RemoteAnthropicSource, data_url: str) -> Mapping[str, object]:
     match remote:
         case _RemoteImage(part, image_url, _):
             return {**part, "image_url": _inlined_image_url(image_url, data_url)}  # mutable-ok: json-serialized part
         case _RemoteFile(part, file, url):
             return {**part, "file": _inlined_file(file, url, data_url)}  # mutable-ok: json-serialized message part
+        case _RemoteAnthropicSource(part, _):
+            return {**part, "source": _inlined_anthropic_source(data_url)}  # mutable-ok: json-serialized message part
 
 
 def _content_parts(message: Mapping[str, object]) -> tuple[object, ...]:

diff --git a/tests/test_litellm/litellm_core_utils/test_image_handling.py b/tests/test_litellm/litellm_core_utils/test_image_handling.py
--- a/tests/test_litellm/litellm_core_utils/test_image_handling.py
+++ b/tests/test_litellm/litellm_core_utils/test_image_handling.py
@@ -371,6 +371,53 @@
     assert async_only_image_fetch.fetched == []
 
 
+async def test_async_inline_remote_media_inlines_native_anthropic_url_sources(async_only_image_fetch):
+    """Native Anthropic ``image`` / ``document`` blocks with ``source.type=url`` must
+    also be walked, otherwise their URLs leak past the async inliner and get
+    fetched by the sync fallback on the event loop (Bedrock invoke) or forwarded
+    to the provider as-is (Mantle)."""
+    image_source_url = f"http://img.example/{uuid.uuid4()}.png"
+    document_source_url = f"http://docs.example/{uuid.uuid4()}.png"
+    messages = [
+        {
+            "role": "user",
+            "content": [
+                {"type": "image", "source": {"type": "url", "url": image_source_url}},
+                {
+                    "type": "document",
+                    "source": {"type": "url", "url": document_source_url},
+                    "title": "Doc",
+                },
+                {
+                    "type": "image",
+                    "source": {"type": "base64", "media_type": "image/png", "data": "AAA="},
+                },
+            ],
+        }
+    ]
+    snapshot = copy.deepcopy(messages)
+
+    inlined = await async_inline_remote_media(messages)
+
+    assert inlined[0]["content"] == [
+        {
+            "type": "image",
+            "source": {"type": "base64", "media_type": "image/png", "data": async_only_image_fetch.base64_png},
+        },
+        {
+            "type": "document",
+            "source": {"type": "base64", "media_type": "image/png", "data": async_only_image_fetch.base64_png},
+            "title": "Doc",
+        },
+        {
+            "type": "image",
+            "source": {"type": "base64", "media_type": "image/png", "data": "AAA="},
+        },
+    ]
+    assert sorted(async_only_image_fetch.fetched) == sorted([image_source_url, document_source_url])
+    assert messages == snapshot
+
+
 async def test_async_inline_remote_media_raises_image_fetch_error_when_the_fetch_fails(monkeypatch):
     async def serve_404(client, url, **kwargs):
         return Response(404, request=Request("GET", url))

You can send follow-ups to the cloud agent here.

@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

… the event loop

The SSRF check in async_safe_get resolved DNS on the event loop and a blocked
address was retried three times; validate_url now runs in a thread and an
SSRFError fails the fetch on the first attempt in both fetchers. The shared
HTTP handler signed the request and ran pre_call logging on the loop after an
async transform; both now run in a thread. Vertex AI Gemini still fetched
http:// images and https images without an inferrable mime type with the sync
converter inside its async body builder; the walker takes a should_inline
predicate and Vertex AI inlines exactly those URLs, leaving https images with a
known mime type and Files API refs to Google. When one download fails the
other in-flight downloads for that request are now cancelled instead of
finishing in the background
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri removed the run-ci label Sep 5, 2026
…y verdict from callers

The image edit handler now awaits BaseImageEditConfig.async_transform_image_edit_request, and
Black Forest Labs overrides it so URL images and masks download through async_safe_get instead of
the blocking safe_get on the event loop. Rejected image fetches raise a fixed policy message with
the user_url_allowed_hosts hint rather than echoing the resolver's verdict (resolved IP, DNS
failure) back to the caller. The test fixture also fails any request-path call of the sync
convert_url_to_base64 so a regression cannot pass unnoticed.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

… instead of blaming the URL policy

validate_url raises HostResolutionError, a SSRFError subclass, for the two
DNS outcomes (lookup failed, no addresses). The image fetch helper maps
that to a "host could not be resolved" message and keeps the
user_url_allowed_hosts hint for the policy verdicts it can actually fix.
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
…itellm_async_remote_image_fetch

# Conflicts:
#	litellm/llms/black_forest_labs/image_edit/transformation.py
@mateo-berri mateo-berri added run-ci and removed run-ci labels Sep 5, 2026
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

1 similar comment
@mateo-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 59e000d. Configure here.

@tin-berri tin-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@mateo-berri
mateo-berri merged commit 9700f66 into litellm_internal_staging Sep 7, 2026
232 of 233 checks passed
@mateo-berri
mateo-berri deleted the litellm_async_remote_image_fetch branch September 7, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants