Skip to content

Proxy forwards image_url parts to text-only zen models -> 400 invalid_request_error #1043

Description

@Cheurteenyt

Client or integration

Codex App

Area

Provider adapter

Summary

When a Codex message contains an image part (image_url), the proxy forwards it as-is to the zen API (https://opencode.ai/zen/v1). The zen API only accepts text and rejects the request with HTTP 400:

Provider error 400: {"error":{"param":null,"type":"invalid_request_error","code":"invalid_request_error","message":"Error from provider (Console): Upstream request failed: [invalid_request_error] Failed to deserialize the JSON body into the target type: messages[65]: unknown variant image_url, expected text at line 1 column 2015840"}}

Root cause: the noVisionModels mechanism (vision sidecar or fail-closed strip) is only applied when the provider is explicitly configured with that list. By default there is no protection for providers whose models are text-only (like the free zen models).

Current mitigation (works locally): the opencode-zen provider config lists the 7 zen free models under noVisionModels and sets defaultMaxOutputTokens: 32000. Text-only providers remain unsafe by default.

Suggested fix: automatically strip (or describe) images whenever the model's inputModalities does not include "image", even when noVisionModels is not configured. This would make text-only providers safe by default.

Reproduction

  1. Configure the opencode-zen provider with free models, without defining a noVisionModels list.
  2. Send a Codex request that contains at least one message with an image_url part (e.g. a screenshot or any image attachment).
  3. The proxy forwards the full message, including the image_url part, to https://opencode.ai/zen/v1.
  4. The zen API rejects the request with HTTP 400 invalid_request_error: Failed to deserialize the JSON body into the target type: messages[65]: unknown variant 'image_url', expected 'text'.

Version

Latest

Operating system

Windows 11

Provider and model

opencode-zen (free models)

Logs or error output

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

Screenshots and supporting files

No response

Redacted configuration

{
  "providers": {
    "opencode-zen": {
      "noVisionModels": ["<the 7 zen free model ids>"],
      "defaultMaxOutputTokens": 32000
    }
  }
}

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingproviderProvider adapters, OpenAI-compat presets, upstream API quirks

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions