anomalyco / anomalyco/opencode

[OpenCode Go / Console Go] OpenAI-compatible chat completions endpoint rejects standard image_url content parts (400: unknown variant `image_url`, expected `text`)

Open
#40,811 2 comments 0 reactions 1 assignee View on GitHub

@MrMushrooooom is already working on this.

Since Aug 6, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Summary

The OpenCode Go ("Console Go") OpenAI-compatible chat completions endpoint rejects any request containing a standard OpenAI image_url content part with HTTP 400 and a raw serde deserialization error — even for models whose actual upstream API (e.g. DeepSeek official API) tolerates images ("unsupported but does not error"). This breaks third-party OpenAI-compatible clients that send images inline (in my case: Codex CLI in responses wire mode → CLIProxyAPI v7.2.120 in OpenAI-compat mode → Console Go /chat/completions).

Error returned

{"error":{"param":null,"type":"invalid_request_error","code":"invalid_request_error","message":"Error from provider (Console Go): Upstream request failed: [invalid_request_error]\nFailed to deserialize the JSON body into the target type: messages[3]: unknown variant `image_url`, expected `text` at line 1 column 76497"}}

Steps to reproduce

Send a standard OpenAI chat completions request with an image content part to the Console Go endpoint (model deepseek-v4-flash):

{
  "model": "deepseek-v4-flash",
  "messages": [
    {"role": "system", "content": "You are a coding agent."},
    {"role": "user", "content": "hello"},
    {"role": "assistant", "content": "hi"},
    {"role": "user", "content": [
      {"type": "text", "text": "what is this?"},
      {"type": "image_url", "image_url": {"url": "data:image/png;base64,iVBORw0KGgo..."}}
    ]}
  ],
  "stream": true
}

Result: HTTP 400 with the serde error above. The identical request with only text content succeeds. The failure is in the request schema, before the model is reached (the error echoes the request body and points at messages[3]).

Why opencode CLI itself never hits this

In opencode CLI, pasted images are stored as file attachments in the session and are not sent inline to the model — the model reads them via tools (e.g. the modlens skill). So the Console Go endpoint is effectively only ever exercised with image_url content parts by third-party OpenAI-compatible clients, which is why this looks fine in the opencode TUI.

Expected behavior

  • Accept standard image_url content parts (pass through, or ignore like the DeepSeek official API does per its docs), OR
  • Return a proper OpenAI-style error envelope instead of echoing a serde error that includes the request body, OR
  • At minimum do not reject the entire request because one message contains an image part.

Environment

  • OpenCode version: latest (1.18.x line), issue filed 2026-08-06
  • Endpoint: Console Go OpenAI-compatible endpoint (opencode-go plan), model deepseek-v4-flash
  • Client path: Codex CLI (wire_api = "responses") → CLIProxyAPI v7.2.120 (openai-compat) → Console Go /chat/completions

Related issues

  • #26106 — same unknown variant 'image_url', expected 'text' serde error (closed as duplicate-spam; underlying issue appears unfixed)
  • #31870 — opencode-go + kimi-k2.6, image_url array on a history message rejected with 400
  • #33942 — OpenCode Go chat completions image input returns HTTP 500 (same feature gap, different failure mode)
  • #37231 / #37771 — Console Go "Upstream request failed" caused by strict provider validators

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.