black-forest-labs/flux-2-klein-4b-lora/editOd 4 kredytów za obraz· Edytuj obraz

FLUX.2 Klein 4B LoRA edycja obrazu na FLUX.2 [klein] 4B od Black Forest Labs: zmieniaj lub łącz do trzech obrazów źródłowych według polecenia, z maksymalnie trzema twoimi plikami LoRA.

Wywołujesz go nazwą modelu black-forest-labs/flux-2-klein-4b-lora/edit w POST /jobs/createTask, od 4 kredyty za obraz (0,04 USD). Nowe konta dostają 30 darmowych kredytów, więc możesz najpierw przetestować go w Playgroundzie.

  • Utwórz obraz
  • Edytuj obraz
  • Do 2K
  • Do 3 obrazów referencyjnych
  • Proporcje obrazu: 9
  • Własne LoRA
Nazwa modelublack-forest-labs/flux-2-klein-4b-lora/edit
EndpointPOST https://api.popnow.ai/api/v1/jobs/createTask
# 1. Create the task. Keep the Idempotency-Key if you retry after a network error.
export IDEMPOTENCY_KEY="$(uuidgen)"
curl -X POST https://api.popnow.ai/api/v1/jobs/createTask \
  -H "Authorization: Bearer $POPNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $IDEMPOTENCY_KEY" \
  -d '{
  "model": "black-forest-labs/flux-2-klein-4b-lora/edit",
  "input": {
    "prompt": "A ceramic teapot on a linen cloth, soft window light, muted palette",
    "image_urls": [
      "https://media.popnow.ai/influencer/examples/marco.webp"
    ],
    "aspect_ratio": "auto",
    "resolution": "1k"
  }
}'

# 2. Copy data.taskId from the response, then poll until state is succeeded, failed, canceled or expired.
TASK_ID="TASK_ID_FROM_RESPONSE"
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
  -H "Authorization: Bearer $POPNOW_API_KEY"

input jest zbudowany ze schematu poniżej, więc przechodzi walidację bez zmian. Zamień prompt i linki na własne.

Cena

OpcjaKredyty za obraz≈ USD
Standard3,060,031 USD

1 kredyt = 0,01 USD · Wszystkie opcje i ceny: GET /models/black-forest-labs/flux-2-klein-4b-lora/edit

Każde zadanie jest zaokrąglane w górę do pełnych kredytów, więc jedno uruchomienie na najniższym poziomie kosztuje 4 kredyty za obraz (0,04 USD).

Limity

Rozdzielczości
1K · 2K
Proporcje obrazu
auto · 1:1 · 16:9 · 9:16 · 4:3 · 3:4 +4
Obrazy referencyjne
3
Długość promptu (znaki)
5,000
Największy przesyłany plik
10 MB

Parametry

Te pola pochodzą z tego samego schematu, którym sprawdzamy każde żądanie. Pola spoza listy są odrzucane.

  • promptstringWymagane

    Say what to change and what must stay the same. Put a LoRA trigger phrase first.

    Zakres
    1 – 5000 chars
  • image_urlsarray<string>Wymagane

    Zdjęcia do edycji lub połączenia. W prompcie napisz, co wnosi każde z nich.

    Zakres
    1 – 3 items · image/jpeg, image/png, image/webp, image/gif · ≤ 10 MB
  • aspect_ratiostringOpcjonalne

    Kształt kadru: szeroki, kwadratowy albo pionowy.

    Domyślnie
    "auto"
    Dozwolone wartości
    "auto""1:1""16:9""9:16""4:3""3:4""3:2""2:3""21:9""9:21"
  • resolutionstringOpcjonalne

    Rozmiar wyniku. Większy jest ostrzejszy i droższy.

    Domyślnie
    "1k"
    Dozwolone wartości
    "1k""2k"
  • lorasarray<object>Opcjonalne

    Wczytaj własne pliki LoRA, by utrwalić styl lub postać.

    Domyślnie
    []
    Zakres
    0 – 3 items
    Pola wewnętrzne
    • loras[].pathstringWymagane

      Direct URL of a LoRA weights file.

      Zakres
      1 – … chars · application/octet-stream
    • loras[].scalenumberWymagane

      Weight strength from zero to four.

      Domyślnie
      1
      Zakres
      0 – 4
  • seedintegerOpcjonalne

    Ta sama liczba daje powtarzalny wynik.

    Zakres
    0 – 2147483647
