Prompt
I need inpainting and outpainting in one API
Latest observation
Nov 13, 2026
OpenAI APIWeb search: off
Yes — you can support both inpainting and outpainting with a single API by using one endpoint and switching behavior based on the inputs.
Recommended design
One endpoint
POST /image/edit
Request fields
image— the source imagemask— optional; if present, do inpaintingcanvasorexpandparameters — optional; if present, do outpaintingprompt— text guidance- other generation settings like
seed,strength,steps, etc.
Behavior
- Inpainting: user provides an image + mask. The API fills masked regions.
- Outpainting: user provides an image + desired expansion bounds or target canvas size. The API extends the image into new areas.
Simple rule
- If
maskis provided → inpaint - If
expand/ target size is provided → outpaint - If both are provided → you can either:
- reject as invalid, or
- allow combined editing if your model supports it
Example request
{
"image": "...base64...",
"mask": "...base64...",
"prompt": "replace the sky with sunset clouds",
"steps": 30,
"strength": 0.8
}
Outpainting example:
{
"image": "...base64...",
"prompt": "extend the scene into a wider landscape",
"outpaint": {
"left": 256,
"right": 256,
"top": 0,
"bottom": 0
},
"steps": 30,
"strength": 0.7
}
Best practice
Use a single response format for both:
{
"image": "...result base64...",
"mode": "inpaint"
}
or
{
"image": "...result base64...",
"mode": "outpaint"
}
If you want, I can help you with one of these next:
- API schema design
- FastAPI/Node implementation
- OpenAPI spec
- Prompt logic for deciding inpaint vs outpaint
If you'd like, I can draft a production-ready single-endpoint spec now.