langchain - 💡(How to fix) Fix OpenAI Responses image content blocks do not support file_id inputs

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

ImageContentBlock supports image inputs by file_id, but the OpenAI Responses block translator currently routes image blocks through the URL/base64 conversion path.

I expect image content blocks with file_id to be converted to OpenAI Responses input_image.file_id payloads. Instead, the conversion raises an unsupported source type error.

A narrow fix is to map image content blocks with file_id, and legacy image ID blocks with source_type: "id", to {"type": "input_image", "file_id": ...} when targeting the OpenAI Responses API. Chat Completions behavior should remain unchanged.

Error Message

ValueError: Unsupported source type. Only 'url' and 'base64' are supported.

Root Cause

ImageContentBlock supports image inputs by file_id, but the OpenAI Responses block translator currently routes image blocks through the URL/base64 conversion path.

I expect image content blocks with file_id to be converted to OpenAI Responses input_image.file_id payloads. Instead, the conversion raises an unsupported source type error.

A narrow fix is to map image content blocks with file_id, and legacy image ID blocks with source_type: "id", to {"type": "input_image", "file_id": ...} when targeting the OpenAI Responses API. Chat Completions behavior should remain unchanged.

Fix Action

Fix / Workaround

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.2.0 numpy: 2.3.4 openai: 2.26.0 orjson: 3.11.6 packaging: 24.2 pydantic: 2.12.5 pytest: 9.0.3 pytest-asyncio: 1.3.0 pytest-benchmark: 5.2.3 pytest-codspeed: 4.2.0 pytest-recording: 0.13.4 pytest-socket: 0.7.0 pyyaml: 6.0.3 requests: 2.33.0 requests-toolbelt: 1.0.0 rich: 14.2.0 syrupy: 5.1.0 tenacity: 9.1.2 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.12.0 vcrpy: 8.1.1 wrapt: 2.1.2 xxhash: 3.6.0 zstandard: 0.25.0

Code Example

from langchain_core.messages import content as types
from langchain_core.messages.block_translators.openai import convert_to_openai_data_block

block = types.create_image_block(file_id="file-abc123")

# Expected: {"type": "input_image", "file_id": "file-abc123"}
print(convert_to_openai_data_block(block, api="responses"))

---

ValueError: Unsupported source type. Only 'url' and 'base64' are supported.
RAW_BUFFERClick to expand / collapse

Submission checklist

  • This is a bug, not a usage question.
  • I added a clear and descriptive title that summarizes this issue.
  • I used the GitHub search to find a similar question and didn't find it.
  • I am sure that this is a bug in LangChain rather than my code.
  • The bug is not resolved by updating to the latest stable version of LangChain (or the specific integration package).
  • This is not related to the langchain-community package.
  • I posted a self-contained, minimal, reproducible example. A maintainer can copy it and run it AS IS.

Package (Required)

  • langchain
  • langchain-openai
  • langchain-anthropic
  • langchain-classic
  • langchain-core
  • langchain-model-profiles
  • langchain-tests
  • langchain-text-splitters
  • langchain-chroma
  • langchain-deepseek
  • langchain-exa
  • langchain-fireworks
  • langchain-groq
  • langchain-huggingface
  • langchain-mistralai
  • langchain-nomic
  • langchain-ollama
  • langchain-openrouter
  • langchain-perplexity
  • langchain-qdrant
  • langchain-xai
  • Other / not sure / general

Related Issues / PRs

I did not find an existing issue or PR for OpenAI Responses image file_id conversion. Related but different scope: #33652 covers video conversion.

Reproduction Steps / Example Code (Python)

from langchain_core.messages import content as types
from langchain_core.messages.block_translators.openai import convert_to_openai_data_block

block = types.create_image_block(file_id="file-abc123")

# Expected: {"type": "input_image", "file_id": "file-abc123"}
print(convert_to_openai_data_block(block, api="responses"))

Error Message and Stack Trace (if applicable)

ValueError: Unsupported source type. Only 'url' and 'base64' are supported.

Description

ImageContentBlock supports image inputs by file_id, but the OpenAI Responses block translator currently routes image blocks through the URL/base64 conversion path.

I expect image content blocks with file_id to be converted to OpenAI Responses input_image.file_id payloads. Instead, the conversion raises an unsupported source type error.

A narrow fix is to map image content blocks with file_id, and legacy image ID blocks with source_type: "id", to {"type": "input_image", "file_id": ...} when targeting the OpenAI Responses API. Chat Completions behavior should remain unchanged.

System Info

System Information

OS: Linux OS Version: #1 SMP PREEMPT_DYNAMIC Mon Dec 1 20:46:23 UTC 2025 Python Version: 3.13.7 (main, Sep 18 2025, 19:47:49) [Clang 20.1.4 ]

Package Information

langchain_core: 1.4.0 langchain: 1.3.1 langsmith: 0.8.0 langchain_openai: 1.2.1 langchain_protocol: 0.0.15 langchain_tests: 1.1.7 langgraph_sdk: 0.3.3

Optional packages not installed

deepagents deepagents-cli

Other Dependencies

httpx: 0.28.1 jsonpatch: 1.33 langgraph: 1.2.0 numpy: 2.3.4 openai: 2.26.0 orjson: 3.11.6 packaging: 24.2 pydantic: 2.12.5 pytest: 9.0.3 pytest-asyncio: 1.3.0 pytest-benchmark: 5.2.3 pytest-codspeed: 4.2.0 pytest-recording: 0.13.4 pytest-socket: 0.7.0 pyyaml: 6.0.3 requests: 2.33.0 requests-toolbelt: 1.0.0 rich: 14.2.0 syrupy: 5.1.0 tenacity: 9.1.2 tiktoken: 0.12.0 typing-extensions: 4.15.0 uuid-utils: 0.12.0 vcrpy: 8.1.1 wrapt: 2.1.2 xxhash: 3.6.0 zstandard: 0.25.0

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING