Fine-tune with the API or CLI

Updated at:

Learn how to tune Qwen models in Alibaba Cloud Model Studio using the API (HTTP) and the command line (shell). Model tuning involves three methods: supervised fine-tuning (SFT), continual pre-training (CPT), and direct preference optimization (DPO).

ImportantThis topic is applicable only to the China (Beijing) region.

Prerequisites

NoteThe API supports only token-based billing for training jobs. To use model training units (prepaid or postpaid), create the job in the console.

Tuning file upload

Preparing fine-tuning files

SFT training set

SFT ChatML (Chat Markup Language) format training data supports multi-turn conversations and various role settings.

The OpenAI name and weight parameters are not supported. All assistant outputs will be trained.

# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
  {"role": "system", "content": "System input 1"},
  {"role": "user", "content": "User input 1"},
  {"role": "assistant", "content": "Expected model output 1"},
  {"role": "user", "content": "User input 2"},
  {"role": "assistant", "content": "Expected model output 2"}
  ...
]}

For information about the differences between system, user, and assistant, see Overview. Sample training datasets: SFT-ChatML_format_example.jsonl, SFT-ChatML_format_example.xlsx. XLS and XLSX formats support only single-turn conversations.

All assistant lines in a single training data entry support the "loss_weight" parameter, which sets the relative importance of that line during training. (Range: 0.0 to 1.0. A larger value indicates higher importance.)

This parameter is available for invitational preview. To use it, contact your account manager.

 {"role": "assistant", "content": "Expected model output 1", "loss_weight": 1.0},
 {"role": "assistant", "content": "Expected model output 2", "loss_weight": 0.5}

SFT thinking model

The training data supports multi-turn conversations and various role settings, but only the last assistant output can be trained. A single line of training data has the following structure when expanded:

The newline characters \n before and after the think tag must be preserved.

# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
  {"role": "system", "content": "System input 1"},
  {"role": "user", "content": "User input 1"},
  {"role": "assistant", "content": "Model output 1"}, --Intermediate assistant outputs should not have <think> tags
   ...
  {"role": "user", "content": "User input 2"},
  {"role": "assistant", "content": "<think>\nExpected thinking content 2\n</think>\n\nExpected output 2"} --Thinking content can only be included in the last assistant output.
]}

For information about the differences between system, user, and assistant, see Overview. Sample training dataset: SFT-deep_thinking_content_example.jsonl.

You can also set the model not to output the <think> tag in the training samples. If you use this output method, it is not recommended to enable the thinking mode for calls after the model is trained.

{"role": "assistant", "content": "Expected model output 2"}  --Tells the model not to enable thinking

The last assistant line of a single training data entry supports the "loss_weight" parameter, which sets the relative importance of that entry during training. (Range: 0.0 to 1.0. A larger value indicates higher importance.)

This parameter is available for invitational preview. To use it, contact your account manager.

 {"role": "assistant", "content": "<think>\nExpected thinking content 2\n</think>\n\nExpected output 2", "loss_weight": 1.0}

SFT visual understanding (Qwen-VL)

The OpenAI name and weight parameters are not supported. All assistant outputs will be trained.

For information about the differences between system, user, and assistant, see Overview. Sample ChatML format training data:

To pass a system message, the corresponding content must use the array format [{"text":"..."}] and not the string format "content":"string".

NoteIf you are training a thinking model, you must also follow the data format requirements for the SFT thinking model.

