Docs / Serverless

Deploy vLLM (OpenAI-compatible)

The prebuilt vLLM worker serves any Hugging Face model behind an OpenAI-compatible API. Point the official OpenAI SDK at your endpoint and change nothing else.

Deploy the worker

Use the image apipods/worker-vllm:v2.4.0. Model weights download on the first start; attach a network volume so they are cached at /volume/hf for every later worker.

curl -X POST https://api.apipods.com/v1/endpoints \
  -H "Authorization: Bearer $APIPODS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "name": "llama-3.3-70b",
    "image": "apipods/worker-vllm:v2.4.0",
    "gpuPoolIds": [
      "H200",
      "H100_SXM"
    ],
    "gpuCount": 2,
    "maxWorkers": 4,
    "idleTimeoutInSec": 60,
    "networkVolumeId": "vol_c7d2h4ke",
    "env": {
      "MODEL_NAME": "meta-llama/Llama-3.3-70B-Instruct",
      "SERVED_MODEL_NAME": "llama-3.3-70b",
      "MAX_MODEL_LEN": "32768",
      "TENSOR_PARALLEL_SIZE": "2",
      "GPU_MEMORY_UTILIZATION": "0.92",
      "QUANTIZATION": "fp8",
      "MAX_CONCURRENCY": "64",
      "HF_HOME": "/volume/hf",
      "HF_TOKEN": "{{ secrets.HF_TOKEN }}"
    }
  }'
Note: Gated models need a Hugging Face token. Store it as a secret (apipods secrets set HF_TOKEN) and reference it as {{ secrets.HF_TOKEN }}; see Environment variables & secrets.

Configuration

VariableDefaultDescription
MODEL_NAMErequiredHugging Face repo ID, or a path on the network volume.
SERVED_MODEL_NAMEMODEL_NAMEThe name clients pass as model.
MAX_MODEL_LENmodel defaultMaximum context length. Lower it to free memory for KV cache.
TENSOR_PARALLEL_SIZEgpuCountGPUs to shard the model across. Keep equal to the endpoint's gpuCount.
GPU_MEMORY_UTILIZATION0.92Fraction of GPU memory vLLM may use.
QUANTIZATIONnonefp8, awq, gptq, or bitsandbytes.
MAX_CONCURRENCY64Concurrent requests per worker (see Concurrency).
HF_TOKENnoneToken for gated or private models.

Call it with the OpenAI SDK

The OpenAI-compatible base URL is https://run.apipods.com/v1/ep_llama70b/openai/v1. Use your Apipods API key as the API key. Supported routes: /chat/completions, /completions and /models, with stream: true.

import os
from openai import OpenAI

client = OpenAI(
    base_url="https://run.apipods.com/v1/ep_llama70b/openai/v1",
    api_key=os.environ["APIPODS_API_KEY"],
)

stream = client.chat.completions.create(
    model="llama-3.3-70b",
    messages=[{"role": "user", "content": "Write a haiku about GPUs."}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="")

Native job API

The worker also accepts regular jobs on /run and /runsync, which is useful for large offline batches that should not hold an HTTP connection open:

Request body
{
  "input": {
    "messages": [
      {
        "role": "user",
        "content": "Summarize this support ticket: ..."
      }
    ],
    "sampling_params": {
      "temperature": 0.2,
      "max_tokens": 256
    }
  }
}

Sizing GPUs

Model sizePrecisionSuggested poolsgpuCount
7B to 8BBF16L40S, L41
13B to 32BFP8L40S, RTX_PRO_60001
70BFP8H200, H100_SXM2
70BBF16H200, H100_SXM4

A 2-GPU worker on H200 costs $27.96/hr while running. Set idleTimeoutInSec to 30 to 120 seconds for chat traffic: a 70B model is expensive to cold start even with Warmstart.