Skip to content

YAML and the CLI

Keep recipes in YAML

A YAML document holds the same parameters as the Python arguments, as a spec. JobSpec.from_yaml and EndpointSpec.from_yaml load one, and ns.Job(spec) or ns.Endpoint(spec) builds from it; nothing contacts Nebius until create(). spec.to_yaml() writes one, with env values hidden unless redact=False.

examples/quickstarts/job_quickstart.yaml
schema_version: 1
kind: job
image: nvidia/cuda:13.1.1-runtime-ubuntu24.04
command: ["nvidia-smi"]
gpu: h100
timeout: 1h
job = ns.Job(ns.JobSpec.from_yaml("examples/quickstarts/job_quickstart.yaml"))
job.create()
examples/inference/vllm-endpoint/endpoint.yaml
schema_version: 1
kind: endpoint
image: vllm/vllm-openai:v0.19.1
command:
  - bash
  - -c
  - python3 -m vllm.entrypoints.openai.api_server --model Qwen/Qwen3-0.6B --host 0.0.0.0 --port 8000
gpu: h100
port: 8000
disk: 500Gi
name: qwen-tiny
spec = ns.EndpointSpec.from_yaml("examples/inference/vllm-endpoint/endpoint.yaml")
endpoint = ns.Endpoint(spec)
endpoint.create()

schema_version: 1 and kind are required. Unknown keys, duplicate keys, aliases, anchors, tags, merge keys, and a document over 1 MiB are rejected. A job document whose kind or execution is function raises UnsupportedFeature. An endpoint document may not hold a token, because YAML files are often committed: use token_secret. The allowed keys are under JobSpec.from_yaml and EndpointSpec.from_yaml.

job.to_cli() returns the nebius ai job create command that sends the same request as create(), one flag per line, and endpoint.to_cli() the nebius ai endpoint create one. It does not contact Nebius.

print(job.to_cli())
examples/quickstarts/job_quickstart.sh
#!/usr/bin/env bash
# The job from job_quickstart.py as a Nebius CLI command: the output of
# ns.Job(spec).to_cli() for that spec, with a fixed --name. A test keeps the
# two in step.
set -euo pipefail

nebius ai job create \
  --name nvidia-smi-quickstart \
  --image nvidia/cuda:13.1.1-runtime-ubuntu24.04 \
  --timeout 1h \
  --container-command nvidia-smi \
  --gpu h100 \
  --preemptible \
  --follows-spot-price \
  --disk-size 250Gi \
  --shm-size 16Gi

Nothing secret is printed: env values become --env KEY="$KEY" placeholders for the shell to fill, secrets appear by id, and a token never appears. Without name=, a fresh name is generated, as create() does. Each argument's flag and API field are in the CLI and API map.