Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Serverless endpoints

Run an HTTP inference server on GPU workers that start on demand, scale with traffic and are released when idle.

Last updated November 24, 202629 min read
View as Markdown

An endpoint gives you one HTTPS address for an HTTP server (for example an OpenAI-compatible LLM server) and runs it on as many GPU workers as your traffic needs, between a minimum and a maximum you choose. Workers start when requests arrive and are released after a quiet period.

Endpoints are not yet available on all accounts. If you do not see Endpoints in the console, they are not switched on for your account yet.

How you are billed

There is no per-request price. Every worker is an ordinary server: it is billed by the second at the hourly price of its GPU and disk, exactly like a server you deploy by hand, from the moment its server is running until it is released (the disk can start up to a minute earlier). That includes the time its start script downloads and loads the model; finding a machine and downloading the image before that is not billed. A minimum of zero workers means you pay nothing while the endpoint is idle, at the price of a cold start on the next request.

Idle time is running time: a worker with nothing to do is billed until the scaler releases it once the idle timeout has passed (the scaler checks once a minute). With an idle timeout of 60 seconds, a worker is released one to two minutes after its last request.

Workers are requested through the same path as any server, so the same rules apply: your balance must cover at least an hour of a new worker, requests may wait for review when your account needs it, and the plan must be in stock. They appear in Servers with the endpoint's name. To read what the workers print, open a worker in Servers and use its log tab, or call GET /api/v1/endpoints/{id}/logs (apidly endpoints logs ID --tail 100), which returns the recent lines of every worker (up to 12 per call) in one response.

Cost estimates

Every price shown for an endpoint is an estimate at today's plan prices; your ledger shows what was actually charged.

  • Per worker: the endpoint page shows what one worker costs per hour while it runs (GPU and disk), and GET /api/v1/endpoints/{id} answers the same figure as workerHourlyUsd.
  • With no traffic: the create form estimates what the endpoint costs with no requests at all: workers kept running pay GPU and disk, stopped warm workers pay their disk only.

Create an endpoint

  1. Open Endpoints and choose New endpoint.
  2. Pick a GPU, then a template. Only templates that start an HTTP server on a known port can be used. The two endpoint worker templates (vLLM, OpenAI-compatible; and Text Generation Inference) are ready to use; set the model in their environment variables.
  3. Choose the settings below and create it.
Setting What it does
Minimum workers (0 to 10) Workers kept running even with no traffic.
Maximum workers (1 to 20) Never more workers than this.
Idle timeout With no request for this long, workers above the minimum are released.
Requests per worker When the requests in progress per ready worker go above this number, another worker is started.
Start-up allowance How long a new worker may take to pass its health check (model download included) before it is replaced.
Spending cap per hour Optional. The endpoint never runs more workers than this amount pays for per hour.
Health path A path on your server that answers 200 once it is ready, for example /health.
Cold-start note Optional text shown on the endpoint page, for example how long your model takes to load.
Minimum warm workers (0 to 10) Stopped workers kept ready to start (see Warm pool).
Warm pool size (0 to 500 %) Keeps this share of the most workers that were ready in the last 24 hours as stopped workers.
Longest wait (0 to 900 s, default 300) How long a request waits for a ready worker before it gets 503. A single request is held for at most 240 seconds (the proxy function limit minus time kept to answer), so a larger value still ends in 503 with Retry-After after 240 s.
Target wait (1 to 120 s, default 10) When requests wait longer than this on average, another worker starts.
How jobs run Held by the platform (any server, at most 280 s per job) or Worker kit (up to an hour). See Async jobs.
Job time limit 10 s up to 280 s (held by the platform) or 3,600 s (worker kit).
Alternative GPUs (up to 2) Other plans tried in order when the main GPU has no machine free.
Requests per minute (1 to 1,200) Optional. The endpoint's own rate limit for all keys together; empty keeps the platform limit of 1,200. See Rate limits.
Roll back automatically Off by default. When a new worker fails its health check during an update, the endpoint goes back to the earlier settings instead of pausing the update. See Updating without downtime.

Endpoint states

