From 13b474c56e7fb4e7a636417ce3160d5c7fda50c6 Mon Sep 17 00:00:00 2001 From: Ayman Kamal Date: Sat, 2 May 2026 01:43:07 -0400 Subject: [PATCH] fix: send correct resolution param to xAI image generation API The xAI /v1/images/generations endpoint expects resolution as a literal string ('1k' or '2k'), not the numeric value ('1024'). - Change _XAI_RESOLUTIONS from a dict mapping to a validation set - Use the resolution key directly instead of the mapped value - Fall back to DEFAULT_RESOLUTION on invalid config values Fixes 422 Unprocessable Entity errors when resolution was sent. --- plugins/image_gen/xai/__init__.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/plugins/image_gen/xai/__init__.py b/plugins/image_gen/xai/__init__.py index 93fd10ce390..ea8721075d0 100644 --- a/plugins/image_gen/xai/__init__.py +++ b/plugins/image_gen/xai/__init__.py @@ -63,10 +63,7 @@ _XAI_ASPECT_RATIOS = { } # xAI resolutions -_XAI_RESOLUTIONS = { - "1k": "1024", - "2k": "2048", -} +_XAI_RESOLUTIONS = {"1k", "2k"} DEFAULT_RESOLUTION = "1k" @@ -177,7 +174,7 @@ class XAIImageGenProvider(ImageGenProvider): aspect = resolve_aspect_ratio(aspect_ratio) xai_ar = _XAI_ASPECT_RATIOS.get(aspect, "1:1") resolution = _resolve_resolution() - xai_res = _XAI_RESOLUTIONS.get(resolution, "1024") + xai_res = resolution if resolution in _XAI_RESOLUTIONS else DEFAULT_RESOLUTION payload: Dict[str, Any] = { "model": API_MODEL,