Surowy JSON Schema
{
  "additionalProperties": false,
  "properties": {
    "aspect_ratio": {
      "default": "auto",
      "description": "Output aspect ratio; auto keeps the shape of the first source image.",
      "enum": [
        "auto",
        "1:1",
        "16:9",
        "9:16",
        "4:3",
        "3:4",
        "3:2",
        "2:3",
        "21:9",
        "9:21"
      ],
      "type": "string"
    },
    "image_urls": {
      "description": "One to three source images, in the order your prompt refers to them.",
      "items": {
        "contentMediaType": [
          "image/jpeg",
          "image/png",
          "image/webp",
          "image/gif"
        ],
        "format": "uri",
        "minLength": 1,
        "type": "string"
      },
      "maxItems": 3,
      "minItems": 1,
      "type": "array"
    },
    "loras": {
      "default": [],
      "description": "Up to three LoRA weight files trained for FLUX.2 [klein] 4B or FLUX.2 [klein] Base 4B, each with its own strength.",
      "items": {
        "additionalProperties": false,
        "properties": {
          "path": {
            "contentMediaType": [
              "application/octet-stream"
            ],
            "description": "Direct URL of a LoRA weights file.",
            "format": "uri",
            "minLength": 1,
            "type": "string"
          },
          "scale": {
            "default": 1,
            "description": "Weight strength from zero to four.",
            "maximum": 4,
            "minimum": 0,
            "type": "number"
          }
        },
        "required": [
          "path",
          "scale"
        ],
        "type": "object"
      },
      "maxItems": 3,
      "type": "array"
    },
    "prompt": {
      "description": "Say what to change and what must stay the same. Put a LoRA trigger phrase first.",
      "maxLength": 5000,
      "minLength": 1,
      "type": "string"
    },
    "resolution": {
      "default": "1k",
      "description": "Output size tier when you choose an aspect ratio; with auto the result keeps the shape of the first source image.",
      "enum": [
        "1k",
        "2k"
      ],
      "type": "string"
    },
    "seed": {
      "description": "Random seed for controlled comparisons.",
      "maximum": 2147483647,
      "minimum": 0,
      "type": "integer"
    }
  },
  "required": [
    "prompt",
    "image_urls"
  ],
  "type": "object"
}

Prawdziwy wynik z FLUX.2 Klein 4B LoRA

Diner pencil redraw
PromptColored pencil hyperdetailed realism. Redraw this photo as a colored pencil drawing at blue hour: the diner windows now show a cobalt dusk sky, the lights inside are warm, and the top buttons of her yellow shirt-dress are undone as she leans on the counter with her chin on her hand, smiling at the viewer. Keep her face and hair.
To samo żądanie przez API
{
  "model": "black-forest-labs/flux-2-klein-4b-lora/edit",
  "input": {
    "prompt": "Colored pencil hyperdetailed realism. Redraw this photo as a colored pencil drawing at blue hour: the diner windows now show a cobalt dusk sky, the lights inside are warm, and the top buttons of her yellow shirt-dress are undone as she leans on the counter with her chin on her hand, smiling at the viewer. Keep her face and hair.",
    "image_urls": [
      "https://media.popnow.ai/influencer/examples/marco.webp"
    ],
    "aspect_ratio": "auto",
    "resolution": "1k",
    "seed": 28843
  }
}

Ten wynik powstał z przesłanego pliku: wstaw własny link w miejsce przykładowego.

Odpowiedzi, odpytywanie i callbacki

Wszystkie modele działają tak samo: utwórz zadanie, a potem odpytuj je albo poczekaj na callback.

Najpierw cena

