For the complete documentation index, see llms.txt. This page is also available as Markdown.

Core Infra SDK

Overview

The Krutrim Python SDK enables developers to interact programmatically with Krutrim Cloud services, including Compute, Networking, Storage, Security, and AI Pods. With a single unified client, you can create and manage resources such as VMs, VPCs, Volumes, Buckets, Security Groups, and AI workloads.

https://github.com/ola-krutrim/Krutrim-client-python


Installation

bashCopyEditpip uninstall krutrim-client-python  # optional: remove previous version
pip install krutrim-client-python    # install from PyPI

Note: If installing from source:

bashCopyEditpython setup.py bdist_wheel
pip install dist/krutrim_client_python-<version>-py3-none-any.whl

Authentication

pythonCopyEditimport requests

url = "https://cloud.olakrutrim.com/iam/v1/signInAsRootUser"
payload = {
    "email": "<your_email>",
    "password": "<your_password>"
}
response = requests.post(url, json=payload)
access_token = response.json()["access_token"]

Tokens refresh every 5 minutes. You should implement a token refresh mechanism for long-running scripts.


Initializing the Client


Services & Methods

1. Networking – VPC & Subnets

Method
Parameters
Description

create_vpc(vpc_data: dict, x_region: str)

vpc_data – dict containing network, security_group, subnet details. x_region – region name (In-Bangalore-1 / In-Hyderabad-1).

Create a new VPC.

get_vpc_task_status(task_id: str, x_region: str)

task_id – ID of the task. x_region – region name.

Check the status of a VPC task.

retrieve_vpc(vpc_id: str, x_region: str, vpc_name: str = None)

vpc_id – VPC ID. x_region – region name. vpc_name – optional name filter.

Get VPC details.

list_vpcs(x_region: str)

x_region – region name.

List all VPCs.

delete_vpc(vpc_id: str, x_region: str)

vpc_id – VPC ID. x_region – region name.

Delete a VPC.

create_subnet(subnet_data: dict, vpc_id: str, router_krn: str, x_region: str)

subnet_data – subnet configuration. vpc_id – VPC ID. router_krn – router KRN. x_region – region name.

Create a subnet in a VPC.


2. Security Groups

Method
Parameters
Description

create_security_group(name: str, description: str, vpcid: str, x_region: str)

name – security group name. description – description. vpcid – VPC ID. x_region – region name.

Create a new security group.

list_by_vpc(vpc_krn_identifier: str, x_region: str)

vpc_krn_identifier – VPC KRN. x_region – region name.

List all security groups in a VPC.

create_rule(direction: str, ethertype: str, protocol: str, port_range_min: int, port_range_max: int, remote_ip_prefix: str, x_region: str)

Standard rule parameters + region.

Create an inbound/outbound rule.

attach_rule(ruleid: str, securityid: str, vpcid: str, x_region: str)

IDs + region name.

Attach a rule.

detach_rule(ruleid: str, securityid: str, vpcid: str, x_region: str)

IDs + region name.

Detach a rule.

delete_rule(securitygroupruleid: str, x_region: str)

Rule ID + region name.

Delete a rule.

delete_security_group(securitygroupid: str, x_region: str)

Security group ID + region.

Delete a security group.

update_port_security_groups(port_krn: str, security_groups: list[str], x_region: str)

port_krn – Port KRN (available in instance.network_ports[].krn).

security_groups – complete list of Security Group KRNs to retain (must not be empty).

x_region – region name.

Updates Security Groups on a port using PUT /api/v1/ports/{port_krn}. This operation replaces the entire Security Group list. Include every Security Group that should remain attached; omit any that should be removed.


3. Compute – Instances (VMs)

Method
Parameters
Description

create_instance(instanceName: str, instanceType: str, region: str, vpc_id: str, subnet_id: str, sshkey_name: str, security_groups: list[str], image_krn: str = None, volume_name: str = None, volume_size: int = None, volumetype: str = None, volumes: list[str] = None, floating_ip: bool = False, user_data: str = "", delete_on_termination: bool = True, tags: list = [], count: int = 1, port_krn: str = None, isGpu: bool = False, timeout: int = None)

instanceName – VM name.instance

Type – e.g. "CPU-2x-8GB"

region – deployment region

vpc_id – VPC ID

subnet_id – subnet ID

sshkey_name – SSH key name

security_groups – list of Security Group KRNs

For a new boot volume, provide image_krn, volume_name, volume_size, volumetype (omit volumes).

To boot from an existing volume, provide volumes (omit image/volume creation fields).network_id is automatically resolved from the VPC and subnet and must not be supplied.

Launches a VM asynchronously using POST /vm/v1/create_instance_async. Returns { message, task_id }. Poll with search_instances() or retrieve_instance() until the VM reaches ACTIVE.

