From 457bf60e2cbc414cdbea441ec6372b958fd56b02 Mon Sep 17 00:00:00 2001 From: feruzm Date: Tue, 25 Aug 2026 12:27:12 +0000 Subject: [PATCH] fix(ai-image): forward the client's idempotency_key to the upstream The web client sends idempotency_key so a retry after a delivery-pending response recovers the same paid generation instead of charging a second one. The handler forwarded only prompt/aspect_ratio/power, so the key never reached the upstream and every retry was billed as a new generation. Fixes #86 --- dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs b/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs index 81517701..9fa3226f 100644 --- a/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs +++ b/dotnet/EcencyApi/Handlers/PrivateApi.Misc.cs @@ -558,7 +558,9 @@ public static async Task AiGenerateImage(HttpContext ctx) { ["us"] = username, }; - MiscCopyIfPresent(data, body, "prompt", "aspect_ratio", "power"); + // idempotency_key lets a retry recover the same paid generation instead of + // charging a second one; the upstream validates its format itself. + MiscCopyIfPresent(data, body, "prompt", "aspect_ratio", "power", "idempotency_key"); // AI image generation legitimately takes 10-60s+; keep it long. await Upstream.Pipe( ApiClient.ApiRequest("ai-image-generate", HttpMethod.Post, null, data, null, 120000), ctx);