Cutrix Python SDK

The official Python SDK for the Cutrix AI video platform. Translate, dub, and subtitle videos with a few lines of Python code.

Start translating in minutes

Use the Client class to interact with the Cutrix API. This minimal example shows how to submit a local video for translation.

Minimal example

python
from cutrix import Client

with Client(api_key="sk-...") as client:
    result = client.video.translate(
        file_path="./demo.mp4",
        target_lang="zh",
    )
    print(f"Task ID: {result.task_id}")

System requirements

Ensure your development environment meets the following prerequisites.

  • Python 3.9+
  • A Cutrix API key (obtainable from the user dashboard). Go to get →
  • Only videos up to 45 minutes are currently supported.
  • pip (Python package installer)

Install the SDK

Install the official package from PyPI using pip.

Terminal

bash
pip install cutrix-video-translate-sdk

API Key authentication

Authenticate your requests by passing your API key when initializing the client. Get API Key →

Initialization

python
import os
from cutrix import Client

# Option 1: Direct initialization
client = Client(api_key="sk-...")

# Option 2: Using environment variables (Recommended)
client = Client(api_key=os.environ.get("CUTRIX_API_KEY"))

Submit a translation job

The translate() method handles file uploading and task initialization. Submit either a local file_path or a public url (YouTube/TikTok/Bilibili), and customize the task with optional parameters.

!
file_path and url are mutually exclusive (provide exactly one). For file_path tasks, source video duration must not exceed 45 minutes. For URL-based tasks, source video duration must not exceed 15 minutes (900 seconds).

Advanced usage

python
from cutrix import Client

with Client(api_key="sk-...") as client:
    result = client.video.translate(
        # file_path="./demo.mp4",  # choose one: file_path or url
        url="https://www.youtube.com/watch?v=example",
        target_lang="zh",
        source_lang="en",
        task_name="Campaign Video V1",
        add_subtitle=True,
        erase_original_subtitle=False,
        remove_cutrix_logo=True,
        remove_background_audio=False
    )

    print(f"Task created: {result.task_id}")
    print(f"Estimated duration: {result.video_duration_seconds}s")

translate() parameters

ParameterTypeRequiredDescription
file_pathstrConditionalPath to your local video file. Mutually exclusive with url. Source duration must be <= 45 minutes.
urlstrConditionalPublic video URL (YouTube/TikTok/Bilibili). Mutually exclusive with file_path. URL source must be <= 15 minutes.
target_langstrYesTarget language code (BCP-47).
source_langstrNoDefaults to "auto" detection.
task_namestrNoLabel for internal tracking.
add_subtitleboolNoWhether to add subtitles (Default: True).
erase_original_subtitleboolNoErase hard-coded source subtitles in the original video (Default: False).
remove_cutrix_logoboolNoRemove platform branding (Default: True).
remove_background_audioboolNoRemove original background audio from the source video (Default: False).

Supported languages

Check the lists below for all supported source and target language codes.

Source languages

CodeLanguage
autoAuto-detect
zhChinese (Mandarin)
enEnglish
yueCantonese
arArabic
csCzech
daDanish
deGerman
elGreek
esSpanish
faPersian
fiFinnish
filFilipino
frFrench
hiHindi
huHungarian
idIndonesian
itItalian
jaJapanese
koKorean
mkMacedonian
msMalay
nlDutch
plPolish
ptPortuguese
roRomanian
ruRussian
svSwedish
thThai
trTurkish
viVietnamese

Target languages

CodeLanguage
zhChinese (Mandarin)
enEnglish
arArabic
daDanish
deGerman
elGreek
esSpanish
fiFinnish
frFrench
heHebrew
hiHindi
idIndonesian
itItalian
jaJapanese
koKorean
msMalay
nlDutch
noNorwegian
plPolish
ptPortuguese
roRomanian
ruRussian
svSwedish
swSwahili
thThai
trTurkish
viVietnamese

Monitor task status

Since video processing is asynchronous, you must poll the get_task() method to determine when the processing is complete.

Polling implementation

python
import time
from cutrix import Client

with Client(api_key="sk-...") as client:
    result = client.video.translate(file_path="./demo.mp4", target_lang="zh")
    
    while True:
        task = client.video.get_task(task_id=result.task_id)
        print(f"Current Status: {task.status}")

        if task.status == "succeed":
            print(f"Download URL: {task.output_video_path}")
            break
        elif task.status == "failed":
            print(f"Error: {task.failed_message}")
            break
            
        time.sleep(30) # Poll every 30 seconds

get_task() parameters

ParameterTypeRequiredDescription
task_idint | strYesUnique identifier returned by translate().

Task status codes

statusDescription
pendingTask is queued, waiting to be picked up
startedProcessing is in progress
downloadingSource media is being downloaded and prepared
succeedTranslation finished successfully. output_video_path is available
failedTask failed. Check failed_code for the reason

get_task() response fields

FieldTypeDescription
okboolWhether the request is successful
id / task_idintTask identifier
statusstr | NoneCurrent status
typestr | NoneTask type, such as one_click
urlstr | NoneOriginal source URL when created from url
output_video_pathstrDownload URL of the translated video when successful
input_video_pathstrURL of the original uploaded video
input_video_jpgstr | NonePreview image URL for the source video
srt_filestr | NoneDownload URL of translated subtitle file (.srt)
source_langstr | NoneDetected or explicitly specified source language
target_langstr | NoneTarget language
input_video_durationfloat | NoneSource video length in seconds
namestr | NoneTask label
remove_background_audiobool | NoneWhether background audio removal is enabled for this task
failed_codeint | str | NoneError code when status is failed
failed_messagestr | NoneSDK-provided human-readable message for known failure codes
created_atdatetime | NoneTask creation time in UTC
estimate_finish_timedatetime | NoneEstimated completion time in UTC
finished_atdatetime | NoneActual completion time in UTC

Failure error codes

CodeReason
2001Automatic language detection failed. Please select the source language manually and try again.
2002No audio was detected. Please make sure the video contains an audio track.
2003No video was detected. Please make sure the file contains video content.
2004Unknown error. Please try again later or contact support.
2005The source and target languages are the same, so translation is not needed.

Exception handling

Handle API and SDK exceptions to ensure your integration is robust.

Error handling

python
from cutrix import Client, AuthenticationError, RateLimitError
from cutrix.exceptions import APIError, SDKError

try:
    with Client(api_key="sk-...") as client:
        # API calls...
        pass
except AuthenticationError:
    print("Invalid API Key.")
except RateLimitError:
    print("Request limit exceeded.")
except APIError as e:
    print(f"API Exception: {e.message} (Status: {e.status_code})")
except SDKError as e:
    print(f"Local SDK Error: {e}")

Need technical assistance?

Our team is available to help with enterprise integrations, custom workflows, or high-volume API usage requirements.

Email Support