State Requests Workers
Active Served Scaled between minimum and maximum, with the warm pool kept.
Paused Refused with 503 endpoint_paused All released, warm workers included. Nothing is billed.
Stopped Refused with 503 endpoint_stopped All stopped, not released. Disks are kept and billed, so Resume brings the endpoint back faster than from paused.

Through the API: POST /api/v1/endpoints/{id}/pause, /resume and /stop.

Warm pool

A stopped worker keeps its disk (the image and the model already downloaded) and starts again faster than a new worker, which must find a machine, pull the image and load the model. A stopped worker is billed for its disk only, not for its GPU.

When the endpoint needs more workers, it starts warm workers first and launches new ones only for the rest. When it needs fewer, it stops ready workers into the warm pool (until the pool is full) and releases the others. When a request is waiting and a warm worker exists, that worker is started at once rather than at the next minute.

Starting a stopped worker can fail: the machine it was on may have been rented by someone else in the meantime. A warm worker that fails to start three times is released and replaced. So a warm pool shortens most cold starts but does not guarantee any.

Call it

Create an API key and send requests to the endpoint address shown on its page, followed by your server's own path:

curl https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/proxy/v1/chat/completions \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "YOUR_MODEL", "messages": [{"role": "user", "content": "Hello"}], "stream": true}'

The endpoint page has ready-made samples in curl, Python and JavaScript, and a box to send a test request from the console.

Chat needs a chat model. /v1/chat/completions turns the messages into a prompt with the model's chat template, so it needs a chat (instruct) model that ships one. If the model has none, the endpoint answers 422 with the code chat_template_missing; send a plain prompt to /v1/completions instead.

OpenAI SDKs

For an OpenAI-compatible server, use the endpoint's OpenAI base URL, https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/openai/v1, as base_url with your API key. Every path under it, /models included, goes to your server's /v1/....

import os

from openai import OpenAI

client = OpenAI(
    base_url="https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/openai/v1",
    api_key=os.environ["APIDLY_API_KEY"],
)
print(client.models.list())
reply = client.chat.completions.create(
    model="YOUR_MODEL",
    messages=[{"role": "user", "content": "Hello"}],
)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/openai/v1",
  apiKey: process.env.APIDLY_API_KEY,
});
const reply = await client.chat.completions.create({
  model: "YOUR_MODEL",
  messages: [{ role: "user", content: "Hello" }],
});

Request headers

Header What it does
X-Session-Id Optional, 1 to 128 letters, digits and ._:-. Requests with the same value go to the same worker while it is ready, for 30 minutes after the last one. If that worker is gone, another one is used. The value is stored only as a hash.
X-Apidly-Cost Optional whole number from 1 to 100 (default 1). How much of a worker's capacity this request uses; scaling counts it instead of 1. Use it when some requests are much heavier than others.

The CLI sends X-Session-Id with apidly endpoints invoke ID PATH --session ID, the JavaScript SDK with { sessionId } in the options of endpoints.proxy and endpoints.proxyGet, and the Python SDK with session_id= on endpoints.proxy and endpoints.proxy_get.

Every answer carries X-Request-Id (find it in the request log), and, when a worker served it, X-Worker-Id and X-Queue-Ms (how long it waited for a worker).

  • GET requests need a key with the read scope; other requests need servers or full. Only keys with servers or higher can wake workers.
  • A key created with a permission list also needs Call endpoints (endpoints.invoke) on it, for every method and for async jobs; otherwise the answer is 403 forbidden. Keys without a list are not affected. See API keys.
  • The request body may be up to 4 MB. The answer streams back as your server sends it, including server-sent events.
  • Your API key is never passed to the worker. Workers receive the endpoint's own secret instead, in the Authorization header and as the environment variable WORKER_TOKEN; the vLLM worker template requires it on its /v1 routes.
  • Limits: 600 requests per minute per key, and 1,200 per minute per endpoint (see Rate limits).

Rate limits

