# Images and files as function call outputs

**URL:** <https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081>\
**Category:** API\
**Created:** [September 26, 2025, 4:53pm UTC](https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081 "2025-09-26T16:53:38Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![edwinarbus](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/edwinarbus/32/455108_2.png) [@edwinarbus](https://community.openai.com/u/edwinarbus)\
**Post date:** [September 26, 2025, 4:53pm UTC](https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081/1 "2025-09-26T16:53:38Z")

</div>

We’ve updated function calling to support files and images as tool call outputs. You can now call functions like `generate_chart` or `load_image` and return those files back to the model, rather than just JSON or text. 🌠

[https://platform.openai.com/docs/guides/function-calling](https://platform.openai.com/docs/guides/function-calling)

---

<div class="post-metadata">

**Author:** ![aprendendo.next](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/aprendendo.next/32/721758_2.png) [@aprendendo.next](https://community.openai.com/u/aprendendo.next)\
**Post date:** [September 26, 2025, 7:51pm UTC](https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081/2 "2025-09-26T19:51:35Z")

</div>

Took me a while to figure it out.

In case anyone is wondering how to pass the output, it is documented [here](https://platform.openai.com/docs/api-reference/responses/create#responses-create-input-input-item-list-item-function-tool-call-output-output).

Basically, you pass it as an array of input types:

 ![image](https://us1.discourse-cdn.com/openai1/original/4X/8/9/d/89d9486e553bfb563329a8263511347bbcb84a08.png)

In a[typical json function](https://platform.openai.com/docs/guides/function-calling#function-tool-example), this would be the function return:

```json
{
    "type": "function_call_output",
    "call_id": item.call_id,
    "output": json.dumps({
                        "horoscope": "horoscope returned by the function"
                    }),
}

```

For example, in a base64 image output it becomes like this:

```json
{
    "type": "function_call_output",
    "call_id": item.call_id,
    "output": [{
                 "type": "input_image",
                 "detail":"low",
                 "image_url": b64_png,
               }],
}

```

---

<div class="post-metadata">

**Author:** ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/766292_2.png) [@\_j](https://community.openai.com/u/_j)\
**Post date:** [September 26, 2025, 8:18pm UTC](https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081/3 "2025-09-26T20:18:26Z")

</div>

In case someone was wondering.

We would still have to await OpenAI recognizing Chat Completions as a low-latency high-performance universal transparent endpoint in order to find image input in the API documentation there, and providing the feature-parity with image functions now in the developer’s control.

Which could look like:

```python
from openai import OpenAI

client = OpenAI()

params = {
  "model": "gpt-5",
  "tools": [
    {
      "type": "function",
      "function": {
        "name": "create_image",
        "description": "Generate an image from a text prompt.",
        "parameters": {
          "type": "object",
          "properties": {
            "prompt": {
              "type": "string",
              "description": "Text description of the image to generate."
            },
            "size": {
              "type": "string",
              "description": "Image size in WxH format, e.g. 1024x1024",
              "enum": ["1536x1024", "1024x1024"]
            },
            "format": {
              "type": "string",
              "description": "Output format for the image.",
              "enum": ["png", "jpeg", "webp"]
            }
          },
          "required": ["prompt"]
        }
      }
    }
  ],
  "messages": [
    {
      "role": "user",
      "content": [
        {
          "type": "text",
          "text": "Create an image of a serene mountain lake at sunrise with mist, ultra-realistic, cinematic lighting."
        }
      ]
    },
    {
      "role": "assistant",
      "content": "Generating your image now.",
      "tool_calls": [
        {
          "id": "call_imgtool_1234567890",
          "type": "function",
          "function": {
            "name": "create_image",
            "arguments": "{\"prompt\":\"serene mountain lake at sunrise with thin mist, ultra-realistic, cinematic lighting, golden hour reflections, 50mm photography, high detail\",\"size\":\"1024x1024\",\"format\":\"png\"}"
          }
        }
      ]
    },
    {
      "role": "tool",
      "tool_call_id": "call_imgtool_1234567890",
      "content": [
        {
          "type": "text",
          "text": "Image successfully generated from prompt."
        },
        {
          "type": "image_url",
          "image_url": {
            "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAoAAAAKACAIAAAB...ELIDED_BASE64_IMAGE_ELIDED...5ErkJggg=="
          }
        }
      ]
    }
  ],
  "max_tokens": 20000
}

# API Call - chat completions
response = client.chat.completions.create(**params)
print(response.choices[0].message.content)

```

If it existed in the API documentation.

A straightforward path that only needs images not impeded by a “role detector”

---

<div class="post-metadata">

**Author:** ![jackiez](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/jackiez/32/511995_2.png) [@jackiez](https://community.openai.com/u/jackiez)\
**Post date:** [October 4, 2025, 10:54pm UTC](https://community.openai.com/t/images-and-files-as-function-call-outputs/1360081/4 "2025-10-04T22:54:42Z")

</div>

Can people confirm this worked in response API. I couldn’t get it working. When sending base64, its counting base64 as string instead of recognizing it as image.  
Here is the payload I used.  
`[{'type': 'function_call_output', 'output': '[{"type": "input_image", "image_url": "data:image/png;base64, <base64 string used>", "detail": "low"}]', 'call_id': 'call_oI0mqpzzXT2eEDdyILm3dvuR'}]`
