# GPT Image 1 Input Fidelity

**URL:** https://community.openai.com/t/gpt-image-1-input-fidelity/1317640
**Category:** API
**Tags:** gpt-image-1
**Created:** [July 16, 2025, 7:30pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640 "2025-07-16T19:30:48Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![Rohan\_Kulkarni](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/rohan_kulkarni/32/511718_2.png) [@Rohan\_Kulkarni](https://community.openai.com/u/Rohan_Kulkarni)
#### Post date: [July 16, 2025, 7:30pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/1 "2025-07-16T19:30:48Z")

</div>

Hi,

I tried to use the Input Fidelity parameter while using the GPT Image 1 API and it returned an error? Is there some mistake that I’m making or is it that the parameter is not accepted anymore?

---

<div class="post-metadata">

### Author: ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/719663_2.png) [@\_j](https://community.openai.com/u/_j)
#### Post date: [July 16, 2025, 9:15pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/2 "2025-07-16T21:15:33Z")

</div>

The `input_fidelity` parameter was only [just announced](https://community.openai.com/t/image-generation-high-fidelity-editing/1317649) today.

It is only on the edits endpoint, and is meant to improve the reproduction of input images if used with `input_fidelity="high"`.

Ensure the latest SDK, as the OpenAI library will block unknown API parameters, quickly becoming obsolete:

`pip install --upgrade --upgrade-strategy=eager openai`

Then send your input image, such as this woman from the announcement:

 ![A woman with long dark hair and a gray t-shirt is smiling at the camera while standing outside in a green park. (Captioned by AI)](https://us1.discourse-cdn.com/openai1/original/4X/e/2/f/e2fcfe13682c3dd863ea56734133dc63be1a599b.jpeg)

Along with a prompt:

```markdown
Photograph of a woman pictured from the input image.
However, she now has colorful rainbow-streaked hair, and wears a pretty yellow blouse.

```

Receive an output, with the cropping received showing that you need to refine the technique, such as demanding a “zoom out”, or needing a vertical profile aspect ratio:

 ![A smiling woman with vibrant rainbow-colored hair wears a yellow top and stands outdoors in a park. (Captioned by AI)](https://us1.discourse-cdn.com/openai1/original/4X/f/e/f/fefdfa75763438ab4c7b1f478099c73727cf6bc1.jpeg)

The model itself requires an organization to be ID-verified.

---

<div class="post-metadata">

### Author: ![roman.skornak](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@roman.skornak](https://community.openai.com/u/roman.skornak)
#### Post date: [July 24, 2025, 6:53pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/3 "2025-07-24T18:53:07Z")

</div>

Hi, it’s great, but I can’t get it to work. What am I doing wrong, it keeps giving me an error:  
❌ Chyba 400: {  
“error”: {  
“message”: “Unknown parameter: ‘input\_fidelity’.”,  
“type”: “invalid\_request\_error”,  
“param”: “input\_fidelity”,  
“code”: “unknown\_parameter”  
}  
}

**This is my python code:**

# -_- coding: utf-8 -_-

import base64  
import requests  
from PIL import Image  
from io import BytesIO

api\_key = “sk-”

# URL obrázků

url\_person = “…/imggallery/reklamyfromgpt/76-23153-36-ig.jpg”  
url\_shirt = “…/imggallery/reklamyfromgpt/slayer-shirt.png”

# Funkce pro převod na base64

def image\_url\_to\_base64(url):  
resp = requests.get(url)  
if resp.status\_code != 200:  
raise Exception(f"Chyba při stahování: {url}")  
return base64.b64encode(resp.content).decode(“utf-8”)

# Načti obrázky jako base64

img\_person = image\_url\_to\_base64(url\_person)  
img\_shirt = image\_url\_to\_base64(url\_shirt)

# JSON payload

payload = {  
“model”: “gpt-image-1”,  
“prompt”: “”"  
The first image shows a man wearing a blank shirt.  
The second image shows a Slayer T-shirt design.  
Put the design from the second image on the shirt in the first image, keeping realistic lighting, folds, and perspective.  
“”",  
“size”: “1024x1024”,  
“quality”: “high”,  
“input\_fidelity”: “high”,  
“response\_format”: “b64\_json”,  
“referenced\_images”: [  
{ “type”: “image”, “data”: img\_person },  
{ “type”: “image”, “data”: img\_shirt }  
]  
}

# Zavolání API přes HTTP

headers = {  
“Authorization”: f"Bearer {api\_key}",  
“Content-Type”: “application/json”  
}

response = requests.post(  
“… /v1/images/generations”,  
headers=headers,  
json=payload  
)

if response.status\_code == 200:  
data = response.json()  
img\_data = base64.b64decode(data[‘data’][0][‘b64\_json’])  
image = Image.open(BytesIO(img\_data))  
image.save(“output.png”)  
image.show()  
print(“✅ Obrázek vygenerován a uložen jako output.png”)  
else:  
print(f"❌ Chyba {response.status\_code}: {response.text}")

---

<div class="post-metadata">

### Author: ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/719663_2.png) [@\_j](https://community.openai.com/u/_j)
#### Post date: [July 24, 2025, 7:22pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/4 "2025-07-24T19:22:00Z")

</div>

You are sending to the “generations” API endpoint URL, which only accepts prompt. Not a good way to “edit”. 🙂 Also, there are elides where you need a full URL. The same issue is possible in your image sources too if you didn’t do that just for privacy.

`.post("https://api.openai.com/v1/images/edits", ...)`

---

<div class="post-metadata">

### Author: ![roman.skornak](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@roman.skornak](https://community.openai.com/u/roman.skornak)
#### Post date: [July 24, 2025, 7:41pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/5 "2025-07-24T19:41:52Z")

</div>

```auto
Now the error is like this, I didn't send it as a code last time, sorry:
❌ Chyba 400: {
  "error": {
    "message": "Unsupported content type: 'application/json'. This API method only accepts 'multipart/form-data' requests, but you specified the header 'Content-Type: application/json'. Please try again with a supported content type.",
    "type": "invalid_request_error",
    "param": null,
    "code": "unsupported_content_type"
  }
}

# -*- coding: utf-8 -*-
import base64
import requests
from PIL import Image
from io import BytesIO

api_key = "sk-"

# URL obrázků
url_person = "https://www.atakt.cz/imggallery/reklamyfromgpt/76-23153-36-ig.jpg"
url_shirt = "https://www.atakt.cz/imggallery/reklamyfromgpt/slayer-shirt.png"

# Funkce pro převod na base64
def image_url_to_base64(url):
    resp = requests.get(url)
    if resp.status_code != 200:
        raise Exception(f"Chyba při stahování: {url}")
    return base64.b64encode(resp.content).decode("utf-8")

# Načti obrázky jako base64
img_person = image_url_to_base64(url_person)
img_shirt = image_url_to_base64(url_shirt)

# JSON payload
payload = {
    "model": "gpt-image-1",
    "prompt": """
The first image shows a man wearing a blank shirt.
The second image shows a Slayer T-shirt design.
Put the design from the second image on the shirt in the first image, keeping realistic lighting, folds, and perspective.
""",
    "size": "1024x1024",
    "quality": "high",
    "input_fidelity": "high",
    "response_format": "b64_json",
    "referenced_images": [
        { "type": "image", "data": img_person },
        { "type": "image", "data": img_shirt }
    ]
}

# Zavolání API přes HTTP
headers = {
    "Authorization": f"Bearer {api_key}",
    "Content-Type": "application/json"
}

response = requests.post(
    "https://api.openai.com/v1/images/edits",
    headers=headers,
    json=payload
)

if response.status_code == 200:
    data = response.json()
    img_data = base64.b64decode(data['data'][0]['b64_json'])
    image = Image.open(BytesIO(img_data))
    image.save("output.png")
    image.show()
    print("✅ Obrázek vygenerován a uložen jako output.png")
else:
    print(f"❌ Chyba {response.status_code}: {response.text}")

```

---

<div class="post-metadata">

### Author: ![roman.skornak](https://avatars.discourse-cdn.com/v4/letter/r/b9e5f3/32.png) [@roman.skornak](https://community.openai.com/u/roman.skornak)
#### Post date: [July 24, 2025, 8:05pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/6 "2025-07-24T20:05:54Z")

</div>

```auto
# this is my last tested version, so I sent multipart/form-data
# but I have another new error

PS C:\PythonScript\GPTImages> python generate_image2.py
❌ Chyba 400: {
  "error": {
    "message": "Unknown parameter: 'response_format'.",
    "type": "invalid_request_error",
    "param": "response_format",
    "code": "unknown_parameter"
  }
}

# -*- coding: utf-8 -*-
import base64
import requests
from io import BytesIO
from PIL import Image

api_key = "sk-"

# URL obrázků
url_person = "https://www.atakt.cz/imggallery/reklamyfromgpt/76-23153-36-ig.jpg"
url_shirt = "https://www.atakt.cz/imggallery/reklamyfromgpt/slayer-shirt.png"

# Stažení obrázku a načtení jako soubor
def download_image(url):
    resp = requests.get(url)
    if resp.status_code != 200:
        raise Exception(f"Chyba při stahování: {url}")
    return BytesIO(resp.content)

# Načti oba obrázky jako soubory
image_person = download_image(url_person)
image_shirt = download_image(url_shirt)

# Sestavení multipart/form-data požadavku
files = {
    "image": ("person.png", image_person, "image/png"),
    "mask": ("mask.png", image_shirt, "image/png")
}

data = {
    "model": "gpt-image-1",
    "prompt": "The first image shows a man wearing a blank shirt.\n"
              "The second image shows a Slayer T-shirt design.\n"
              "Put the design from the second image on the shirt in the first image, "
              "keeping realistic lighting, folds, and perspective.",
    "size": "1024x1024",
    "response_format": "b64_json"
}

headers = {
    "Authorization": f"Bearer {api_key}"
}

# Odeslání požadavku
response = requests.post(
    "https://api.openai.com/v1/images/edits",
    headers=headers,
    data=data,
    files=files
)

# Zpracování odpovědi
if response.status_code == 200:
    data = response.json()
    img_data = base64.b64decode(data['data'][0]['b64_json'])
    image = Image.open(BytesIO(img_data))
    image.save("output.png")
    image.show()
    print("✅ Obrázek vygenerován a uložen jako output.png")
else:
    print(f"❌ Chyba {response.status_code}: {response.text}")

```

---

<div class="post-metadata">

### Author: ![\_j](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/_j/32/719663_2.png) [@\_j](https://community.openai.com/u/_j)
#### Post date: [July 24, 2025, 8:53pm UTC](https://community.openai.com/t/gpt-image-1-input-fidelity/1317640/7 "2025-07-24T20:53:34Z")

</div>

You’ve asked how to properly use the “files=” parameter of Python’s requests library. You send binaries with the files method, such as bytes from a different file download or by reading a file, and should provide a file name. That creates the `multipart/form-data` API request.

The model gpt-image-1 does not accept a “response\_format”, as it only can send you base64 in a JSON.

Here’s a complete learning path through making an edits API call, submitting the form with the alternate httpx library, with some parameters for you. It is focused on local files being read. I commented the new parameter so first experiments are cheaper.

```python
"""
Edit one or more images via the /v1/images/edits endpoint, using httpx
and multipart/form‑data. The code mirrors my earlier SDK example of another
topic, while keeping the same parameter documentation and error‑handling style.
"""

import os
import base64
from pathlib import Path
import httpx

# ---------------------------------------------------------------------------
# User‑supplied inputs
# ---------------------------------------------------------------------------
PROMPT = "The woman pictured is transformed into a blonde!"
INPUT_PATHS = [
    "your-input.png",
    # "another_dir/yet_another_file.png",
]
OUTPUT_FILE = "new-output.png"

# ---------------------------------------------------------------------------
# Build the multipart payload
# ---------------------------------------------------------------------------
# Convert string paths to Path objs (normalizes Win/Mac/Linux separators)
file_paths = [Path(p) for p in INPUT_PATHS]

# Each form part is a 2‑tuple: (field_name, (filename|None, bytes|fileobj, content_type?))
# * All parts, including non‑file params, MUST go in the `files=` argument.
multipart_parts = []

# Image file parts
for p in file_paths:
    # "image" is the official field name; endpoint accepts multiple of them
    multipart_parts.append(
        (
            "image",
            (p.name, p.open("rb"), "image/png"), # supply filename
        )
    )

# Non‑file parameters (model, prompt, options...)
params = {
    "model": "gpt-image-1",
    "prompt": PROMPT.strip(),
    "quality": "medium", # "high" | "medium" | "low"
    "size": "1024x1024", # or "1536x1024", "1024x1536", "auto"
    "output_format": "png", # "png" | "jpg" | "webp"
    "background": "opaque", # "opaque" | "transparent" (not with jpg)
    # "input_fidelity": "high", # this is the new parameter - additional $0.04 or $0.06 for better copying
    "stream": "false",
    "user": "myCustomer",
}

# For form‑data, non‑file fields go in the same list; give them no filename
for key, val in params.items():
    multipart_parts.append((key, (None, str(val))))

# ---------------------------------------------------------------------------
# Send the request
# ---------------------------------------------------------------------------
api_key = os.getenv("OPENAI_API_KEY")
if not api_key:
    raise RuntimeError("OPENAI_API_KEY env var is missing")

headers = {"Authorization": f"Bearer {api_key}"}
url = "https://api.openai.com/v1/images/edits"

try:
    with httpx.Client(timeout=60.0) as client:
        resp = client.post(url, files=multipart_parts, headers=headers)
        resp.raise_for_status() # raises httpx.HTTPStatusError on 4xx/5xx

    # -----------------------------------------------------------------------
    # Decode the returned base64 image
    # -----------------------------------------------------------------------
    data = resp.json()
    b64 = data["data"][0]["b64_json"]
    img_bytes = base64.b64decode(b64)

    out_path = Path(OUTPUT_FILE)
    out_path.parent.mkdir(parents=True, exist_ok=True)
    out_path.write_bytes(img_bytes)

    print(f"Image written to {out_path.resolve()}")

except httpx.HTTPStatusError as e:
    # API returned a non‑2xx; include code and body for debugging
    print(f"OpenAI API error [{e.response.status_code}]: {e.response.text}")

except httpx.RequestError as e:
    # Network problem, DNS failure, etc.
    print(f"Request error: {e}")

```