An endpoint takes at most 1,200 requests per minute through its address and the OpenAI-style address, all keys together, and one key at most 600. You can set a lower limit for one endpoint with Requests per minute (rateLimitPerMinute, 1 to 1,200; null or an empty field returns to 1,200). It can only lower the platform limit, never raise it. It does not apply to async jobs, which have their own limit of 100 waiting jobs.

  • Over the limit the answer is 429 with the code rate_limited and a Retry-After header (seconds until the minute window ends). The request is not sent to a worker.
  • With your own limit set, every answer also carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset (when the window ends, in epoch seconds). Without it, answers stay as they are.
  • API: PATCH /api/v1/endpoints/{id} with {"rateLimitPerMinute": 300}. CLI: apidly endpoints update ID --rate-limit 300 (--rate-limit none for the platform limit).

A step-by-step guide to the rate limit, job priorities and lifetimes and automatic rollback: Protect an endpoint.

When no worker is ready

If no worker is ready (for example after scaling to zero), the request waits in the queue for up to the endpoint's longest wait (300 seconds by default, at most 900, but never more than 240 seconds in one request) while a worker starts. If one becomes ready in time, the request is served. Otherwise the answer is 503 with the code queue_timeout (or no_worker_ready when the longest wait is 0) and a Retry-After header. Build your client to retry on 503 after the number of seconds in Retry-After. How long a cold start takes depends on the image, the model size and the machine; a large model can take many minutes, much longer than any queue wait.

The first request after an idle period can take several minutes. In our tests (November 2026, 16 GB GPUs, a 0.5-billion-parameter model) a small HTTP image answered the first request after 110 to 145 seconds; Text Generation Inference took 4 to 6 minutes, and about 11 minutes when the machine first had to download the server image. Larger models and images take longer. A request is held for at most 240 seconds, so for a model server the first request usually gets 503 with Retry-After while the worker is still loading. Use the async jobs route (below), which has no such limit, or keep one warm worker (minimum workers 1, or a warm pool) so the first request never meets a cold start.

A cold start has four parts, and the endpoint page shows the first two with their times for each starting worker: getting a machine and its image (about a minute when the machine already has the image; about 7 minutes for a model server image on a machine without it, in our tests), then loading: the start script downloads and loads the model (under a minute for the small model above). Before that, the scaler notices the waiting request, and after it the health check finds the worker ready; both run once a minute, so each adds up to a minute.

At most 50 units of cost may wait per endpoint at once; beyond that, requests get 503 without waiting. Time spent waiting counts towards the 300 second limit of the request.

Long requests

A single request can last at most 300 seconds, waiting included; longer ones are cut off. For very long generations, stream the answer, or send the work as an async job.

Async jobs

A job is a request we store and run on a worker for you; you fetch the answer later. Send it with a key that has the servers scope (and, if the key has a permission list, Call endpoints):

curl https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/jobs \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"path": "/generate", "input": {"prompt": "Hello"}, "webhook": true}'
# 202 {"job": {"id": "job_...", "status": "queued", ...}}

