Compress models using techniques like quantization to reduce inference costs.
Overview
The Model Compression API compresses custom full-parameter fine-tuned models through techniques such as quantization, reducing inference memory footprint and improving throughput. Currently, the compression feature only supports quantization and covers the complete lifecycle from querying templates, creating tasks, polling status, retrieving logs, to canceling/deleting tasks.
Typical flow:
- List quantizable models and configuration templates → obtain the
template_idand the quantizablemodel - Create a compression task → obtain the
job_id - Poll Query compression task / Get compression task logs → until
SUCCEEDED/FAILED/CANCELED - After
SUCCEEDED, usequantized_outputto create a deployment; when no longer needed, Cancel compression task / Delete compression task
https://dashscope-intl.aliyuncs.com. Authentication uniformly uses Authorization: Bearer ${YOUR_API_KEY}, and POST requests must include Content-Type: application/json.
For the meanings of task object fields and the state machine, see Compression task object; for unified error codes, see Error codes at the end of the document.
Quick Start
The model compression API is currently available only in the Singapore Region. If you use another Region, complete model compression operations through the Bailian console of that Region.The model compression API provides a complete set of RESTful interfaces covering query templates, creating jobs, polling status, obtaining logs, and canceling/deleting jobs. This document is intended for developers to integrate compression capabilities via OpenAPI or SDK. For console introductions, see related documents.
Prerequisites
Before calling the interfaces in this document, please complete the following:
- Activated Alibaba Cloud Bailian service and completed real-name verification.
- The current workspace has at least one custom full-parameter fine-tuned model based on
qwen3.5-flash-2026-02-23(completed via the fine-tuning job interface). The current compression feature only supports this model; LoRA models and already-quantized models are not supported. - Obtained an API Key (see Obtain API Key).
The deployment unit specifications supported by the compressed output model are determined by the selected quantization template, and the deployment quantity is configured in the Bailian console under "Model Deployment". The current compression feature is free for a limited time.
Interface List
All interface domains: https://dashscope-intl.aliyuncs.com
# | Method | Path | Description |
|---|---|---|---|
1 | GET |
| List quantizable models and configuration templates |
2 | POST |
| Create compression job |
3 | GET |
| List compression jobs |
4 | GET |
| Query compression job details |
5 | GET |
| Get compression job logs |
6 | POST |
| Cancel compression job |
7 | DELETE |
| Delete compression job |
Authentication
All interfaces carry the API Key via HTTP Header:
Content-Type: application/json applies to POST request body scenarios.
Get Started in 5 Minutes
- HTTP
base_model is qwen3.5-flash-2026-02-23, suffix is test, job_id is quant-202604111200-a1b2, and the output model ID is:
Compression job object
The model compression API is currently available only in the Singapore Region. If you use another Region, complete model compression in that Region's Bailian console.
Object properties
Response parameters
Field | Type | Description |
|---|---|---|
job_id | String | Job ID |
job_name | String | Job name |
job_description | String | Job description |
status | String | Job status (see Job status) |
model | String | Source model ID |
base_model | String | Base model ID |
template_id | String | ID of the compression template in use |
template_name | String | Template name |
template_description | String | Template description |
training_type | String | Job type, fixed as |
compress_type | String | Compression type, same as |
hyper_parameters | Object | Actually effective hyperparameters (only returns user-visible parameters) |
custom_calibration_file_ids | Array<String> | List of file IDs for the custom calibration dataset |
quantized_output | String | Model ID produced after quantization (only has a value when SUCCEEDED) |
create_time | String | Job creation time |
start_time | String | Job start execution time (null when PENDING/QUEUING) |
end_time | String | Job completion time (has a value in terminal states) |
error | Object | Error information on failure, containing |
group | String | Job group, fixed as |
usage | Integer | GPU duration (seconds), appears when SUCCEEDED or CANCELED |
Job status
Status | Description |
|---|---|
| Job created, waiting for scheduling |
| Entered the scheduling queue, waiting for GPU resources |
| Job in progress |
| Cancel initiated, waiting for termination |
| Job succeeded, the |
| Job failed, the |
| Job canceled |
List quantizable models and configuration templates
Lists all quantizable custom fine-tuned models of the current user, as well as the compression templates bound to each model. Templates are bound to models; different combinations of model architecture × precision × target MU specifications correspond to different templates.
Only returns custom models that the current user has fully fine-tuned (SFT/DPO/CPT) based on a base model. LoRA fine-tuned models and already-quantized models will not appear in the results.Endpoint
Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | String | No | - | Filter by model ID; when a base model name is passed, returns all custom models based on that base model |
lang | String | No | zh-CN | Response language: |
Response example (complete: with tunable hyperparameters)
Response example (complete: with tunable hyperparameters)
Field | Type | Description |
|---|---|---|
base_models | Array<String> | List of base model names that support compression |
custom_models[].model | String | Model ID |
custom_models[].model_name | String | Model display name |
custom_models[].base_model | String | Base model name |
custom_models[].templates | Array | List of compression configuration templates supported by this model, inherited from its base model's templates |
templates[].template_id | String | Template ID, passed as the template_id parameter when creating a compression task |
templates[].template_name | String | Template name (supports multi-language; returns the corresponding language version based on the |
templates[].description | String | Template description (supports multi-language; returns the corresponding language version based on the |
templates[].compress_type | String | Compression type, fixed as |
templates[].hyper_parameters | Array | Tunable hyperparameters; an empty array means no tunable hyperparameters |
hyper_parameters[].name | String | Parameter name (used as the Key when creating a task) |
hyper_parameters[].type | String | Type: |
hyper_parameters[].display_name | String | Parameter display name (supports multi-language; returns the corresponding language version based on the |
hyper_parameters[].description | String | Parameter description (supports multi-language; returns the corresponding language version based on the |
hyper_parameters[].defaultValue | String | Default value |
hyper_parameters[].recommend_value | String | Recommended value |
hyper_parameters[].required | Boolean | Whether required |
hyper_parameters[].support_values | Array<String> | List of enumeration values (only present when |
hyper_parameters[].data_range | Array<String> | Numeric range (only present when |
hyper_parameters[].step | Integer | Step size (only present when |
Create a compression job
Endpoint
Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | String | Yes | - | Source model ID, which can be obtained via the API |
template_id | String | Yes | - | Compression template ID, which can be obtained via the API |
job_name | String | No | Auto-generated | Job name; duplicates are not allowed under the same user; up to 50 characters |
job_description | String | No | - | Job description; up to 200 characters |
hyper_parameters | Object | No | Template default value | Hyperparameter overrides (key-value); only pass the items you want to override |
custom_calibration_file_ids | Array<String> | No | - | List of custom calibration dataset file IDs (dataset group ID, in the format |
output_model_suffix | String | No | - | Suffix of the quantized output model name; up to 8 characters, only lowercase letters and digits. Output model name format: |
List compression jobs
Supports filtering by status, model, template, quantization spec, algorithm, time range, job name/ID, and supports sorting by creation time and pagination.
Endpoint
Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
status | String | No | - | Filter by status (e.g., RUNNING, SUCCEEDED) |
model | String | No | - | Filter by source model ID |
template_id | String | No | - | Filter by template ID |
quant_spec | String | No | - | Filter by quantization spec (e.g., |
quant_method | String | No | - | Filter by quantization algorithm (e.g., |
start_time | String | No | - | Job start time is no earlier than this value. Format: |
end_time | String | No | - | Job end time is no later than this value, format same as |
job_name | String | No | - | Fuzzy match by job name |
job_id | String | No | - | Fuzzy match by job ID |
search_key | String | No | - | Search keyword. When |
select_key | String | No | - | Search field for |
sort_by | String | No | create_time | Sort field, currently only supports |
sort_order | String | No | desc | Sort direction, |
page_no | Integer | No | 1 | Page number |
page_size | Integer | No | 10 | Page size, max 100 |
Field | Type | Description |
|---|---|---|
total | Integer | Total number of matching jobs |
page_no | Integer | Current page number |
page_size | Integer | Page size |
jobs | Array | Job list, field meanings are the same as the response parameters of creating a compression job |
Query a compression job
Endpoint
Field | Type | Description |
|---|---|---|
job_id | String | Job ID, which can be obtained via the create compression job or list compression jobs interface |
job_name | String | Job name |
job_description | String | Job description |
status | String | Job status (see Job status for details) |
model | String | Source model ID |
base_model | String | Base model ID |
template_id | String | ID of the compression template used |
template_name | String | Template name |
template_description | String | Template description |
training_type | String | Job type, fixed as |
compress_type | String | Compression type, same as |
hyper_parameters | Object | Actually effective hyperparameters (only returns user-visible parameters) |
custom_calibration_file_ids | Array<String> | List of file IDs for the custom calibration dataset |
quantized_output | String | Model ID produced after quantization (only has a value when SUCCEEDED), can be used by the Create deployment interface for model deployment |
create_time | String | Job creation time |
start_time | String | Job start execution time (null when PENDING/QUEUING) |
end_time | String | Job completion time (has a value at terminal states) |
error | Object | Error information on failure, containing |
group | String | Job group, fixed as |
usage | Integer | GPU duration (seconds), present when SUCCEEDED or CANCELED |
Get compression job logs
Endpoint
{job_id} is the compression job ID, which can be obtained via the create compression job or list compression jobs interface.
Request parameters
Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
offset | Integer | No | 0 | Skip the first N lines and start reading from the (N+1)th line |
line | Integer | No | 100 | Number of lines to read, up to 1000 |
- When a custom calibration dataset is provided for the job, the logs contain a data processing completion marker
data process succeeded, start to quantization - The log interface has filtered out internal system markers and only returns user-readable compression progress information
Cancel a compression job
You can cancel only jobs in the PENDING, QUEUING, or RUNNING state. Cancellation is an asynchronous operation. The job first enters the CANCELING transitional state and eventually becomes CANCELED.
Endpoint
{job_id} is the compression job ID, which can be obtained from the Create compression job or List compression jobs API.
Request example
Delete a compression job
You can delete only jobs in a terminal state (SUCCEEDED / FAILED / CANCELED). Deleting a job record does not delete the already-generated quantized model (quantized_output).
Endpoint
{job_id} is the compression job ID, which can be obtained from the Create compression job or List compression jobs API.
Request example
Error code
Common error codes
Error code | HTTP | Description |
|---|---|---|
| 400 | Invalid request parameter |
| 400 | Missing required parameter |
| 401 | Authentication failed |
| 403 | No permission to access |
| 404 | Resource does not exist |
| 400 | The resource state does not allow this operation (e.g., canceling a job that is already in a terminal state) |
| 429 | Quota exceeded |
| 500 | Internal service error |
Business error codes
The following business error codes are listed by scenario. External Code is the actual code field value returned by the interface.
Parameter validation
External Code | HTTP | Description |
|---|---|---|
| 400 | Missing required parameter |
| 400 | Missing required parameter |
| 400 | Direct quantization of base models is not supported |
| 400 | The specified configuration template does not exist |
| 400 | The current model does not support this compression template |
| 400 | The model does not support quantization |
| 400 | LoRA fine-tuned models do not support quantization |
| 400 | Model data unavailable |
| 400 | The job name contains unsupported characters |
| 400 |
|
| 400 | The source model is not ready |
| 403 | No permission to use this compression template |
External Code | HTTP | Description |
|---|---|---|
| 400 | Required hyperparameter not provided |
| 400 | Unknown hyperparameter provided |
| 400 | The hyperparameter value is not in the enumeration list |
| 400 | The hyperparameter value is out of range |
| 400 | The hyperparameter value is not a valid number |
External Code | HTTP | Description |
|---|---|---|
| 404 | The specified compression job does not exist |
| 400 | Missing required parameter |
External Code | HTTP | Description |
|---|---|---|
| 400 | Invalid page number parameter (must be ≥ 1) |
| 400 | Invalid page size (must be 1–100) |
| 400 | Invalid time format |