query() with image content block via AsyncIterable[dict] prompt → 400 "Could not process image"

Resolved 💬 1 comment Opened May 30, 2026 by teelr Closed Jul 3, 2026

Summary

When claude_agent_sdk.query(prompt=<AsyncIterable[dict]>) is given a user message whose content includes an Anthropic image block (base64), the bundled Claude Code CLI subprocess returns 400 "Could not process image" instead of forwarding the image to the Anthropic API. Text-only async-iterable prompts work; the same image block sent directly via anthropic.AsyncAnthropic also works — so the image payload is valid and the failure is specific to the SDK → CLI streaming-input path.

Environment

  • claude-agent-sdk 0.1.68
  • claude CLI present
  • Python 3.11, Linux
  • Streaming-mode input (prompt is an AsyncIterable[dict]), max_turns=1

Minimal reproduction

import asyncio, base64
import claude_agent_sdk as SDK
from claude_agent_sdk import ClaudeAgentOptions

# 1x1 red PNG
PNG = base64.b64encode(
    b"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x01\x00\x00\x00\x01"
    b"\x08\x02\x00\x00\x00\x90wS\xde\x00\x00\x00\x0cIDATx\x9cc\xf8\x0f\x00"
    b"\x00\x01\x01\x00\x05\x18\xd8N\x00\x00\x00\x00IEND\xaeB`\x82"
).decode()

async def prompt():
    yield {
        "type": "user", "session_id": "", "parent_tool_use_id": None,
        "message": {"role": "user", "content": [
            {"type": "text", "text": "Reply with the single word: PASS"},
            {"type": "image", "source": {
                "type": "base64", "media_type": "image/png", "data": PNG}},
        ]},
    }

async def main():
    async for msg in SDK.query(prompt=prompt(),
                               options=ClaudeAgentOptions(max_turns=1)):
        print(type(msg).__name__, msg)

asyncio.run(main())

Expected

The model receives the image and replies (here, PASS).

Actual

The request fails with 400 "Could not process image". The image block is not forwarded to the Anthropic API by the CLI subprocess.

Impact

This is the only blocker preventing token-level streaming (TextDelta) for multimodal turns when driving the SDK via its async-iterable prompt interface. The documented workaround is to bypass the SDK CLI path and call anthropic.AsyncAnthropic.messages.stream() directly — which works but is a parallel code path we'd like to retire once this is fixed.

Ask

Confirm whether image content blocks are expected to be supported on the AsyncIterable[dict] streaming-input path, and if so, fix the CLI forwarding.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