# A single line of training data (in JSON format) has the following structure when expanded:
{"messages": [
  {"role": "system", "content": [{"text": "System input"}]},
  {"role": "user", "content": [{"text": "User input 1"}, {"image": "image_file_name1.jpg", "resized_width": 200, "resized_height": 200}]},
  {"role": "assistant", "content": [{"text": "Expected model output 1"}]},
  {"role": "user", "content": [{"text": "User input 2"}, {"video": "video_file_name1.mp4", "fps": 3.0, "resized_width": 200, "resized_height": 200, "video_start": 0.0, "video_end": 3.0}]},
  {"role": "assistant", "content": [{"text": "Expected model output 2"}]},
  {"role": "user", "content": [{"text": "User input 2"}, {"video": ["0.jpg", "1.jpg", "2.jpg", "3.jpg"], "sample_fps": 5.0, "resized_width": 200, "resized_height": 200}]},
  {"role": "assistant", "content": [{"text": "Expected model output 2"}]},
  ...
]}

Click here to see more supported parameters

Field

Type

Required

Description

Image file

image

str

Yes

Image file path

resized_width

int

No

Target image scaling width (pixels)

resized_height

int

No

Target image scaling height (pixels)

Video file - Video file path mode (supported only by qwen3.5 and later VL models)

Sample:AlibabaCloud_VL_Video.zip

video

str

Yes

Video file path mode: {"video": "video_file_name1.mp4"}

resized_width

int

No

Target video scaling width (pixels)

resized_height

int

No

Target video scaling height (pixels)

fps

float

No

Input frequency during training. If you set fps=30, the actual frame rate used for training is 30 fps.

video_start

float

No

Video clip start time (seconds)

video_end

float

No

Video clip end time (seconds)

Video file - Image frame list mode (supported only by qwen3.5 and later VL models)

video

List[str]

Yes

Image frame list mode: {"video": ["0.jpg", "1.jpg", "2.jpg", ...], "sample_fps": 2.0}

sample_fps

float

No

Used to inform the frame rate of the image frames.

resized_width

int

No

Image frame scaling width (pixels)

resized_height

int

No

Image frame scaling height (pixels)

Suggestions for training object localization:
  • Qwen2.5-VL: The training coordinates are absolute values relative to the top-left corner of the scaled image, in pixels.
  • Qwen3-VL: The training coordinates are relative, and the coordinate values are scaled to the range of [0, 999].
ZIP file requirements:
  1. Format: ZIP. The maximum size is 2 GB. Folders and file names within the ZIP file must only contain ASCII characters, including letters (a-z, A-Z), numbers (0-9), underscores (_), and hyphens (-).

  2. The training text file must be named data.jsonl and located in the root directory of the ZIP file. Ensure that thedata.jsonlfile is at the top level of the ZIP file and not in a subfolder.

  3. The width and height of a single image must not exceed 1024 pixels, and the size must not exceed 10 MB. The supported formats are .bmp, .jpeg /.jpg, .png, .tif /.tiff, and .webp.

  4. Image file names must be unique, even if they are in different folders.

  5. ZIP file directory structure:

    Multi-level directory

    1. The data.jsonl file must be in the root directory of the ZIP file.

    2. In the data.jsonl file, you only need to specify the image or video filename, not the file path. For example:

      Correct example: image1.jpg. Incorrect example: jpg_folder/image1.jpg.

    3. Image/video file names must be globally unique within the ZIP file.

    Trainingdata_vl.zip
        |--- data.jsonl #Note: Do not wrap in an outer folder
        |--- jpg_folder
        |   └── image1.jpg
        |--- mp4_folder
            └── video.mp4
    

DPO dataset

DPO ChatML format training data. A single line of training data has the following structure when expanded:

For information about the differences between system, user, and assistant, see Overview. Sample training dataset: DPO_ChatML_format_example.jsonl.

# A single line of training data (in JSON format) has the following typical structure when expanded:
{"messages": [
  {"role": "system", "content": "System input"},
  {"role": "user", "content": "User input 1"},
  {"role": "assistant", "content": "Model output 1"},
  {"role": "user", "content": "User input 2"},
  {"role": "assistant", "content": "Model output 2"},
  {"role": "user", "content": "User input 3"}
 ],
 "chosen":
   {"role": "assistant", "content": "Agreed-upon expected model output 3"},
 "rejected":
   {"role": "assistant", "content": "Rejected expected model output 3"}}

