This guide explains how to use theDocumentation Index
Fetch the complete documentation index at: https://novita.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
novita-gpus SDK to call an Async Serverless Endpoint and how to customize a worker handler.
1. Install SDK
Install the SDK in your client environment or worker runtime environment:2. Submit Jobs with SDK
Thenovita-gpus SDK default request URL is https://async-public.serverless.novita.ai/v1. To call an Endpoint, set your API Key and create a client with the Endpoint name.
3. ComfyUI Job Example
Fornovitalabs/comfyui-worker:v0.0.1, the job input must include a ComfyUI workflow. The following minimal example matches the tested case:
4. Custom Handler
On the worker side, callnovita_gpus.start({"handler": handler}) to start the task loop. The platform passes task data to handler(job):
job["id"]: current job idjob["input"]: input content submitted by the client- The handler return value is used as the job output
- If the returned dict contains an
errorfield, the job is marked as failed
5. Complete Worker Examples
For complete worker source code, Docker image build instructions, and task submission scripts, see the Novita GPUs Python examples. The repository includes two examples:- comfyui-worker: runs ComfyUI from
handler.pyand returns generated images. - sleep-worker: a minimal
handler.pythat waits for a requested duration and returns a JSON result.
handler.py: defineshandler(job)and starts the worker withnovita_gpus.start({"handler": handler}).Dockerfile: builds the worker image.requirements.txt: installsnovita-gpus.submit_task.py: submits a task with thenovita-gpusclient SDK.
<endpoint-id>-<app-name>.
For example, Endpoint ID o8UJWkag5WTn and app name async produce:
submit_task.py examples accept the Endpoint ID and app name separately, then compose the final Endpoint name:
6. Return Images or Files
The Async Serverless Endpointstatus API has an output size limit. For large files such as images and videos, upload them to object storage first and return URLs in the output.
Configure object storage environment variables in the Endpoint:
7. FAQ
Do I need to configure an API Key in the worker?
Usually no. API Keys are mainly used by clients to submit, query, and cancel jobs.What handler return value marks a job as failed?
If the handler returns a dict that contains anerror field, the job is marked as failed: