Endpoint doesn’t work? Rather, it is your implementation that doesn’t work.
Tell that AI that wrote your little code snippet that it will have to do better: that it is a file that must be sent, not binary data, and it must have a filename attached so that mime type discriminator can properly construct a well-formed multipart/form-type request as is performed in the OpenAI SDK when it employs the httpx library as its client and transport mechanism.
Might hit you back with exact what you said was the issue…
Nee bother, pet —here’s what’s gannin’ on.
What the SDK is looking for
When the Python SDK sees a value for image=… it checks:
- Is it a file‑like object?
Something with a.read()method. - Does that object have a
.nameattribute?
The filename lets httpx guess the MIME type (mimetypes.guess_type).
3.If there’s no name it falls back toapplication/octet-stream.*
A plain bytes object (what you get from byte_stream.getvalue()) has neither a read() nor a name, so it’s treated as raw bytes and lands in the request as octet‑stream, which the Images endpoint quite rightly rejects.
You also aren’t going to be able to “edit” a black cat that is in RGB. You must have an alpha channel of pure transparency for the AI to fill in, a mask in 32 bit color.
Like, say, your 32 bit RGBA cat was a bit too polydactyl for your tastes…