The model takes all content within messages as input. DPO is used to train the model on positive and negative feedback for User input 3.

For deep thinking content, you need to wrap it with <think> tags:

{"role": "assistant", "content": "<think>Expected model thinking content</think>Expected model output"}

The "chosen" module of a single training data entry supports the "loss_weight" parameter, which sets the relative importance of that training data in the training process. (Range: 0.0 to 1.0. A larger value indicates higher importance.)

This parameter is available for invitational preview. To use it, contact your account manager.

 "chosen":
   {"role": "assistant", "content": "Agreed-upon expected model output 3", "loss_weight": 1.0},

CPT training set

CPT plain text format training data. A single line of training data has the following structure when expanded:

{"text":"Text content"}

Sample training dataset: CPT-text_generation_training_set_example.jsonl

You can also download a data template from the Model Studio console.

image

Upload fine-tuning fileto Model Studio

DashScope API

For Windows CMD, replace ${DASHSCOPE_API_KEY} with %DASHSCOPE_API_KEY%. For PowerShell, replace it with $env:DASHSCOPE_API_KEY.

curl --request POST \
'https://dashscope.aliyuncs.com/api/v1/files' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--form 'files=@"/path/to/your/file.jsonl"' \
--form 'purpose="fine-tune"' \
--form 'descriptions="a sample fine-tune data file for qwen"'

NoteLimitations:

  • The maximum size of a single file is 300 MB.
  • The total size of all non-deleted files is limited to 5 GB.
  • You can store a maximum of 100 non-deleted files.
  • Files are stored indefinitely.

For more details, see model fine-tuning file management service.

Sample response:

{
  "request_id":"xx",
  "data":{
    "uploaded_files":[{
      "file_id":"976bd01a-f30b-4414-86fd-50c54486e3ef",
      "name":"qwen-fine-tune-sample.jsonl"}],
   "failed_uploads":[]}
 }

Model fine-tuning

Create a fine-tuning job

HTTP

For Windows CMD, replace ${DASHSCOPE_API_KEY} with %DASHSCOPE_API_KEY%. For PowerShell, use $env:DASHSCOPE_API_KEY.

curl --location "https://dashscope.aliyuncs.com/api/v1/fine-tunes" \
--header "Authorization: Bearer ${DASHSCOPE_API_KEY}" \
--header 'Content-Type: application/json' \
--data '{
    "model":"qwen3-8b",
    "training_file_ids":[
        "<your_training_file_id_1>",
        "<your_training_file_id_2>"
    ],
    "hyper_parameters":
    {
        "n_epochs": 3,
        "batch_size": 16,
        "max_length": 8192,
        "learning_rate": "1.6e-5",
        "lr_scheduler_type": "linear",
        "split": 0.9,
        "warmup_ratio": 0.05,
        "eval_steps": 50,
        "data_augmentation": true,
        "augmentation_ratio": "0.1,0.05,0.15",
        "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
        "save_strategy": "epoch",
        "save_total_limit": 10
    },
    "training_type":"sft"
}'

Parameters

Parameter

Required

Type

Location

Description

training_file_ids

Yes

Array

Body

A list of file IDs for the training set.

validation_file_ids

No

Array

Body

A list of file IDs for the validation set.

model

Yes

String

Body

The ID of the base model for fine-tuning, or the ID of a previously fine-tuned model.

hyper_parameters

No

Map

Body

Hyperparameters for the fine-tuning job. Supported parameters and their default values vary by model. To view the default values, go to the console and select the same model and fine-tuning method.

The following parameters are required because they affect the training cost: n_epochs (number of epochs), batch_size (batch size), and max_length (sequence length).

training_type

No

String

Body

Specifies the fine-tuning method. Valid values are:

cpt

sft

efficient_sft

dpo_full

dpo_lora

rl (reinforcement learning, see Reinforcement learning)

