Skip to content

Accept images in the local API for Claude and Codex - #14

Merged
redacid merged 1 commit into
mainfrom
feat/api-images
Dec 3, 2026
Merged

redacid merged 1 commit into
mainfrom
feat/api-images

Conversation

@redacid

@redacid redacid commented Dec 3, 2026

Copy link
Copy Markdown
Owner

image_url parts were refused with only text content is supported. Claude Code and Codex both read images, so the API now passes them on.

What

  • image_url parts with base64 data: URLs (PNG, JPEG, GIF, WebP) for claude/… and codex/… models; each becomes [image N] in the transcript text.
  • Claude Code: --input-format stream-json, one user message with the text and image content blocks.
  • Codex: images written into the request's temporary folder (deleted afterwards) and attached with --image; view_image stays disabled.
  • Web URLs (https://…) are refused: the API never fetches a URL, so a request cannot make it reach other hosts.
  • Gemini: 400 (its CLI reads images only through its file tools, which stay off). Audio and file parts: 400 as before.
  • Body limit 4 → 32 MB.

Tested

  • make check: 198 tests (parsing, numbering, refusals, Claude stream-json input, Codex --image with the file written).
  • Live through ApiServer with a red PNG: Codex "Red." (4.4 s), Claude Code haiku "Red" (3.6 s; streaming 2.5 s).

Docs: docs/api.md (Images), docs-dev/architecture.md, OpenAPI description, README status.

Requests with image_url parts were refused, though both Claude Code and
Codex read images. Accept PNG, JPEG, GIF and WebP as base64 data: URLs;
each becomes "[image N]" in the transcript. Claude Code gets them as
content blocks of one stream-json user message; Codex gets them written
into the request's temporary folder and attached with --image, while its
view_image tool (which could read any file) stays off.

The API does not fetch http(s) image URLs, so a request cannot make it
reach other hosts. Gemini CLI could only read images through its file
tools, which stay off, so images for it get 400. The body limit grows
from 4 to 32 MB to fit base64 images.
@redacid
redacid merged commit edaaa26 into main Dec 3, 2026
8 checks passed
redacid pushed a commit that referenced this pull request Dec 3, 2026
Version bump and changelog for images in the local API (#14).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant