開發者

Text-to-Image API

An async, task-based REST API: submit a prompt, get a `task_id` immediately (HTTP 202), then poll until the image URL is ready. One key works across capabilities; failed tasks never consume quota.

最後更新:2026-11-08

本頁暫無本地語言版本,以下為英文原文。

Quick start

Issue a key on your account page, then submit a task with X-API-Key:

# 1. Submit — returns HTTP 202 with a task_id immediately
curl -X POST https://create.litelake.com/api/open/t2i \
  -H "X-API-Key: lcr_…" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"a calm lake at dawn, soft light","aspect_ratio":"16:9","output_format":"png"}'
{
  "code": 200,
  "message": "ok",
  "data": {
    "task_id": "tsk_…",
    "status": "queued",
    "capability": "t2i",
    "created_at": "2026-11-08T02:00:00Z",
    "usage": {
      "personal": { "used_today": 1, "limit_per_day": 1 },
      "site_free": { "used_today": 3, "limit_per_day": 10 },
      "reset_at_utc": "…"
    }
  }
}
# 2. Poll — every 2 seconds until status is a terminal state
curl https://create.litelake.com/api/open/tasks/tsk_… \
  -H "X-API-Key: lcr_…"
{
  "code": 200,
  "message": "ok",
  "data": {
    "task_id": "tsk_…",
    "status": "succeeded",
    "capability": "t2i",
    "prompt": "a calm lake at dawn, soft light",
    "aspect_ratio": "16:9",
    "output_format": "png",
    "image": { "url": "https://…", "expires_at": "…" },
    "error": null,
    "latency_ms": 8210,
    "created_at": "2026-11-08T02:00:00Z",
    "finished_at": "2026-11-08T02:00:09Z"
  }
}

Authentication

All open endpoints authenticate with a request header: X-API-Key: lcr_…. Create keys on your account page; the full key is shown only once at issuance. Keys inherit your personal daily quota; super keys (issued through the Admin Center) are unlimited.

Submit — POST /api/open/t2i

Returns HTTP 202 (acceptance) with the envelope above. The task is queued; nothing is returned synchronously.

ParameterTypeDescription
promptstringRequired. What to generate, up to 2000 characters.
aspect_ratio"1:1" | "2:3" | "3:2" | "3:4" | "4:3" | "9:16" | "16:9"Defaults to 1:1.
output_format"png" | "jpeg" | "webp"Defaults to png.

Poll — GET /api/open/tasks/{task_id}

Returns the task resource. status walks the pipeline:

StatusMeaning
queuedAccepted, waiting for a worker.
submittedSent to the upstream model.
runningThe model is generating.
transferringGenerated — the image is being copied to storage.
succeededDone. image.url is the download link (keep for 24h per fetch; image itself retained 7 days).
failederror.code / error.message say why. Quota was not consumed for upstream failures.
expiredThe result window lapsed before retrieval. Submit again.

Poll every 2 seconds. Tasks typically finish in about 10 seconds; stop polling after 90 seconds and treat the task as still-running (check again later).

List tasks — GET /api/open/tasks?limit=N

Returns your most recent tasks, newest first (limit defaults to 20).

Error codes

Business errors keep the envelope with a code in body.code. Codes below apply to both the open API and the signed-in playground.

CodeMeaning
40001invalid_params — a parameter is missing or outside the whitelist.
40021prompt_too_long — prompt exceeds 2000 characters.
40102unauthorized — no valid session or key (HTTP 401 on the user surface).
40301account_suspended — the account is banned.
42901personal daily quota exhausted — resets at 00:00 UTC.
42902site-wide free budget exhausted — resumes at the next UTC day.
42903concurrency limit — wait for your in-flight task to finish, then submit again.
50021upstream generation failed — retry later; quota not consumed.
50022upstream timeout — retry; quota not consumed.
50023network error interrupted the task — retry.
50024rate-limit store unavailable — retry shortly.
50025upstream busy — retry shortly; quota not consumed.

Limits & notes

  • Free Beta: 1 successful generation per user per day (UTC reset); failed or timed-out tasks do not count.
  • The free tier also shares a site-wide daily budget; when it runs out (42902), generation resumes at the next UTC day.
  • Generated images are retained for 7 days. The image.url returned per poll is a direct link valid for 24 hours after each fetch — re-fetch the task to get a fresh link.
  • Concurrency: one in-flight task per identity (42903).
  • Capability is fixed to t2i in Beta; more dimensions (image-to-image, text-to-video) are planned.

取得 API Key

登錄後在帳戶頁自助建立;明文只在建立時展示一次。 打開帳戶頁