Skip to main content
The Nebius AI Cloud SDK for Python is a client library for working with Nebius AI Cloud resources from Python applications. For documentation, see:

Supported Python versions

The SDK supports Python 3.10 and later. If your project uses SDK version 0.2.x, check the migration notes in the Python SDK repository before updating to version 0.3.x or later.

Installation and update

Before installing the SDK, consider creating a Python virtual environment for your project to avoid dependency conflicts.
Install the SDK package:
If you installed the SDK earlier, update it to the latest version:

Initialization and authentication

For server-to-server communication, use a service account to authenticate SDK requests. The SDK uses the service account credentials to generate a JSON Web Token, exchange it for an IAM token and refresh the IAM token in the background.
  1. Create a service account.
  2. Create a private and public key pair:
    This command creates the private.pem and public.pem files in the current directory.
  3. Upload the public key to create an authorized key:
    In the command, specify the service account ID.
  4. Initialize the SDK with the private key file:
    The SDK constructor initializes the SDK and uses the service account private key file to authenticate requests. The user_agent_prefix argument adds a prefix to the User-Agent header sent with each request. Use user_agent_prefix to identify your application in the list of requests. In the script, set the following parameters:
    • <application_name>/<application_version_or_comment>: Application or library that calls the SDK. The version or comment is optional.
    • <private_key_file_path>: Path to the private key file, for example private.pem.
    • <public_key_ID>: ID of the public key generated for the service account.
    • <service_account_ID>: ID of your service account.
For local usage, authenticate SDK requests by using an IAM token, CLI configuration or a credentials file. For more information, see the Python SDK repository.

Sending a request

The SDK provides service clients grouped by Nebius AI Cloud services and API versions. For mutating operations, such as creating, updating and deleting resources, the SDK returns an operation object. If an operation is asynchronous, call wait to wait until it is completed. The following example creates a Compute virtual machine.
  1. Create a Python file with the following code. This script already includes SDK initialization and authentication.
    In the script, set the following parameters:
    • <application_name>/<application_version_or_comment>: Application or library that calls the SDK. For more information, see Initialization and authentication.
    • <private_key_file_path>: Path to the private key file.
    • <public_key_ID>: ID of the public key generated for the service account.
    • <service_account_ID>: ID of your service account.
    • <project_ID>: ID of the project where you create the resources.
    • <image_family_name>: Name of the boot disk image family, for example, ubuntu24.04-driverless.
    • <platform_name>: Name of the Compute platform, for example, cpu-e2.
    • <preset_name>: Name of the resource preset. Available presets depend on the selected platform, for example, 2vcpu-8gb for cpu-e2.
    • <subnet_ID>: ID of the subnet for the VM.
  2. Execute the file:
After you run the example, delete the VM and its boot disk if you no longer need them. Otherwise, Compute continues charging for these resources.