Images are silently dropped when translating Anthropic /v1/messages to an OpenAI chat/completions provider

Author: chanasiaCreated Aug 16, 2026Updated Sep 24, 2026

Images are silently dropped when translating Anthropic /v1/messages to an OpenAI chat/completions provider

Environment

  • CCR 3.0.21 (musistudio/claude-code-router:latest, digest ce6100046ce0), Docker
  • Provider: custom OpenAI-compatible relay, api_base_url ending in /v1/chat/completions
  • Client: Claude Code (also reproducible with a plain curl to /v1/messages)

Symptom

Pasting an image into Claude Code produces a reply as if no image was sent — no error, no warning, HTTP 200. The model answers "I don't see an image attached".

Reproduction

bash
# through CCR -> model does not see the image
curl -s http://127.0.0.1:3458/v1/messages \
  -H "x-api-key: $CCR_KEY" -H "anthropic-version: 2023-06-01" -H "content-type: application/json" \
  -d '{"model":"myprovider,my-model","max_tokens":100,"messages":[{"role":"user","content":[
        {"type":"image","source":{"type":"base64","media_type":"image/png","data":"<base64 of a solid red png>"}},
        {"type":"text","text":"What color is this image? One word."}]}]}'
# -> "I don't see an image attached"

# same model, same relay, OpenAI format sent directly -> the image is seen
curl -s https://relay.example.com/v1/chat/completions \
  -H "authorization: Bearer $KEY" -H "content-type: application/json" \
  -d '{"model":"my-model","max_tokens":100,"messages":[{"role":"user","content":[
        {"type":"image_url","image_url":{"url":"data:image/png;base64,<same base64>"}},
        {"type":"text","text":"What color is this image? One word."}]}]}'
# -> "red"

So the model and the relay both handle vision correctly; the image is lost inside CCR.

Input-token counts confirm it: 61 tokens without the image, 74 with the image when the image actually arrives, 61 when routed through CCR.

Root cause

Translation is delegated to @the-next-ai/[email protected], which ships a sourcemap, so the original TypeScript is inspectable.

  1. src/types.ts:937-980 — StandardRequestInputContent has no image variant:
typescript
export type StandardRequestInputContent =
  | { type: 'input_text'; text: string }
  | { type: 'tool_use'; ... }
  | { type: 'tool_result'; ... }
  | { type: 'tool_search_call'; ... }
  | { type: 'tool_search_output'; ... }
  | { type: 'reasoning'; ... };
  1. src/adapters/builtins/source/parsers.ts:1320-1392 — normalizeAnthropicContent() handles thinking, tool_use, tool_result, then falls through to a text extraction:
typescript
const text = extractTextFromPart(block);
if (text) {
  normalized.push({ type: 'input_text', text });
}

An Anthropic { type: 'image', source: { type: 'base64', media_type, data } } block carries no text, so it is dropped with no diagnostic.

  1. src/adapters/builtins/target/openai-responses.ts:392-467 — standardInputToOpenAIChatMessages() only ever emits content: <string> for user messages, so there is no way to emit image_url parts even if the image had survived step 2.

The string image does not appear anywhere under src/adapters/.

Text survives only because a text block has the same shape in both protocols. Any protocol translation therefore loses images, regardless of provider or model. Passthrough (client protocol == provider protocol) is unaffected.

Expected

Either translate Anthropic image blocks to OpenAI image_url parts, or fail loudly when a request contains content the translation layer cannot represent. Silent data loss makes this look like a model limitation, which is what it was mistaken for.

Suggested fix

  1. Add an image variant to StandardRequestInputContent, e.g. { type: 'input_image'; image_url: string; detail?: 'auto' | 'low' | 'high' }.
  2. In normalizeAnthropicContent(), map type: 'image' blocks — source.type === 'base64' to data:${media_type};base64,${data}, source.type === 'url' to source.url — before the text fallback.
  3. In standardInputToOpenAIChatMessages(), emit an array content when a user message carries images: [{ type: 'text', text }, { type: 'image_url', image_url: { url } }], and emit the message even when the text part is empty (image-only messages are currently skipped entirely, since if (text) guards the push).
  4. Same treatment for the Gemini and Anthropic target adapters (inline_data / source).
  5. Images inside tool_result content (Claude Code's Read tool on a .png) go through normalizeAnthropicToolResultContent() and need the same handling.

A local patch implementing points 2 and 3 against the bundled dist/index.js works: pasted images, multiple images per message, streaming, tool calls, and text-only requests all behave correctly afterwards.

Related

Possibly the same underlying cause as #372 and #958.

Source: musistudio/claude-code-router