job_name

No

String

Body

Specifies the name of the fine-tuning job.

model_name

No

String

Body

Specifies the name of the fine-tuned model. This is not the model ID, which is generated by the system.

Response

{
    "request_id": "635f7047-003e-4be3-b1db-6f98e239f57b",
    "output":
    {
        "job_id": "ft-202511272033-8ae7",
        "job_name": "ft-202511272033-8ae7",
        "status": "PENDING",
        "finetuned_output": "qwen3-8b-ft-202511272033-8ae7",
        "model": "qwen3-8b",
        "base_model": "qwen3-8b",
        "training_file_ids":
        [
            "9e9ffdfa-c3bf-436e-9613-6f053c66aa6e"
        ],
        "validation_file_ids":
        [],
        "hyper_parameters":
        {
            "n_epochs": 3,
            "batch_size": 16,
            "max_length": 8192,
            "learning_rate": "1.6e-5",
            "lr_scheduler_type": "linear",
            "split": 0.9,
            "warmup_ratio": 0.05,
            "eval_steps": 50,
            "data_augmentation": true,
            "augmentation_ratio": "0.1,0.05,0.15",
            "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
            "save_strategy": "epoch",
            "save_total_limit": 10
        },
        "training_type": "sft",
        "create_time": "2025-11-27 20:33:15",
        "workspace_id": "llm-8v53etv3hwb8orx1",
        "user_identity": "1654290265984853",
        "modifier": "1654290265984853",
        "creator": "1654290265984853",
        "group": "llm",
        "max_output_cnt": 10
    }
}

Base models ( model ) and training types ( training_type )

Supported models

Text generation

Model service

Model code

CPT full-parameter training

SFT full-parameter training

SFT efficient training

DPO full-parameter training

DPO efficient training

Qwen3.8-27B

qwen3.8-27b

×

×

×

Qwen3.7-Plus-2026-05-26

qwen3.7-plus-2026-05-26

×

×

×

×

Qwen3.6-27B

qwen3.6-27b

×

×

×

Qwen3.6-Flash-2026-04-16

qwen3.6-flash-2026-04-16

×

×

×

×

Qwen3.6-Plus-2026-04-02

qwen3.6-plus-2026-04-02

×

×

×

×

Qwen3.5-27B

qwen3.5-27b

×

×

×

Qwen3.5-9B

qwen3.5-9b

×

×

×

Qwen3.5-4B

qwen3.5-4b

×

×

×

Qwen3.5-Flash-2026-02-23

qwen3.5-flash-2026-02-23

×

×

×

×

Qwen3.5-Plus-2026-02-15

qwen3.5-plus-2026-02-15

×

×

×

×

Qwen3-32B

qwen3-32b

Qwen3-30B-A3B-Instruct-2507

qwen3-30b-a3b-instruct-2507

×

×

Qwen3-14B

qwen3-14b

×

Qwen3-8B

qwen3-8b

×

Qwen3-4B-Instruct-2507

qwen3-4b-instruct-2507

Qwen3-1.7B

qwen3-1.7b

Qwen3-0.6B

qwen3-0.6b

Qwen2.5-72B-Instruct

qwen2.5-72b-instruct

Qwen2.5-32B-Instruct

qwen2.5-32b-instruct

Qwen2.5-14B-Instruct

qwen2.5-14b-instruct

Qwen2.5-7B-Instruct

qwen2.5-7b-instruct

Qwen-Plus-Character-2025-11-06

qwen-plus-character-2025-11-06

×

Visual understanding (Qwen-VL)

Model service

Model code

CPT full-parameter training

SFT full-parameter training

SFT efficient training

DPO full-parameter training

DPO efficient training

Qwen3-VL-8B-Instruct

qwen3-vl-8b-instruct

×

×

×

Qwen3-VL-8B-Thinking

qwen3-vl-8b-thinking

×

×

×