curl https://YOUR-DOMAIN/api/v1/endpoints/EPN_ID/jobs/JOB_ID \
  -H "Authorization: Bearer $APIDLY_API_KEY"
  • path is your server's path, method is POST (default), PUT or GET, and query an optional query string. Send JSON as input, or other bytes as bodyBase64 with contentType. The request may be up to 1 MB.
  • Send an Idempotency-Key header to make a submit safe to repeat: the same key with the same body answers the same job instead of queueing a second one, which would run and be billed again.
  • The answer may be up to 4 MB and is kept for 24 hours after the job ends, then deleted. A job that is still waiting after an hour expires. GET .../jobs/JOB_ID returns it in result (text as is, other content in base64); POST .../jobs/JOB_ID/cancel cancels a job that has not finished, and so does Cancel next to a waiting or running job on the endpoint page.
  • With "webhook": true, the webhook event endpoint.job.completed is sent when the job ends (the event carries the status, not the answer).
  • At most 100 jobs may wait per endpoint. Jobs count towards scaling like waiting requests.
  • Each job is sent to a worker at most three times when the worker cannot be reached; a job that reached the worker is never resent, unless a worker kit worker built with requeue_on_stop=True gives it back while stopping (see Worker kit).
  • A worker kit job can report its progress; GET .../jobs/JOB_ID shows the last value as progress.
  • priority (-10 to 10, default 0) sets the order in which waiting jobs of one endpoint go to workers: a higher priority first, and jobs of one priority oldest first. The order is strict: a lower-priority job waits as long as a higher one is waiting for a worker, so it may wait until its queue time ends and then expire with no_worker. A higher-priority job that cannot be sent for a reason of its own (it failed, or another run already took it) does not hold the lower ones back. Give background work a negative priority rather than urgent work a high one if you do not want the rest to wait. A job sent while a worker is free can start at once, unless a job with a higher priority is waiting. Jobs of different endpoints do not affect each other. CLI: apidly endpoints submit ID PATH --priority 5 (write a negative value as --priority=-5).
  • queueTtlSeconds (60 to 3,600, default 3,600) is how long a job may wait for a worker before it expires; resultTtlSeconds (60 to 86,400, default 86,400) is how long the finished job and its answer are kept. Both can only shorten the defaults and are checked once a minute. CLI: --queue-ttl SECONDS and --result-ttl SECONDS on apidly endpoints submit.
  • keepRequest: true keeps the request after the job ends, for as long as the finished job is kept, so it can be retried; by default the request is deleted when the job ends. POST .../jobs/JOB_ID/retry sends a job that failed, was cancelled or expired again as a new job with the same request (retryOf names the original; the body may change priority, queueTtlSeconds and resultTtlSeconds). It counts like any new job and honours Idempotency-Key. A job whose request is gone answers 409 job_request_gone; a job without a body can always be retried. Retry next to such a job on the endpoint page does the same. CLI: apidly endpoints retry-job ID JOB_ID, and --keep-request on apidly endpoints submit.
  • POST .../jobs/purge cancels every job still waiting for a worker (running jobs are not touched) with the error code purged; olderThanSeconds limits it to jobs that have waited at least that long, and dryRun: true only counts them. It needs a key with the full scope. Empty queue on the endpoint page says how many jobs it will cancel before it does anything. CLI: apidly endpoints purge ID [--older-than SECONDS] asks first unless you pass --yes.
  • GET .../jobs/JOB_ID?waitSeconds=60 waits up to 60 seconds for the job to end and answers as soon as it has; otherwise it answers with the job as it is then, so call it again to wait longer. A key may make 30 calls per minute that wait. endpoints.waitJob (JavaScript SDK), endpoints.wait_job (Python SDK) and apidly endpoints job ID JOB_ID --wait repeat it for you, for up to 600 seconds unless you set another limit.

How long a job may run depends on the mode, and this limit is real:

  • Held by the platform (default). Any HTTP server works, because we send the job as an ordinary request and hold the connection open. Our functions run for at most 300 seconds, so a job may run for at most 280 seconds; longer ones fail with job_timeout. A job is started within about a minute of being sent, sooner when a worker is free.
  • Worker kit. Your image runs our worker kit (below). The kit accepts the job at once, works on it in the background and posts the answer back to us, so a job may run for up to one hour. We also ask the kit about running jobs every minute or two, in case the answer did not reach us.

Worker kit

The worker kit is a small Python package with no dependencies. It runs an HTTP server in front of your code and speaks everything the endpoint expects of a worker, so you only write the function that answers a request. It needs Python 3.9 or newer.

Install

The kit is not on PyPI yet. Download it from apidly.com, check it against the checksum list and install the file (or copy the apidly_worker folder from the downloaded archive into your image):

curl -fsSLO https://apidly.com/downloads/SHA256SUMS
curl -fsSLO https://apidly.com/downloads/apidly_worker-0.2.4-py3-none-any.whl
grep -F apidly_worker-0.2.4-py3-none-any.whl SHA256SUMS | sha256sum -c -    # macOS: shasum -a 256 -c -
pip install ./apidly_worker-0.2.4-py3-none-any.whl

The check catches a damaged download, not a compromised site, because the file and the list come from the same place. The stable names https://apidly.com/downloads/apidly-worker.whl and apidly-worker.tar.gz always point to the newest version.

