Queue deployments
Send jobs to a queue deployment on api.hips.run: run and runsync, the status object, waits, streams, cancel, retry and purge, webhooks, limits, how long inputs and results are kept, and health.
On this page13 sections
A queue deployment takes jobs rather than HTTP requests. You submit a job's input to the deployment's queue on `api.hips.run`, one of its workers runs it, and you read the result, wait for it, stream it, or receive it at a webhook. The routes, the bodies and the job states keep the names existing serverless queue clients already use.
Create it as any container deployment, with type QUEUE (Deployment settings). It has no host of its own: its jobs go through api.hips.run. The deployment's timeout is each job's execution timeout and its jobTtl each job's time to live unless a job sets its own. A deployment that is stopped, or whose workers.max is 0, queues no job.
Queue a job
POST https://api.hips.run/v2/<deployment>/runAuthorization: Bearer $HIPS_API_KEYContent-Type: application/json{"input": {"prompt": "A lighthouse at dusk"}}Answer
{"id":"3f2b8c1e-5a7d-4c9b-8e2f-1a6d4b7c9e05","status":"IN_QUEUE"}<deployment> is the deployment's dep_ id, or the same 26 characters after dep- or dep, as in its host name. Send an inference_only or full API key of the deployment's workspace as the bearer. A job's id is a UUID; a runsync job's id starts with sync-.
On https://api.hips.run, each under the deployment's id.
/v2/{id}/runservedQueue a job; answers {"id", "status": "IN_QUEUE"} at once.
/v2/{id}/runsyncservedQueue a job and wait for its end, up to ?wait=; answers the status object.
/v2/{id}/status/{job}servedThe job's status object, with an ended job's result. ?ttl= sets the job's time to live first.
/v2/{id}/status-sync/{job}servedThe status object after waiting for the job's end, up to ?wait=.
/v2/{id}/stream/{job}servedThe parts the job's handler streamed since the last read, each once.
/v2/{id}/cancel/{job}servedCancel a waiting or running job.
/v2/{id}/retry/{job}servedQueue a FAILED or TIMED_OUT job again with its own input.
/v2/{id}/purge-queueservedRemove every waiting job; running jobs go on.
/v2/{id}/requestsservedThe deployment's newest jobs, at most 100.
/v2/{id}/healthservedAny container deployment's job and worker counts, a load-balanced one's included.
run and runsync take one JSON object. A body is at most 10 MiB on run and 20 MiB on runsync; a larger one answers 400 before the rest is read. Members not listed here are ignored.
inputAny JSON value butnullRequired- Your handler's input, kept byte for byte: strings, escapes, key order and the text of numbers reach the worker as sent. A body without
input, or withinputnull, answers 400. s3ConfigJSON objectOptional- Handed to the worker beside
input, byte for byte. Anything but an object answers 400. webhookStringOptional- An
httpsURL on port 443, at most 2,048 bytes, that receives the job's status object when it ends (Webhooks). Another scheme or port answers 400 when the job is submitted. policy.executionTimeoutInteger millisecondsDefaults to the deployment's timeout- 5,000 to 604,800,000. A job that runs longer ends
TIMED_OUT. With neither set, a job has no execution timeout. policy.ttlInteger millisecondsDefaults to the deployment's jobTtl- 10,000 to 604,800,000: the job's whole life from its submission, waiting and running included. At its end the job is stopped and removed, its result with it.
?ttl=on the URL sets the same value;policy.ttlwins when both are sent. policy.lowPriorityBooleanDefault false- A low-priority job does not count when the deployment scales up: it runs when one of the deployment's workers is free and starts none itself.
?wait=Integer milliseconds,runsynconlyDefault 90,000- 1,000 to 570,000: how long
runsyncwaits for the job's end before it answers the job as it stands.
status, status-sync, runsync and a webhook answer the same object. Each member is there only where it applies; output, and an error your handler posted, are its bytes as it posted them.
{"delayTime":824,"executionTime":3120,"id":"3f2b8c1e-5a7d-4c9b-8e2f-1a6d4b7c9e05","output":{"image_url":"https://example.com/lighthouse.png"},"status":"COMPLETED"}idString- The job's id, the same on every read.
statusIN_QUEUE,IN_PROGRESS,COMPLETED,FAILED,CANCELLEDorTIMED_OUT- Waiting, running, or how it ended.
delayTimeInteger milliseconds- From the submission to the moment a worker last took the job, once one has.
executionTimeInteger milliseconds- From that moment to the job's end, once it ended after running.
outputJSON- On
COMPLETED, and onFAILEDwhere the handler posted one. errorJSON- On
FAILED: the handler's error, or HIPS's own text:job timed out after 1 retrieswhen the job lost its worker twice,output too largefor a result over 20,000,000 bytes,output invalidfor a result that is not a JSON object. retriesInteger- On
FAILED, when the job was queued again before: how many times.
A job whose worker is lost while it runs goes back to the queue once. Lost a second time, it ends FAILED with job timed out after 1 retries.
Never past the job's time to live. Once either is over, every read of the job answers 404.
| Submitted with | Result readable after the job ends |
|---|---|
run | 30 minutes |
runsync | 1 minute |
runsync with ?wait= | 5 minutes |
run- Result readable after the job ends
- 30 minutes
runsync- Result readable after the job ends
- 1 minute
runsyncwith?wait=- Result readable after the job ends
- 5 minutes
- A job lives for its time to live from its submission, waiting and running included.
statuswith?ttl=(10,000 to 604,800,000 ms) sets it again, counted from the submission, longer or shorter; a time to live already over removes the job. - A job's input is kept encrypted while the job waits or runs. It is deleted once the job completes or is cancelled; a
FAILEDorTIMED_OUTjob's input is kept until its result expires, soretrycan run it again. Never past the job's time to live. - A result is kept encrypted, readable by the deployment's workspace alone, until exactly its expiry, and deleted after.
- HIPS writes no input, output or webhook address to its logs.
runsync queues the job and holds the request until the job ends or ?wait= passes. An ended job is answered whole; one still waiting or running is answered as it stands, with no result, and you read it again with status or status-sync. status-sync waits the same way for a job already queued, with the same ?wait= (1,000 to 570,000 ms, 90,000 by default).
A handler that yields parts streams them. GET .../stream/<job> answers {"status": "IN_PROGRESS", "stream": [...]} with every part not read yet, each once and oldest first, each the JSON your handler yielded. Read again until status is an ended state and stream is empty. Up to 32 MiB of unread parts are kept for a job, the oldest unread part dropped past it, and unread parts are kept until the job's result expires.
POST .../cancel/<job>ends a waiting or running jobCANCELLED, stops it on its worker, and answers{"id", "status": "CANCELLED"}. A job that is not waiting or running answers 404.POST .../retry/<job>queues aFAILEDorTIMED_OUTjob again before its result expires, with the same id, input, policy and webhook, discards its earlier result, and answers{"id", "status": "IN_QUEUE"}. It takes no body. A job in another state answers 400; a job whose input is no longer kept answers 400, and you submit it again withrun.POST .../purge-queueremoves every waiting job, which then reads as gone, and answers{"removed": <count>, "status": "completed"}. Running jobs are not touched.GET .../requestslists the deployment's jobs that can still be read, newest first, at most 100, each as its status object withoutoutput.
- A job submitted with
webhookis posted there when it endsCOMPLETED,FAILEDorTIMED_OUT: aPOSTwithContent-Type: application/jsonwhose body is the status object, its result included. A cancelled job posts nothing. - Any 2xx answer is delivery. Otherwise HIPS tries twice more, each try 10 seconds after the one before ended, and each try has 10 seconds for the whole exchange.
- HIPS calls only public addresses, on 443: an address that is private, loopback, link-local or a cloud metadata service, or a name that resolves to one, is never called, and that try fails.
Per deployment and route. Past either limit the route answers 429 with `Retry-After` in seconds.
| Route | Requests per 10 seconds | Requests at once |
|---|---|---|
run, retry | 1,000 | 200 |
runsync, status, status-sync, stream | 2,000 | 400 |
cancel | 100 | 20 |
purge-queue | 2 | No limit |
requests | 10 | 2 |
health | 2,000 | No limit |
run,retry- Requests per 10 seconds
- 1,000
- Requests at once
- 200
runsync,status,status-sync,stream- Requests per 10 seconds
- 2,000
- Requests at once
- 400
cancel- Requests per 10 seconds
- 100
- Requests at once
- 20
purge-queue- Requests per 10 seconds
- 2
- Requests at once
- No limit
requests- Requests per 10 seconds
- 10
- Requests at once
- 2
health- Requests per 10 seconds
- 2,000
- Requests at once
- No limit
A route past its limit answers with Retry-After alone. RateLimit-Policy and RateLimit are not sent here: they carry the management routes' quota (Requirements and headers), which these routes do not count against.
The workspace's own requests a minute apply first, answered as on every other route (Limits). Past 100,000 waiting and running jobs on a deployment, run and runsync answer 429 with Retry-After: 10.
The queue's own refusals are short problem documents (Content-Type: application/problem+json). A refusal by HIPS's account rules carries the error envelope of every other route.
| Status | Body | When |
|---|---|---|
| 400 | {"title": "Bad Request", "detail": "<what was refused>", "status": 400} | A body that is not a JSON object or whose webhook or policy has the wrong type, a missing or null input, an s3Config that is not an object, a value outside its range (policy.executionTimeout, policy.ttl, ?ttl=, ?wait=), a webhook that is not https on 443 or is longer than 2,048 bytes, a body over its bound, or a retry the job's state or its input does not allow. detail says which, such as the body is not a JSON object, or its webhook or policy has the wrong type, webhook must be an https URL on port 443 or only a FAILED or TIMED_OUT job is retried. |
| 404 | {"title": "Not Found", "detail": "endpoint not found", "status": 404} | The one body for a deployment that does not exist, was deleted, is another workspace's or is not a queue deployment, and for a job that is unknown, another deployment's, purged, or past its time to live or its result's keep time. A key learns nothing of another workspace's deployments or jobs. |
| 409 | {"title": "Conflict", "detail": "...", "status": 409, "code": "ENDPOINT_PAUSED"} | run or runsync on a deployment that is stopped or has workers.max 0. No job is queued. |
| 429 | {"title": "Too Many Requests", "detail": "rate limit exceeded", "status": 429} with Retry-After | A route's limit, or the deployment's 100,000 waiting and running jobs. |
| 401, 402, 403, 429 | The error envelope | A missing or invalid key, a key that reaches no deployment, the workspace's state or plan, or its requests a minute. |
| 503 | The error envelope, overloaded, with Retry-After | HIPS could not reach the queue's store. Retry after the delay. |
400
- Body
{"title": "Bad Request", "detail": "<what was refused>", "status": 400}- When
- A body that is not a JSON object or whose
webhookorpolicyhas the wrong type, a missing ornullinput, ans3Configthat is not an object, a value outside its range (policy.executionTimeout,policy.ttl,?ttl=,?wait=), a webhook that is nothttpson 443 or is longer than 2,048 bytes, a body over its bound, or aretrythe job's state or its input does not allow.detailsays which, such asthe body is not a JSON object, or its webhook or policy has the wrong type,webhook must be an https URL on port 443oronly a FAILED or TIMED_OUT job is retried.
404
- Body
{"title": "Not Found", "detail": "endpoint not found", "status": 404}- When
- The one body for a deployment that does not exist, was deleted, is another workspace's or is not a queue deployment, and for a job that is unknown, another deployment's, purged, or past its time to live or its result's keep time. A key learns nothing of another workspace's deployments or jobs.
409
- Body
{"title": "Conflict", "detail": "...", "status": 409, "code": "ENDPOINT_PAUSED"}- When
runorrunsyncon a deployment that is stopped or hasworkers.max0. No job is queued.
429
- Body
{"title": "Too Many Requests", "detail": "rate limit exceeded", "status": 429}withRetry-After- When
- A route's limit, or the deployment's 100,000 waiting and running jobs.
401, 402, 403, 429
- Body
- The error envelope
- When
- A missing or invalid key, a key that reaches no deployment, the workspace's state or plan, or its requests a minute.
503
- Body
- The error envelope,
overloaded, withRetry-After - When
- HIPS could not reach the queue's store. Retry after the delay.
Requests to these routes that reach the deployment and their answers, and each webhook body that reaches your endpoint, count as the deployment's caller_in and caller_out transfer (Deployment billing); HIPS's own 5xx answers and health reads are not counted.
GET https://api.hips.run/v2/<deployment>/health, with a key of the deployment's workspace, answers any container deployment's counts, at most a second old. A read starts no worker and never resets an idle timer. It answers the same 404 and 429 bodies as the queue.
{"jobs":{"completed":12,"failed":1,"inProgress":2,"inQueue":5,"retried":0},"workers":{"idle":1,"initializing":0,"ready":3,"running":2,"throttled":0,"unhealthy":0}}Every member is always present. A load-balanced deployment's job counts are always zero.
jobs.inQueue, jobs.inProgressInteger- The jobs waiting and running now.
jobs.completed, jobs.failed, jobs.retriedInteger- The jobs that completed, failed, or were queued again, in the last 30 minutes.
workers.idle, workers.initializing, workers.running, workers.throttled, workers.unhealthyInteger- The workers in each worker state.
workers.readyInteger- The idle workers, and the running workers taking requests now.
Updated
Sign in to the Console