Skip to content

Commit fa850fe

Browse files
feat: gen alibaba/z-image-turbo / -lora
1 parent 2226706 commit fa850fe

4 files changed

Lines changed: 466 additions & 30 deletions

File tree

Lines changed: 238 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,238 @@
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+
"alibaba/z-image-turbo-lora"
27+
]
28+
},
29+
"prompt": {
30+
"type": "string",
31+
"maxLength": 4000,
32+
"description": "The text prompt describing the content, style, or composition of the image to be generated."
33+
},
34+
"image_size": {
35+
"anyOf": [
36+
{
37+
"type": "object",
38+
"properties": {
39+
"width": {
40+
"type": "integer",
41+
"minimum": 512,
42+
"maximum": 2048,
43+
"default": 1024
44+
},
45+
"height": {
46+
"type": "integer",
47+
"minimum": 512,
48+
"maximum": 2048,
49+
"default": 768
50+
}
51+
},
52+
"description": "For both height and width, the value must be a multiple of 32."
53+
},
54+
{
55+
"type": "string",
56+
"enum": [
57+
"square_hd",
58+
"square",
59+
"portrait_4_3",
60+
"portrait_16_9",
61+
"landscape_4_3",
62+
"landscape_16_9"
63+
],
64+
"description": "The size of the generated image."
65+
}
66+
],
67+
"default": "landscape_4_3"
68+
},
69+
"output_format": {
70+
"type": "string",
71+
"enum": [
72+
"jpeg",
73+
"png",
74+
"webp"
75+
],
76+
"default": "png",
77+
"description": "The format of the generated image."
78+
},
79+
"enable_prompt_expansion": {
80+
"type": "boolean",
81+
"default": true,
82+
"description": "If set to True, prompt will be upsampled with more details."
83+
},
84+
"num_inference_steps": {
85+
"type": "integer",
86+
"minimum": 1,
87+
"maximum": 8,
88+
"description": "The number of inference steps to perform."
89+
},
90+
"seed": {
91+
"type": "integer",
92+
"minimum": 1,
93+
"description": "The same seed and the same prompt given to the same version of the model will output the same image every time."
94+
},
95+
"num_images": {
96+
"type": "number",
97+
"minimum": 1,
98+
"maximum": 4,
99+
"default": 1,
100+
"description": "The number of images to generate."
101+
},
102+
"enable_safety_checker": {
103+
"type": "boolean",
104+
"default": true,
105+
"description": "If set to True, the safety checker will be enabled."
106+
},
107+
"acceleration": {
108+
"type": "string",
109+
"enum": [
110+
"none",
111+
"regular",
112+
"high"
113+
],
114+
"default": "regular",
115+
"description": "The speed of the generation. The higher the speed, the faster the generation."
116+
},
117+
"loras": {
118+
"type": "array",
119+
"items": {
120+
"type": "object",
121+
"properties": {
122+
"path": {
123+
"type": "string",
124+
"description": "URL, HuggingFace repo ID (owner/repo)."
125+
},
126+
"scale": {
127+
"type": "number",
128+
"minimum": 0,
129+
"maximum": 4,
130+
"description": "Scale factor for LoRA application."
131+
}
132+
},
133+
"required": [
134+
"path"
135+
]
136+
},
137+
"maxItems": 3,
138+
"description": "List of LoRA weights to apply (maximum 3). Each LoRA can be a URL, HuggingFace repo ID, or local path."
139+
}
140+
},
141+
"required": [
142+
"model",
143+
"prompt"
144+
],
145+
"title": "alibaba/z-image-turbo-lora"
146+
}
147+
}
148+
}
149+
},
150+
"responses": {
151+
"200": {
152+
"content": {
153+
"application/json": {
154+
"schema": {
155+
"type": "object",
156+
"properties": {
157+
"data": {
158+
"type": "array",
159+
"nullable": true,
160+
"items": {
161+
"type": "object",
162+
"properties": {
163+
"url": {
164+
"type": "string",
165+
"nullable": true,
166+
"description": "The URL where the file can be downloaded from.",
167+
"example": "https://cdn.aimlapi.com/generations/hedgehog/1749730923700-29fe35d2-4aef-4bc5-a911-6c39884d16a8.png"
168+
},
169+
"b64_json": {
170+
"type": "string",
171+
"nullable": true,
172+
"description": "The base64-encoded JSON of the generated image.",
173+
"example": null
174+
}
175+
}
176+
},
177+
"description": "The list of generated images."
178+
},
179+
"meta": {
180+
"type": "object",
181+
"nullable": true,
182+
"properties": {
183+
"usage": {
184+
"type": "object",
185+
"nullable": true,
186+
"properties": {
187+
"tokens_used": {
188+
"type": "number",
189+
"description": "The number of tokens consumed during generation.",
190+
"example": 120000
191+
}
192+
},
193+
"required": [
194+
"tokens_used"
195+
]
196+
}
197+
},
198+
"description": "Additional details about the generation."
199+
}
200+
}
201+
}
202+
}
203+
}
204+
}
205+
},
206+
"x-hideTryItPanel": true,
207+
"x-codeSamples": [
208+
{
209+
"lang": "JavaScript",
210+
"source": "async function main() {\n const response = await fetch('https://api.aimlapi.com/v1/images/generations', {\n method: 'POST',\n headers: {\n 'Authorization': 'Bearer <YOUR_AIMLAPI_KEY>',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n model: 'alibaba/z-image-turbo-lora',\n prompt: 'A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.',\n }),\n });\n\n const data = await response.json();\n console.log(JSON.stringify(data, null, 2));\n}\n\nmain();"
211+
},
212+
{
213+
"lang": "Python",
214+
"source": "import requests\n\nresponse = requests.post(\n \"https://api.aimlapi.com/v1/images/generations\",\n headers={\n \"Content-Type\":\"application/json\", \n \"Authorization\":\"Bearer <YOUR_AIMLAPI_KEY>\",\n },\n json={\n \"model\":\"alibaba/z-image-turbo-lora\",\n \"prompt\": \"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.\"\n }\n)\n\ndata = response.json()\nprint(data)"
215+
},
216+
{
217+
"lang": "cURL",
218+
"source": "curl -L \\\n --request POST \\\n --url 'https://api.aimlapi.com/v1/images/generations' \\\n --header 'Authorization: Bearer <YOUR_AIMLAPI_KEY>' \\\n --header 'Content-Type: application/json' \\\n --data '{\n \"model\": \"alibaba/z-image-turbo-lora\",\n \"prompt\": \"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.\"\n }'"
219+
},
220+
{
221+
"lang": "HTTP",
222+
"source": "POST /v1/images/generations HTTP/1.1\nHost: api.aimlapi.com\nAuthorization: Bearer <YOUR_AIMLAPI_KEY>\nContent-Type: application/json\nAccept: */*\n\n{\n \"model\": \"alibaba/z-image-turbo-lora\",\n \"prompt\": \"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses.\"\n}"
223+
}
224+
]
225+
}
226+
}
227+
},
228+
"components": {
229+
"securitySchemes": {
230+
"access-token": {
231+
"scheme": "bearer",
232+
"bearerFormat": "<YOUR_AIMLAPI_KEY>",
233+
"type": "http",
234+
"description": "Bearer key"
235+
}
236+
}
237+
}
238+
}

0 commit comments

Comments
 (0)