You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
xAI: a GIF image gets 400 invalid_image and breaks the session (v2) #53786
xAI only accepts JPEG, PNG and WebP images. When a GIF is sent to an xAI model, either attached by the user or returned by the read tool, the request fails with 400 invalid_image. The GIF stays in the session, so every later turn fails the same way and the session is stuck.
The API returns the same error for a plain request, while the same request with a PNG works:
curl https://api.x.ai/v1/chat/completions -H "Authorization: Bearer $XAI_API_KEY" -H "Content-Type: application/json" \
-d '{"model":"grok-4.7","messages":[{"role":"user","content":[{"type":"text","text":"What is in this image?"},{"type":"image_url","image_url":{"url":"data:image/gif;base64,'"$(base64 < shapes.gif | tr -d '\n')"'"}}]}]}'# 400 {"code":"invalid_image","error":"... Downloaded response does not contain a valid JPG, PNG, WebP, or ICO image."}
Thanks for the detailed report. I reproduced this on v2.0.24 using a local stand-in for the xAI endpoint that returns xAI's invalid_image 400 for GIFs:
opencode run -m xai/grok-4.7 -f assets/shapes.gif "What shapes are in this image?": the GIF is sent as data:image/gif;base64,... and the request fails with Image could not be processed: Downloaded response does not contain a valid JPG, PNG, WebP, or ICO image.
opencode run -m xai/grok-4.7 --continue "Just reply OK.": the stored GIF is sent again and the turn fails the same way, so the session stays stuck.
OpenCode only checks whether a model accepts images at all, not which image formats a provider accepts, so a GIF goes to xAI unchanged. Your PR #53787 targets this, and #53014 proposes a more general way to recover from rejected attachments.
Activity
opencode-agent commentedon Oct 7, 2026
Thanks for the detailed report. I reproduced this on v2.0.24 using a local stand-in for the xAI endpoint that returns xAI's
invalid_image400 for GIFs:opencode run -m xai/grok-4.7 -f assets/shapes.gif "What shapes are in this image?": the GIF is sent asdata:image/gif;base64,...and the request fails withImage could not be processed: Downloaded response does not contain a valid JPG, PNG, WebP, or ICO image.opencode run -m xai/grok-4.7 --continue "Just reply OK.": the stored GIF is sent again and the turn fails the same way, so the session stays stuck.OpenCode only checks whether a model accepts images at all, not which image formats a provider accepts, so a GIF goes to xAI unchanged. Your PR #53787 targets this, and #53014 proposes a more general way to recover from rejected attachments.