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.


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

pythonCopyEditfrom krutrim_client_python import KrutrimClient

client = KrutrimClient(api_key=access_token)

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.


3. Compute – Instances (VMs)

Method
Parameters
Description

create_instance(instanceName: str, imageKrn: str, instanceType: str, subnetId: str, sshKeyName: str, volumeSize: int, x_region: str)

instanceName – name of VM. imageKrn – image KRN. instanceType – e.g., "cpu-standard-4". subnetId – subnet ID. sshKeyName – name of SSH key. volumeSize – in GB. x_region – region name.

Launch a new VM.

search_instances(filters: dict)

Filter dictionary.

Search for instances.

retrieve_instance(krn: str, x_region: str)

krn – instance KRN. x_region – region name.

Retrieve VM details.

list_instance_info(vpc_krn: str, x_region: str)

vpc_krn – VPC KRN. x_region – region name.

List VM info in a VPC.

perform_action(instance_krn: str, action: str, x_region: str)

instance_krn – instance KRN. action"start", "stop", "reboot". x_region – region name.

Start, stop, or reboot a VM.

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

instanceKrn – VM KRN. deleteVolume – whether to delete attached volume. x_region – region name.

Delete a VM.


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.


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?