Qwen3-VL-4B-Instruct

qwen3-vl-4b-instruct

×

×

×

Qwen2.5-VL-72B-Instruct

qwen2.5-vl-72b-instruct

×

×

×

Qwen2.5-VL-32B-Instruct

qwen2.5-vl-32b-instruct

×

×

×

Qwen2.5-VL-7B-Instruct

qwen2.5-vl-7b-instruct

×

×

×

Comparison of tuning methods

Feature

CPT (Continual Pre-training)

SFT (Supervised Fine-tuning)

DPO (Direct Preference Optimization)

Summary

Supplements knowledge (Injects domain knowledge)

Learns to perform tasks (Follows instructions)

Performs tasks better (Aligns with human preferences)

Input data

10 million+ tokens

Unlabeled domain text

Over 1,000 entries

High-quality "question-answer" pairs

100+ sets

"Better-worse" response pairs for the same instruction

Core objective

Domain adaptation. Learns specialized vocabulary and facts.

Teaches the model conversation formats and task execution capabilities.

Makes model outputs better align with human values and preferences.

Learning method

Self-supervised learning (Predicts the next word)

Supervised learning (Imitates the ground truth)

Direct preference learning (Increases the probability of good responses and decreases the probability of bad responses)

Model stage

Typically before SFT

After CPT and before DPO

Typically after SFT, as the final step for alignment.

Comparison of training patterns

Full-parameter training

Efficient training (LoRA, recommended)

Scenarios

• The model needs to acquire new capabilities

• Achieving optimal global performance.

• Optimizing model performance for specific scenarios.

• For cost-sensitive and time-sensitive scenarios.

Training time

Longer, with slower convergence.

Shorter, with faster convergence.

hyper_parameters : Supported settings

Supported parameters and their default values vary by model. To view specific default values, go to theconsoleand select the model and training method.

ParameterRecommended setting

Type

Description

n_epochs

(Number of epochs) [Required]

Data size < 10,000: 3–5Data size > 10,000: 1–2

Integer

The number of times the model iterates over the entire training set. Adjust this value based on your fine-tuning experience.

More epochs increase training time and cost.

learning_rate

(Learning rate)

Use the recommended default value provided by Model Studio.

Float

Controls the step-size for weight updates during training.

  • A high learning rate can cause training to diverge, yielding poor results.
  • A low learning rate can result in slow training and minimal performance improvement.

freeze_vit

(Freeze visual backbone)

Adjust as needed

Boolean

Whether to freeze the visual backbone parameters, which prevents their weights from being updated during training. This parameter applies only to Qwen-VL (visual understanding) models.

WarningToken-based billing is available only when freeze_vit is set to “true”.

batch_size

(Batch size) [Required]

Use the recommended default value provided by Model Studio.

Integer

Specifies the number of training examples processed in one iteration. A small value can significantly increase training time. Default values vary by model; check the console for details.

eval_steps

(Evaluation steps)

Adjust as needed

Integer

The step interval for evaluating the model's training accuracy and loss.

This parameter affects how often Validation Loss and Validation Token Accuracy are displayed during fine-tuning.

logging_steps

(Logging steps)

Adjust as needed

Integer

The step interval for logging fine-tuning progress.

lr_scheduler_type

(Learning rate scheduler)

Recommended linear/Inverse_sqrt

String

The strategy for dynamically adjusting the learning rate during training.

For details about each strategy, see Fine-tune a model in the console.

max_length

(Sequence length) [Required]

8192

Integer

The maximum sequence length (in tokens) for a single training example. Examples that exceed this length are discarded.

For the relationship between characters and tokens, see How to convert between tokens and characters.

max_split_val_dataset_sample

(Max validation set samples)

Use the recommended default value provided by Model Studio.

Integer

When "validation_file_ids" is not set, the validation set that is automatically split by Model Studio contains a maximum of 1,000 entries.

This parameter has no effect when "validation_file_ids" is set.

