APIMaster.ai
Back to Blog
APIMaster Blog

Fix OpenCode "Model Does Not Support Image Input" — GPT & Claude Vision Not Working

OpenCode won't read your image with GPT or Claude? The model supports vision, but OpenCode only sends the file name. Fix it by declaring attachment and modalities for gpt-5.5 and Claude models in opencode.jsonc.

OpenCodeimage inputVisionGPTClaudeopencode.jsonc

Published 2026-07-14

Quick Answer

You attached a PNG/JPG in OpenCode, asked GPT or Claude to describe it, and got back something like "the current model does not support image input" — or the model only mentions the file name, not the picture. In almost every case the model does support vision; the problem is that OpenCode never sent the image as multimodal input.

Root cause: OpenCode only forwards an image when the model is declared image-capable in opencode.jsonc. Without that declaration it treats the attachment as a plain file reference and drops the pixels.

Fast fix: add two fields to the model in opencode.jsonc, then restart OpenCode:

"attachment": true,
"modalities": {
  "input": ["text", "image"],
  "output": ["text"]
}

If you need a vision-capable OpenAI-compatible endpoint that works with this config today, APIMaster serves gpt-5.5 and Claude vision models at https://apimaster.ai/v1. Full setup: OpenCode configuration guide.

What This Problem Looks Like

  • You switch to a GPT or Claude model in OpenCode, drag in a screenshot, and ask "describe this image."
  • The reply is a variation of "I can't read images", "image input is not supported for this model", or the model answers about a filename (screenshot.png) instead of the actual content.
  • The same image works fine when you paste it into ChatGPT or Claude directly.

This is not a model limitation and not a broken API key. gpt-5.5, claude-sonnet-4-6, claude-opus-4-7, claude-opus-4-8, and claude-haiku-4-5 all accept image input over the OpenAI-compatible Chat Completions API. The image simply never left OpenCode.

Why It Happens

OpenCode decides per model whether an attachment can be sent, and whether that attachment may be an image. It reads this from your provider config in opencode.jsonc. If your model entry looks like this:

"gpt-5.5": {
  "name": "gpt-5.5"
}

…then OpenCode has no signal that the model takes images. Depending on the build, it either refuses to attach the file or passes only the attachment name into the prompt text. The model receives "[attachment: diagram.png]" — a string, not a picture — and correctly replies that it wasn't given an image.

The fix is to tell OpenCode two things explicitly:

Field Meaning
"attachment": true This model is allowed to receive attachments.
"modalities": { "input": ["text", "image"] } This model accepts image input, so OpenCode converts the file into a multimodal image_url content block.

Once both are set, OpenCode base64-encodes the image and sends it as proper vision input — and the model reads it.

How to Fix It

1. Locate your opencode.jsonc

OS Path
macOS / Linux ~/.config/opencode/opencode.jsonc
Windows C:\Users\<username>\.config\opencode\opencode.jsonc

2. Add attachment + modalities to each vision model

Here is a working provider block for GPT and Claude on an OpenAI-compatible endpoint:

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "apimaster": {
      "name": "APIMaster.ai",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://apimaster.ai/v1"
      },
      "models": {
        "gpt-5.5": {
          "name": "gpt-5.5",
          "attachment": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        },
        "claude-sonnet-4-6": {
          "name": "claude-sonnet-4-6",
          "attachment": true,
          "modalities": {
            "input": ["text", "image"],
            "output": ["text"]
          }
        }
      }
    }
  }
}

The full example covering claude-opus-4-7, claude-opus-4-8, claude-haiku-4-5, and reasoning variants is in the OpenCode setup guide. You can enable image input for just one model — only that model needs the two fields.

3. Use the correct base URL

The OpenAI-compatible host is:

https://apimaster.ai/v1

Do not use https://api.apimaster.ai/v1 — the api. prefix host can cause TLS / connection failures.

4. Restart OpenCode

Config changes are loaded at startup. Fully quit and reopen OpenCode, or at minimum start a new session, or the old (image-blind) config stays active.

5. Prefer local upload / base64 over public URLs

Upload a local PNG/JPG in OpenCode — it gets converted to a base64 data URL, which is the reliable path. Passing a public image URL directly can fail, because the upstream has to download it and may hit format, size, MIME, or hotlink limits:

Error while downloading file. Upstream status code: 400.

If you see that, switch to a local file / base64 data URL instead of a remote URL.

Test That It Works

In OpenCode

Switch to apimaster/gpt-5.5 or apimaster/claude-sonnet-4-6, upload an image, and ask:

Describe the main content of this image.

A correct config returns a real description. If it still only sees a file name, the attachment / modalities fields are missing or OpenCode wasn't restarted.

Directly via the API (isolate the problem)

To confirm the endpoint itself handles vision — separating an OpenCode config issue from a provider issue — send a base64 image. Never hardcode a real key; use an environment variable:

export APIMASTER_API_KEY="your APIMaster API key"

curl https://apimaster.ai/v1/chat/completions \
  -H "Authorization: Bearer $APIMASTER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {
        "role": "user",
        "content": [
          { "type": "text", "text": "Describe this image." },
          {
            "type": "image_url",
            "image_url": { "url": "data:image/png;base64,YOUR_IMAGE_BASE64" }
          }
        ]
      }
    ],
    "max_tokens": 1000
  }'

Swap model to claude-sonnet-4-6 to test Claude the same way. A 200 response that describes the image means vision works at the API layer — so any remaining failure is on the OpenCode config side.

Keep Your API Key Safe

  • Never put the API key inside opencode.jsonc. That file holds only the provider, models, and capabilities.
  • Configure the key through OpenCode's /connect flow, the Connect Provider UI, or an environment variable.
  • Don't paste the key into chats, screenshots, issues, or public repos. If it leaks, revoke and regenerate it in your provider console immediately.

How APIMaster Helps

If you want a single OpenAI-compatible endpoint where GPT and Claude vision "just work" with the config above, APIMaster is built for exactly this:

Advantage What you get
One endpoint, many vision models gpt-5.5, claude-sonnet-4-6, claude-opus-4-7, claude-opus-4-8, claude-haiku-4-5 — all image-capable, all at https://apimaster.ai/v1 with one key.
Discount Marketplace pricing up to ~90% off OpenAI-list and ~85% off Claude-list rates (live prices on site).
Model fidelity A cheap relay can quietly swap models — confirm you're getting the real thing with fingerprint detection.

From $1 top-up, pay-as-you-go, no subscription. Full step-by-step OpenCode setup — including image input — is in the OpenCode configuration guide.

Register on APIMaster →

FAQ

Does OpenCode support image input at all? Yes. OpenCode can send images to any vision-capable model, but you must declare attachment: true and modalities.input: ["text", "image"] for that model in opencode.jsonc. Without the declaration it sends only the file name.

Which APIMaster models can read images in OpenCode? gpt-5.5, claude-sonnet-4-6, claude-opus-4-7, claude-opus-4-8, and claude-haiku-4-5 all accept image input. Add the two capability fields to each one you want to use with images.

Why does the model only see the file name? OpenCode didn't convert the attachment into image input — it put the attachment name into the prompt text instead. This is the tell-tale sign the attachment / modalities fields are missing.

I added the fields and it still fails. Now what? Fully restart OpenCode, start a new session, and confirm the active model is the one you configured. Then test the endpoint directly with the base64 curl above to check whether the problem is OpenCode or the provider.

Why did a public image URL error out? The upstream has to download remote URLs and can be blocked by size, format, MIME, or hotlink protection (Error while downloading file. Upstream status code: 400.). Use a local upload / base64 data URL instead.