Luma UNI-1
luma-uni-1 · Images · unitool
Фотомодель Luma: генерация изображений по тексту, до девяти референсов стиля и персонажей, редактирование готовой картинки словами.
Generations are async: create, wait or poll, the result by link for 7 days. Details: Media generations
Генерация изображения
Mode t2i · luma-uni-1:t2i
Price
Depends on the parameters: 7 tokens for the example below, base 7. Get the exact price of your request from POST /v1/quotes.
Price make-up (pricing from GET /v1/models/{id})
JSON
{
"unit": "tokens",
"kind": "by_parameters",
"base": 7,
"example_price": 7,
"matrix": [
{
"when": {
"quality": "high"
},
"price": 17
},
{
"when": {
"quality": "standard"
},
"price": 7
}
]
}Parameters
| Parameter | Type | Description |
|---|---|---|
promptrequired | string | |
quality | standard | high | Модель. Max рисует детальнее и стоит дороже.Default "standard" |
aspect_ratio | 1:1 | 16:9 | 3:2 | 2:1 | 3:1 | 9:16 | 2:3 | 1:2 | 1:3 | Соотношение сторонDefault "1:1" |
reference_image_urls | array of file (≤ 9) | A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
Example request
curl
curl https://api.unitool.ai/v1/generations \
-H "Authorization: Bearer $UNITOOL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Prefer: wait=60" \
-d '{
"model": "luma-uni-1",
"mode": "t2i",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"aspect_ratio": "1:1"
}
}'Python (requests)
import json, os, time, uuid, requests
API = "https://api.unitool.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['UNITOOL_API_KEY']}"}
body = json.loads(r'''{
"model": "luma-uni-1",
"mode": "t2i",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"aspect_ratio": "1:1"
}
}''')
gen = requests.post(f"{API}/generations", json=body,
headers={**headers, "Idempotency-Key": str(uuid.uuid4()), "Prefer": "wait=60"}).json()
while gen["status"] in ("queued", "running"):
time.sleep(5)
gen = requests.get(f"{API}/generations/{gen['id']}", headers=headers).json()
print(gen["status"], [o["url"] for o in gen["outputs"]])JavaScript (fetch)
const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "luma-uni-1",
"mode": "t2i",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"aspect_ratio": "1:1"
}
};
let gen = await (await fetch(`${API}/generations`, {
method: "POST", body: JSON.stringify(body),
headers: { ...headers, "Idempotency-Key": crypto.randomUUID(), Prefer: "wait=60" },
})).json();
while (gen.status === "queued" || gen.status === "running") {
await new Promise((resolve) => setTimeout(resolve, 5000));
gen = await (await fetch(`${API}/generations/${gen.id}`, { headers })).json();
}
console.log(gen.status, gen.outputs.map((output) => output.url));Редактирование изображения
Mode edit · luma-uni-1:edit
Price
Depends on the parameters: 7 tokens for the example below, base 7. Get the exact price of your request from POST /v1/quotes.
Price make-up (pricing from GET /v1/models/{id})
JSON
{
"unit": "tokens",
"kind": "by_parameters",
"base": 7,
"example_price": 7,
"matrix": [
{
"when": {
"quality": "high"
},
"price": 17
},
{
"when": {
"quality": "standard"
},
"price": 7
}
]
}Parameters
| Parameter | Type | Description |
|---|---|---|
prompt | string | |
quality | standard | high | Модель. Max рисует детальнее и стоит дороже.Default "standard" |
reference_image_urlsrequired | array of file | Референсы. До восьми дополнительных картинок — с них берут стиль, свет или фактуру. Исходник прикрепите скрепкой к сообщению. A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
image_urlsrequired | array of file (≤ 1) | A file_ref (asset:… or attachment:…), an https URL or a data: URL. |
Example request
curl
curl https://api.unitool.ai/v1/generations \
-H "Authorization: Bearer $UNITOOL_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: $(uuidgen)" \
-H "Prefer: wait=60" \
-d '{
"model": "luma-uni-1",
"mode": "edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"reference_image_urls": [
"https://example.com/input.png"
],
"image_urls": [
"https://example.com/input.png"
]
}
}'Python (requests)
import json, os, time, uuid, requests
API = "https://api.unitool.ai/v1"
headers = {"Authorization": f"Bearer {os.environ['UNITOOL_API_KEY']}"}
body = json.loads(r'''{
"model": "luma-uni-1",
"mode": "edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"reference_image_urls": [
"https://example.com/input.png"
],
"image_urls": [
"https://example.com/input.png"
]
}
}''')
gen = requests.post(f"{API}/generations", json=body,
headers={**headers, "Idempotency-Key": str(uuid.uuid4()), "Prefer": "wait=60"}).json()
while gen["status"] in ("queued", "running"):
time.sleep(5)
gen = requests.get(f"{API}/generations/{gen['id']}", headers=headers).json()
print(gen["status"], [o["url"] for o in gen["outputs"]])JavaScript (fetch)
const API = "https://api.unitool.ai/v1";
const headers = { Authorization: `Bearer ${process.env.UNITOOL_API_KEY}`, "Content-Type": "application/json" };
const body = {
"model": "luma-uni-1",
"mode": "edit",
"input": {
"prompt": "A red fox running through fresh snow at sunrise",
"quality": "standard",
"reference_image_urls": [
"https://example.com/input.png"
],
"image_urls": [
"https://example.com/input.png"
]
}
};
let gen = await (await fetch(`${API}/generations`, {
method: "POST", body: JSON.stringify(body),
headers: { ...headers, "Idempotency-Key": crypto.randomUUID(), Prefer: "wait=60" },
})).json();
while (gen.status === "queued" || gen.status === "running") {
await new Promise((resolve) => setTimeout(resolve, 5000));
gen = await (await fetch(`${API}/generations/${gen.id}`, { headers })).json();
}
console.log(gen.status, gen.outputs.map((output) => output.url));