Repository navigation
Description
Please read this first
-
Have you read the docs?Agents SDK docs
Yes. the only mention of ToolOutputImage is here: https://openai.github.io/openai-agents-python/tools/ -
Have you searched for related issues? Others may have faced similar issues.
Yes. There were no issues involving ToolOutputImage usage with LiteLLM
Describe the bug
When using the OpenAI Agents SDK with OpenAI models directly (model="gpt-5.1"), an agent can successfully interpret tool outputs of type ToolOutputImage.
The reasoning engine correctly handles the Base64 data URL, and the model describes the image as expected.
However, when switching the model to:
model = LitellmModel(model="azure/responses/gpt-5.1", api_key=...)
…the agent no longer recognizes the tool output as an image.
Even though the tool returns:
ToolOutputImage(image_url="data:image/jpeg;base64,...", detail="high")
LiteLLM sends an empty function_call_output to the Azure OpenAI endpoint:
'input': [{'type': 'message', 'role': 'user', 'content': [{'type': 'input_text', 'text': 'Show me the image in path/to/image.jpeg. What do you see in this image?'}]}, {'type': 'function_call', 'call_id': 'call_mprvAO3bXx8xLbA2MfDsPzKA', 'name': 'retrieve_test_image', 'arguments': '{"path":"path/to/image.jpeg"}'}, {'type': 'function_call_output', 'call_id': 'call_mprvAO3bXx8xLbA2MfDsPzKA', 'output': []}],
Because of this, the agent receives no image content and cannot describe the image.
This works correctly when not using LiteLLM.
Debug information
- Agents SDK version: (e.g.
v0.6.1) - Python version (e.g. Python 3.10)
Repro steps
Minimal python script that can be run to reproduce the bug:
Without LiteLLM and working:
from agents import ToolOutputImage, function_tool, Agent, Runner,
from agents.extensions.models.litellm_model import LitellmModel
from typing import Union
import json
import base64
import litellm
litellm._turn_on_debug()
@function_tool
async def retrieve_test_image(path : str) -> Union[ToolOutputImage, str]:
b64 = base64.b64encode(open(path, "rb").read()).decode()
return ToolOutputImage(image_url=f"data:image/jpeg;base64,{b64}", detail="high")
test_agent = Agent(
name="Image Test Agent",
instructions="You retrieve and describe images.",
model="gpt-5.1",
tools=[retrieve_test_image]
)
result = await Runner.run(test_agent, "Show me the image in path/to/image.jpeg. What do you see in this image?")
With LiteLLM and not working:
from agents import ToolOutputImage, function_tool, Agent, Runner,
from agents.extensions.models.litellm_model import LitellmModel
from typing import Union
import json
import base64
import litellm
litellm._turn_on_debug()
@function_tool
async def retrieve_test_image(path : str) -> Union[ToolOutputImage, str]:
b64 = base64.b64encode(open(path, "rb").read()).decode()
return ToolOutputImage(image_url=f"data:image/jpeg;base64,{b64}", detail="high")
test_agent = Agent(
name="Image Test Agent",
instructions="You retrieve and describe images.",
model=LitellmModel(model="azure/responses/gpt-5.1", api_key=settings.AZURE_API_KEY),
tools=[retrieve_test_image]
)
result = await Runner.run(test_agent, "Show me the image in path/to/image.jpeg. What do you see in this image?")
Expected behavior
LiteLLM should pass the tool output exactly as provided (the Base64 data URL) to the Azure OpenAI Responses API so the agent can interpret it as an image, just like when using OpenAI directly.
Activity
seratch commentedon Dec 9, 2025
Thanks for sharing this. The LiteLLM adapter is available for Chat Completions compatible format at this moment, so indeed using azure responses this way may not work. We recommend directly using OpenAI client for fully-compatible Responses API models but if anyone is interested in working on the enhancement to support this use case, we're happy to have such changes (that said, if the enhancement could make the internals of the LiteLLM adapter complicated, we may want to hold off having the changes).
UssuGit commentedon Dec 16, 2025
Thanks @seratch for the response!
After debugging this further, I found the root cause is actually in chatcmpl_converter.py, not in the LiteLLM adapter itself. The issue affects multimodal tool outputs regardless of the Responses API.
The bug is on line 547 in src/agents/models/chatcmpl_converter.py:
The problem is that extract_text_content() only keeps text content and drops everything else (images, audio, files):
Meanwhile, extract_all_content() (which already exists in the same file) properly handles images by converting input_image → image_url format.
The fix is a one-line change:
This wouldn't add any complexity to the LiteLLM adapter - it's fixing the Converter to properly handle multimodal tool outputs that the SDK already supports for user messages.
I've tested this fix locally and confirmed it works, now with a similar example I've opened the issue with i can see the output being properly sent:
Would you be open to a PR with this change? Happy to submit one.
seratch commentedon Dec 22, 2025
@UssuGit Thanks for taking time for investigating this! @ihower submitted a pull request that aims to resolve this. If you help the PR, it'd be appreciated!
fix: #2163 Preserve non-text tool outputs in LiteLLM and chatcmpl con…
spacegpu commentedon Jan 4, 2026
Hi. does ToolOutputImage work with gemini models or is it restricted to only openai models as of now
ihower commentedon Jan 4, 2026
@Anurag-gg I added support for non-OpenAI models (via LiteLLM) in the PR related to this issue (#2214 ), but it is not released yet.
In general,
ToolOutputImageis not limited to OpenAI models. I tested it withanthropic/claude-sonnet-4-5-20250929, and it works.However, there are a few requirements:
So this can work with non-OpenAI models, but the provider, the Agents SDK, and LiteLLM all need to support it.