Skip to content

feat(decisions): send images to Cloudflare Clef from /v1/decisions and /v1/systemone - #45762

Closed
devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
litellm_clef_decisions_images
Closed

devin-ai-integration[bot] wants to merge 3 commits into
mainfrom
litellm_clef_decisions_images

Conversation

@devin-ai-integration

@devin-ai-integration devin-ai-integration Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

TLDR

Problem this solves:

  • Cloudflare Clef accepts up to 4 images, but the Decisions API refused them
  • /v1/decisions returned 400 on any input_image part
  • /v1/systemone silently dropped images, so Clef answered blind

How it solves it:

  • System One requests take an images list (data URLs or content_type + base64)
  • input_image parts on /v1/decisions are forwarded as Clef images
  • Providers opt in with supports_image_input, only Cloudflare does today
  • Other providers still refuse image requests instead of dropping images

User Flow

Before: a developer asking Clef about a screenshot either gets a 400 or a coin-flip answer

  1. They send POST https://litellm-domain/v1/decisions with a text part and an input_image data URL
  2. LiteLLM answers 400 input_image content parts are not supported because System One providers accept text input only
  3. They retry with POST https://litellm-domain/v1/systemone and "images": ["data:image/png;base64,..."]
  4. They get a 200, but Clef never saw the image, so answers hover near 50/50

After: both routes reach Clef with the image and the answers reflect what is in it

  1. They send the same POST https://litellm-domain/v1/decisions with the input_image part
  2. They get a 200 with confident answers about the image
  3. The same POST https://litellm-domain/v1/systemone with images returns the same confident answers

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/unit/<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

Real proxy, real Cloudflare Workers AI, no mocks. The image is a synthetic 64x64 red square PNG, base64 elided in the commands below. Config

model_list:
  - model_name: clef
    litellm_params:
      model: cloudflare/@cf/cloudflare/clef
      api_key: os.environ/CLOUDFLARE_API_KEY
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY

Questions asked are "Is the shape in the image red?" (predicate / noul) and "What shape is shown?" (choice of square or circle)

Before (f57906c)

/v1/decisions with input_image

  1. Send the request
  2. Rejected with 400
$ curl -s localhost:4001/v1/decisions -H "Authorization: Bearer $LITELLM_KEY" -d {"model":"clef","input":[{"role":"user","content":[{"type":"input_text","text":"What shape is this?"},{"type":"input_image","image_url":"data:image/png;base64,<red square png>"}]}],"questions":[...]}
{
    "error": {
        "message": "litellm.BadRequestError: Decisions provider 'cloudflare' cannot serve this request: input_image content parts are not supported because System One providers accept text input only\n\nLiteLLM: model group 'clef' failed with the error above. No fallback was attempted.",
        "type": "invalid_request_error",
        "param": null,
        "code": "400"
    }
}

/v1/systemone with images

  1. Send the request
  2. 200, but the image never reached Clef, so red is 0.35 and square vs circle is 0.53 vs 0.47 at 214 input tokens
$ curl -s localhost:4001/v1/systemone -H "Authorization: Bearer $LITELLM_KEY" -d {"model":"clef","state":"What shape is this?","images":["data:image/png;base64,<red square png>"],"questions":{...}}
{
    "model": "clef",
    "answers": {
        "red": {
            "type": "noul",
            "noul": 0.3467
        },
        "shape": {
            "type": "choice",
            "choice": "square",
            "confidence": 0.0027,
            "probabilities": {
                "square": 0.5259,
                "circle": 0.4741
            }
        }
    },
    "usage": {
        "input_tokens": 214,
        "output_tokens": 0
    }
}

After (83db782)

Last updated be88844, later commits only touch tests so this run still holds

/v1/decisions with input_image

  1. Send the same request
  2. 200, red 0.99 and square 0.99 at 281 input tokens, so the image reached Clef
$ curl -s localhost:4002/v1/decisions -H "Authorization: Bearer $LITELLM_KEY" -d {"model":"clef","input":[{"role":"user","content":[{"type":"input_text","text":"What shape is this?"},{"type":"input_image","image_url":"data:image/png;base64,<red square png>"}]}],"questions":[...]}
{
    "model": "clef",
    "answers": [
        {
            "type": "predicate",
            "name": "red",
            "probability": 0.9927
        },
        {
            "type": "choice",
            "name": "shape",
            "choice": "square",
            "probabilities": [
                {
                    "value": "square",
                    "probability": 0.9939
                },
                {
                    "value": "circle",
                    "probability": 0.0061
                }
            ],
            "confidence": 0.9758
        }
    ],
    "usage": {
        "input_tokens": 281,
        "input_tokens_details": {
            "cached_tokens": 0,
            "cache_write_tokens": 0
        },
        "output_tokens": 0,
        "output_tokens_details": {
            "reasoning_tokens": 0
        },
        "total_tokens": 281
    }
}