What the kit does

  • Health. GET /health (no authentication) answers 503 until your code is loaded, then 200 with {"ready": true, "load": 2, "busy": false, "perf": 1530}. We read load (requests in progress) and busy for scaling and routing, and show perf (a benchmark score your code may compute at start) on the endpoint page. Set the template's health path to /health and its port to the one the kit listens on (PORT, default 8000).
  • Readiness. The worker is ready when your setup function and optional benchmark have finished and your health check, asked on every health call, says yes. While it is not ready we send it no work.
  • Requests. Every other request must carry Authorization: Bearer $WORKER_TOKEN; we set that variable on each worker and send it with every request. Your callers' API keys never reach the worker. Your handler gets the method, path, query, headers and body and returns a dict (JSON), a string, bytes or a Response.
  • Async jobs. The kit implements the job protocol (/.apidly/jobs) for jobs that last longer than 280 seconds: it accepts a job at once (202), runs it through the same handler in the background, posts the answer back to us and answers GET /.apidly/jobs/<id> with the job's status. Set the endpoint's job mode to Worker kit. Answers up to 4 MB are kept; a bigger one fails the job.
  • Concurrency limit. max_concurrency is how many requests count as fully busy (busy turns true). With hard_limit=True a request that arrives while that many are running is refused with 429 busy and Retry-After: 1. We route new requests to workers that are not busy first, so use this as a safety net, not as the way to queue work (a refusal reaches the caller). It is not counted as a worker failure.
  • Streaming. Return a generator (yield each piece of text or bytes) and the answer is sent piece by piece as you yield; Response.sse(events) sends server-sent events (each item one data: event, dicts as JSON). The request counts as load until the stream ends. A streamed job answer is collected and kept like any other.
  • Progress. In a job, req.progress({"step": 3, "of": 10}) (any JSON, at most 1000 bytes) is shown as the job's progress in GET .../jobs/JOB_ID. It is pushed to us at most every 5 seconds and also read when we ask the kit about the job. In an ordinary request it is ignored.
  • Graceful stop. On SIGTERM or Ctrl-C the kit stops reporting ready, lets requests and jobs in progress finish for up to 25 seconds, then exits. A job still running then is reported at once: it fails with worker_stopped, or, with Worker(requeue_on_stop=True), it is sent again to another worker (at most three sends in all). Turn that on only when your handler is safe to run twice for the same input.
  • Logs. One JSON line per request on standard output (time, method, path, status, milliseconds) and one for each error, which names the error type only. When your setup function fails, its line also has the error message, and /health answers {"ready": false, "error": "setup_failed"}. The kit never logs headers, query strings, bodies or the token; keep your own log lines and setup messages free of them too. The lines show in the worker's log on the endpoint page.

Example worker

A complete worker that answers POST /generate with a JSON body {"prompt": "..."}:

# worker.py
import time
from apidly_worker import Benchmark, Worker

model = None

def setup():
    global model
    time.sleep(5)                      # load your model here; /health says 503 until this returns
    model = lambda prompt: prompt.upper()

worker = Worker(
    setup=setup,
    benchmark=Benchmark(lambda: model("warm up"), runs=3),   # becomes `perf` in /health
    max_concurrency=4,
    hard_limit=True,
)

@worker.route("/generate")
def generate(req):
    prompt = req.json()["prompt"]
    return {"text": model(prompt)}

if __name__ == "__main__":
    worker.serve()                     # port from $PORT, default 8000

For the simplest case, one function for every request:

from apidly_worker import serve

serve(lambda req: {"echo": req.body.decode()}, port=8000, health=lambda: True)

To put the kit in front of a server you already run, use Worker(upstream="http://127.0.0.1:8001").serve(port=8000): every request no handler matches is forwarded there, and jobs are sent to it as ordinary requests.

Test it on your own machine without a token (leave WORKER_TOKEN unset): curl localhost:8000/health, then curl -X POST localhost:8000/generate -d '{"prompt":"hi"}'.

