Multimodal models such as Qwen-VL require file URLs for image, video, and audio inputs. Model Studio provides free temporary storage if you lack public URLs: upload a file and get an oss:// URL valid for 48 hours .
Usage restrictions
- File-model binding: You must specify the model name when uploading a file, and the model must be the same as the one used in subsequent calls. Files cannot be shared across different models.
- File size limit: Files uploaded through this API must not exceed 1GB. Exceeding this limit causes the upload to fail. In addition, different models impose different limits on input file sizes. Exceeding these limits causes model calls to fail.
- File-account binding: The API keys used for file upload and model calls must belong to the same Alibaba Cloud primary account. Uploaded files can only be used by that primary account and the corresponding model, and cannot be shared with other primary accounts or models.
- File validity period: Files are valid for 48 hours after upload and are automatically cleaned up after they expire. Make sure you complete model calls within the validity period.
- File usage restrictions: Once uploaded, files cannot be queried, modified, or downloaded. They can only be used as URL parameters in model calls.
- Upload rate limit: The file upload credential API is rate-limited to 100 QPS per "Alibaba Cloud primary account + model". Exceeding the rate limit causes requests to fail.
dashscope.aliyuncs.com with dashscope-intl.aliyuncs.com in the request URL, and use an API key for the Singapore region (the API keys of the two regions are different; see Get an API key).How to use
- Get a file URL: First upload a file (image, video, or audio) in Step 1 to get a temporary URL prefixed with
oss://. - Call the model: Make sure to use the temporary URL for the call as described in Step 2. This step cannot be skipped; otherwise the API returns an error.
Step 1: Get a temporary URL
- Method 1: Upload a file with code
- Method 2: Upload a file with the CLI
Example code
- Python
- Java
- DashScope SDK (Python)
- dashscope CLI
- Python 3.9 or later is recommended.
- Install the required dependencies.
- api_key: The Alibaba Cloud Model Studio API key.
- model_name: The model that the file will be used with, such as
qwen3-vl-plus. - file_path: The path of the local file to upload (image, video, etc.).
Step 2: Call the model with the temporary URL
Usage restrictions
- File format: The temporary URL must be generated using the preceding methods and be a URL string prefixed with
oss://. - File not expired: The file URL is still within the 48-hour validity period after upload.
- Model consistency: The model used in the model call must be exactly the same as the model specified at upload.
- Account consistency: The API key used in the model call and the API key used at upload must belong to the same Alibaba Cloud primary account.
Method 1: Call via HTTP
If you call the API directly with curl, Postman, or any other HTTP client, you must follow these rules:
- Sample request
- Sample response
- Example of the uploaded local image
oss://... with your actual temporary URL; otherwise the request fails.Method 2: Call with the DashScope SDK
You can also use the Python or Java SDK provided by Alibaba Cloud Model Studio.
- Pass the URL directly: When calling the model SDK, pass the
oss://-prefixed URL string directly as the file parameter. - No header configuration required: The SDK automatically adds the required request headers, so no extra action is needed.
The OpenAI SDK is not supported.
- Python
- Java
2.0.1.Example codeThis example calls the qwen3-vl-plus model to recognize the content of an image. This code example applies only to qwen-vl and omni series models.- Sample request
- Sample response
oss://... in the image parameter with your actual temporary URL; otherwise the request fails.Additional API details
In the two methods of getting a temporary URL described above, the code calls and the CLI have integrated the following three steps to simplify file uploads. This section describes the API for each step.
Step 1: Get a file upload credential
Prerequisites
You need to get an API key and configure the API key as an environment variable.Request endpoint
Request parameters
Location | Field | Type | Required | Description | Example value |
|---|---|---|---|---|---|
Header | Content-Type | string | Yes | Request type: application/json. | application/json |
Authorization | string | Yes | The Alibaba Cloud Model Studio API key, for example: Bearer sk-xxx. | Bearer sk-xxx | |
Params | action | string | Yes | The operation type. In this scenario, it is | getPolicy |
model | string | Yes | The name of the model to call. | qwen3-vl-plus |
Response parameters
Field | Type | Description | Example value |
|---|---|---|---|
request_id | string | The unique system ID of this request. | 7574ee8f-...-11c33ab46e51 |
data | object | - | - |
data.policy | string | The upload credential. | eyJl...1ZSJ9XX0= |
data.signature | string | The signature of the upload credential. | g5K...d40= |
data.upload_dir | string | The directory for the uploaded file. | dashscope-instant/xxx/2024-07-18/xxxx |
data.upload_host | string | The upload host address. | |
data.expire_in_seconds | string | The validity period of the credential (in seconds). After the credential expires, call this API again to get a new credential. | 300 |
data.max_file_size_mb | string | The maximum file size allowed for this upload (in MB). This value depends on the model to be accessed. | 100 |
data.capacity_limit_mb | string | The daily upload capacity limit for the same primary account (in MB). | 999999999 |
data.oss_access_key_id | string | The access key used for the upload. | LTAxxx |
data.x_oss_object_acl | string | The access permission of the uploaded file. | private |
data.x_oss_forbid_overwrite | string | Whether files with the same name can be overwritten. | true |
Sample request
$DASHSCOPE_API_KEY with your actual API key, for example: --header "Authorization: Bearer sk-xxx".Sample response
Step 2: Upload the file to temporary storage
Prerequisites
- You have obtained a file upload credential.
-
Make sure the file upload credential is within its validity period. If the credential expires, call the API in Step 1 again to get a new credential.
To check the validity period of the file upload credential: the output parameter
data.expire_in_secondsof Step 1 is the credential validity period, in seconds.
Request endpoint
data.upload_host from Step 1.Request parameters
| Location | Field | Type | Required | Description | Example value |
|---|---|---|---|---|---|
| Header | Content-Type | string | No | The form must be submitted as multipart/form-data.When the form is submitted, Content-Type appears in the format multipart/form-data;boundary=xxxxxx.The boundary is a randomly generated string and does not need to be specified manually. If an SDK is used to construct the form, the SDK also generates this random value automatically. | multipart/form-data; boundary=9431149156168 |
| form-data | OSSAccessKeyId | text | Yes | The value of the output parameter data.oss_access_key_id of the file upload credential API. | LTAm5xxx |
| policy | text | Yes | The value of the output parameter data.policy of the file upload credential API. | g5K...d40= | |
| Signature | text | Yes | The value of the output parameter data.signature of the file upload credential API. | YOUR_SIGNATURE | |
| key | text | Yes | The value of the output parameter data.upload_dir of the file upload credential API, appended with / and the file name. | For example, if upload_dir is dashscope-instant/xxx/2024-07-18/xxx and the file to upload is named cat.png, the complete concatenated path is:dashscope-instant/xxx/2024-07-18/xxx/cat.png | |
| x-oss-object-acl | text | Yes | The value of the output parameter data.x_oss_object_acl of the file upload credential API. | private | |
| x-oss-forbid-overwrite | text | Yes | The value of the output parameter data.x_oss_forbid_overwrite of the file upload credential API. | true | |
| success_action_status | text | No | Typically 200. After the upload is complete, the API returns HTTP code 200, indicating a successful operation. | 200 | |
| file | text | Yes | The file or text content.
| For example, if the file to upload cat.png is stored in the /tmp directory on a Linux system, this field should be file=@"/tmp/cat.png". |
Response parameters
When the call succeeds, this API has no output parameters.
Sample request
Step 3: Generate the file URL
File URL concatenation logic: oss:// + key (the input parameter key of Step 2). The URL is valid for 48 hours.
Error codes
If an API call fails and returns an error message, see Error codes for troubleshooting.
This API also has specific status codes, as shown below.
| HTTP status code | API error code (code) | API error message (message) | Description |
|---|---|---|---|
| 400 | invalid_parameter_error | InternalError.Algo.InvalidParameter: The provided URL does not appear to be valid. Ensure it is correctly formatted. | The URL is invalid. Check whether the URL is correct.
If you use a temporary file URL, make sure the parameter |
| 400 | InvalidParameter.DataInspection | The media format is not supported or incorrect for the data inspection. | Possible causes:
|
| 403 | AccessDenied | Invalid according to Policy: Policy expired. | The file upload credential has expired.Call the file upload credential API again to generate a new credential. |
| 429 | Throttling.RateQuota | Requests rate limit exceeded, please try again later. | The call frequency has triggered rate limiting.The file upload credential API is rate-limited to 100 QPS (per Alibaba Cloud primary account + model). After rate limiting is triggered, we recommend reducing the request frequency, or migrating to your own storage service such as OSS to avoid the limit. |
FAQ
Q: What should I do if an error occurs when I call with a URL prefixed with oss://?
A: Troubleshoot as follows:
- Check the request header (Header):
If you call the API directly over HTTP (such as with Postman or curl), you must add the parameterX-DashScope-OssResourceResolve: enableto the Header. Without this parameter, the server cannot recognize the OSS internal protocol. For request header configuration, see Call via HTTP. - Check URL validity:
oss://links are temporary URLs. Make sure the link was generated within the last 48 hours. If the link has expired, upload the file again to get a new URL.
