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
OpenAI-compatible providers: image_url content type fails deserialization when sending images #26106
When using DeepSeek V4 Flash (or other OpenAI-compatible providers) via a custom provider configuration with modalities: { input: ["text", "image"] }, attempting to paste/send an image attachment causes OpenCode to crash with a JSON deserialization error.
Error message
Failed to deserialize the JSON body into the target type: messages[196]: unknown variant `image_url`, expected `text` at line 1 column 764958
Root cause analysis
OpenCode's internal message content schema (used for validating request bodies) only recognizes text, image, and audio as valid type variants in message content parts. However, when building the actual HTTP API request for OpenAI-compatible providers, image file parts are correctly converted to the OpenAI image_url format (e.g. { type: "image_url", image_url: { url: "data:..." } }). This converted format then fails schema validation because image_url is not a recognized variant in the internal schema.
The conversion from file parts to image_url happens correctly in the provider layer, but the request body is subsequently validated against a schema that was designed for the MCP-style { type: "image", data: ..., mimeType: ... } format.
Steps to reproduce
Configure an OpenAI-compatible provider (e.g., DeepSeek) with image modality enabled:
Paste an image (Ctrl+V) or attach an image file to the message
The application crashes with the deserialization error shown above
Expected behavior
OpenCode should properly handle image attachments by either:
a) Supporting image_url as a valid content variant alongside text, image, and audio in the request validation schema, OR
b) Converting image content to the MCP-compatible image format before validation
Activity
rekram1-node commentedon Jun 22, 2026
STOP SPAMMING ISSUES.
VL4DST3R commentedon Jun 22, 2026
I was following this issue as well, is this effectively a duplicate of #30071 ? In the sense that i should follow it there instead?