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

# Video translation and dubbing in Serverless AI

With Serverless AI, you can translate and [dub a video](https://en.wikipedia.org/wiki/Dubbing) into another language. To do so, create a Docker image and run a fine-tuning job based on it. The job converts audio to text, translates the text, and creates a dubbed video.

## Costs

Nebius AI Cloud charges you for the following billing items:

* [Compute virtual machines](https://docs.nebius.com/compute/resources/pricing.md#virtual-machines-gpus-vcpus-ram) (VMs)
* [Boot disks](https://docs.nebius.com/compute/resources/pricing.md#disks) attached to the VMs
* Used space in Standard storage in an [Object Storage bucket](https://docs.nebius.com/object-storage/resources/pricing.md#storing-data)

## Prerequisites

> [tab] Web console
>
> 1. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
> 2. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] CLI
>
> 1. [Install and configure](https://docs.nebius.com/cli/install.md) the Nebius AI Cloud CLI.
>
> 2. Install [jq](https://jqlang.github.io/jq/) to prepare the cloud-init configuration:
>
>    ```bash Ubuntu theme={null}
>    sudo apt-get install jq
>    ```
>
>    ```bash macOS theme={null}
>    brew install jq
>    ```
>
> 3. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
>
> 4. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] Terraform
>
> 1. [Install and configure](https://docs.nebius.com/terraform-provider/install.md) the Nebius AI Cloud provider for Terraform.
>
> 2. Install [jq](https://jqlang.github.io/jq/) to prepare the cloud-init configuration:
>
>    ```bash Ubuntu theme={null}
>    sudo apt-get install jq
>    ```
>
>    ```bash macOS theme={null}
>    brew install jq
>    ```
>
> 3. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
>
> 4. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] Go SDK
>
> 1. [Install and initialize the Nebius SDK for Go](https://docs.nebius.com/sdk/go/install-auth.md).
> 2. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
> 3. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] Python SDK
>
> 1. [Install and initialize the Nebius SDK for Python](https://docs.nebius.com/sdk/python/install-auth.md).
> 2. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
> 3. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] JavaScript SDK
>
> 1. [Install and initialize the Nebius SDK for JavaScript](https://docs.nebius.com/sdk/javascript/install-auth.md).
> 2. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
> 3. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

> [tab] REST API
>
> 1. Get an access token to [authenticate to the REST API](https://docs.nebius.com/rest-api/authentication.md).
>
> 2. Install [jq](https://jqlang.github.io/jq/) to process JSON responses:
>
>    ```bash Ubuntu theme={null}
>    sudo apt-get install jq
>    ```
>
>    ```bash macOS theme={null}
>    brew install jq
>    ```
>
> 3. Make sure you are in a [group](https://docs.nebius.com/iam/authorization/groups/index.md) that has at least the `editor` role within your tenant or project; for example, the default `editors` group. You can check this in the [Administration → IAM](https://console.nebius.com/iam) section of the web console.
>
> 4. Generate an [SSH key pair](https://docs.nebius.com/compute/virtual-machines/ssh-keys.md).

## Steps

### Prepare infrastructure

> [!NOTE]
>
> Create all resources in the same [project](https://docs.nebius.com/iam/overview.md#projects).

1. Create a CPU-only VM. The VM is required to build the Docker image based on the VM's Linux operating system (OS). If you build the image on a non-Linux OS, the image architecture will be incompatible with Serverless AI, and the fine-tuning job will fail.

   Configure SSH access to the VM so that you can connect to it later.

   > [tab] Web console
   >
   > 1. In the [web console](https://console.nebius.com), go to  **Compute** → **Virtual machines**.
   >
   > 2. Click **Create resource** → **Virtual machine**.
   >
   > 3. On the page that opens, set the following VM configuration:
   >
   >    * **Computing resources**: Without GPU.
   >    * **Platform**: Non-GPU AMD Epyc Genoa.
   >    * **Preset**: 4 CPUs — 16 GiB RAM.
   >    * **Boot disk operating system**: Ubuntu 24.04 LTS.
   >    * **Boot disk size**: At least 100 GiB.
   >    * **Public IP address**: `Auto assign dynamic IP`.
   >    * **Username and SSH key**: Configure access credentials.
   >
   > 4. Click **Create VM**.

   > [tab] CLI
   >
   > 1. Create a boot disk and save its ID to the `BOOT_DISK_ID` environment variable:
   >
   >    ```bash theme={null}
   >    export BOOT_DISK_ID=$(nebius compute disk create \
   >      --name video-translation-boot-disk \
   >      --size-gibibytes 100 \
   >      --type network_ssd \
   >      --source-image-family-image-family ubuntu24.04-driverless \
   >      --block-size-bytes 4096 \
   >      --format jsonpath='{.metadata.id}')
   >    ```
   >
   > 2. To add a user for connections to the VM, create a configuration by using the [cloud-init](https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups) format:
   >    ```bash theme={null}
   >    export USER_DATA=$(jq -Rrs '.' <<EOF
   >    #cloud-config
   >    users:
   >      - name: $USER
   >        sudo: ALL=(ALL) NOPASSWD:ALL
   >        shell: /bin/bash
   >        ssh_authorized_keys:
   >          - $(cat ~/.ssh/id_ed25519.pub)
   >    EOF
   >    )
   >    ```
   >
   > 3. Create the VM by using the boot disk ID saved in `BOOT_DISK_ID`:
   >
   >    ```bash theme={null}
   >    nebius compute instance create \
   >      --name video-translation-vm \
   >      --boot-disk-existing-disk-id "$BOOT_DISK_ID" \
   >      --boot-disk-attach-mode READ_WRITE \
   >      --resources-platform cpu-d3 \
   >      --resources-preset 4vcpu-16gb \
   >      --network-interfaces "[{\"name\": \"eth0\", \"subnet_id\": \"<subnet_ID>\", \"ip_address\": {}, \"public_ip_address\": {}}]" \
   >      --cloud-init-user-data "$USER_DATA"
   >    ```
   >
   >    In `--network-interfaces`, for `subnet_id`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id-cli).
   >
   >    This command creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.

   > [tab] Terraform
   >
   > 1. Create the boot disk:
   >
   >    ```hcl theme={null}
   >    resource "nebius_compute_v1_disk" "video_translation_boot_disk" {
   >      name           = "video-translation-boot-disk"
   >      parent_id      = "<project_ID>"
   >      size_gibibytes = 100
   >      type           = "NETWORK_SSD"
   >      source_image_family = {
   >        image_family = "ubuntu24.04-driverless"
   >      }
   >      block_size_bytes = 4096
   >    }
   >    ```
   >
   >    For `parent_id`, specify your [project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id-terraform).
   >
   > 2. To add a user for connections to the VM, create a configuration by using the [cloud-init](https://cloudinit.readthedocs.io/en/latest/reference/modules.html#users-and-groups) format:
   >    ```bash theme={null}
   >    export USER_DATA=$(jq -Rrs '.' <<EOF
   >    #cloud-config
   >    users:
   >      - name: $USER
   >        sudo: ALL=(ALL) NOPASSWD:ALL
   >        shell: /bin/bash
   >        ssh_authorized_keys:
   >          - $(cat ~/.ssh/id_ed25519.pub)
   >    EOF
   >    )
   >    ```
   >
   > 3. Create the VM:
   >
   >    ```hcl theme={null}
   >    resource "nebius_compute_v1_instance" "video_translation_vm" {
   >      name      = "video-translation-vm"
   >      parent_id = "<project_ID>"
   >      resources = {
   >        platform = "cpu-d3"
   >        preset   = "4vcpu-16gb"
   >      }
   >      boot_disk = {
   >        existing_disk = {
   >          id = nebius_compute_v1_disk.video_translation_boot_disk.id
   >        }
   >        attach_mode = "READ_WRITE"
   >      }
   >      cloud_init_user_data = var.user_data
   >      network_interfaces = [
   >        {
   >          name              = "eth0"
   >          ip_address        = {}
   >          public_ip_address = {}
   >          subnet_id         = "<subnet_ID>"
   >        }
   >      ]
   >    }
   >    ```
   >
   >    In the configuration:
   >
   >    * For `boot_disk.existing_disk.id`, specify the ID of the boot disk created in the previous step.
   >    * For `network_interfaces[0].subnet_id`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id).
   >
   >    This manifest creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.
   >
   > 4. Check that the configuration is correct:
   >    ```bash theme={null}
   >    terraform validate
   >    ```
   >
   > 5. Apply the changes:
   >    ```bash theme={null}
   >    terraform apply
   >    ```

   > [tab] Go SDK
   >
   > 1. Create the boot disk:
   >
   >    ```go theme={null}
   >    createDiskService := sdk.Services().Compute().V1().Disk()
   >    diskOperation, err := createDiskService.Create(
   >        ctx,
   >        &compute.CreateDiskRequest{
   >            Metadata: &common.ResourceMetadata{
   >                ParentId: "<project_ID>",
   >                Name:     "video-translation-boot-disk",
   >            },
   >            Spec: &compute.DiskSpec{
   >                Size: &compute.DiskSpec_SizeGibibytes{
   >                    SizeGibibytes: 100,
   >                },
   >                Type:           compute.DiskSpec_NETWORK_SSD,
   >                BlockSizeBytes: 4096,
   >                Source: &compute.DiskSpec_SourceImageFamily{
   >                    SourceImageFamily: &compute.SourceImageFamily{
   >                        ImageFamily: "ubuntu24.04-driverless",
   >                    },
   >                },
   >            },
   >        },
   >    )
   >    if err != nil {
   >        return fmt.Errorf("create disk: %w", err)
   >    }
   >    if _, err = diskOperation.Wait(ctx); err != nil {
   >        return fmt.Errorf("wait for disk creation: %w", err)
   >    }
   >    bootDiskID := diskOperation.ResourceID()
   >    ```
   >
   >    For `Metadata.ParentId`, specify your [project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id-go-sdk).
   >
   > 2. Create the VM:
   >
   >    ```go theme={null}
   >    createInstanceService := sdk.Services().Compute().V1().
   >        Instance()
   >    publicKey, err := os.ReadFile(
   >        os.Getenv("HOME") + "/.ssh/id_ed25519.pub",
   >    )
   >    if err != nil {
   >        return fmt.Errorf("read SSH public key: %w", err)
   >    }
   >    userData := "#cloud-config\nusers:\n  - name: user\n" +
   >        "    sudo: ALL=(ALL) NOPASSWD:ALL\n" +
   >        "    shell: /bin/bash\n    ssh_authorized_keys:\n" +
   >        "      - " + string(publicKey)
   >    instanceOperation, err := createInstanceService.Create(
   >        ctx,
   >        &compute.CreateInstanceRequest{
   >            Metadata: &common.ResourceMetadata{
   >                ParentId: "<project_ID>",
   >                Name:     "video-translation-vm",
   >            },
   >            Spec: &compute.InstanceSpec{
   >                Resources: &compute.ResourcesSpec{
   >                    Platform: "cpu-d3",
   >                    Size: &compute.ResourcesSpec_Preset{
   >                        Preset: "4vcpu-16gb",
   >                    },
   >                },
   >                BootDisk: &compute.AttachedDiskSpec{
   >                    AttachMode:
   >                        compute.AttachedDiskSpec_READ_WRITE,
   >                    Type: &compute.AttachedDiskSpec_ExistingDisk{
   >                        ExistingDisk: &compute.ExistingDisk{
   >                            Id: bootDiskID,
   >                        },
   >                    },
   >                },
   >                NetworkInterfaces:
   >                    []*compute.NetworkInterfaceSpec{
   >                        {
   >                            Name: "eth0",
   >                            SubnetId: "<subnet_ID>",
   >                            IpAddress: &compute.IPAddress{},
   >                            PublicIpAddress:
   >                                &compute.PublicIPAddress{},
   >                        },
   >                    },
   >                CloudInitUserData: userData,
   >            },
   >        },
   >    )
   >    if err != nil {
   >        return fmt.Errorf("create VM: %w", err)
   >    }
   >    if _, err = instanceOperation.Wait(ctx); err != nil {
   >        return fmt.Errorf("wait for VM creation: %w", err)
   >    }
   >    ```
   >
   >    In the code:
   >
   >    * For `Spec.BootDisk.Type.ExistingDisk.Id`, specify the ID of the boot disk created in the previous step.
   >    * For `Spec.NetworkInterfaces[0].SubnetId`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id-go-sdk).
   >
   >    The code creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.

   > [tab] Python SDK
   >
   > 1. Create the boot disk:
   >
   >    ```python theme={null}
   >    create_disk_service = DiskServiceClient(sdk)
   >    disk_operation = await create_disk_service.create(
   >        CreateDiskRequest(
   >            metadata=ResourceMetadata(
   >                parent_id="<project_ID>",
   >                name="video-translation-boot-disk",
   >            ),
   >            spec=DiskSpec(
   >                size_gibibytes=100,
   >                type=DiskSpec.DiskType.NETWORK_SSD,
   >                block_size_bytes=4096,
   >                source_image_family=SourceImageFamily(
   >                    image_family="ubuntu24.04-driverless",
   >                ),
   >            ),
   >        ),
   >    )
   >    await disk_operation.wait()
   >    boot_disk_id = disk_operation.resource_id
   >    ```
   >
   >    For `metadata.parent_id`, specify your [project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id-python-sdk).
   >
   > 2. Create the VM:
   >
   >    ```python theme={null}
   >    create_instance_service = InstanceServiceClient(sdk)
   >    public_key = Path.home().joinpath(
   >        ".ssh/id_ed25519.pub",
   >    ).read_text()
   >    user_data = (
   >        "#cloud-config\nusers:\n  - name: user\n"
   >        "    sudo: ALL=(ALL) NOPASSWD:ALL\n"
   >        "    shell: /bin/bash\n"
   >        "    ssh_authorized_keys:\n"
   >        f"      - {public_key}"
   >    )
   >    instance_operation = await create_instance_service.create(
   >        CreateInstanceRequest(
   >            metadata=ResourceMetadata(
   >                parent_id="<project_ID>",
   >                name="video-translation-vm",
   >            ),
   >            spec=InstanceSpec(
   >                resources=ResourcesSpec(
   >                    platform="cpu-d3",
   >                    preset="4vcpu-16gb",
   >                ),
   >                boot_disk=AttachedDiskSpec(
   >                    attach_mode=(
   >                        AttachedDiskSpec.AttachMode.READ_WRITE
   >                    ),
   >                    existing_disk=ExistingDisk(
   >                        id=boot_disk_id,
   >                    ),
   >                ),
   >                network_interfaces=[
   >                    NetworkInterfaceSpec(
   >                        name="eth0",
   >                        subnet_id="<subnet_ID>",
   >                        ip_address=IPAddress(),
   >                        public_ip_address=PublicIPAddress(),
   >                    ),
   >                ],
   >                cloud_init_user_data=user_data,
   >            ),
   >        ),
   >    )
   >    await instance_operation.wait()
   >    ```
   >
   >    In the code:
   >
   >    * For `spec.boot_disk.existing_disk.id`, specify the ID of the boot disk created in the previous step.
   >    * For `spec.network_interfaces[0].subnet_id`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id-python-sdk).
   >
   >    The code creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.

   > [tab] JavaScript SDK
   >
   > 1. Create the boot disk:
   >
   >    ```ts theme={null}
   >    const createDiskService = new DiskService(sdk);
   >    const diskOperation = await createDiskService.create(
   >      CreateDiskRequest.create({
   >        metadata: {
   >          parentId: "<project_ID>",
   >          name: "video-translation-boot-disk",
   >        },
   >        spec: {
   >          size: {
   >            $case: "sizeGibibytes",
   >            sizeGibibytes: 100,
   >          },
   >          type: DiskSpec_DiskType.NETWORK_SSD,
   >          blockSizeBytes: 4096,
   >          source: {
   >            $case: "sourceImageFamily",
   >            sourceImageFamily: SourceImageFamily.create({
   >              imageFamily: "ubuntu24.04-driverless",
   >            }),
   >          },
   >        },
   >      }),
   >    ).result;
   >    await diskOperation.wait();
   >    const bootDiskId = diskOperation.resourceId();
   >    ```
   >
   >    For `metadata.parentId`, specify your [project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id-javascript-sdk).
   >
   > 2. Create the VM:
   >
   >    ```ts theme={null}
   >    const createInstanceService = new InstanceService(sdk);
   >    const publicKey = readFileSync(
   >      `${process.env.HOME}/.ssh/id_ed25519.pub`,
   >      "utf8",
   >    );
   >    const userData = "#cloud-config\nusers:\n  - name: user\n" +
   >      "    sudo: ALL=(ALL) NOPASSWD:ALL\n" +
   >      "    shell: /bin/bash\n    ssh_authorized_keys:\n" +
   >      `      - ${publicKey}`;
   >    const instanceOperation = await createInstanceService.create(
   >      CreateInstanceRequest.create({
   >        metadata: {
   >          parentId: "<project_ID>",
   >          name: "video-translation-vm",
   >        },
   >        spec: {
   >          resources: {
   >            platform: "cpu-d3",
   >            size: {
   >              $case: "preset",
   >              preset: "4vcpu-16gb",
   >            },
   >          },
   >          bootDisk: {
   >            attachMode:
   >              AttachedDiskSpec_AttachMode.READ_WRITE,
   >            type: {
   >              $case: "existingDisk",
   >              existingDisk: { id: bootDiskId },
   >            },
   >          },
   >          networkInterfaces: [{
   >            name: "eth0",
   >            subnetId: "<subnet_ID>",
   >            ipAddress: {},
   >            publicIpAddress: {},
   >          }],
   >          cloudInitUserData: userData,
   >        },
   >      }),
   >    ).result;
   >    await instanceOperation.wait();
   >    ```
   >
   >    In the code:
   >
   >    * For `spec.bootDisk.type.existingDisk.id`, specify the ID of the boot disk created in the previous step.
   >    * For `spec.networkInterfaces[0].subnetId`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id-javascript-sdk).
   >
   >    The code creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.

   > [tab] REST API
   >
   > 1. Create the boot disk:
   >
   >    ```bash theme={null}
   >    curl --request POST \
   >      --url 'https://api.nebius.cloud/compute/v1/disks' \
   >      --header "Authorization: Bearer <access_token>" \
   >      --header 'Content-Type: application/json' \
   >      --data '{
   >        "metadata": {
   >          "parentId": "<project_ID>",
   >          "name": "video-translation-boot-disk"
   >        },
   >        "spec": {
   >          "sizeGibibytes": "100",
   >          "type": "NETWORK_SSD",
   >          "blockSizeBytes": "4096",
   >          "sourceImageFamily": {
   >            "imageFamily": "ubuntu24.04-driverless"
   >          }
   >        }
   >      }'
   >
   >    ```
   >
   >    For `metadata.parentId`, specify your [project ID](https://docs.nebius.com/iam/manage-projects.md#how-to-get-a-project-id).
   >
   >    The response returns the boot disk ID in `resourceId`. Save it for the VM request.
   >
   > 2. Create the VM:
   >
   >    ```bash theme={null}
   >    curl --request POST \
   >      --url 'https://api.nebius.cloud/compute/v1/instances' \
   >      --header "Authorization: Bearer <access_token>" \
   >      --header 'Content-Type: application/json' \
   >      --data '{
   >        "metadata": {
   >          "parentId": "<project_ID>",
   >          "name": "video-translation-vm"
   >        },
   >        "spec": {
   >          "resources": {
   >            "platform": "cpu-d3",
   >            "preset": "4vcpu-16gb"
   >          },
   >          "bootDisk": {
   >            "existingDisk": {
   >              "id": "<boot_disk_ID>"
   >            },
   >            "attachMode": "READ_WRITE"
   >          },
   >          "networkInterfaces": [
   >            {
   >              "name": "eth0",
   >              "subnetId": "<subnet_ID>",
   >              "ipAddress": {},
   >              "publicIpAddress": {}
   >            }
   >          ],
   >          "cloudInitUserData": "<cloud_init_user_data>"
   >        }
   >      }'
   >
   >    ```
   >
   >    In the request:
   >
   >    * For `spec.bootDisk.existingDisk.id`, specify the ID of the boot disk returned in `resourceId` by the previous request.
   >    * For `spec.networkInterfaces[0].subnetId`, specify your [subnet ID](https://docs.nebius.com/vpc/networking/resources.md#how-to-get-a-subnet-id).
   >    * For `spec.cloudInitUserData`, specify a cloud-init configuration containing your public SSH key.
   >
   >    The request creates a VM without GPUs, assigns a dynamic public IP address, and configures SSH access.

2. Create a bucket to store the dubbed video's output files.

   > [tab] Web console
   >
   > 1. In the web console, go to  **Storage** → **Object Storage**.
   > 2. Click  **Create bucket**.
   > 3. In the **Name** field, enter `video-translation-bucket`.
   > 4. In the **Maximum size** field, select **Unlimited**.
   > 5. Click **Create bucket**.

   > [tab] CLI
   >
   > Create the bucket and save its ID to the `BUCKET_ID` environment variable:
   >
   > ```bash theme={null}
   > export BUCKET_ID=$(nebius storage bucket create \
   >   --name video-translation-bucket \
   >   --format jsonpath='{.metadata.id}')
   > ```

   > [tab] Terraform
   >
   > 1. Use the following configuration file:
   >
   >    ```hcl theme={null}
   >    resource "nebius_storage_v1_bucket" "video_translation_bucket" {
   >      name      = "video-translation-bucket"
   >      parent_id = "<project_ID>"
   >    }
   >    ```
   >
   > 2. Check that the configuration is correct:
   >    ```bash theme={null}
   >    terraform validate
   >    ```
   >
   > 3. Apply the changes:
   >    ```bash theme={null}
   >    terraform apply
   >    ```

   > [tab] Go SDK
   >
   > Create the bucket and save its ID in `bucketID`:
   >
   > ```go theme={null}
   > bucketService := sdk.Services().Storage().V1().Bucket()
   > bucketOperation, err := bucketService.Create(
   >     ctx,
   >     &storage.CreateBucketRequest{
   >         Metadata: &common.ResourceMetadata{
   >             ParentId: "<project_ID>",
   >             Name:     "video-translation-bucket",
   >         },
   >     },
   > )
   > if err != nil {
   >     return fmt.Errorf("create bucket: %w", err)
   > }
   > if _, err = bucketOperation.Wait(ctx); err != nil {
   >     return fmt.Errorf("wait for bucket creation: %w", err)
   > }
   > bucketID := bucketOperation.ResourceID()
   > ```

   > [tab] Python SDK
   >
   > Create the bucket and save its ID in `bucket_id`:
   >
   > ```python theme={null}
   > bucket_service = BucketServiceClient(sdk)
   > bucket_operation = await bucket_service.create(
   >     CreateBucketRequest(
   >         metadata=ResourceMetadata(
   >             parent_id="<project_ID>",
   >             name="video-translation-bucket",
   >         ),
   >     ),
   > )
   > await bucket_operation.wait()
   > bucket_id = bucket_operation.resource_id
   > ```

   > [tab] JavaScript SDK
   >
   > Create the bucket and save its ID in `bucketId`:
   >
   > ```ts theme={null}
   > const bucketService = new BucketService(sdk);
   > const bucketOperation = await bucketService.create(
   >   CreateBucketRequest.create({
   >     metadata: {
   >       parentId: "<project_ID>",
   >       name: "video-translation-bucket",
   >     },
   >   }),
   > ).result;
   > await bucketOperation.wait();
   > const bucketId = bucketOperation.resourceId();
   > ```

   > [tab] REST API
   >
   > Create the bucket:
   >
   > ```bash theme={null}
   > curl --request POST \
   >   --url 'https://api.nebius.cloud/storage/v1/buckets' \
   >   --header "Authorization: Bearer <access_token>" \
   >   --header 'Content-Type: application/json' \
   >   --data '{
   >     "metadata": {
   >       "parentId": "<project_ID>",
   >       "name": "video-translation-bucket"
   >     }
   >   }'
   >
   > ```
   >
   > The response returns the bucket ID in `resourceId`. Save the ID because you will need it in a later step.

### Prepare files for the Docker image

1. To connect to the VM, get its public IP address:

   > [tab] Web console
   >
   > 1. In the web console, go to  **Compute** → **Virtual machines**.
   > 2. On the **Standalone VMs** tab, open the VM page.
   > 3. In **Network** → **Public IPv4**, copy the address.

   > [tab] CLI
   >
   > Run the following command:
   >
   > ```bash theme={null}
   > nebius compute instance get-by-name \
   >   --name video-translation-vm \
   >   --format jsonpath='{.status.network_interfaces[0].public_ip_address.address}'
   > ```

   > [tab] Go SDK
   >
   > Get the public IP address of the VM:
   >
   > ```go theme={null}
   > getInstanceService := sdk.Services().Compute().V1().
   >     Instance()
   > instance, err := getInstanceService.GetByName(
   >     ctx,
   >     &common.GetByNameRequest{
   >         Name: "video-translation-vm",
   >     },
   > )
   > if err != nil {
   >     return fmt.Errorf("get VM by name: %w", err)
   > }
   > fmt.Println(instance.GetStatus().GetNetworkInterfaces()[0].
   >     GetPublicIpAddress().GetAddress())
   > ```

   > [tab] Python SDK
   >
   > Get the public IP address of the VM:
   >
   > ```python theme={null}
   > get_instance_service = InstanceServiceClient(sdk)
   > instance = await get_instance_service.get_by_name(
   >     GetByNameRequest(name="video-translation-vm"),
   > )
   > print(
   >     instance.status
   >     .network_interfaces[0]
   >     .public_ip_address.address
   > )
   > ```

   > [tab] JavaScript SDK
   >
   > Get the public IP address of the VM:
   >
   > ```ts theme={null}
   > const getInstanceService = new InstanceService(sdk);
   > const instance = await getInstanceService.getByName(
   >   GetByNameRequest.create({
   >     name: "video-translation-vm",
   >   }),
   > );
   > console.log(
   >   instance.status?.networkInterfaces[0]
   >     ?.publicIpAddress?.address,
   > );
   > ```

   > [tab] REST API
   >
   > Get the public IP address of the VM:
   >
   > ```bash theme={null}
   > curl --request GET \
   >   --url "https://api.nebius.cloud/compute/v1/instances/get-by-name?parentId=<project_ID>&name=video-translation-vm" \
   >   --header "Authorization: Bearer <access_token>" \
   >   | jq -r '.status.networkInterfaces[0].publicIpAddress.address'
   > ```

2. [Connect to the VM](https://docs.nebius.com/compute/virtual-machines/connect.md#connect-to-the-vm-by-using-ssh) by using SSH:
   ```bash theme={null}
   ssh <username>@<IP_address>
   ```
   Specify the username that you set when creating the VM.

3. On the VM, create a working directory:

   ```bash theme={null}
   mkdir ~/video-translation-nebius
   cd ~/video-translation-nebius
   ```

4. In this directory, create the following files for building the Docker image:

   > [accordion] requirements.txt
   >
   > ```txt theme={null}
   > # Core API
   > fastapi==0.115.12
   > uvicorn[standard]==0.30.6
   > requests==2.32.3
   >
   > # ASR
   > openai-whisper==20250625
   >
   > # Translation
   > transformers==4.48.3
   > accelerate==1.6.0
   > sentencepiece==0.2.0
   >
   > # Text to speech
   > TTS==0.22.0
   >
   > # Media pipeline
   > moviepy==1.0.3
   >
   > # Torch stack
   > torch==2.5.1
   > torchaudio==2.5.1
   > ```

   > [accordion] process\_video.py
   >
   > ```python theme={null}
   > #!/usr/bin/env python3
   > import argparse
   > import subprocess
   > from pathlib import Path
   > import requests
   > import torch
   > import whisper
   > from transformers import AutoModelForSeq2SeqLM, AutoTokenizer
   > from TTS.api import TTS
   >
   > def run(cmd):
   >     print("+", " ".join(cmd), flush=True)
   >     subprocess.run(cmd, check=True)
   >
   > def download(url: str, dst: Path):
   >     with requests.get(url, stream=True, timeout=60) as r:
   >         r.raise_for_status()
   >         with dst.open("wb") as f:
   >             for chunk in r.iter_content(chunk_size=1024 * 1024):
   >                 if chunk:
   >                     f.write(chunk)
   >
   > def split_text(text: str, max_chars: int = 700):
   >     text = " ".join(text.split())
   >     chunks, cur = [], ""
   >     for sent in text.split(". "):
   >         s = sent.strip()
   >         if not s:
   >             continue
   >         s = s + ("" if s.endswith(".") else ".")
   >         if len(cur) + len(s) + 1 > max_chars:
   >             if cur:
   >                 chunks.append(cur.strip())
   >             cur = s
   >         else:
   >             cur = (cur + " " + s).strip()
   >     if cur:
   >         chunks.append(cur)
   >     return chunks
   >
   > def translate_text(text: str, target_lang: str):
   >     model_name = "jbochi/madlad400-3b-mt"
   >     tokenizer = AutoTokenizer.from_pretrained(model_name)
   >     model = AutoModelForSeq2SeqLM.from_pretrained(
   >         model_name,
   >         torch_dtype=torch.float16 if torch.cuda.is_available() else torch.float32,
   >         device_map="auto",
   >     )
   >     out = []
   >     for chunk in split_text(text):
   >         prompt = f"<2{target_lang}> {chunk}"
   >         ids = tokenizer(prompt, return_tensors="pt", truncation=True, max_length=1024).to(model.device)
   >         gen = model.generate(**ids, max_new_tokens=512)
   >         out.append(tokenizer.decode(gen[0], skip_special_tokens=True))
   >     return " ".join(out).strip()
   >
   > def main():
   >     p = argparse.ArgumentParser()
   >     p.add_argument("--url", required=True)
   >     p.add_argument("--target-lang", default="de")
   >     p.add_argument("--work-dir", default="/tmp/work")
   >     p.add_argument("--output-dir", default="/mnt/data/output")
   >     p.add_argument("--tts-model", default="tts_models/de/thorsten/vits")
   >     args = p.parse_args()
   >
   >     work = Path(args.work_dir)
   >     out = Path(args.output_dir)
   >     work.mkdir(parents=True, exist_ok=True)
   >     out.mkdir(parents=True, exist_ok=True)
   >
   >     in_mp4 = work / "input.mp4"
   >     asr_wav = work / "asr.wav"
   >     dub_wav = work / "dub.wav"
   >     tmp_out_mp4 = work / "output_video_with_audio.mp4"
   >     out_mp4 = out / "output_video_with_audio.mp4"
   >     transcript_txt = out / "transcript.txt"
   >     translated_txt = out / "translated.txt"
   >
   >     download(args.url, in_mp4)
   >
   >     run(["ffmpeg", "-y", "-i", str(in_mp4), "-vn", "-ac", "1", "-ar", "16000", str(asr_wav)])
   >
   >     device = "cuda" if torch.cuda.is_available() else "cpu"
   >     asr = whisper.load_model("turbo", device=device)
   >     r = asr.transcribe(str(asr_wav))
   >     source_text = " ".join(r["text"].split())
   >     transcript_txt.write_text(source_text, encoding="utf-8")
   >
   >     translated = translate_text(source_text, args.target_lang)
   >     translated_txt.write_text(translated, encoding="utf-8")
   >
   >     tts = TTS(model_name=args.tts_model, gpu=torch.cuda.is_available())
   >     tts.tts_to_file(text=translated, file_path=str(dub_wav))
   >
   >     run([
   >         "ffmpeg", "-y",
   >         "-i", str(in_mp4),
   >         "-i", str(dub_wav),
   >         "-map", "0:v:0",
   >         "-map", "1:a:0",
   >         "-c:v", "copy",
   >         "-c:a", "aac",
   >         "-shortest",
   >         str(tmp_out_mp4),
   >     ])
   >
   >     # IMPORTANT: write locally first, then copy to mounted Object Storage
   >     with tmp_out_mp4.open("rb") as src, out_mp4.open("wb") as dst:
   >         dst.write(src.read())
   >
   >     print(f"Done: {out_mp4}", flush=True)
   >
   > if __name__ == "__main__":
   >     main()
   > ```

   > [accordion] app.py
   >
   > ```python theme={null}
   > from fastapi import FastAPI, HTTPException
   > from fastapi.responses import FileResponse
   > from pathlib import Path
   >
   > app = FastAPI()
   > OUT = Path("/mnt/data/output")
   >
   > @app.get("/health")
   > def health():
   >     return {"ok": True, "output_dir": str(OUT), "exists": OUT.exists()}
   >
   > @app.get("/outputs")
   > def outputs():
   >     if not OUT.exists():
   >         return {"files": []}
   >     return {"files": sorted([p.name for p in OUT.iterdir() if p.is_file()])}
   >
   > @app.get("/download")
   > def download():
   >     f = OUT / "output_video_with_audio.mp4"
   >     if not f.exists():
   >         raise HTTPException(status_code=404, detail="output_video_with_audio.mp4 not found")
   >     return FileResponse(str(f), media_type="video/mp4", filename=f.name)
   > ```

   > [accordion] Dockerfile
   >
   > ```dockerfile theme={null}
   > FROM nvidia/cuda:13.1.2-cudnn-runtime-ubuntu24.04
   >
   > ENV DEBIAN_FRONTEND=noninteractive
   > WORKDIR /app
   >
   > RUN apt-get update && apt-get install -y --no-install-recommends \
   >     software-properties-common curl git ffmpeg libgl1 libglib2.0-0 espeak-ng \
   >     && add-apt-repository ppa:deadsnakes/ppa -y \
   >     && apt-get update && apt-get install -y --no-install-recommends \
   >     python3.11 python3.11-venv python3.11-dev \
   >     && rm -rf /var/lib/apt/lists/*
   >
   > ENV VENV_PATH=/opt/venv
   > RUN python3.11 -m venv $VENV_PATH
   > ENV PATH="$VENV_PATH/bin:$PATH"
   >
   > COPY requirements.txt /app/requirements.txt
   > RUN pip install --upgrade pip setuptools wheel && \
   >     pip install --no-cache-dir -r /app/requirements.txt
   >
   > COPY process_video.py /app/process_video.py
   > COPY app.py /app/app.py
   >
   > EXPOSE 8000
   > CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
   > ```

   To verify that all files are present, run `ls` or `tree`.

5. Make the `process_video.py` file executable:

   ```bash theme={null}
   chmod +x process_video.py
   ```

### Build and push the Docker image

On the VM:

1. [Install Docker](https://docs.docker.com/engine/install/ubuntu/#install-using-the-repository).

2. Install additional packages and prepare Docker for building the image:

   ```bash theme={null}
   sudo apt-get update
   sudo apt-get install -y docker.io git curl wget unzip python3 python3-pip ca-certificates
   sudo usermod -aG docker "$USER"
   newgrp docker
   ```

3. Check that the Docker daemon is running:
   ```bash theme={null}
   docker ps
   ```
   If Docker is running, this command returns a table of containers (can be empty). If you don't see the table and the daemon isn't running, [launch it](https://docs.docker.com/engine/daemon/start/).

4. [Create an account](https://docs.docker.com/accounts/create-account/) in Docker Hub. Use it for authentication when you push your image to a repository.

5. [Create a public repository](https://docs.docker.com/get-started/docker-concepts/the-basics/what-is-a-registry/) in Docker Hub. You will push your Docker image there.

6. In the `~/video-translation-nebius` directory, build the image:

   ```bash theme={null}
   docker build -t <repository>/<image>:video-translation-nebius .
   ```

   In the command, specify your public repository. For example, `myrepository/dubbing:video-translation-nebius`.

   This operation can take several minutes to complete.

7. Authenticate in Docker Hub:
   ```bash theme={null}
   docker login -u <username>
   ```
   Specify your username at Docker Hub and enter your password when prompted.

8. Push the image to the repository:

   ```bash theme={null}
   docker push <repository>/<image>:video-translation-nebius
   ```

   This operation can take several minutes to complete.

### Create a dubbed video

1. Create a fine-tuning job that generates a model for translation and that dubs the video:

   > [tab] Web console
   >
   > 1. In the web console, go to  **Serverless AI** → **Jobs**.
   >
   > 2. Click  **Create job**.
   >
   > 3. On the page that opens, specify the following job parameters:
   >
   >    * **Configuration**: Custom.
   >
   >    * **Image path**: `<repository>/<image>:video-translation-nebius`. Set the image that you've pushed to the Docker repository.
   >
   >    * **Entrypoint command**:
   >
   >      ```bash theme={null}
   >      python3 /app/process_video.py --url https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4 --target-lang de --work-dir /tmp/work --output-dir /mnt/data/output
   >      ```
   >
   >      The `--url` parameter contains a link to the video being processed. The `--target-lang` parameter specifies what language the audio track is translated into.
   >
   >    * **Computing resources** and **Container disk**: Keep the predefined settings.
   >
   >    * **Mounted volumes**: Click **Attach volume** and select the bucket created earlier.
   >
   >    * **Mount path**: `/mnt/data`.
   >
   > 4. Click **Create job**.
   >
   > > [!TIP]
   > >
   > > While the job is running, you can check its logs on the job's page, on the **Logs** tab. The logs show how the model processes the audio and transcribes and translates the text.

   > [tab] CLI
   >
   > Run the following command:
   >
   > ```bash theme={null}
   > nebius ai job create \
   >   --name fine-tune-model \
   >   --image <repository>/<image>:video-translation-nebius \
   >   --container-command python3 \
   >   --args "/app/process_video.py --url https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4 --target-lang de --work-dir /tmp/work --output-dir /mnt/data/output" \
   >   --volume "${BUCKET_ID}:/mnt/data" \
   >   --platform gpu-l40s-a \
   >   --preset 1gpu-8vcpu-32gb \
   >   --disk-size 250Gi \
   >   --subnet-id <subnet_ID>
   > ```
   >
   > In `--args`, the `--url` parameter contains a link to the video being processed. The `--target-lang` parameter specifies what language the audio track is translated into.
   >
   > > [!TIP]
   > >
   > > While the job is running, you can check its logs by using `nebius ai logs <job_ID>`. The logs show how the model processes the audio and transcribes and translates the text.

   > [tab] Go SDK
   >
   > Create the job:
   >
   > ```go theme={null}
   > jobService := sdk.Services().Ai().V1().Job()
   > jobOperation, err := jobService.Create(
   >     ctx,
   >     &ai.CreateJobRequest{
   >         Metadata: &common.ResourceMetadata{
   >             ParentId: "<project_ID>",
   >             Name:     "fine-tune-model",
   >         },
   >         Spec: &ai.JobSpec{
   >             Image:            "<repository>/<image>:video-translation-nebius",
   >             ContainerCommand: "python3",
   >             Args: "/app/process_video.py --url " +
   >                 "https://archive.org/download/" +
   >                 "BigBuckBunny_328/BigBuckBunny_512kb.mp4 " +
   >                 "--target-lang de --work-dir /tmp/work " +
   >                 "--output-dir /mnt/data/output",
   >             Platform: "gpu-l40s-a",
   >             Preset:   "1gpu-8vcpu-32gb",
   >             SubnetId: "<subnet_ID>",
   >             Disk: &ai.JobSpec_DiskSpec{
   >                 Type:      compute.DiskSpec_NETWORK_SSD,
   >                 SizeBytes: 268435456000,
   >             },
   >             Volumes: []*ai.JobSpec_VolumeMount{
   >                 {
   >                     Source:        bucketID,
   >                     ContainerPath: "/mnt/data",
   >                     Mode:
   >                         ai.JobSpec_VolumeMount_READ_WRITE,
   >                 },
   >             },
   >         },
   >     },
   > )
   > if err != nil {
   >     return fmt.Errorf("create job: %w", err)
   > }
   > if _, err = jobOperation.Wait(ctx); err != nil {
   >     return fmt.Errorf("wait for job creation: %w", err)
   > }
   > ```
   >
   > In `Spec.Args`, the `--url` argument links to the source video and `--target-lang` specifies the language of the translated audio track. The code uses the `bucketID` value saved when you created the bucket.

   > [tab] Python SDK
   >
   > Create the job:
   >
   > ```python theme={null}
   > job_service = JobServiceClient(sdk)
   > job_operation = await job_service.create(
   >     CreateJobRequest(
   >         metadata=ResourceMetadata(
   >             parent_id="<project_ID>",
   >             name="fine-tune-model",
   >         ),
   >         spec=JobSpec(
   >             image="<repository>/<image>:video-translation-nebius",
   >             container_command="python3",
   >             args=(
   >                 "/app/process_video.py --url "
   >                 "https://archive.org/download/"
   >                 "BigBuckBunny_328/BigBuckBunny_512kb.mp4 "
   >                 "--target-lang de --work-dir /tmp/work "
   >                 "--output-dir /mnt/data/output"
   >             ),
   >             platform="gpu-l40s-a",
   >             preset="1gpu-8vcpu-32gb",
   >             subnet_id="<subnet_ID>",
   >             disk=JobSpec__DiskSpec(
   >                 type=DiskSpec__DiskType.NETWORK_SSD,
   >                 size_bytes=268435456000,
   >             ),
   >             volumes=[
   >                 JobSpec__VolumeMount(
   >                     source=bucket_id,
   >                     container_path="/mnt/data",
   >                     mode=(
   >                         JobSpec__VolumeMount__Mode.READ_WRITE
   >                     ),
   >                 ),
   >             ],
   >         ),
   >     ),
   > )
   > await job_operation.wait()
   > ```
   >
   > In `spec.args`, the `--url` argument links to the source video and `--target-lang` specifies the language of the translated audio track. The code uses the `bucket_id` value saved when you created the bucket.

   > [tab] JavaScript SDK
   >
   > Create the job:
   >
   > ```ts theme={null}
   > const jobService = new JobService(sdk);
   > const jobOperation = await jobService.create(
   >   CreateJobRequest.create({
   >     metadata: {
   >       parentId: "<project_ID>",
   >       name: "fine-tune-model",
   >     },
   >     spec: {
   >       image: "<repository>/<image>:video-translation-nebius",
   >       containerCommand: "python3",
   >       args: "/app/process_video.py --url " +
   >         "https://archive.org/download/" +
   >         "BigBuckBunny_328/BigBuckBunny_512kb.mp4 " +
   >         "--target-lang de --work-dir /tmp/work " +
   >         "--output-dir /mnt/data/output",
   >       platform: "gpu-l40s-a",
   >       preset: "1gpu-8vcpu-32gb",
   >       subnetId: "<subnet_ID>",
   >       disk: {
   >         type: DiskSpec_DiskType.NETWORK_SSD,
   >         sizeBytes: 268435456000n,
   >       },
   >       volumes: [{
   >         source: bucketId,
   >         containerPath: "/mnt/data",
   >         mode: JobSpec_VolumeMount_Mode.READ_WRITE,
   >       }],
   >     },
   >   }),
   > ).result;
   > await jobOperation.wait();
   > ```
   >
   > In `spec.args`, the `--url` argument links to the source video and `--target-lang` specifies the language of the translated audio track. The code uses the `bucketId` value saved when you created the bucket.

   > [tab] REST API
   >
   > Send the request to create the job:
   >
   > ```bash theme={null}
   > curl --request POST \
   >   --url 'https://api.nebius.cloud/ai/v1/jobs' \
   >   --header "Authorization: Bearer <access_token>" \
   >   --header 'Content-Type: application/json' \
   >   --data '{
   >     "metadata": {
   >       "parentId": "<project_ID>",
   >       "name": "fine-tune-model"
   >     },
   >     "spec": {
   >       "image": "<repository>/<image>:video-translation-nebius",
   >       "containerCommand": "python3",
   >       "args": "/app/process_video.py --url https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4 --target-lang de --work-dir /tmp/work --output-dir /mnt/data/output",
   >       "platform": "gpu-l40s-a",
   >       "preset": "1gpu-8vcpu-32gb",
   >       "subnetId": "<subnet_ID>",
   >       "disk": {
   >         "type": "NETWORK_SSD",
   >         "sizeBytes": "268435456000"
   >       },
   >       "volumes": [
   >         {
   >           "source": "<bucket_ID>",
   >           "containerPath": "/mnt/data",
   >           "mode": "READ_WRITE"
   >         }
   >       ]
   >     }
   >   }'
   > ```
   >
   > In `spec.args`, the `--url` argument links to the source video and `--target-lang` specifies the language of the translated audio track.
   >
   > Replace `<bucket_ID>` with the ID returned when you created the bucket.

   After the job reaches the `Complete` status, the following files are created in the bucket:

   * `output/transcript.txt`: Speech that the model recognized in the video.
   * `output/translated.txt`: Translation of this speech.
   * `output/output_video_with_audio.mp4`: Dubbed video.

   The speech-to-text (STT) quality in this tutorial is not production-level. Accuracy may be low with short sample videos and default model settings. That is expected because the tutorial's purpose is only to showcase the process of STT, video translation, and dubbing. To improve the quality, use stronger STT or translation models, split audio into smaller segments, and add audio post-processing.

2. Download the dubbed video:

   > [tab] Web console
   >
   > 1. Open the bucket's page and go to the `output` directory.
   > 2. In the line of the `output/output_video_with_audio.mp4` object, click  → **Download**.

## How to delete the created resources

Some of the created resources are chargeable. If you don't need them, delete these resources, so Nebius AI Cloud doesn't charge for them:

* [CPU-only VM](https://docs.nebius.com/compute/virtual-machines/delete.md)
* [Boot disk](https://docs.nebius.com/compute/storage/manage.md#how-to-delete-a-volume) attached to the VM
* [Bucket](https://docs.nebius.com/object-storage/buckets/manage.md#how-to-delete-buckets)