Or test it without starting a server: python worker.py --test_input '{"prompt": "hi"}' runs setup, sends that JSON to your handler once and prints the answer (streams and progress included) with the full traceback of any error; the exit code is 0 for an answer below 400. Add --test_path /generate when the worker has several routes, and use --test_input @input.json to read the input from a file. In your own tests, worker.test({"prompt": "hi"}) returns the answer as a Response. A step-by-step guide: Your first endpoint with your own code.

Keys for one endpoint

When you create an API key you can tie it to one endpoint (Limit to one endpoint in the console, apidly api-keys create --endpoint ID, endpointId in the API). That key can call only the endpoint's address and its jobs. The same key on another endpoint gets 404, and on every other route (settings, other resources) it gets 403. Use it for keys you put into an application or hand to a customer. Such a key sees, reads and cancels only the jobs it created itself; jobs sent with other keys or from the console answer 404 to it.

Such a key is invoke-only: it cannot read metrics, logs, releases or settings, apply a preset or restore a release.

Updating without downtime

Changing an endpoint's template, disk size, environment variables or hardware requirements, or editing its template, starts a rolling update. Scaling limits, the health path and notes do not. In the console, change these under Worker setup on the endpoint page: the confirmation lists what changes and how many workers will be replaced.

  • A new worker starts for each old one, up to Extra workers during an update at a time (1 by default, at most 5). They are billed while they run.
  • When the new worker is healthy, the old one stops taking new requests, is released once its requests have finished (after 5 minutes at most), and the next one is replaced. Ready capacity never falls below the number of workers wanted.
  • If a new worker cannot start or does not become healthy, the update pauses and the endpoint page says why. Old workers keep serving. Choose Resume update, Cancel update or Roll back.
  • If the hourly spending cap leaves no room for an extra worker, the update waits instead of swapping.
  • Roll back restores the settings from before the change and replaces the new workers. A change made by editing the template cannot be rolled back this way: restore the template instead.
  • With Roll back automatically on (autoRollback, off by default), an update whose new worker fails its health check (three failed checks in a row after its start-up allowance, or not healthy within it) rolls back by itself instead of pausing. The activity list shows Rolled back automatically, and the rollback runs like one you start yourself. A worker that could not be started still pauses the update, an automatic rollback never rolls back again, and when the earlier settings are unknown (after a template edit) the update pauses as usual. API: PATCH /api/v1/endpoints/{id} with {"autoRollback": true}. CLI: apidly endpoints update ID --auto-rollback on.

Workers that were already running when this feature arrived count as current, so nothing is replaced until you next change something. Through the API: POST /api/v1/endpoints/{id}/rollout with {"action": "resume"} (or cancel, start, rollback). From the CLI: apidly endpoints rollout ID resume|cancel|start|rollback.

Releases

Every saved change of an endpoint's settings (worker setup, environment variables, scaling, limits and notes) is kept as a numbered release with who made it and when (Automatic for a rollback); the last 50 are kept. Who made it is shown by name; the member's email address only to those who may manage the team. The Releases card lists them with what changed since the one before. Environment variables are shown by name only, never with their values. Restore first lists what will change, then puts that release's settings back as a new release. A restore that changes the worker setup starts a rolling update like a change made by hand; one that changes only scaling does not. The GPU plan, the name and the worker groups are not part of a release. A release whose settings are no longer accepted (because limits changed since) answers 409 release_not_restorable.

API: GET /api/v1/endpoints/{id}/releases?limit=20 and POST /api/v1/endpoints/{id}/releases/{version}/restore (a key with the full scope). CLI: apidly endpoints releases ID and apidly endpoints restore ID VERSION (asks first unless you pass --yes). SDKs: endpoints.releases and endpoints.restoreRelease (JavaScript), endpoints.releases and endpoints.restore_release (Python). The history starts with the first change made after releases arrived; that change also records the settings from before it as release 1.

Environment values in a release are stored encrypted, like your secrets, and never leave the server. Each endpoint keeps its latest releases (50 unless your account is set otherwise), and the releases of a deleted endpoint are removed.

Worker groups and GPU fallbacks

