Collage Poster Maker with GPT Image 2 Serverless API
Create Visually Impactful Collage Posters with GPT Image 2 and Claude 4.5 Sonnet.
~$0.1455
1import requests
2import time
3import json
4
5api_key = "YOUR_API_KEY"
6url = "https://api.segmind.com/workflows/v2/6a60b4f46010deb9d8f2c9c0-v1"
7
8data = {
9 "input_character_image": "https://segmind-inference-inputs.s3.amazonaws.com/fb1cf924-527c-499b-b9b9-2106aa4f574b-bb2ee16f-c2e4-456e-87f2-7b64fb97066a-Dipke CJP protest.webp",
10 "referance_images": [
11 "https://segmind-inference-inputs.s3.amazonaws.com/455be0a7-c636-4d57-91eb-678dcc6df15a-8433aab9d7dbb0e598678f6feee24769.jpg",
12 "https://segmind-inference-inputs.s3.amazonaws.com/2cb1c422-8928-4b63-8514-b4c42bbc0255-7de362878fb802d5348eb5ff8cc5eb4d.jpg"
13 ],
14 "text_x2yhq": "in the style of the two posters attached which are @Image 1 and @Image 2 create a poster of @Image 3 as the main subject. you can use the grunge and distorted imagery as is for the cutout of the man in the vest and red paint dripping from his head with the copy \"You can tear gas the streets, but you can't silence the youth!\". Keep the colours of the indian flag as the main colour palatte. add textures like handmade paper and hand-drawn art. keep the main subject seen in @Image 3 as the hero of the poster. do not add any extra text in the poster."
15}
16
17def poll_for_result(poll_url):
18 """Poll the API until the generation is complete"""
19 while True:
20 response = requests.get(
21 poll_url,
22 headers={'Authorization': f'Bearer {api_key}'}
23 )
24 result = response.json()
25
26 if result['status'] == 'COMPLETED':
27 # Parse the output (it's a JSON string)
28 outputs = json.loads(result['output'])
29 return outputs
30 elif result['status'] == 'FAILED':
31 raise Exception(result.get('error', 'Generation failed'))
32
33 # Wait 7 seconds before polling again
34 time.sleep(7)
35
36# Make the initial request
37response = requests.post(
38 url,
39 json=data,
40 headers={
41 'Authorization': f'Bearer {api_key}',
42 'Content-Type': 'application/json'
43 }
44)
45
46if response.status_code == 200:
47 result = response.json()
48 print('Request queued:', result)
49
50 # Start polling for results
51 outputs = poll_for_result(result['poll_url'])
52 print('Generation complete:', outputs)
53else:
54 print(f"Error: {response.status_code}")
55 print(response.text) 1import requests
2import time
3import json
4
5api_key = "YOUR_API_KEY"
6url = "https://api.segmind.com/workflows/v2/6a60b4f46010deb9d8f2c9c0-v1"
7
8data = {
9 "input_character_image": "https://segmind-inference-inputs.s3.amazonaws.com/fb1cf924-527c-499b-b9b9-2106aa4f574b-bb2ee16f-c2e4-456e-87f2-7b64fb97066a-Dipke CJP protest.webp",
10 "referance_images": [
11 "https://segmind-inference-inputs.s3.amazonaws.com/455be0a7-c636-4d57-91eb-678dcc6df15a-8433aab9d7dbb0e598678f6feee24769.jpg",
12 "https://segmind-inference-inputs.s3.amazonaws.com/2cb1c422-8928-4b63-8514-b4c42bbc0255-7de362878fb802d5348eb5ff8cc5eb4d.jpg"
13 ],
14 "text_x2yhq": "in the style of the two posters attached which are @Image 1 and @Image 2 create a poster of @Image 3 as the main subject. you can use the grunge and distorted imagery as is for the cutout of the man in the vest and red paint dripping from his head with the copy \"You can tear gas the streets, but you can't silence the youth!\". Keep the colours of the indian flag as the main colour palatte. add textures like handmade paper and hand-drawn art. keep the main subject seen in @Image 3 as the hero of the poster. do not add any extra text in the poster."
15}
16
17def poll_for_result(poll_url):
18 """Poll the API until the generation is complete"""
19 while True:
20 response = requests.get(
21 poll_url,
22 headers={'Authorization': f'Bearer {api_key}'}
23 )
24 result = response.json()
25
26 if result['status'] == 'COMPLETED':
27 # Parse the output (it's a JSON string)
28 outputs = json.loads(result['output'])
29 return outputs
30 elif result['status'] == 'FAILED':
31 raise Exception(result.get('error', 'Generation failed'))
32
33 # Wait 7 seconds before polling again
34 time.sleep(7)
35
36# Make the initial request
37response = requests.post(
38 url,
39 json=data,
40 headers={
41 'Authorization': f'Bearer {api_key}',
42 'Content-Type': 'application/json'
43 }
44)
45
46if response.status_code == 200:
47 result = response.json()
48 print('Request queued:', result)
49
50 # Start polling for results
51 outputs = poll_for_result(result['poll_url'])
52 print('Generation complete:', outputs)
53else:
54 print(f"Error: {response.status_code}")
55 print(response.text)API Endpoint
POST
https://api.segmind.com/workflows/v2/6a60b4f46010deb9d8f2c9c0-v1Parameters
input_character_imageoptionalstring (uri)Input Character Image
Default:
"https://segmind-inference-inputs.s3.amazonaws.com/fb1cf924-527c-499b-b9b9-2106aa4f574b-bb2ee16f-c2e4-456e-87f2-7b64fb97066a-Dipke CJP protest.webp"referance_imagesoptionalarrayReferance Images
Default:
["https://segmind-inference-inputs.s3.amazonaws.com/455be0a7-c636-4d57-91eb-678dcc6df15a-8433aab9d7dbb0e598678f6feee24769.jpg","https://segmind-inference-inputs.s3.amazonaws.com/2cb1c422-8928-4b63-8514-b4c42bbc0255-7de362878fb802d5348eb5ff8cc5eb4d.jpg"]text_x2yhqoptionalstringText X2yhq
Default:
"in the style of the two posters attached which are @Image 1 and @Image 2 create a poster of @Image 3 as the main subject. you can use the grunge and distorted imagery as is for the cutout of the man in the vest and red paint dripping from his head with the copy \"You can tear gas the streets, but you can't silence the youth!\". Keep the colours of the indian flag as the main colour palatte. add textures like handmade paper and hand-drawn art. keep the main subject seen in @Image 3 as the hero of the poster. do not add any extra text in the poster."Response Format
Returns: Polling-based asynchronous response
Initial request returns a poll_url. Poll every 7 seconds until status is COMPLETED.
Common Error Codes
The API returns standard HTTP status codes. Detailed error messages are provided in the response body.
400
Bad Request
Invalid parameters or request format
401
Unauthorized
Missing or invalid API key
403
Forbidden
Insufficient permissions
404
Not Found
Workflow not found
406
Insufficient Credits
Not enough credits to process request
429
Rate Limited
Too many requests
500
Server Error
Internal server error
502
Bad Gateway
Service temporarily unavailable
504
Timeout
Request timed out