Our API offers control over your Compute Resources via HTTP/HTTPS requests. It allows you to for example create and destroy, start and stop instances. For a detailed description of it's capabilities take a look at our API documentation



Using the Python requests package to create an instance


If you don't have already, download and install the requests package. You can do so for example using pip using your command line:

pip install requests

From you can use any editor of your choice, to create your python file and run the following commands. We'll use the requests package to create an 8x RTX 3090 instance in Iceland with the standard security group and SSH access. All further lines of code are part of the python code.


First import the requests package:

import requests as r

In order to authorize ourselves we will need to provide the api with a token which we'll create on the console page. When sending any request to the api we will provide it with a header containing this token:

header={
"X-Auth-Token": <Your Secret Token>
}

We want to set up our instance bound to a specific ssh key. To add a key to our account, we will use requests.post():

sshParams = {"name": <desired name of the key>,"value":  <your private ssh key as a string (e.g. "ssh-rsa AASHDFAOISHIJJFHRHGURHEIJIJIJJIJKJKSJASPDJFP rsa-key-20241201")>}

response = r.post("https://api.genesiscloud.com/compute/v1/ssh-keys", headers=header, json=sshParams)

The response object has a function response.json() which gives us all the details of our ssh key in a dictionary:

sshDetails = response.json()

In the following we will only need the ID of our key to later assign it to the instance we want to create:

sshID = sshDetails["id"]
The next step is to define all instance parameters, such as name, image or ip type. We will pass them as a dictionary:
instanceParameters={
    "name": "correctly-formatted-name",
    "hostname": "correctly-formatted-hostname",
    "type": "vcpu-32_memory-192g_disk-80g_nvidia3090-8",
    "region": "ARC-IS-HAF-1",
    "image": "ac26fa2b-c6d5-47a7-bc4e-5a219797e70f",
    "ssh_keys": [sshID],
    "public_ip_type": "static"
    }

Now finally in order to create the instance we can again use requests.post():

instanceResponse=r.post("https://api.genesiscloud.com/compute/v1/instances",headers=header,json=instanceParameters)

Our header is passed as "headers" and our parameters as "json". Again our response object "instanceResponse" contains information about the instance we created, including all parameters we used to configure it.


The requests package supports all API request types needed in order to use the Genesis Cloud Computer Service API, such as POST, GET, DELETE, PUT and PATCH. Every request requires a set of parameters and the header. Details about necessary parameters and commands can be found in the API documentation.