An endpoint without groups has one implicit group: its GPU plan and up to two alternative plans. With groups (the Worker groups card, apidly endpoints set-groups, PUT /endpoints/ID/groups) you set up to 5 groups, each with up to 3 GPU plans in order, a minimum and maximum number of workers, and an optional price limit per worker per hour (disk included).

Every group's minimum is started first, then the first group is filled up to its maximum, then the next. Inside a group, a plan that has no machines free (remembered for 15 minutes) or costs more than the price limit is skipped for the next one; when none of a group's plans can be used, the next group takes over. A plan belongs to one group only, and running workers stay where they are.

The card also shows the speed measured for each plan from the benchmark score the workers report. It is shown for information and cannot be edited.

Scaling, health and safety stops

Every minute the endpoint checks each worker's health path (3 second timeout) and decides how many workers it wants:

  • it starts workers when requests are refused because none is ready, or when requests in progress per ready worker exceed your target;
  • it keeps what it has while traffic is recent;
  • after the idle timeout it releases workers down to the minimum, never one that is in the middle of a request;
  • a worker that fails three health checks in a row after being ready, or never becomes ready within the start-up allowance, is replaced.

The endpoint pauses itself and emails the owner when your balance would last less than one hour (whether it is about to start a worker or already runs some; its workers are released in the same check), or when three worker requests in a row fail. A paused endpoint refuses requests (503 endpoint_paused) and releases its workers. Fix the cause and choose Resume. You can also pause it yourself at any time.

Scaling presets and the monthly cap

The Scaling and spending card sets the scaling settings in one click and states what each preset costs per hour at the plan's current price, with no traffic and at full load:

  • Scale to zero (cheapest): no worker runs without traffic (minimum 0, workers released after 60 seconds idle, queue target 10 seconds). The first request waits for a cold start.
  • Always one warm: one worker always runs (minimum 1, extra workers released after 10 minutes idle), so requests do not wait for a cold start. It is billed all the time.
  • Burst: one worker runs and one stopped worker is ready to start (see Warm pool); the maximum is raised to at least 5 (at most 20), extra workers are released after 2 minutes idle and the queue target is 2 seconds.

A preset keeps your maximum (except Burst) and every other setting, and it is saved like any other change, so it also appears under Releases. Worker groups keep their own minimum and maximum. API: GET /api/v1/endpoints/{id}/presets lists the presets with idleHourlyMicros and maxHourlyMicros, and POST with {"preset": "burst"} applies one (a key with the full scope). CLI: apidly endpoints presets ID and apidly endpoints preset ID burst.

Monthly spending cap. Set a cap in USD per calendar month (UTC) on the same card, with monthlySpendCapUsd in PATCH /api/v1/endpoints/{id} (null removes it) or with apidly endpoints update ID --monthly-cap 50 (none removes it). It counts what this endpoint's workers were charged this month, the same entries your ledger shows. When the total reaches the cap, the endpoint pauses itself, releases its workers and emails the owner, and the card shows this month's total against the cap. Charges are checked every minute, so a month can end a few minutes of worker time above the cap. While the cap is reached, resuming answers 409 spend_cap_reached: raise or remove the cap, or wait for the next month. The endpoint does not resume by itself when the month changes, and a stopped endpoint is not paused by the cap. The hourly spending cap limits how many workers run at once; the monthly cap stops the endpoint.

While the cap is reached, a new job is refused with 409 spend_cap_reached too, and requests to the endpoint's address get 503 endpoint_paused.

At the cap and after it. By default an endpoint paused by its cap stays paused. Choose Resume automatically on the card (resumeAtNewMonth: true, or apidly endpoints update ID --resume-at-new-month on) and it resumes by itself once a new UTC month starts below the cap, with an email to the owner. An endpoint paused for its balance, after failed worker requests, by a person or by staff is never resumed this way. A stopped endpoint is not paused by the cap, so its stopped workers' disks and model cache keep billing: the card and spendCap.afterCap in GET /api/v1/endpoints/{id} show what keeps charging per hour at today's prices. Release stopped workers at the cap (releaseStoppedAtCap: true, --release-stopped-at-cap on) releases them at the cap so spending stops; the next start is then a cold one. If your account has a default cap for new endpoints, the create form shows it filled in and you can change or clear it; an API create that leaves out monthlySpendCapUsd gets it and answers monthlySpendCapFromDefault: true (send null for no cap).

