LastShoot Python SDK
Website · Docs · API reference · Get an API key · GitHub
Official Python client for the LastShoot AI product-photography API: product-to-model, virtual try-on, background change and removal, edits, upscaling, branding, identity, video, speech and 3D.
pip install lastshoot
Requires Python 3.9+. One runtime dependency: httpx.
Quickstart
Get an API key from the dashboard.
from lastshoot import LastShoot
client = LastShoot("ls_live_xxxxxxxxxxxx") # or LastShoot() with LASTSHOOT_API_KEY set
# Generate
result = client.generate.image(prompt="fashion model, white studio background, editorial lighting")
print(result.url)
# Virtual try-on
result = client.identity.tryon(
person_image="https://cdn.example.com/model.jpg",
clothing_image="https://cdn.example.com/shirt.jpg",
gender="woman",
clothing_type="shirt",
)
print(result.url)
result.url is a temporary link (expires within 24 hours). Download and store the file.
Local files
Every image parameter takes a public URL. Upload a local file first:
uploaded = client.upload.image("product.jpg") # path, bytes, or a file opened with "rb"
result = client.background.change(
input_image=uploaded.url,
prompt="white marble table, soft daylight",
subject_description="glass perfume bottle",
)
client.upload("product.jpg") is shorthand for client.upload.image(...).
Jobs, progress and webhooks
Every compute method submits a job and blocks until it finishes. Pass wait=False to get a
Job back immediately, then wait when you are ready:
job = client.edit.image(input_image=url, prompt="make the dress emerald green", wait=False)
print(job.job_id, job.status) # e.g. "queued"
result = job.wait(
poll_interval=2, # seconds between polls
timeout=600, # raise JobTimeoutError after this
on_progress=lambda s: print(s.status, s.progress),
)
print(result.url, result.mime_type, result.cost_usd)
Look up any job later with client.jobs.get("/edit/image/v1", job_id) (returns a JobStatus) or
client.jobs.wait("/edit/image/v1", job_id).
Pass callback_url= to any compute method to have a WebhookEvent POSTed when the job
finishes. lastshoot.WebhookEvent is a TypedDict of that payload.
Methods
| Method | Endpoint |
|---|---|
client.generate.image(prompt=...) |
POST /generate/image/v1 |
client.generate.video(input_image=...) |
POST /generate/video/v1 |
client.generate.speech(text=...) |
POST /generate/speech/v1 |
client.generate.generate_3d(image_path=...) |
POST /generate/3d/v1 |
client.edit.image(prompt=..., input_image=...) |
POST /edit/image/v1 |
client.background.change(input_image=..., prompt=..., subject_description=...) |
POST /background/change/image/v1 |
client.background.remove(input_image=...) |
POST /background/remove/image/v1 |
client.upscale.image(input_image=...) |
POST /upscale/image/v1 |
client.branding.logo(input_image=..., logo_url=...) |
POST /branding/logo/image/v1 |
client.branding.template(input_image=...) |
POST /branding/template/image/v1 |
client.identity.tryon(person_image=..., clothing_image=..., gender=..., clothing_type=...) |
POST /creator/tryon/image/v1 |
client.identity.faceswap(target=..., source=...) |
POST /identity/faceswap/image/v1 |
client.identity.lock(input_image=..., prompt=...) |
POST /identity/lock/image/v1 |
client.identity.replace(input_image=..., prompt=...) |
POST /identity/replace/image/v1 |
client.identity.instamodel(prompt=..., input_face=...) |
POST /creator/instamodel/image/v1 |
client.identity.voice_clone(text=..., reference_voice_url=...) |
POST /identity/voice/clone/v1 |
client.identity.create_profile / list_profiles / get_profile / update_profile / delete_profile |
/profiles/v1 |
client.upload.image(file) |
POST /upload/image/v1 |
client.jobs.get(endpoint, job_id) / client.jobs.wait(endpoint, job_id) |
GET <endpoint>/status/{job_id} |
All parameters are keyword arguments in snake_case, typed from the live OpenAPI spec. Options you leave out use the server default. Full parameter reference: lastshoot.com/docs/sdks/python.
Async
import asyncio
from lastshoot import AsyncLastShoot
async def main():
async with AsyncLastShoot() as client:
result = await client.upscale.image(input_image="https://cdn.example.com/shoe.jpg", scale=2)
print(result.url)
asyncio.run(main())
Errors
from lastshoot import (
LastShootError, # base class
APIError, # any non-2xx response: .status_code .message .code .body
AuthenticationError, # 401
InsufficientCreditsError, # 402
PermissionDeniedError, # 403
NotFoundError, # 404
InvalidRequestError, # 400 / 422
RateLimitError, # 429 (.retry_after)
InternalServerError, # 5xx
APIConnectionError, APITimeoutError,
JobFailedError, # job ended failed/cancelled: .failure_reason_code .retryable .error
JobTimeoutError, # wait() gave up; the job keeps running server-side
)
Status polls (GET) retry automatically on 429, 5xx and network errors with exponential
backoff (max_retries=2 by default). Job submissions (POST) are never retried automatically,
so a job is never billed twice.
Configuration
LastShoot(
api_key=None, # default: LASTSHOOT_API_KEY env var
base_url="https://api.lastshoot.com",
timeout=60.0, # per HTTP request
max_retries=2, # GET retries
poll_interval=2.0, # default for wait()
wait_timeout=600.0, # default for wait()
)
License
MIT
Metadata
Release files for lastshoot 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| lastshoot-0.1.1.tar.gz | 31.7 kB | Without provenance | Details for lastshoot-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| lastshoot-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for lastshoot-0.1.1-py3-none-any.whl |
Total release size: 61.5 kB
Release files / lastshoot-0.1.1.tar.gz
| Download URL | lastshoot-0.1.1.tar.gz |
|---|---|
| Size | 31.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ccbfc4210fc7fb9ee3f18d05350f2bc431261939b39dd543471770086efecfc7
|
|
BLAKE2b-256 checksum How to use checksums |
49653afe8ced0ba1a8f616bdaa19e9b2f14caa94234d938f33f1fb46fcf6cf16
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Release files / lastshoot-0.1.1-py3-none-any.whl
| Download URL | lastshoot-0.1.1-py3-none-any.whl |
|---|---|
| Size | 29.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
5d43eb0481a61222beb8b40382b1f8534ad14a963e2ccb78b6530b8e4f3cb64a
|
|
BLAKE2b-256 checksum How to use checksums |
feb6400c03f508f1c423216811ad4714a0bdc8d6e3b214eadbcc7141ec3cf345
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.10
|
Security for lastshoot 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.