Skip to main content

lamina-sdk

Async-first Python SDK for Lamina video generation. Duration values are whole minutes, from 1 to 5.

Install

pip install lamina-sdk

Python 3.11 or newer is required.

Quick Start

from lamina import Simi

async with Simi(api_key="lamina_your_key") as client:
    video = await client.generate("A blue sphere moving across white background", duration=1)
    await video.save("out.mp4")

You can also set LAMINA_API_KEY and call Simi() with no arguments. Requests go to https://api.laminalabs.ai unless you set base_url=....

Submit And Stream Events

from lamina import Simi

async with Simi(api_key="lamina_your_key") as client:
    job = await client.submit_async(
        "A blue sphere moving across white background",
        duration=1,
        document="brief.txt",
    )

    async for event in client.stream_events(job):
        if event.is_progress():
            print(event.payload["phase"], event.payload.get("progress"))
        else:
            print(event.type)

Events use a small public vocabulary: progress, chunk, output, job.completed, job.failed, and job.cancelled. If the stream drops, the SDK reconnects and resumes from the last sequence it delivered, so you will not see an event twice.

Callback Style

from lamina import Simi

async with Simi(api_key="lamina_your_key") as client:
    job = await client.submit_async("A narrated lesson about derivatives")
    job.onstream(lambda event: print(event.type))
    job.oncompletion(lambda video: print(f"Ready: {video.job_id}"))
    await job.wait()

Listing And Cancelling

async with Simi() as client:
    jobs = await client.list_jobs(limit=10, status="complete")
    for job in jobs:
        print(job.job_id, job.status)

    await client.cancel("job_abc123")

Retries And Errors

Reads are retried automatically on 429 and 5xx with exponential backoff, honouring retry-after. A submit is only retried when you pass an idempotency_key, so a retry can never create a second video.

from lamina import Simi, SimiRateLimitError

async with Simi(max_retries=3) as client:
    try:
        job = await client.submit_async("Explain our refund policy", idempotency_key="req-1")
    except SimiRateLimitError as error:
        print(error.status, error.retry_after, error.request_id)

Errors all derive from SimiError: SimiAPIError (with status, request_id, and retry_after), SimiRateLimitError, SimiJobError, SimiStreamError, SimiDownloadError, and SimiCancelledError.

Public API

  • job = client.submit(prompt, *, duration=1, document=None, language=None, idempotency_key=None)
  • job = await client.submit_async(...) — same arguments
  • video = await client.generate(...) — same arguments, waits for completion
  • jobs = await client.list_jobs(*, limit=20, cursor=None, status=None)
  • state = await client.cancel(job_or_id)
  • playback = await client.get_playback(job_or_video_or_id)
  • await client.save(job_or_video, path)
  • await client.aclose() or async with Simi()
  • api_key is required in Simi(...) unless LAMINA_API_KEY is set.
  • duration is in minutes (1-5).

Use async with in async code. with is supported only outside a running event loop and will tell you so if you get it wrong.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lamina_sdk-0.3.0.tar.gz (28.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lamina_sdk-0.3.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file lamina_sdk-0.3.0.tar.gz.

File metadata

  • Download URL: lamina_sdk-0.3.0.tar.gz
  • Upload date:
  • Size: 28.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for lamina_sdk-0.3.0.tar.gz
Algorithm Hash digest
SHA256 927dc477857bad407bbb0a6543acc6ffe53ca6cdb01658c9ba0557ceca97ea00
MD5 181dd940d29184a7682a046ddcfa9aac
BLAKE2b-256 63eda2ffdfcad2c53279f62331622e143aa1d764a1f314e451afbc83ced7c4aa

See more details on using hashes here.

File details

Details for the file lamina_sdk-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: lamina_sdk-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 22.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.13

File hashes

Hashes for lamina_sdk-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e04d2914dc67093acca198078252dd6317f56a03690e329542c38289dd8d7c36
MD5 c25e245676a004d56ca32638fd558c08
BLAKE2b-256 3ee80559457f3488021ad875b4e52dbe06b5581e929931cec9c4f12a4048e9a2

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.0

2 files

0.1.4

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page