Create a model fine-tuning training job for video generation. Datasets can be uploaded via API or mounted from OSS.
Prerequisites
- Supported regions: The features described in this topic are only available in the Singapore region, and you must use an API Key from this region.
- Account permissions: If you use an Alibaba Cloud sub-account (RAM user), you need to grant the sub-account permissions for model invocation, training, and deployment.
- Configure environment variables: You have successfully obtained an API Key and configured it as an environment variable.
- Preparation: You have read Fine-tuning video generation models to understand the supported models for fine-tuning, fine-tuning steps, data formats, and billing.
Create a fine-tuning job
- Singapore
POST https://dashscope-intl.aliyuncs.com/api/v1/fine-tunesFor Windows CMD, replace$DASHSCOPE_API_KEYwith%DASHSCOPE_API_KEY%. For PowerShell, replace with$env:DASHSCOPE_API_KEY
Request ParametersHeadersContent-Typestring (Required)Fixed value: application/jsonAuthorization string (Required)API Key authentication, format: Bearer sk-xxxx.Request Bodymodelstring (Required)Specifies the base model for fine-tuning.Image-to-video based on first frame:
array[string] (Conditionally required)Training dataset file ID array, supports multiple IDs. Use either this or training_datasets . If using training_datasets, this parameter is not needed. File IDs are obtained from the Upload File API.validation_file_ids array[string] (Optional)Validation dataset file ID array, supports multiple IDs. Use either this or validation_datasets . If using validation_datasets, this parameter is not needed. If neither is provided, the system will automatically split from the training set. File IDs are obtained from the Upload File API.training_type string (Required)Fine-tuning type. Currently only supports efficient_sft (LoRA efficient fine-tuning).hyper_parameters object (Optional)Hyperparameter configuration. For initial training, it is recommended to use the default hyperparameters. If the model performance is poor or training does not converge, you can try adjusting parameters such as n_epochs or learning_rate.
Hyperparameter properties batch_size int (Required)Batch size. The number of data samples sent to the model for training at once.This parameter is a per-instance configuration. We recommend using the default value for each model. Do not adjust unless necessary.
The actual number of instances running for a training job is determined by platform scheduling. The Global Step output in training logs may differ from estimated results, but this does not change the total amount of training data or affect the final model performance. int (Required)Number of training epochs. Recommended value: 50.steps = n_epochs × ⌈dataset_size / batch_size⌉. It is recommended that total steps >= 800.Example: With 5 data samples and batch_size=4, steps per epoch = ceil(5/4) = 2, minimum n_epochs = 800/2 = 400.
float (Required)Learning rate. Recommended value: 2e-5. Controls the magnitude of model weight updates. Too high may degrade the model, too low may result in minimal changes.eval_epochs int (Required)Validation interval. Recommended value: 20. Must be >= n_epochs/10. Specifies how many epochs between each validation evaluation during training.max_pixels int (Required)Maximum resolution for training videos. Sets the total pixel count (width x height) limit for training video resolution. The system only scales videos that exceed this value.
float (Optional)Training set split ratio. Recommended value: 0.9. Value range: (0, 1).Only effective when validation_file_ids. This parameter automatically splits a validation set from the training set proportionally. For example, 0.9 means 90% training set and 10% validation set.max_split_val_dataset_sample int (Optional)Maximum number of samples to automatically split from the training set as validation set. Recommended value: 5. Must be >= 1.Only effective when validation_file_ids is not specified. This parameter sets an upper limit for the validation set size: validation_count = min(total_dataset × (1 - split), max_split_val_dataset_sample)save_total_limit int (Optional)Checkpoint save limit. Recommended value: 10. Limits the maximum number of models saved; the system will only keep the last N checkpoints.lora_rank int (Optional)LoRA low-rank matrix dimension. Recommended value: 32. This value determines the size of fine-tuning parameters; larger values provide stronger fitting capability but slower training speed. Must be a power of 2n (e.g., 16, 32, 64).lora_alpha int (Optional)LoRA weight scaling factor. Recommended value: 32. Used to adjust the influence of fine-tuned parameters on the original model weights. Must be a power of 2n (e.g., 16, 32, 64).Array of Dataset (Conditionally required)Training dataset file list. Use either this or training_file_ids. If using training_file_ids, this parameter is not needed.
Dataset structure data_source_type string (Required)Data source type. Available values:
object (Conditionally required)Required when data source type is oss_mount. OSS mount information.
Properties region string (Required)The region of the OSS Bucket to mount. Supports Beijing (cn-beijing) and Singapore (ap-southeast-1).bucket string (Required)The name of the OSS Bucket to mount.file_path string (Required)The OSS file path (object key) to mount. For datasets containing multiple files, use the path to data.jsonl. Unlike the file_id method, you need to upload the uncompressed dataset folder to OSS. Zip files are not supported.string (Conditionally required)Required when data source type is file_id. File ID, generated by the Upload File API.Array of Dataset (Optional)Validation dataset file list. Same structure as training_datasets.Use either this or validation_file_ids. If neither is provided, the system will automatically split from the training set.job_name string (Optional)Tuning job name.model_name string (Optional)Model name after tuning is complete. |
Response Parametersrequest_idstringUnique identifier for the request.output objectJob details.
Properties job_id stringUnique identifier for the fine-tuning job, used to query job details, logs, cancel, or delete the job. Generation rule: ft-{yyyyMMddHHmm}-{4 char uuid}.job_name stringFine-tuning job name.status stringStatus of the fine-tuning job:
stringThe new model ID produced after fine-tuning, needed for deployment and invocation. Returned when job status is SUCCEEDED.model stringThe base model used.base_model stringThe base model used.training_file_ids arrayLegacy field for backward compatibility, always returns an empty array for new jobs. Please use training_datasets.training_datasets Array of DatasetTraining dataset list.validation_file_ids arrayLegacy field for backward compatibility, always returns an empty array for new jobs. Please use validation_datasets.validation_datasets Array of DatasetValidation dataset list. Empty array if no validation set is specified.hyper_parameters objectActual hyperparameters used.training_type stringThe training method for model fine-tuning.create_time stringJob creation time.end_time stringJob end time. Returned when job status is SUCCEEDED, FAILED, or CANCELED.usage integerToken consumption of the fine-tuning job. Returned when job status is SUCCEEDED or CANCELED.workspace_id stringThe workspace ID associated with the Alibaba Cloud Model Studio API Key. See Get the Workspace ID.user_identity stringUser identity, Alibaba Cloud account ID.creator stringCreator's Alibaba Cloud account ID.modifier stringModifier's Alibaba Cloud account ID.group stringFine-tuning job group.max_output_cnt integerMaximum number of checkpoints saved during training. Equivalent to the save_total_limit hyperparameter value.stringError code. Returned when the call fails. Refer to the error code table below.message stringDetailed error description. Returned when the call fails. |
Key fields: output.job_id (Job ID), output.finetuned_output (New model name produced after fine-tuning). |
Error Codes
If the call fails and returns an error message, refer to the table below for troubleshooting.
HTTP Status Code | Error Codes | Solution |
|---|---|---|
400 | InvalidParameter | Parameter error: missing parameters or parameter format issues. Correct your parameters based on the error message. |
400 | UnsupportedOperation | The resource cannot be operated on when it is in a specific state. Wait until the resource reaches an operable state before performing the operation. |
404 | NotFound | The resource to query/operate does not exist. Check if the resource ID is incorrect. |
409 | Conflict | A deployment instance with the same name already exists. Specify a suffix to differentiate. |
429 | Throttling | Resource creation triggered platform limits. Delete models that are no longer in use. |
500 | InternalError | Internal error. Record the request_id and contact Alibaba Cloud engineers via a ticket for troubleshooting. |