Text zu Bild

Kling Image 4.0 — long image

Kling Image 4.0 — long image über die MegaBrain API (Text zu Bild): $0.258 pro Bild. Ein Schlüssel für alle Modelle, Bezahlung aus einem Prepaid-Guthaben in US-Dollar, ohne Abo.

kling-image/v4/long-image
Preis
$0.258
pro Bild

Wird abgebucht, wenn der Auftrag in die Warteschlange kommt, und erstattet, wenn die Generierung scheitert.

Beispielergebnis

Im Browser ausprobieren

Nach der Anmeldung führt der Playground auf der englischen Seite Kling Image 4.0 — long image im Browser aus, bezahlt aus demselben Guthaben wie die API.

Playground öffnen

Anfrageparameter

Felder des JSON-Bodys der Anfrage. Andere Felder nimmt das Modell nicht an: Eine Anfrage mit ihnen erhält einen 400-Fehler.

  • promptStringerforderlich
  • image_urlsListe von URLsoptional
    Bis zu 3 Einträge
  • skillStringoptional
    Standard:
    webpage
    Werte:
    ecommerce, webpage
  • lengthStringoptional
    Standard:
    medium
    Werte:
    short, medium, long
  • resolutionStringoptional
    Standard:
    2k
    Werte:
    1k, 2k

Nutzung über die API

Senden Sie den Auftrag, fragen Sie seine status_url ab, bis sie COMPLETED meldet, und holen Sie das Ergebnis von response_url. Derselbe Schlüssel und dasselbe Guthaben gelten für die Textmodelle. API-Dokumentation (auf Englisch)

curl

curl -X POST https://getmegabrain.com/api/gateway/v1/queue/kling-image/v4/long-image \
  -H "Authorization: Bearer $MEGABRAIN_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"a ceramic coffee mug on a sunlit oak table, product photo"}'

# Then poll status_url and fetch the result from response_url:
curl https://getmegabrain.com/api/gateway/v1/queue/requests/$REQUEST_ID -H "Authorization: Bearer $MEGABRAIN_API_KEY"

Python

import os, time, requests

BASE = "https://getmegabrain.com/api/gateway/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['MEGABRAIN_API_KEY']}"}

job = requests.post(f"{BASE}/queue/kling-image/v4/long-image", headers=HEADERS, json={
  "prompt": "a ceramic coffee mug on a sunlit oak table, product photo"
}).json()

while requests.get(job["status_url"], headers=HEADERS).json()["status"] not in ("COMPLETED", "FAILED"):
    time.sleep(2)

print(requests.get(job["response_url"], headers=HEADERS).json())

JavaScript

const BASE = 'https://getmegabrain.com/api/gateway/v1';
const headers = {
  Authorization: `Bearer ${process.env.MEGABRAIN_API_KEY}`,
  'Content-Type': 'application/json',
};

const job = await fetch(`${BASE}/queue/kling-image/v4/long-image`, {
  method: 'POST',
  headers,
  body: JSON.stringify({
    "prompt": "a ceramic coffee mug on a sunlit oak table, product photo"
  }),
}).then(r => r.json());

let status = job.status;
while (status !== 'COMPLETED' && status !== 'FAILED') {
  await new Promise(r => setTimeout(r, 2000));
  ({ status } = await fetch(job.status_url, { headers }).then(r => r.json()));
}
console.log(await fetch(job.response_url, { headers }).then(r => r.json()));

Häufige Fragen

Was kostet die Kling Image 4.0 — long image API?

$0.258 pro Bild. Der Betrag wird aus einem Prepaid-Guthaben in US-Dollar abgebucht; eine fehlgeschlagene Generierung wird vollständig erstattet. Es gibt kein Abo.

Wie nutze ich Kling Image 4.0 — long image über die API?

Senden Sie den Auftrag mit POST https://getmegabrain.com/api/gateway/v1/queue/kling-image/v4/long-image und Ihrem MegaBrain API-Schlüssel, fragen Sie seine status_url ab, bis sie COMPLETED meldet, und holen Sie das Ergebnis von response_url. Derselbe Schlüssel und dasselbe Guthaben gelten für die Textmodelle.

Kann ich Kling Image 4.0 — long image ohne Code ausprobieren?

Ja: Nach der Anmeldung führt der Playground auf der englischen Seite des Modells Kling Image 4.0 — long image im Browser aus, bezahlt aus demselben Guthaben wie die API.