This document provides an example of how to post a job for a specific endpoint and then query its status until it is completed.
Endpoint JSON Format
This is the JSON representation of this endpoint:
{
"name": "CNY-SnakeYear",
"coverUrl": "https://toolkit.instantstudio.ai/rails/active_storage/representations/proxy/eyJfcmFpbHMiOnsiZGF0YSI6NzM3NzAyLCJwdXIiOiJibG9iX2lkIn19--9f5ef50ee765e29aa49818a6e28ae55fc3398bd2/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJqcGVnIiwicmVzaXplX3RvX2xpbWl0IjpbODAwLG51bGxdLCJzYXZlciI6eyJxdWFsaXR5Ijo5MH19LCJwdXIiOiJ2YXJpYXRpb24ifX0=--2d5f07e1fd078af8834d9de3496a98604b84cac5/ComfyUI_00087__%E5%89%AF%E6%9C%AC.png",
"endpointId": "PrOhEE",
"fieldIds": [
"load_image_22",
"seed_56"
]
}
Submit a Job
To submit a job, use the POST
method with the necessary parameters for the endpoint. Below is an example:
curl -X POST -H "Authorization: Bearer YOUR_API_KEY" \
-F "load_image_22=@/path/to/file" \
-F "seed_56=20" \
"https://toolkit.instantstudio.ai/api/v1/jobs?endpoint=PrOhEE"
Sample Response:
{
"job_id": "44fefe50-2547-494f-aaa2-71dc3f661234",
"job_state": "pending",
"started_at": null,
"completed_at": null
}
Step 2: Query the Job Status
Once the job is submitted, use the GET
method to query its status using the job_id
from the response.
curl -X GET -H "Authorization: Bearer <api_key>" \
"https://toolkit.instantstudio.ai/api/v1/jobs/44fefe50-2547-494f-aaa2-71dc3f661234"
Sample Responses:
{
"job_id": "44fefe50-2547-494f-aaa2-71dc3f661234",
"job_state": "in_queue",
"started_at": null,
"completed_at": null
}
{
"job_id": "44fefe50-2547-494f-aaa2-71dc3f661234",
"job_state": "processing",
"started_at": "2024-12-11T13:47:30.421+08:00",
"completed_at": null
}
{
"job_id": "44fefe50-2547-494f-aaa2-71dc3f661234",
"job_state": "succeeded",
"started_at": "2024-12-11T13:47:30.421+08:00",
"completed_at": "2024-12-11T13:51:00.829+08:00",
"image_urls": [
"..."
]
}
Notes:
- Continue polling the
GET
endpoint until the job_state
is "succeeded"
or "failed"
.
- Ensure to save the generated images (
image_urls
) before the job data is deleted after 24 hours.