OpenAI 图像编码器
Give a vision model a look at your canvas
- image
- content_item
- base64_string
The vision adapter for chat-completions
Same idea as the Gemini encoder, different wire format. OpenAIImageEncoder takes an IMAGE tensor and wraps it as a data URL in the shape OpenAI-compatible vision models expect - {"input_image": {"image_url": "data:...;base64,...", "detail": ...}}. Then OpenAIChat can ask the model to critique the composition, caption the render, or fix the prompt based on what's actually in the image. It's pure local encoding; nothing leaves your machine until the content item reaches the Chat node.
How it works
The node takes the first image of the input batch, converts it to PIL, encodes it to your chosen format at your chosen quality, base64-encodes the bytes, and builds a full data: URI. The detail setting rides along on the content item and gets passed through to the API. No network, no key, no cost at this stage.
The fields that matter
image- the IMAGE tensor. Onlyimage[0]is encoded.detail-auto,low, orhigh. This is the token lever:hightiles the image and costs a lot more tokens but reads fine detail;lowis cheap and perfect for "what's the vibe" questions.autolets the provider decide.format-png,jpeg,webp. Default jpeg.quality- 10–100, default 85, applies to jpeg/webp.
The practical defaults are solid: jpeg at 85 for photos and renders, PNG for text and line art where artifacts would mislead the model. high detail for anything where the model needs to read small text or judge fine detail; low everywhere else.
Outputs
content_item - the OAI_CONTENT_ITEM for OpenAIChat or a connector. base64_string - the full data: URI, and note the name: this is the URI, not raw base64. If you're expecting bare base64 for something else, you'll be surprised.
The trap: batches
Like its Gemini sibling, it encodes only the first frame of a batch, silently. A 16-frame batch means the model sees frame 1 and you'll never know. Split batches before encoding if you need per-frame analysis.
Other gotchas: RGBA gets flattened to RGB for jpeg (fine - jpeg has no alpha anyway). Large images produce large data URIs and proportionally more input tokens, so downscale before encoding to keep costs sane. And a missing key doesn't matter here - this node works before you've even configured a loader, because it does no API calls of its own.
Install
With the pack via ComfyUI Manager (search "comfyui-aichat") or:
cd ComfyUI/custom_nodes
git clone https://github.com/spawner1145/comfyui-aichat
Restart ComfyUI. Dependencies are just openai, httpx, and PyYAML; no model downloads.
Inputs (4)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| detail | COMBO | auto | 3 options: auto, low, high |
| format | COMBO | jpeg | 3 options: png, jpeg, webp |
| quality | INT | 8510–100 | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| content_item | OAI_CONTENT_ITEM | — |
| base64_string | STRING | — |