Docs / Pods

Environment variables & secrets

Configure your container with environment variables. Keep tokens and passwords in secrets and reference them, so their values never appear in the pod object or logs.

Set variables

Pass env as an object of string values. Updating env on a running pod restarts it. Like other object fields, env is replaced as a whole on PATCH, so send every variable you want to keep.

curl -X PATCH https://api.apipods.com/v1/pods/pod_8f2k1x9q \
  -H "Authorization: Bearer $APIPODS_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "env": {
      "HF_HOME": "/workspace/hf",
      "WANDB_PROJECT": "llama-ft",
      "HF_TOKEN": "{{ secrets.HF_TOKEN }}"
    }
  }'

Secrets

Secrets are encrypted values stored at the organization level. Reference them in any env value as {{ secrets.NAME }}; the reference is resolved when the container starts. The API returns the reference, never the value.

$ apipods secrets set HF_TOKEN
Value: ****************
Created secret HF_TOKEN (sec_3n7q2w8k)
  • Names are upper-case letters, digits and underscores, up to 64 characters.
  • Rotating a secret affects pods at their next start or restart.
  • A pod that references a missing secret fails to start and stays in CREATED with an error event. See Secrets API.

Injected variables

Apipods sets these in every pod. They override variables with the same name.

VariableExampleDescription
APIPODS_POD_IDpod_8f2k1x9qID of this pod
APIPODS_GPU_COUNT1Number of GPUs attached
APIPODS_REGION_IDeu-nl-1Region the pod runs in
APIPODS_PUBLIC_IP203.0.113.42Public IP of the host, if it has one
APIPODS_TCP_PORT_2240122Public port mapped to container port 22 (one per TCP port)
CUDA_VISIBLE_DEVICES0Set by the NVIDIA runtime
Note: Your API key is never injected into pods. If code in a pod needs to call the Apipods API, store a READ key as a secret and reference it explicitly.