split

(Training set ratio)

Use the recommended default value provided by Model Studio.

Float

If you do not set "validation_file_ids", Alibaba Cloud Model Studio automatically uses 80% of the training file as the training set and 20% as the validation set.

When "validation_file_ids" is set, this parameter has no effect.

warmup_ratio

(Warm-up ratio)

Use the recommended default value provided by Model Studio.

Float

The proportion of the total training process used for learning rate warm-up. During warm-up, the learning rate linearly increases from a small initial value to the specified learning rate.

This parameter helps stabilize training by limiting large parameter changes at the beginning.

A ratio that is too high has an effect similar to a low learning rate, causing minimal performance changes.

A ratio that is too low has an effect similar to a high learning rate and may degrade model performance.

This parameter has no effect if the learning rate scheduler is set to constant.

weight_decay

(Weight decay)

Use the recommended default value provided by Model Studio.

Float

The strength of L2 regularization. Regularization helps maintain the model's generalization ability. An excessively high value can reduce fine-tuning effectiveness.

Parameters for efficient fine-tuning (supportsefficient_sft and dpo_lora)

NoteWhen you perform a second round of efficient fine-tuning on a model that has already been efficiently fine-tuned, the lora_rank, lora_alpha, and lora_dropout parameters must remain consistent.

lora_rank

(LoRA rank)

64

Integer

The rank of the low-rank matrices in LoRA. A higher rank can improve fine-tuning results but may slightly increase training time.

lora_alpha

(LoRA alpha)

Use the recommended default value provided by Model Studio.

Integer

The scaling factor that controls the combination of original model weights and the LoRA low-rank correction term.

A larger alpha gives more weight to the LoRA correction, making the model rely more on task-specific information.

A smaller alpha makes the model retain more knowledge from the base model.

lora_dropout

(LoRA dropout)

Use the recommended default value provided by Model Studio.

Float

The dropout rate for the values in the low-rank matrices during LoRA training.

Using the recommended value enhances the model's generalization capabilities.

An overly large value can diminish the fine-tuning effect.

Parameters for mixed training (supportsefficient_sft and sft)

data_augmentation

(Enable mixed training)

Mix based on the model's use case.

Boolean

If enabled, Model Studio mixes your training data with its general-purpose datasets. This improves training performance and helps prevent catastrophic forgetting. The mixed-in data is included in the total training token count and billed at the standard rate.

augmentation_types

(Preset data types)

Mix based on the model's use case.

Example: "augmentation_types": "dialogue_CN,general_purpose_CN,NLP"

Must be used in conjunction with augmentation_ratio.

String

Dataset code

Dataset name

Supported models

dialogue_cn

Chinese-Dialogue

Qwen2 series

math_cn

Chinese-Math

general_coding_cn

Chinese-Code

general_purpose_cn

Chinese-General

nlp

NLP-Understanding

dialogue_en

English-Dialogue

math_en

English-Math

general_coding_en

English-Code

general_purpose_en

English-General

mix_v2

General-V2

Qwen 3 series

vl_mix

General

Qwen 3 VL series

augmentation_ratio

(Mixing ratio)

Mix based on the model's use case.

String

  • The format must be a one-to-one match with augmentation_types.
  • Example: "0.1,0.05,0.15" (The values correspond to the three datasets listed in augmentation_types, respectively.)
  • Description: Randomly samples and mixes 10%/5%/15% of the training data.
  • Range: 0.0 ~ 2.0

Parameters for publishing model parameter snapshots (forefficient_sft and sftonly)

save_strategy

(Snapshot save strategy)

It can be set to epoch or steps.

  • When set to steps, you can adjust the save interval by setting the save_steps parameter.

String

The strategy for saving model parameter snapshots (checkpoints). Valid options are epoch (save after each epoch) and steps (save at a specified step interval).

save_steps

(Save steps)