Metrics

The endpoint page shows requests, errors, requests refused for lack of a ready worker, latency (median and 95th percentile), average wait (for requests that found a worker already running; the wait of a request that had to wait for a cold start is shown in the request log instead), tokens (from the usage object of non-streamed OpenAI-style JSON answers), workers over time, an estimated cost and what was actually charged, for the last hour, day or week. Latency is measured on our side from the request to the end of the answer and is reported as the upper bound of a range (for example "under 2.5 s"). The estimated cost comes from the workers' hourly prices; Actually charged is the sum of the ledger entries for this endpoint's workers in the range (net of credits), the same amount your ledger shows (summary.chargedMicros in GET /api/v1/endpoints/{id}/metrics). Metrics are kept for 7 days.

The second row of figures and the charts below it add requests and jobs per minute, jobs by outcome (done, failed, timed out, expired), the queue wait of requests and of jobs and the run time of jobs (each as median and 95th percentile), cold starts (new workers that became ready, with the median and 95th percentile of their start time), the cost per hour and the cost per 1,000 calls. Finished jobs are kept for 24 hours at most, so job figures for a week cover the last day only. API: GET /api/v1/endpoints/{id}/metrics?window=1h (1h, 24h or 7d; range is the older name of the same parameter) answers with points per time step and a summary. CLI: apidly endpoints metrics ID --window 1h.

Health summary

GET /api/v1/endpoints/EPN_ID/health tells in one call how the endpoint is doing: workers by state, waiting and running jobs and how long the oldest has waited, results of the last 15 minutes, the rolling update, the pause reason and the last scaling event, with a status of ok, degraded, down or paused and the reasons behind it. down means jobs have waited 10 minutes with no ready worker, or none of at least 5 recent results succeeded. The same summary is the Health card at the top of the endpoint page. CLI: apidly endpoints health ID.

Each reason has a code, a message and sometimes a value. down comes from no_ready_worker (a job has waited 10 minutes and no worker is ready) or nothing_succeeded (none of at least 5 results in the last 15 minutes succeeded). degraded comes from high_error_rate (at least 20% of at least 5 recent results failed or expired), unhealthy_workers, below_min_workers, queue_slow (a job has waited 5 minutes although workers are ready), jobs_timed_out, jobs_expired, rollout_paused and launch_failed. paused comes with paused (by you, by a safety stop, or at the monthly spending cap) or stopped.

Reading a job with waitSeconds (at most 60) is limited to 30 calls a minute per key and 120 a minute per organization; past that the answer is 429 with Retry-After, and reads without waitSeconds still work. A purge's olderThanSeconds runs from 0 to 3,600.

Request log

Every request through the endpoint (and every job) is logged for 7 days with its ID, time, status, latency, queue wait, the worker that served it, bytes in and out and token counts. Request and answer bodies are never stored. Filter it by status on the endpoint page, download it as CSV, or read it with GET /api/v1/endpoints/EPN_ID/requests (status, kind, limit, before, format=csv).

Worker logs

The endpoint page shows the server log of each worker with the same viewer as the server page.

GET /api/v1/endpoints/{id}/logs?worker=SERVER_ID reads one worker only (apidly endpoints logs ID --worker SERVER_ID). A job that reached a worker has Worker log in the job list: GET /api/v1/endpoints/{id}/jobs/{jobId}/logs (apidly endpoints job-logs ID JOB_ID) returns the latest lines of the worker that ran it, read at the time of the call. Log lines carry no time, so they can include other jobs on the same worker, and once the worker is released its log is gone (reason: "worker_gone"; a job that never reached a worker answers not_dispatched). Your organization's secret values are hidden in every log.

tail sets how many of the latest lines each worker returns: 100 by default for the endpoint's logs and 200 for a job's log, at most 500 in both.

Ready to try it?

Create a free account and add credit when you want to start a server. The smallest top-up is $10.

Create a free account

Was this helpful?

Still stuck? Contact us