Are you an LLM? Read llms.txt for a summary of the docs, or llms-full.txt for the full context.
Skip to content

Images, video and audio

For images and video, query the model catalog with your key and inspect the exact endpoint, parameters and example. For audio, use the model-selection guidance below. Availability and options depend on the model and deployment; one model need not support all media types. Examples require Python 3 and the requests package (python -m pip install requests). Set LAZU_API_KEY and the model variables below.

Generate an image

Set LAZU_IMAGE_MODEL to a model supporting /v1/images/generations. The response can include data[].url or data[].b64_json; handle the actual returned form. Size, quality and output format depend on the model. Do not assume generated URLs are permanent.

import os
import requests

origin = os.environ.get("LAZU_API_ORIGIN", "https://api.lazu.ai").rstrip("/")
response = requests.post(origin + "/v1/images/generations",
    headers={"Authorization": "Bearer " + os.environ["LAZU_API_KEY"]},
    json={"model": os.environ["LAZU_IMAGE_MODEL"], "prompt": "A blue ceramic cup"},
    timeout=180)
response.raise_for_status()
print(response.json()["data"])

Seedream images, edits and layers

Use POST /v1/images/generations for both generation and editing. Send references in the JSON image field as a URL, data URL, or array. Seedream does not use multipart /v1/images/edits in Lazu. Responses are non-streaming. Studio supports ordinary generation and reference editing; use the API for native batch generation and decomposition.

Published standard prices at launch (USD; the authenticated catalog is authoritative for your current price):

ModelUSD / successful output
seedream-5.0-flash$0.018
seedream-5.0-lite$0.035
seedream-4.5$0.040
seedream-5.0-pro$0.045 (≤ 2,610,000 pixels), $0.090 (> 2,610,000 pixels)

For Pro decomposition, every returned image including the base image costs $0.0225 at ≤ 2,610,000 pixels or $0.045 above that threshold. Pro's first reference is free; each additional reference costs $0.003 per successful request. References are free on Flash, Lite and 4.5. Flash decomposition uses its normal $0.018 per returned image. Successful images alone are charged, even if a batch is incomplete; failed or moderated outputs are not charged. data[].size determines each image's pixel tier. Output tokens reported by the provider are not an additional token charge.

Pro/Flash accept 1K, 1.5K, 2K or valid dimensions and up to 10 references. Lite accepts 2K, 3K, 4K; 4.5 accepts 2K, 4K; both accept up to 14 references. Legacy 1024x1024 is too small for Lite/4.5. Read parameters from the catalog for the selected model.

Lite/4.5 support sequential_image_generation: "auto" with max_images. References plus the requested maximum cannot exceed 15. n > 1 is a convenience alias for this native batch operation. Pro/Flash generate one ordinary image per request.

{
  "model": "seedream-5.0-lite",
  "prompt": "Create two matching blue ceramic cup designs",
  "size": "2K",
  "sequential_image_generation": "auto",
  "sequential_image_generation_options": { "max_images": 2 }
}

For Pro/Flash layers, send layer_decomposition: true, exactly one image, and optionally prompt; size defaults to auto. The response may contain a base image and up to 16 layers. Preserve z_index, bounding_box, name, description and each image's size. Decomposition reserves up to 17 outputs, then releases the difference after settlement.

Prices are exposed in pricing.image_pricing (also per lane): output_usd, pixel_threshold, high_resolution_output_usd, layer_usd, high_resolution_layer_usd, reference_usd, free_references. Reconcile the returned usage.cost and usage.generated_images using the request's usage record. The gateway reserves the maximum possible charge first, then settles successful outputs at their actual sizes; keep enough key/project balance for that reservation.

Official references: image API, pricing.

Submit and poll a video

Set LAZU_VIDEO_MODEL to a model supporting /v1/videos. A successful submission returns HTTP 202 and a job ID. Read the job with the same key and ?wait=60: the call answers as soon as the job's status changes or it finishes, and otherwise after 60 seconds, each time with progress (0–100) and eta_seconds; repeat it until the status is final, with no sleep between calls. GET /v1/videos/{id}/events sends the same as Server-Sent Events until the job is done. succeeded carries artifact.url, a download link that works for an hour (read the job again for a fresh one), and artifact.expires_at, when the stored file is deleted. GET /v1/videos/{id}/content downloads the same file with your key. failed includes an error, and the held amount is refunded. A local wait timeout does not cancel or fail the job. Save the ID and resume polling; do not submit another paid job just because the wait ended.

import os
import time
import requests

origin = os.environ.get("LAZU_API_ORIGIN", "https://api.lazu.ai").rstrip("/")
headers = {"Authorization": "Bearer " + os.environ["LAZU_API_KEY"]}
response = requests.post(origin + "/v1/videos", headers=headers,
    json={"model": os.environ["LAZU_VIDEO_MODEL"], "prompt": "Ocean waves at sunrise"},
    timeout=180)