If you need to modify it manually, set it to an integer multiple of the eval_steps parameter.

Integer

The interval, in training steps, between each model parameter snapshot save.

save_total_limit

(Snapshot save limit)

10

Integer

The maximum number of model parameter snapshots to retain. Once the limit is reached, older snapshots are automatically deleted.

Retrieve a fine-tuning job

To retrieve the details of a fine-tuning job, use the job_id returned when you create the job.

HTTP

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Request parameters

Parameter

Type

Location

Required

Description

job_id

String

Path

Yes

The ID of the fine-tuning job.

Successful response

{
    "request_id": "d100cddb-ac85-4c82-bd5c-9b5421c5e94d",
    "output":
    {
        "job_id": "ft-202511272033-8ae7",
        "job_name": "ft-202511272033-8ae7",
        "status": "RUNNING",
        "finetuned_output": "qwen3-8b-ft-202511272033-8ae7",
        "model": "qwen3-8b",
        "base_model": "qwen3-8b",
        "training_file_ids":
        [
            "9e9ffdfa-c3bf-436e-9613-6f053c66aa6e"
        ],
        "validation_file_ids":
        [],
        "hyper_parameters":
        {
            "n_epochs": 3,
            "batch_size": 16,
            "max_length": 8192,
            "learning_rate": "1.6e-5",
            "lr_scheduler_type": "linear",
            "split": 0.9,
            "warmup_ratio": 0.05,
            "eval_steps": 50,
            "data_augmentation": true,
            "augmentation_ratio": "0.1,0.05,0.15",
            "augmentation_types": "dialogue_CN,general_purpose_CN,NLP",
            "save_strategy": "epoch",
            "save_total_limit": 10
        },
        "training_type": "sft",
        "create_time": "2025-11-27 20:33:15",
        "workspace_id": "llm-8v53etv3hwb8orx1",
        "user_identity": "1654290265984853",
        "modifier": "1654290265984853",
        "creator": "1654290265984853",
        "group": "llm",
        "max_output_cnt": 10
    }
}

Job status

Description

PENDING

The job is waiting to start.

QUEUING

The job is queued. Only one fine-tuning job runs at a time.

RUNNING

The job is running.

CANCELING

The job is being canceled.

SUCCEEDED

The job succeeded.

FAILED

The job failed.

CANCELED

The job was canceled.

NoteAfter a fine-tuning job succeeds, the finetuned_output field provides the resulting model ID. Use this ID for model deployment.

Get fine-tuning job logs

HTTP

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/logs?offset=0&line=1000' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Use the offset and line parameters to retrieve a range of log lines. The offset parameter specifies the starting line, and the line parameter specifies the maximum number of lines to return.

Sample response:

{
    "request_id":"1100d073-4673-47df-aed8-c35b3108e968",
    "output":{
        "total":57,
        "logs":[
            "{Fine-tuning log 1}",
            "{Fine-tuning log 2}",
            ...
            ...
            ...
        ]
    }
}

Query and publish model checkpoints

Only SFT fine-tuning (efficient_sft and sft) supports saving and publishing checkpoints from intermediate training states.

List checkpoints for a fine-tuning job

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/checkpoints' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'
Request parameters

Parameter

Type

Parameter location

Required

Description

job_id

String

Path Parameter

Yes

The ID of the fine-tuning job.

Sample response

NoteThe checkpoint field contains the checkpoint ID, which specifies the checkpoint to publish in the Model publishing (optional) API. The model_name field contains the model ID used for model deployment. The finetuned_output field in the original fine-tuning job response is the model_name of the final checkpoint.

{
    "request_id": "c11939b5-efa6-4639-97ae-ed4597984647",
    "output":
    [
        {
            "create_time": "2025-11-11T16:25:42",
            "full_name": "ft-202511272033-8ae7-checkpoint-20",
            "job_id": "ft-202511272033-8ae7",
            "checkpoint": "checkpoint-20",
            "model_name": "qwen3-8b-instruct-ft-202511272033-8ae7",
            "status": "SUCCEEDED"
        }
    ]
}

