From 48f933a26e9daecc6e9a850cd8ee17092f58db3a Mon Sep 17 00:00:00 2001 From: Yehoav Rabinovich Date: Thu, 4 Dec 2025 10:39:40 +0200 Subject: [PATCH] feat: update README to reflect new async processing with Queue API - Revised the video transformation section to introduce the Queue API for job submission and result polling. - Added examples for both automatic and manual job management, enhancing clarity on usage. --- README.md | 48 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 711ec9a..b292ad6 100644 --- a/README.md +++ b/README.md @@ -45,22 +45,46 @@ async def main(): asyncio.run(main()) ``` -### Video Transformation +### Async Processing (Queue API) + +For video generation jobs, use the queue API to submit jobs and poll for results: ```python async with DecartClient(api_key=os.getenv("DECART_API_KEY")) as client: - # Transform a video file - with open("input.mp4", "rb") as video_file: - result = await client.process({ - "model": models.video("lucy-pro-v2v"), - "prompt": "Anime style with vibrant colors", - "data": video_file, - "enhance_prompt": True, - }) + # Submit and poll automatically + result = await client.queue.submit_and_poll({ + "model": models.video("lucy-pro-t2v"), + "prompt": "A cat playing piano", + "on_status_change": lambda job: print(f"Status: {job.status}"), + }) + + if result.status == "completed": + with open("output.mp4", "wb") as f: + f.write(result.data) + else: + print(f"Job failed: {result.error}") +``` - # Save the result - with open("output.mp4", "wb") as f: - f.write(result) +Or manage the polling manually: + +```python +async with DecartClient(api_key=os.getenv("DECART_API_KEY")) as client: + # Submit the job + job = await client.queue.submit({ + "model": models.video("lucy-pro-t2v"), + "prompt": "A cat playing piano", + }) + print(f"Job ID: {job.job_id}") + + # Poll for status + status = await client.queue.status(job.job_id) + print(f"Status: {status.status}") + + # Get result when completed + if status.status == "completed": + data = await client.queue.result(job.job_id) + with open("output.mp4", "wb") as f: + f.write(data) ``` ## Development