Skip to main content
Create multiple instances from a list of offer IDs.

Signature

VastAI.create_instances(
    ids: List[int],
    template_hash: Optional[str] = None,
    user: Optional[str] = None,
    disk: Optional[float] = 10,
    image: Optional[str] = None,
    login: Optional[str] = None,
    label: Optional[str] = None,
    onstart: Optional[str] = None,
    onstart_cmd: Optional[str] = None,
    entrypoint: Optional[str] = None,
    ssh: bool = False,
    jupyter: bool = False,
    direct: bool = False,
    jupyter_dir: Optional[str] = None,
    jupyter_lab: bool = False,
    lang_utf8: bool = False,
    python_utf8: bool = False,
    env: Optional[str] = None,
    args: Optional[str] = None,
    force: bool = False,
    cancel_unavail: bool = False,
    bid_price: Optional[float] = None,
    create_volume: Optional[int] = None,
    link_volume: Optional[int] = None,
    volume_size: Optional[int] = None,
    mount_path: Optional[str] = None,
    volume_label: Optional[str] = None
) -> dict

Parameters

ids
List[int]
required
ids of instance types to launch (returned from search offers)
template_hash
Optional[str]
Create instance from template info
user
Optional[str]
User to use with docker create. This breaks some images, so only use this if you are certain you need it.
disk
Optional[float]
default:"10"
size of local disk partition in GB
image
Optional[str]
docker container image to launch
login
Optional[str]
docker login arguments for private repo authentication, surround with ”
label
Optional[str]
label to set on the instance
onstart
Optional[str]
filename to use as onstart script
onstart_cmd
Optional[str]
contents of onstart script as single argument
entrypoint
Optional[str]
override entrypoint for args launch instance
ssh
bool
Launch as an ssh instance type
jupyter
bool
Launch as a jupyter instance instead of an ssh instance
direct
bool
Use (faster) direct connections for jupyter & ssh
jupyter_dir
Optional[str]
For runtype ‘jupyter’, directory in instance to use to launch jupyter. Defaults to image’s working directory
jupyter_lab
bool
For runtype ‘jupyter’, Launch instance with jupyter lab
lang_utf8
bool
Workaround for images with locale problems: install and generate locales before instance launch, and set locale to C.UTF-8
python_utf8
bool
Workaround for images with locale problems: set python’s locale to C.UTF-8
env
Optional[str]
env variables and port mapping options, surround with ”
args
Optional[str]
list of arguments passed to container ENTRYPOINT. Onstart is recommended for this purpose. (must be last argument)
force
bool
Skip sanity checks when creating from an existing instance
cancel_unavail
bool
Return error if scheduling fails (rather than creating a stopped instance)
bid_price
Optional[float]
(OPTIONAL) create an INTERRUPTIBLE instance with per machine bid price in $/hour
create_volume
Optional[int]
Create a new local volume using an ID returned from the “search volumes” command and link it to the new instance
ID of an existing rented volume to link to the instance during creation. (returned from “show volumes” cmd)
volume_size
Optional[int]
Size of the volume to create in GB. Only usable with —create-volume (default 15GB)
mount_path
Optional[str]
The path to the volume from within the new instance container. e.g. /root/volume
volume_label
Optional[str]
(optional) A name to give the new volume. Only usable with —create-volume

Returns

dict

Example

from vastai import VastAI

client = VastAI(api_key="YOUR_API_KEY")
result = client.create_instances(ids=12345)
print(result)