Status

Description

PENDING

The checkpoint is pending publication. You must publish it using the Model publishing API before you can use it for model deployment and invocation.

PROCESSING

The checkpoint is being published.

SUCCEEDED

The checkpoint has been published successfully. You can now use it for model deployment and invocation.

FAILED

The checkpoint failed to publish.

Model publishing (optional)

NoteIn Model Studio, after a fine-tuning job completes, you must export a checkpoint before you can deploy the model.

Exported checkpoints are stored in cloud storage. You cannot access or download them at this time.

curl --request GET 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/export/<checkpoint_id>?model_name=<model_name>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'
Request parameters

Parameter

Type

Parameter location

Required

Description

job_id

String

Path Parameter

Yes

The ID of the fine-tuning job.

checkpoint_id

String

Path Parameter

Yes

The ID of the checkpoint to publish.

model_name

String

Path Parameter

Yes

The custom model ID to assign to the published model.

Sample response
{
    "request_id": "ed3faa41-6be3-4271-9b83-941b23680537",
    "output": true
}

The publishing task is asynchronous. Use the List checkpoints for a fine-tuning job API to monitor the publishing status of the checkpoint.

More fine-tuning operations

List fine-tuning jobs

curl 'https://dashscope.aliyuncs.com/api/v1/fine-tunes' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Cancel a fine-tuning job

Cancels a running fine-tuning job.

curl --request POST 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>/cancel' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

Delete a fine-tuning job

You cannot delete a running fine-tuning job.

curl --request DELETE 'https://dashscope.aliyuncs.com/api/v1/fine-tunes/<job_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY} \
--header 'Content-Type: application/json'

API reference

This topic provides a reference for DashScope command-line calls. For details on API calls, see API details.

Model deployment and invocation

Model deployment

For other deployment methods, see Deploy a model by using the API.

curl "https://dashscope.aliyuncs.com/api/v1/deployments" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "model_name": "qwen3-8b-ft-202511132025-0260",
    "plan": "lora",
    "capacity": 1,
    "name": "qwen3-8b-ft"
}'
curl "https://dashscope.aliyuncs.com/api/v1/deployments" \
--header "Authorization: Bearer $DASHSCOPE_API_KEY" \
--header 'Content-Type: application/json' \
--data '{
    "name": "my_qwen_plus",
    "model_name": "qwen-plus-2025-12-01",
    "plan": "mu",
    "deploy_spec": "MU1",
    "enable_thinking": true,
    "capacity": 4,
    "max_context_length": 10000,
    "rpm_limit": 500,
    "tpm_limit": 1000
}'

Query deployment status

Once the deployment status is RUNNING, you can invoke the model.

curl 'https://dashscope.aliyuncs.com/api/v1/deployments/<your_model_instance_id>' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY}  \
--header 'Content-Type: application/json'

For other deployment operations, such as scaling and deprovisioning, see Model Deployment - API Details.

Model invocation

Once the model deployment status is RUNNING, you can invoke the fine-tuned model just like any other model.

You can also get the Model Code from the model deployment console.

For details on usage and parameters, see the DashScope API Reference.

curl 'https://dashscope.aliyuncs.com/api/v1/services/aigc/text-generation/generation' \
--header 'Authorization: Bearer '${DASHSCOPE_API_KEY}  \
--header 'Content-Type: application/json' \
--data '{
    "model": "<your_model_instance_id>",
    "input":{
        "messages":[
            {
                "role": "user",
                "content": "Who are you?"
            }
        ]
    },
    "parameters": {
        "result_format": "message"
    }
}'

Model evaluation

The model evaluation feature is exclusive to the Alibaba Cloud Model Studio console. Go to the Model Evaluation page to evaluate model performance.

For more information, see Model Evaluation.