GPT Image 1 Edit Serverless API
Edit and compose images using natural language with GPT Image 1 Edit, OpenAI’s powerful inpainting and multi-reference editing model. Perfect for marketing visuals, product updates, and creative asset generation.
1import requests
2import json
3
4url = "https://api.segmind.com/v1/gpt-image-1-edit"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Make a picture of a 3D action figure toy, named 'Teena'. Display it in transparent blister packaging with 'Teena' in white text at the top. Action figure wears a trendy, chic outfit featuring a stylish crop top with high-waisted skinny jeans and fashionable heels. Include accessories: a smartphone with selfie stick, a small ring light, and a designer handbag beside the figure. Use minimalist cardboard packaging design in cute toy store style. Cartoonish, cute yet neat appearance.",
12 "image_urls": [
13 "https://segmind-resources.s3.amazonaws.com/output/cf5d6d3d-9be2-4538-b6b2-3d8ff11594b9-Beach-walk.png"
14 ],
15 "mask": null,
16 "size": "auto",
17 "quality": "auto",
18 "background": "opaque",
19 "output_compression": 100,
20 "output_format": "png",
21 "moderation": "auto"
22}
23
24response = requests.post(url, headers=headers, json=data)
25
26if response.status_code == 200:
27 result = response.json()
28 print(json.dumps(result, indent=2))
29else:
30 print(f"Error: {response.status_code}")
31 print(response.text) 1import requests
2import json
3
4url = "https://api.segmind.com/v1/gpt-image-1-edit"
5headers = {
6 "x-api-key": "YOUR_API_KEY",
7 "Content-Type": "application/json"
8}
9
10data = {
11 "prompt": "Make a picture of a 3D action figure toy, named 'Teena'. Display it in transparent blister packaging with 'Teena' in white text at the top. Action figure wears a trendy, chic outfit featuring a stylish crop top with high-waisted skinny jeans and fashionable heels. Include accessories: a smartphone with selfie stick, a small ring light, and a designer handbag beside the figure. Use minimalist cardboard packaging design in cute toy store style. Cartoonish, cute yet neat appearance.",
12 "image_urls": [
13 "https://segmind-resources.s3.amazonaws.com/output/cf5d6d3d-9be2-4538-b6b2-3d8ff11594b9-Beach-walk.png"
14 ],
15 "mask": null,
16 "size": "auto",
17 "quality": "auto",
18 "background": "opaque",
19 "output_compression": 100,
20 "output_format": "png",
21 "moderation": "auto"
22}
23
24response = requests.post(url, headers=headers, json=data)
25
26if response.status_code == 200:
27 result = response.json()
28 print(json.dumps(result, indent=2))
29else:
30 print(f"Error: {response.status_code}")
31 print(response.text)API Endpoint
https://api.segmind.com/v1/gpt-image-1-editParameters
image_urlsrequiredstring[]A list of images.
maskrequiredstring (uri)Input Image.
promptrequiredstringText prompt used to generate the image.
""backgroundoptionalstringSelect whether the image background should be transparent or opaque.
"opaque""transparent""opaque"moderationoptionalstringControls the moderation strictness - use low for less restrictions.
"auto""low""auto"output_compressionoptionalintegerSelect the compression level for the output image (1-100).
100output_formatoptionalstringSelect the output format of the image.
"png""png""jpeg""webp"qualityoptionalstringControls the visual quality of the output image.
"auto""low""medium""high""auto"sizeoptionalstringSelect image resolution. Square is the fastest to generate.
"auto""1024x1024""1536x1024""1024x1536""auto"Response Type
Returns: Image
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
Bad Request
Invalid parameters or request format
Unauthorized
Missing or invalid API key
Forbidden
Insufficient permissions
Not Found
Model or endpoint not found
Insufficient Credits
Not enough credits to process request
Rate Limited
Too many requests
Server Error
Internal server error
Bad Gateway
Service temporarily unavailable
Timeout
Request timed out