Generate and edit images
Validate text-to-image first. Add reference images and masks gradually so a failed field is easy to identify.
Endpoint
POST /v1/images/generations
Authorization: Bearer <GATEWAY_API_KEY>
Text to image
curl -X POST http://localhost:9890/v1/images/generations \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_GATEWAY_KEY" \
-d '{
"model": "agnes-2.1",
"prompt": "minimal product photo, soft natural light, clean background",
"size": "1024x1024",
"response_format": "url"
}'
Single reference image
{
"model": "agnes-2.1",
"prompt": "keep the subject and composition, change to a cinematic poster style",
"image": "https://example.com/input.jpg",
"strength": 0.55,
"size": "1024x1024",
"response_format": "url"
}
A higher strength generally allows more deviation from the source. Start with a moderate value.
Multiple references
{
"model": "agnes-2.0",
"prompt": "combine the clothing style from the first image with the scene from the second",
"images": [
"https://example.com/look.jpg",
"https://example.com/scene.jpg"
],
"size": "1024x1024"
}
Mask editing
{
"model": "agnes-2.1",
"prompt": "replace the selected area with white tulips and preserve the original lighting",
"image": "https://example.com/original.jpg",
"mask": "https://example.com/mask.png",
"size": "1024x1024"
}
Input guidance
- Reference URLs must be safely reachable by Gateway; a browser-only local path will not work.
- Validate two-image requests before adding more references.
- Keep mask dimensions aligned with the source and know which color represents the edit area.
- Use
b64_jsononly when an embedded response is required; URLs are simpler for normal use.