Skip to content

Commit 02497dd

Browse files
feat: re-gen gpt-image-1-GENERATE and gpt-image-1-EDIT
1 parent 1c53e0c commit 02497dd

3 files changed

Lines changed: 415 additions & 335 deletions

File tree

Lines changed: 205 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,205 @@
1+
{
2+
"openapi": "3.0.0",
3+
"info": {
4+
"title": "AIML API",
5+
"version": "1.0.0"
6+
},
7+
"servers": [
8+
{
9+
"url": "https://api.aimlapi.com"
10+
}
11+
],
12+
"paths": {
13+
"/v1/images/generations": {
14+
"post": {
15+
"operationId": "_v1_images_generations",
16+
"requestBody": {
17+
"required": true,
18+
"content": {
19+
"application/json": {
20+
"schema": {
21+
"type": "object",
22+
"properties": {
23+
"model": {
24+
"type": "string",
25+
"enum": [
26+
"openai/gpt-image-1"
27+
]
28+
},
29+
"prompt": {
30+
"type": "string",
31+
"maxLength": 32000,
32+
"description": "The text prompt describing the content, style, or composition of the image to be generated."
33+
},
34+
"background": {
35+
"type": "string",
36+
"enum": [
37+
"transparent",
38+
"opaque",
39+
"auto"
40+
],
41+
"default": "auto",
42+
"description": "Allows to set transparency for the background of the generated image(s). When auto is used, the model will automatically determine the best background for the image.\nIf transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp."
43+
},
44+
"moderation": {
45+
"type": "string",
46+
"enum": [
47+
"low",
48+
"auto"
49+
],
50+
"default": "auto",
51+
"description": "Control the content-moderation level for images."
52+
},
53+
"n": {
54+
"type": "number",
55+
"enum": [
56+
1
57+
],
58+
"default": 1,
59+
"description": "The number of images to generate."
60+
},
61+
"output_compression": {
62+
"type": "integer",
63+
"minimum": 0,
64+
"maximum": 100,
65+
"default": 100,
66+
"description": "The compression level (0-100%) for the generated images."
67+
},
68+
"output_format": {
69+
"type": "string",
70+
"enum": [
71+
"png",
72+
"jpeg",
73+
"webp"
74+
],
75+
"default": "png",
76+
"description": "The format of the generated image."
77+
},
78+
"quality": {
79+
"type": "string",
80+
"enum": [
81+
"low",
82+
"high",
83+
"medium"
84+
],
85+
"default": "medium",
86+
"description": "The quality of the image that will be generated."
87+
},
88+
"size": {
89+
"type": "string",
90+
"enum": [
91+
"1024x1024",
92+
"1024x1536",
93+
"1536x1024"
94+
],
95+
"default": "1024x1024",
96+
"description": "The size of the generated image."
97+
},
98+
"response_format": {
99+
"type": "string",
100+
"enum": [
101+
"url",
102+
"b64_json"
103+
],
104+
"default": "url",
105+
"description": "The format in which the generated images are returned."
106+
}
107+
},
108+
"required": [
109+
"model",
110+
"prompt"
111+
],
112+
"title": "openai/gpt-image-1"
113+
}
114+
}
115+
}
116+
},
117+
"responses": {
118+
"200": {
119+
"content": {
120+
"application/json": {
121+
"schema": {
122+
"type": "object",
123+
"properties": {
124+
"data": {
125+
"type": "array",
126+
"nullable": true,
127+
"items": {
128+
"type": "object",
129+
"properties": {
130+
"url": {
131+
"type": "string",
132+
"nullable": true,
133+
"description": "The URL where the file can be downloaded from.",
134+
"example": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png"
135+
},
136+
"b64_json": {
137+
"type": "string",
138+
"nullable": true,
139+
"description": "The base64-encoded JSON of the generated image.",
140+
"example": null
141+
}
142+
}
143+
},
144+
"description": "The list of generated images."
145+
},
146+
"meta": {
147+
"type": "object",
148+
"nullable": true,
149+
"properties": {
150+
"usage": {
151+
"type": "object",
152+
"nullable": true,
153+
"properties": {
154+
"tokens_used": {
155+
"type": "number",
156+
"description": "The number of tokens consumed during generation.",
157+
"example": 120000
158+
}
159+
},
160+
"required": [
161+
"tokens_used"
162+
]
163+
}
164+
},
165+
"description": "Additional details about the generation."
166+
}
167+
}
168+
}
169+
}
170+
}
171+
}
172+
},
173+
"x-hideTryItPanel": true,
174+
"x-codeSamples": [
175+
{
176+
"lang": "JavaScript",
177+
"source": "import fs from 'fs';\nimport fetch from 'node-fetch';\nimport FormData from 'form-data';\n\nasync function main() {\n const formData = new FormData();\n formData.append('model', 'openai/gpt-image-1');\n formData.append('prompt', \"Add a crown to the T-rex's head.\");\n formData.append('image', fs.createReadStream('<YOUR_IMAGE_PATH.png>'), {\n filename: '<IMAGE_NAME>',\n contentType: 'image/png',\n });\n\n const response = await fetch('https://api.aimlapi.com/v1/images/edits', {\n method: 'POST',\n headers: {\n Authorization: 'Bearer <YOUR_AIMLAPI_KEY>',\n ...formData.getHeaders(),\n },\n body: formData,\n });\n\n const data = await response.json();\n console.log(data);\n}\n\nmain();"
178+
},
179+
{
180+
"lang": "Python",
181+
"source": "import requests\nwith open(\"<YOUR_IMAGE_PATH.png>\", \"rb\") as file:\n files = {\"image\": (\"<IMAGE_NAME>\", file, \"image/png\")}\n response = requests.post(\n \"https://api.aimlapi.com/v1/images/edits\",\n headers={\n \"Authorization\":\"Bearer <YOUR_AIMLAPI_KEY>\",\n },\n data={\n \"model\":\"openai/gpt-image-1\",\n \"prompt\": \"Add a crown to the T-rex's head.\"\n },\n files=files\n )\n\n data = response.json()\n print(data)"
182+
},
183+
{
184+
"lang": "cURL",
185+
"source": "curl -L \\\n --request POST \\\n --url 'https://api.aimlapi.com/v1/images/edits' \\\n --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \\\n --form \"prompt=Add a crown to the T-rex's head.\" \\\n --form \"image=@<YOUR_IMAGE_PATH.png>;type=image/png;filename=<IMAGE_NAME>\""
186+
},
187+
{
188+
"lang": "HTTP",
189+
"source": "POST /v1/images/edits HTTP/1.1\nHost: api.aimlapi.com\nAuthorization: Bearer <YOUR_AIMLAPI_KEY>\nContent-Type: multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW\n\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"model\"\n\nopenai/gpt-image-1\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"prompt\"\n\nAdd a crown to the T-rex's head.\n------WebKitFormBoundary7MA4YWxkTrZu0gW\nContent-Disposition: form-data; name=\"image\"; filename=\"<IMAGE_NAME>\"\nContent-Type: image/png\n\n(data)\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
190+
}
191+
]
192+
}
193+
}
194+
},
195+
"components": {
196+
"securitySchemes": {
197+
"access-token": {
198+
"scheme": "bearer",
199+
"bearerFormat": "<YOUR_AIMLAPI_KEY>",
200+
"type": "http",
201+
"description": "Bearer key"
202+
}
203+
}
204+
}
205+
}

0 commit comments

Comments
 (0)