Docs / Serverless

Overview

Serverless turns a Docker image with a handler function into an autoscaling GPU endpoint. Requests go into a queue, workers pull jobs from it, and you pay per second only while workers are running.

How it works

An endpoint is a queue plus a fleet of workers. Each worker is a container started from your image on a GPU from the pools you choose. Inside the container, the apipods Python SDK connects to the queue, hands each job to your handler(job) function and reports the result.

  1. You send a job

    POST https://run.apipods.com/v1/ep_4n8wq2zt/run with a JSON input. The API answers immediately with a job ID and status IN_QUEUE.

  2. The autoscaler adds workers

    If no worker is free, a new one starts on the first available GPU in your priority list. With Warmstart it restores from a snapshot of an initialized worker, typically in under 2 seconds.

  3. A worker runs your handler

    The job moves to IN_PROGRESS. Whatever your handler returns becomes the job output; exceptions become a FAILED job with an error.

  4. You collect the result

    Poll /status/{jobId}, read partial results from /stream/{jobId}, or receive the finished job on a webhook. Idle workers shut down after the idle timeout.

Flex and Active workers

Flex workersActive workers
SettingminWorkers: 0minWorkers above 0
Scales to zeroYesNo, the minimum is always running
Cold startsOn scale-up (reduced by Warmstart)None for traffic the always-on workers can absorb
BillingPer second, from worker start until the idle timeout endsCommitted capacity at a discounted rate
How to get itEvery planEnterprise plan (sales@apipods.com)

Most endpoints run on Flex workers only. Add Active workers when you have steady baseline traffic and cannot accept a cold start on the first request. Active workers are part of the Enterprise plan; on other plans, setting minWorkers above 0 returns 403 active_workers_not_enabled. Flex workers above the minimum still scale up to maxWorkers during bursts.

GPU pools and pricing

Serverless workers run in the same Tier III/IV data centers as pods and are billed per second by GPU pool. There is one pool per GPU type, named after its CLI alias; you list pools in priority order in gpuPoolIds.

Pool IDGPUVRAMPer secondPer hour
B300B300288 GB$0.00666$23.98
B200B200180 GB$0.00599$21.58
H200H200 SXM141 GB$0.00388$13.98
H100_SXMH100 SXM80 GB$0.00327$11.78
RTX_PRO_6000RTX PRO 600096 GB$0.00205$7.38
A100_80GBA100 80GB80 GB$0.00166$5.98
L40SL40S48 GB$0.00105$3.78
L4L424 GB$0.00042$1.50

Example: a job that runs for 2 seconds on L40S costs about $0.00210 of GPU time. The cheapest pool starts at $1.50/hr. Worker time includes initialization and the idle timeout, so short idle timeouts keep costs close to pure execution time. See Pricing for storage rates.

Serverless or pods?

Use serverless whenUse a pod when
Traffic is bursty or unpredictableYou need a GPU for hours at a time (training, fine-tuning)
Each request is a self-contained job (inference, transcription, rendering)You want an interactive machine with SSH or Jupyter
You want to scale to zero overnightProcesses keep long-lived state in memory between requests
You want a queue, retries and webhooks without running them yourselfYou need multi-day runs beyond the 24-hour execution limit

Next steps