From 36b393758fca1372b7cdc7f6cc3c5a27b62c9bfb Mon Sep 17 00:00:00 2001 From: Wagner Bruna Date: Tue, 10 Feb 2026 12:48:05 -0300 Subject: [PATCH] feat: accept legacy image parameter on v1/images/edits The OpenAI API originally supported only a single image, passed through 'image' instead of 'image[]'. 'Old' OpenAI modules (as recent as 1.69 from Debian stable), and probably other clients, send edit requests in this format. --- examples/server/main.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/server/main.cpp b/examples/server/main.cpp index 0fb10c7a3..58bc0fbc7 100644 --- a/examples/server/main.cpp +++ b/examples/server/main.cpp @@ -565,7 +565,8 @@ int main(int argc, const char** argv) { std::string sd_cpp_extra_args_str = extract_and_remove_sd_cpp_extra_args(prompt); size_t image_count = req.form.get_file_count("image[]"); - if (image_count == 0) { + bool has_legacy_image = req.form.has_file("image"); + if (image_count == 0 && !has_legacy_image) { res.status = 400; res.set_content(R"({"error":"at least one image[] required"})", "application/json"); return; @@ -576,6 +577,10 @@ int main(int argc, const char** argv) { auto file = req.form.get_file("image[]", i); images_bytes.emplace_back(file.content.begin(), file.content.end()); } + if (image_count == 0 && has_legacy_image) { + auto file = req.form.get_file("image"); + images_bytes.emplace_back(file.content.begin(), file.content.end()); + } std::vector mask_bytes; if (req.form.has_file("mask")) {