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.
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.
Print the CLI command for a job¶
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.
#!/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.