> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cudocompute.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Python client

> Use the CUDO Compute Python client to interact with the API

## Install cudoctl

To use this client you will need to

1. **[Create an API key](/docs/api/authentication#create-an-api-key)**
2. Download and install cudoctl command line tool from **[here](/docs/tools/cudoctl)**
3. Run `cudoctl init` and enter your API key and select a project/billing account.

Once cudoctl is set up the python client will use the default API key configured by cudoctl. If you would like to change project in the python client you will need to run `cudoctl init` again.

## Install via pip

To install the python client via pip run:

```sh theme={null}
pip install cudo-compute
```

## Example code

For more information see the [GitHub Repository](https://github.com/cudoVentures/cudo-compute-python-client) Full examples can be found in the `examples` directory.
Below are some simplified examples:

### Create a virtual machine

```python theme={null}
from cudo_compute import cudo_api, Disk, CreateVMBody

disk = Disk(storage_class="STORAGE_CLASS_NETWORK", size_gib=100,
                id="my-disk-id")

request = CreateVMBody(vm_id="my-vm-id", machine_type="epyc-rome-rtx-a4000",
                           data_center_id="no-luster-1", boot_disk_image_id='ubuntu-nvidia-docker',
                           memory_gib=16, vcpus=4, gpus=1, gpu_model="A4000", boot_disk=disk,
                           metadata={"group":"a"})

api = cudo_api.virtual_machines()
vm = api.create_vm(cudo_api.project_id(), request)
```

### List current virtual machines

```python theme={null}
from cudo_compute import cudo_api

api = cudo_api.virtual_machines()
vms = api.list_vms(cudo_api.project_id())
```

### Terminate a virtual machine

```python theme={null}
from cudo_compute import cudo_api

api = cudo_api.virtual_machines()
api.terminate_vm(cudo_api.project_id(), 'my-vm-id')
```

### Other services

The API has multiple services (other than virtual\_machines)

* apikeys
* disks
* networks
* object\_storage
* permissions
* ssh\_keys
* search
* user
* virtual\_machines

Other services  can be used like this:

```python theme={null}
from cudo_compute import cudo_api

api = cudo_api.networks()
```

For more information see the `/docs` directory of the [GitHub Repository](https://github.com/cudoVentures/cudo-compute-python-client/tree/main/docs)