search_instances(vpc_id: str, x_region: str, page: int = None, limit: int = None)

vpc_id – VPC ID.

x_region – region name.

page – optional page number.

limit – optional page size.

Search instances in a VPC using GET /vm/v1/search_instances. Recommended for polling asynchronous VM create/delete operations.

retrieve_instance(krn: str, x_region: str)

krn – Instance KRN.

x_region – region name.

Retrieve complete VM details using GET /v1/highlvlvpc/instance, including network_ports[].krn, required for Security Group and Floating IP operations.

delete_instance(instanceKrn: str, deleteVolume: bool, x_region: str)

instanceKrn – VM KRN.

deleteVolume – delete attached boot volume.

x_region – region name.

Deletes a VM asynchronously using DELETE /vm/v1/delete_instance_async. Returns { message, task_id }. Poll search_instances() until the VM is removed.

create_instance_template(name: str, vpc_id: str, subnet_id: str, instanceType: str, sshkey_name: str, region: str, image_krn: str, volumetype: str, volume_size: int, volume_name: str, security_groups: list[str], isGpu: bool = False, user_data: str = None)

name – template name. vpc_id – VPC ID. subnet_id – subnet ID. instanceType – VM flavor. sshkey_name – SSH key. region – deployment region. image_krn – image KRN. volumetype – boot volume type. volume_size – boot volume size. volume_name – boot volume name. security_groups – Security Group KRNs.

Creates an Instance Template using POST /vm/v1/instance-templates/create. Returns a template object containing template_krn. network_id is resolved automatically.

list_instance_templates(x_region: str, page: int = None, limit: int = None)

x_region – region name. page – optional page number. limit – optional page size.

Lists all Instance Templates using GET /vm/v1/instance-templates/list.

retrieve_instance_template(template_krn: str, x_region: str)

template_krn – Instance Template KRN. x_region – region name.

Retrieves details of an Instance Template using GET /vm/v1/instance-templates/details.

delete_instance_template(template_krn: str, x_region: str)

template_krn – Instance Template KRN. x_region – region name.

Deletes an Instance Template using DELETE /vm/v1/instance-templates/delete. Returns { "message": "Template deleted" }.

batch_create_vms(template_krn: str, count: int, instanceName: str, x_region: str)

template_krn – Instance Template KRN. count – number of VMs. instanceName – VM name prefix. x_region – region name.

Creates multiple VMs using POST /vm/v1/batch-vm-create. Returns { batch_source, job_id, message, total_count }. Recommended instead of create_instance(count > 1) to avoid boot-volume naming conflicts.


4. Block Storage

Method
Parameters
Description

create_volume(volumeName: str, size: int, volumeType: str, availabilityZone: str, x_region: str)

Name, size (GB), type ("standard"/"ssd"), AZ, region.

Create a block volume.

retrieve_volume(volumeId: str, x_region: str)

Volume ID, region.

Get volume details.

delete_volume(volumeId: str, x_region: str)

Volume ID, region.

Delete a volume.

list_volumes(k_tenant_id: str, x_region: str)

VPC KRN, region.

List all volumes in a VPC.

attach_volume(volume_id: str, instance_id: str, k_tenant_id: str, x_region: str, mount_partition: str = "/dev/vdz")

Volume KRN, instance KRN, VPC KRN, region, mount path (default /dev/vdz).

Attach a volume to an instance. Returns attachments[].remote_attachment_id, needed later as attachment_id when detaching.

detach_volume(volume_id: str, instance_id: str, attachment_id: str, k_tenant_id: str, x_region: str)

Volume KRN, instance KRN, attachment ID (from attachments[].remote_attachment_id), VPC KRN, region.

Detach a volume from an instance.


5. Object Storage

Method
Parameters
Description

create_access_keys(key_name: str, x_region: str)

Key name, region.

Create a storage access key.

list_access_keys()

None.

List all keys.

delete_access_keys(access_key_id: str, x_region: str)

Access key ID, region.

Delete an access key.

create_bucket(bucketName: str, region: str)

Name, region.

Create a bucket.

list_buckets()

None.

List buckets.

delete_bucket(bucketName: str, region: str)

Name, region.

Delete a bucket.


6. AI Pods

Method
Parameters
Description

kpod.pod.create(podName: str, imageKrn: str, instanceType: str, sshKeyName: str, volumeSize: int, x_region: str)

Name, image KRN, instance type, SSH key, volume size, region.

Create an AI Pod.

kpod.pod.update(kpod_krn: str, action: str)

Pod KRN, action ("start", "stop", "restart").

Update AI Pod state.

kpod.pod.delete(kpod_krn: str)

Pod KRN.

Delete AI Pod.

Last updated

Was this helpful?