/v1/systemone with images

  1. Send the same request
  2. 200 with the same confident answers and token count as the OpenAI format route
$ curl -s localhost:4002/v1/systemone -H "Authorization: Bearer $LITELLM_KEY" -d {"model":"clef","state":"What shape is this?","images":["data:image/png;base64,<red square png>"],"questions":{...}}
{
    "model": "clef",
    "answers": {
        "red": {
            "type": "noul",
            "noul": 0.9927
        },
        "shape": {
            "type": "choice",
            "choice": "square",
            "confidence": 0.9758,
            "probabilities": {
                "square": 0.9939,
                "circle": 0.0061
            }
        }
    },
    "usage": {
        "input_tokens": 281,
        "output_tokens": 0
    }
}

Video

Narrated walkthrough at be88844 covering the Admin UI playground, before and after on both routes, a blue image negative case, the object form, two images and SDK errors, watch here

Mutation check

Each mutation below was applied alone with the fix in place, and the three touched unit files plus tests/integration/run.py providers tests/integration/translation/decisions/images/test_decisions_images_cloudflare.py were run, then the mutation was reverted

Mutation Unit Integration
Drop the images key from the System One wire body 3 failed 2 of 2 failed
CloudflareDecisionsConfig.supports_image_input = False 2 failed 2 of 2 failed
systemone_request_to_ir drops images 4 failed /v1/systemone case failed
Messages path drops input_image urls 4 failed /v1/decisions case failed
OpenAI provider input ignores images 1 failed not on this path

Type

🆕 New Feature

Caveats (if any)

Low

  • Cloudflare enforces the 4 image cap and size limits, LiteLLM passes its error through
  • images together with OpenAI input in the SDK raises a 400, use input_image parts instead

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

Link to Devin session: https://app.devin.ai/sessions/e660dcb9fd6b400b94cc10cb9ca99dd2
Open in Devin Desktop: https://app.devin.ai/desktop/session/e660dcb9fd6b400b94cc10cb9ca99dd2?variant=devin


Note

Medium Risk
Changes request validation and IR-to-provider translation for Decisions; incorrect forwarding could affect multimodal answers, but scope is limited to opt-in providers and is covered by unit/integration tests.

Overview
Adds image support to the Decisions API so Cloudflare Clef (and future opt-in providers) actually receive screenshots instead of ignoring or rejecting them.

System One (/v1/systemone, SDK state + images): requests can include an images list (data URLs or {content_type, base64}), which flows through the IR into the provider wire body when the provider sets supports_image_input (Cloudflare Clef today).

OpenAI format (/v1/decisions, input with input_image parts): input_image URLs are collected and forwarded as Clef images instead of returning a blanket “text only” error. Providers without supports_image_input still get a clear unsupported response rather than silently dropping images.

The public decisions / adecisions entrypoints accept images for System One calls and reject mixing top-level images with OpenAI input. OpenAI-provider translation can emit input_image messages when System One state carries images.

Reviewed by Cursor Bugbot for commit be88844. Bugbot is set up for automated code reviews on this repo. Configure here.

…d /v1/systemone

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@devin-ai-integration

devin-ai-integration Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

@greptile-apps

greptile-apps Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerConfidence Score: 5/5

[Medium impact] This PR appears safe to merge; no blocking findings remain.

Summary

This PR forwards images from /v1/decisions and /v1/systemone to Cloudflare Clef.

  • Decisions requests can now send images to Cloudflare Clef.

Reviews (3) · Last reviewed commit: "test(decisions): assert whole request va..." · Reviewed by Greptile

Comment thread tests/unit/decisions/test_main.py Resolved
@codspeed

codspeed Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

⚠️ 1 benchmark spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

✅ 31 untouched benchmarks


Comparing litellm_clef_decisions_images (be88844) with main (bb9174f)1

Open in CodSpeed

Footnotes

  1. No successful run was found on main (bd75b5b) during the generation of this report, so bb9174f was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@codecov

codecov Bot commented Oct 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
@mateo-berri

Copy link
Copy Markdown
Contributor

@greptileai

@mateo-berri

Copy link
Copy Markdown
Contributor

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 be88844. Configure here.

@mateo-berri

Copy link
Copy Markdown
Contributor

Overlaps #45734, which also follows drop_params and inlines remote image URLs. Driving that one and closing this as superseded once it merges

@mateo-berri

Copy link
Copy Markdown
Contributor

Closing since #45734 merged the same Cloudflare Clef image support for both decisions routes, so this branch is no longer needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant