Endpoints
Jobs and batches
Run training or batch Jobs on the same GPU ledger as serving, preemptible jobs that resume from checkpoints, and OpenAI's files and batches API.
The control plane schedules two kinds of work beside endpoints: Kubernetes Jobs on the GPU ledger, and OpenAI-style batches against an endpoint.
In short
A job runs your own container on the same GPUs as your endpoints, for example a fine-tune. It takes a card from the same ledger, so it never collides with serving. Mark it preemptible and it gives its card back when an endpoint needs it, then resumes from its checkpoint. A batch is OpenAI's batch API: you upload a file of requests, and the control plane runs them against one endpoint and writes the answers to your object store.
When you need it
- Jobs: a training run or an offline script should use idle cards at night and yield them by day.
- Batches: you have thousands of requests that need no answer now, and an OpenAI client that already speaks the batch API.
Do it: a preemptible job
Submit it
curl -s -H "$H" -H 'Content-Type: application/json' -X POST https://cp.example.com/api/v1/jobs -d '{ "name": "finetune-support", "priority": "preemptible", "spec": { "recipe": { "engine": "generic", "image": "registry.example.com/train@sha256:…", "command": ["python", "train.py"], "args": ["--resume", "/ckpt"] }, "gpus": 1, "maxRetries": 3 } }' | jq '{id, state, message}'The recipe must write its checkpoints to
/ckptand resume from there.Follow it
curl -s -H "$H" https://cp.example.com/api/v1/jobs/<id> | jq '{state, node, gpu, attempts, preempted, gpuSeconds}' curl -s -H "$H" "https://cp.example.com/api/v1/jobs/<id>/logs?tail=100"
Do it: a batch
Connect the object store
On the Connectors page, save the
batchfilessettings: at leastOPODCP_BATCH_FILES_BUCKET, and for MinIO or CephOPODCP_BATCH_FILES_ENDPOINTandOPODCP_BATCH_FILES_PATH_STYLE=1. The bucket must exist. On 0.2.1, setports.batchFiles.bucket(and.endpoint,.pathStyle) withhelm upgradeinstead.Write the input file
One request per line, OpenAI's format. Every line's
modelmust resolve to the same endpoint:{"custom_id": "1", "method": "POST", "url": "/v1/chat/completions", "body": {"model": "qwen2.5-7b-instruct", "messages": [{"role": "user", "content": "Summarise: …"}]}}Upload it and start the batch
Use the Python example in Run a batch, pointed at
https://cp.example.com/v1with an endpoint key.Collect the results
b = client.batches.retrieve(b.id) # until b.status == "completed" print(client.files.content(b.output_file_id).text)
Check it worked
- Job:
statemovesqueued→placing→running→succeeded. A preempted job readspreempted, thenrunningagain withpreemptedone higher. The console's Jobs page shows the same. - Batch:
GET /v1/batches/{id}readscompleted, withrequest_counts.failedat 0, and the output file is in your bucket.
If it fails
| Symptom or code | Cause | Fix |
|---|---|---|
Job stays queued | no card is free; message says why | wait, free a card, or make the job shared with a vramBudgetGb |
400 naming a field on submit | a rule is broken, for example a CPU job with no spec.node | fix the named field |
| A preempted job restarts from zero | the recipe does not resume from /ckpt, or it moved node without pvc:// checkpoints | resume from /ckpt; save OPODCP_JOB_CHECKPOINTS=pvc://… |
| An endpoint create is refused for a job's card | the job is standard, which keeps its card | make such jobs preemptible |
501 batch_store_not_configured (E-BATCH-STORE) | no batch object store is connected, or it cannot be used | connect batchfiles on the Connectors page and restart |
batch_store_credentials_expire | the store's credentials expire before the batch window ends | static keys, or a shorter completion_window |
batch_store_unavailable | the control plane could not ask the store when its credentials expire (the store did not answer, or refused) | check the store from the control plane's pod: the doctor's batchfiles row names the reason |
Batch lines fail with interrupted | the runner was killed after it sent the line and before the answer came | run those lines again in a new batch |
Jobs
A job is a container run on the same GPUs as serving. It claims capacity in the same ledger as an endpoint worker and runs as a Kubernetes Job. It is the second thing the control plane schedules, beside endpoints.
curl -s -H "$H" -H 'Content-Type: application/json' -X POST https://cp.example.com/api/v1/jobs -d '{
"name": "finetune-support",
"team": "search",
"priority": "preemptible",
"spec": {
"recipe": { "engine": "generic", "image": "registry.example.com/train@sha256:…",
"command": ["python", "train.py"], "args": ["--resume", "/ckpt"], "env": { "EPOCHS": "3" } },
"gpus": 1, "vendor": "nvidia", "colocation": "dedicated", "maxRetries": 3
}
}'| Field | Default | Meaning |
|---|---|---|
name | — | a DNS label: a-z, 0-9 and -, at most 40 characters |
team | — | the owning team; a team-scoped operator's job lands in their team |
priority | standard | standard keeps its claim to completion; preemptible yields its card to serving and resumes later |
spec.recipe | — | engine: generic (the only recipe built): an image (required), command, args, env; the image is pinned by digest at submit when the registry answers |
spec.gpus | — | GPUs, 0 or more; 0 is a CPU job, which must name its node in spec.node |
spec.vendor | any vendor with an image | nvidia, amd, … or none |
spec.node | the placer chooses | pin the job to a node of this cell; a GPU job needs a node with an accelerator |
spec.colocation | dedicated | dedicated whole GPUs, or shared: one device, with spec.vramBudgetGb required, judged against measured VRAM |
spec.checkpoint | a directory named after the job | where the recipe writes and resumes, mounted at /ckpt: a name is a directory under the node's checkpoint root (or the claim of that name with pvc://); an absolute path is a host directory (host-path mode only) |
spec.maxRetries | 0 | retries of a failed run |
A rule broken is refused 400 with the field. The container gets the node's model cache at /data/models and a checkpoint directory at /ckpt.
The job record adds id, state, node, gpu, pod, message (why it is queued or failed), attempts (pod starts, retries and resumes counted), preempted (times evicted), gpuSeconds, startedAt, finishedAt, createdAt, updatedAt and by.
States: queued (with the reason, while no card is free), placing, running, preempted, succeeded, failed, cancelled.
Preemption. A create or a plan change that needs a preemptible job's card evicts that job within one reconcile. In 0.3.0 it evicts only the jobs whose cards it takes (0.2.1 evicts every preemptible job in the cell), and the autoscaler's growth may evict one too. The job reads preempted, keeps its GPU-seconds, and is placed again when capacity returns; the recipe resumes from /ckpt. An endpoint that needs a standard job's card is refused.
Checkpoints. By default /ckpt lives under the node's model cache, so a preempted job resumes on the same node only. Save OPODCP_JOB_CHECKPOINTS=pvc://[storageClass]?size=20Gi on the Connectors page (on 0.2.1, the chart value ports.checkpoints.url) for one PersistentVolumeClaim per job, kept across preemption and deleted with the job, to resume on any node. Object-store checkpoints (s3://, gs://, azblob://) are not supported, and the control plane refuses them by name.
GPU-seconds are pod running time × GPUs, charged when a run segment ends (preempted, succeeded, failed or cancelled), as one usage row per segment.
| Route | Purpose |
|---|---|
GET /api/v1/jobs, GET /api/v1/jobs/{id} | list, read |
POST /api/v1/jobs | submit (operator) |
GET /api/v1/jobs/{id}/logs?tail=N | the trainer's log; tail 1 to 5000, default 200. Once the pod is gone, the last 64 KB kept when the job ended (X-Opod-Log-Source: kept, with X-Opod-Log-Kept-At) |
POST /api/v1/jobs/{id}/cancel | cancel |
DELETE /api/v1/jobs/{id} | delete a finished job |
planned Packaged training recipes (axolotl, TRL, torchtune, LLaMA-Factory), train-to-serve, multi-node jobs and a Kueue adapter are not built.
OpenAI files and batches
The control plane serves OpenAI's /v1/files and /v1/batches, so an OpenAI client runs a batch with no new code, pointed at the control plane's URL.
It needs your object store
File bytes live only in an S3-compatible store you run: AWS S3, MinIO, Ceph RGW, or GCS in S3 mode. The control plane keeps the records and no bytes. With no store, every route answers 501 batch_store_not_configured (E-BATCH-STORE). Save these on the Connectors page (batchfiles). On 0.2.1 they are chart values under ports.batchFiles (bucket, prefix, endpoint, region, pathStyle, credentialsSecret, downloads).
| Setting | Meaning |
|---|---|
OPODCP_BATCH_FILES_BUCKET | the bucket; it must exist |
OPODCP_BATCH_FILES_PREFIX | empty by default: files go to the bucket root. Example batch-files |
OPODCP_BATCH_FILES_ENDPOINT | http(s)://host[:port]; empty = AWS S3 |
OPODCP_BATCH_FILES_REGION | the region |
OPODCP_BATCH_FILES_PATH_STYLE | 1 for MinIO, Ceph and in-cluster stores |
OPODCP_BATCH_FILES_ACCESS_KEY, _SECRET_KEY | stored sealed; unset = the standard AWS chain (environment, EKS workload identity, instance metadata) |
OPODCP_BATCH_FILES_DOWNLOADS | proxy (default: the control plane streams file content) or redirect (OpenAI clients get a 307 to a 5-minute presigned URL) |
The batch runner reads its input and writes its results directly through presigned URLs, so the store must be reachable from pods in the namespace. Temporary credentials that expire before a batch's window are refused (batch_store_credentials_expire); give the store static keys or use shorter windows.
Run a batch
from openai import OpenAI
client = OpenAI(base_url="https://cp.example.com/v1", api_key="sk-orc-<endpoint key>")
f = client.files.create(file=open("requests.jsonl", "rb"), purpose="batch")
b = client.batches.create(input_file_id=f.id, endpoint="/v1/chat/completions", completion_window="24h")- Auth: an endpoint key, or a console credential (viewer reads, operator writes). A key sees only what it created.
- Files: up to 200 MB, streamed into the store as they arrive.
purposeisbatch. - Batches:
endpointis/v1/chat/completions,/v1/completionsor/v1/embeddings;completion_windowis1hto167h;metadataholds up to 16 pairs. - One batch is one endpoint. Every line's
modelresolves, through the cell door's aliases or the id exactly one endpoint serves, to one endpoint. - Statuses are OpenAI's:
validating,in_progress,finalizing,completed,failed,expired,cancelling,cancelled.
| Route | Role | Purpose |
|---|---|---|
POST /v1/files | operator | upload, as multipart/form-data with purpose and file |
GET /v1/files, GET /v1/files/{id} | viewer | list (filter with ?purpose=), read one |
GET /v1/files/{id}/content | viewer | the bytes, streamed or redirected (OPODCP_BATCH_FILES_DOWNLOADS) |
POST /v1/batches | operator | create |
GET /v1/batches, GET /v1/batches/{id} | viewer | list (limit 1 to 100, default 20; after a batch id), read one |
POST /v1/batches/{id}/cancel | operator | cancel |
GET /api/v1/batches | viewer | the console's list of every batch you may see |
The roles are for a console credential; an endpoint key may use every route, on what it created. Errors use OpenAI's shape, for example 400 invalid_request_error. There is no file delete route: retention is your bucket's.
When a batch starts, the control plane mints a sheddable-class key on the endpoint and runs one Kubernetes Job from the leader image (core's opod batch run) against the endpoint's leader. The Job needs no GPU. A line is marked sent before its request goes, so no line is sent twice; a line found sent but unanswered after a kill is written to the error file as interrupted. A runner replaced on another node resumes only with pvc:// checkpoints. The minted key is revoked when the batch ends.
The control plane deletes no object when a batch ends: retention is your bucket's lifecycle rule. It computes no price or discount.
planned Reaching /v1/files and /v1/batches through the cell door's URL.
Last updated · Source: content/docs/control-plane-endpoints/jobs-batches.mdx · View as Markdown