Skip to main content
GET
curl
Send Prefer: respond-async with an edit or a generation. You can also set the async field. Use "async": true in JSON or -F async=true in a multipart form. The JSON string "true" also works. Generations accept JSON or multipart fields. Edits take multipart uploads.

Start a job

The API checks the request fields before it returns HTTP 202. Save the relative path in Location. Wait the number of seconds in Retry-After before your first poll.
You can disconnect after submission. The job keeps one of your account’s four concurrent slots until it finishes. You can poll and cancel even when all four slots are in use. If result storage is unavailable at submission, you get 503 storage_unavailable.

Poll for the result

Send GET /v1/jobs/{id} with a token from the account that submitted the job. Each successful lookup returns HTTP 200. Read status to decide what to do next. Finished jobs include completed_at. Both timestamps use Unix seconds. A successful job lookup with a result includes the cost and balance headers from the job’s quote. A network restart marks unfinished jobs failed with error.code set to interrupted. You can submit a new request. You aren’t charged for the interrupted job.

Polling example

These examples submit one generation, wait for each Retry-After, and save the finished PNG. Use the same loop with the Location from an edit.

Cancel a job

Send POST /v1/jobs/{id}/cancel with the same account’s token. You can leave the body empty.
If the job is unfinished, you get HTTP 200 with status: "cancelled" and the full hold goes back to your balance. If it has already finished, you get its current state. Cancelling a successful job returns its result and leaves the charge in place.

Ownership and expiry

You have one hour from completed_at to retrieve a finished job. After that, polling or cancelling returns 404 job_expired to your account. An unknown id or another account’s id returns 404 not_found, even if that job has expired. Both errors name id in error.param.

Authorizations

Authorization
string
header
required

An API token from the account panel on sharemy.ai. Tokens start with smai_.

Path Parameters

id
string
required

Response

The current state. Check status even on HTTP 200. A successful job includes result and a failed job includes error.

id
string
required

Job id returned at submission.

object
string
required
Allowed value: "job"
created
integer
required

Unix time in seconds.

endpoint
enum<string>
required
Available options:
/v1/images/generations,
/v1/images/edits
status
enum<string>
required
Available options:
queued,
running,
succeeded,
failed,
cancelled
completed_at
integer
required if status = succeeded, failed or cancelled

Unix time in seconds when the job finished. The job expires one hour later.

result
object
required if status = succeeded

Only on success. The response from the original image endpoint.

error
object
required if status = failed

Only on failure. An interrupted job was refunded after a network restart.