response.raise_for_status()
job_id = response.json()["id"]
print("Save job ID:", job_id, flush=True)
deadline = time.monotonic() + 600
while time.monotonic() < deadline:
    # wait=60 answers as soon as the job finishes, or after 60 s.
    response = requests.get(origin + "/v1/videos/" + job_id, params={"wait": 60},
                            headers=headers, timeout=90)
    if response.status_code in (429, 503):
        retry_after = response.headers.get("Retry-After", "5")
        delay = float(retry_after) if retry_after.isdecimal() else 5
        if delay >= deadline - time.monotonic():
            print("Still waiting; resume GET for job:", job_id)
            break
        time.sleep(max(1, delay))
        continue
    response.raise_for_status()
    job = response.json()
    if job["status"] == "succeeded":
        artifact = job.get("artifact") or {}
        if artifact.get("url"):
            video = requests.get(artifact["url"], timeout=300)
        else:
            video = requests.get(origin + "/v1/videos/" + job_id + "/content",
                                 headers=headers, timeout=300)
        video.raise_for_status()
        with open("video.mp4", "wb") as out:
            out.write(video.content)
        print("Saved video.mp4")
        break
    if job["status"] == "failed":
        raise RuntimeError(job.get("error", {"message": "Video failed"}))
else:
    print("Still waiting; resume GET for job:", job_id)
# A local timeout does not cancel the remote job. Keep job_id for later GETs.

Clip length, resolution, frames and references

Every video model publishes what it takes in the model catalog: the clip lengths, resolution tiers, aspect ratios and inputs it accepts. Send seconds, resolution (480p, 720p, 1080p, 4k) and aspect_ratio (16:9, 9:16, …); size as WIDTHxHEIGHT is accepted as a shorthand for both. A value the model does not take is refused with HTTP 400 before any charge, and the error names the values it accepts.

Image-to-video takes frame_images, each with a url and a frame_type of first_frame or last_frame. Models that take reference material take input_references, each with a url and a type of image, video or audio. generate_audio asks for synchronized audio on models that make it, and seed fixes the random seed. Fields the catalog lists as provider options pass through unchanged.

response = requests.post(origin + "/v1/videos", headers=headers, json={
    "model": os.environ["LAZU_VIDEO_MODEL"],
    "prompt": "The fox turns toward the camera as the wind moves her fur",
    "seconds": 5,
    "resolution": "720p",
    "aspect_ratio": "16:9",
    "generate_audio": True,
    "frame_images": [{"url": "https://example.com/first.png", "frame_type": "first_frame"}],
}, timeout=180)

A succeeded job carries usage with what the provider reported: seconds, resolution, fps and, for token-billed models such as Seedance, output_tokens. The charge on cost_snapshot follows that report, so a clip that comes back shorter or longer than asked is billed as delivered, at the prices in effect when the job was submitted. A report that leaves out a dimension keeps the submission's estimate for it, and a report that would charge more than twice the amount held at submission is billed at the held amount. A request with a reference video holds for the longest reference the model accepts (30 seconds for Seedance 2.5), because providers bill reference video by the second along with the output; the job then settles at what the provider reports and the rest of the hold is released.

Lazu stores the finished video itself, so the provider's short-lived link never reaches you: download it with GET /v1/files/{artifact.file_id}/content using the same key. Videos generated through the API are kept for a limited time (three days on lazu.ai), then deleted; save the file if you need it longer.

For Seedance 2.5 (reference syntax, prices, holds and limits), see Seedance 2.5.

Generate speech or transcribe audio

Set LAZU_AUDIO_MODEL to a speech model and LAZU_VOICE to a supported voice. /v1/audio/speech returns binary audio, not JSON. For transcription, choose a compatible model and upload a local audio file to /v1/audio/transcriptions as multipart data. These are separate model capabilities.

The catalog currently has no speech/transcription endpoint types. Audio modality alone cannot identify either capability. Obtain the exact model ID, endpoint and supported voice from your deployment operator or Lazu support, and confirm that the model is accessible to your API key. Do not select these models by audio modality alone. Set LAZU_TRANSCRIPTION_MODEL to the confirmed transcription model and LAZU_AUDIO_FILE to your local audio path.

import os
from pathlib import Path
import requests

origin = os.environ.get("LAZU_API_ORIGIN", "https://api.lazu.ai").rstrip("/")
headers = {"Authorization": "Bearer " + os.environ["LAZU_API_KEY"]}
response = requests.post(origin + "/v1/audio/speech", headers=headers,
    json={"model": os.environ["LAZU_AUDIO_MODEL"], "input": "Hello from Lazu",
          "voice": os.environ["LAZU_VOICE"], "response_format": "mp3"}, timeout=180)
response.raise_for_status()
Path("speech.mp3").write_bytes(response.content)
import os
import requests

origin = os.environ.get("LAZU_API_ORIGIN", "https://api.lazu.ai").rstrip("/")
with open(os.environ["LAZU_AUDIO_FILE"], "rb") as audio:
    response = requests.post(origin + "/v1/audio/transcriptions",
        headers={"Authorization": "Bearer " + os.environ["LAZU_API_KEY"]},
        data={"model": os.environ["LAZU_TRANSCRIPTION_MODEL"]},
        files={"file": audio}, timeout=180)
response.raise_for_status()
print(response.json())

Errors and results

On failure, preserve the request or job ID and inspect the error code. If submission times out before a job ID arrives, check the video job list (GET /v1/videos) or contact support before resubmitting. For a succeeded job, use artifact.url when available; if only artifact.file_id is returned, retrieve it through the Files API. Reconcile charges through Billing.

API Explorer