cURL
curl -X POST https://api.popnow.ai/api/v1/jobs/quote \
  -H "Authorization: Bearer $POPNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "black-forest-labs/flux-2-klein-4b-lora/edit",
  "input": {
    "prompt": "A ceramic teapot on a linen cloth, soft window light, muted palette",
    "image_urls": [
      "https://media.popnow.ai/influencer/examples/marco.webp"
    ],
    "aspect_ratio": "auto",
    "resolution": "1k"
  }
}'

To samo ciało co createTask. Zwraca przewidywaną i maksymalną możliwą opłatę, niczego nie uruchamiając.

Przyjęte

HTTP
HTTP/1.1 202 Accepted

{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_01k3m8x9q2z4v7n5p6r8s0t1w3",
    "state": "queued"
  },
  "request_id": "req_example_create"
}

HTTP 202 oznacza, że zadanie przyjęto, a kredyty są zarezerwowane, jeszcze nie pobrane. Ostateczna opłata nigdy nie przekroczy rezerwacji.

Sprawdź status

cURL
curl "https://api.popnow.ai/api/v1/jobs/recordInfo?taskId=$TASK_ID" \
  -H "Authorization: Bearer $POPNOW_API_KEY"

Odpytuj co kilka sekund, stopniowo wydłużając odstęp, i przestań, gdy state ma wartość succeeded, failed, canceled lub expired.

Gotowe zadanie

JSON
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_01k3m8x9q2z4v7n5p6r8s0t1w3",
    "model": "black-forest-labs/flux-2-klein-4b-lora/edit",
    "state": "succeeded",
    "output": {
      "assets": [
        {
          "url": "https://cdn.popnow.ai/tasks/task_01k3m8x9q2z4v7n5p6r8s0t1w3/output.png?signature=FROM_RESPONSE",
          "expiresAt": "2026-10-17T12:20:00Z",
          "mime": "image/png",
          "width": 1024,
          "height": 1024
        }
      ]
    },
    "settled": true
  },
  "request_id": "req_example_record"
}

Pobierz plik z url przed expiresAt. Potrzebujesz później nowego linku? Poproś o niego przez POST /common/download-url.

Weryfikacja callbacku

Node.js
import { createHash, createHmac, timingSafeEqual } from "node:crypto";
import express from "express";

const app = express();
// express.raw keeps the exact bytes that were signed; express.json would not match.
app.post("/hooks/popnow", express.raw({ type: "application/json" }), (req, res) => {
  const timestamp = req.header("X-Webhook-Timestamp");
  const signature = req.header("X-Webhook-Signature") ?? "";
  const body = JSON.parse(req.body.toString("utf8"));
  const taskId = body.data?.taskId ?? body.task_id;
  const digest = createHash("sha256").update(req.body).digest("hex");
  const expected = createHmac("sha256", process.env.POPNOW_WEBHOOK_SECRET)
    .update(`${taskId}.${timestamp}.${digest}`)
    .digest("base64");
  const ok = expected.length === signature.length && timingSafeEqual(Buffer.from(expected), Buffer.from(signature));
  // Check the signature first, then reject anything older than five minutes.
  if (!ok || Math.abs(Date.now() / 1000 - Number(timestamp)) > 300) return res.status(401).end();
  res.status(200).end(); // answer fast, then fetch the task and store its files
});

Gdy ustawisz callBackUrl, wyślemy ci gotowe zadanie. Zanim mu zaufasz, sprawdź podpis na surowym ciele żądania.

Wysyłanie pliku lokalnego

cURL
curl -X POST https://api.popnow.ai/api/v1/common/upload-url \
  -H "Authorization: Bearer $POPNOW_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"contentType": "image/png", "bytes": 482113}'

# PUT the file bytes to data.uploadUrl with every header in data.headers, then commit it:
curl -X POST https://api.popnow.ai/api/v1/files/$FILE_ID/commit \
  -H "Authorization: Bearer $POPNOW_API_KEY"
# The commit returns a popnow://f/... reference. Put it in any image, video or
# audio field of the task input instead of a public https URL.

Publiczne linki https działają bez zmian. Pliki lokalne przechodzą najpierw przez upload-url i commit.