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 .
How it works
- Upload a file and specify the target model. The API returns an
oss://URL. - Pass that URL in your model call. You must complete Step 2 to use the temporary URL -- skipping it causes errors. For HTTP calls, add the header
X-DashScope-OssResourceResolve: enable. The DashScope SDK adds this header automatically.
Limitations
Constraint | Detail |
|---|---|
File-model binding | Specify the model name at upload. Use the same model in subsequent calls -- files cannot be shared across models. |
File Size Limits | The file size must not exceed 1GB and must also comply with the specific limits of the selected model. |
File-account binding | API keys for upload and model calls must belong to the same Alibaba Cloud account -- files cannot be shared across accounts. |
48-hour expiry | Files are automatically deleted after 48 hours. Complete model calls within this period. |
No post-upload management | Files cannot be queried, modified, or downloaded -- they serve only as URL parameters in model calls. |
Rate limiting | The upload credential API is limited to 100 QPS per account per model. Excess requests fail. The temporary storage does not support scale-out. |
Prerequisites
Before you begin:
- An API key configured as an environment variable
- The model name that will consume the file (e.g.,
qwen-vl-plus)
Step 1: Get a temporary URL
Upload a file and get its temporary URL using one of these methods:
- Upload with code
- Upload with the CLI
- Python
- Java
- Python 3.8 or later
- Install dependencies:
Parameter | Description | Example |
|---|---|---|
| Model Studio API key | Read from |
| The model that will consume the file |
|
| Path to the local file |
|
Step 2: Call the model with the temporary URL
After uploading a file, use the oss:// URL in your model call. Two rules apply:
- Model consistency: Use the same model you specified during upload.
- Account consistency: Use an API key that belongs to the same Alibaba Cloud account.
HTTP
When calling the API over HTTP (curl, Postman, etc.), add this header:
oss:// URLs and requests fail.
Example request
This example calls qwen-vl-plus to describe an uploaded image.
Replace oss://... with your actual temporary URL.
DashScope SDK
The DashScope SDK handles the X-DashScope-OssResourceResolve header automatically -- pass the oss:// URL directly as the file parameter.
The OpenAI SDK is not supported. Not all models support SDK calls -- see the specific model's API reference for details.
- Python
- Java
1.24.0 or later.This example calls qwen-vl-plus to describe an uploaded image. This code applies to qwen-vl and omni models.
Replace oss://... in the image parameter with your actual temporary URL.
API reference
The code samples and CLI in Step 1 wrap these three API operations internally. Use this reference to implement the upload flow manually.
Get a file upload credential
Request parameters
Location | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
Header | Content-Type | _string_ | Yes | Request type. |
|
Header | Authorization | _string_ | Yes | Model Studio API key. |
|
Params | action | _string_ | Yes | Operation type. Set to |
|
Params | model | _string_ | Yes | Target model name. |
|
Response parameters
Field | Type | Description | Example |
|---|---|---|---|
request_id | _string_ | Unique request ID. |
|
data | _object_ | - | - |
data.policy | _string_ | Upload credential. |
|
data.signature | _string_ | Credential signature. |
|
data.upload_dir | _string_ | Upload directory path. |
|
data.upload_host | _string_ | OSS host for uploading. | |
data.expire_in_seconds | _string_ | Credential validity in seconds. Get a new credential after expiry. |
|
data.max_file_size_mb | _string_ | Maximum upload file size in MB. Varies by model. |
|
data.capacity_limit_mb | _string_ | Daily upload capacity per Alibaba Cloud account in MB. |
|
data.oss_access_key_id | _string_ | Access key for the upload. |
|
data.x_oss_object_acl | _string_ | Uploaded file access permission. |
|
data.x_oss_forbid_overwrite | _string_ | Whether overwriting files with the same name is blocked. |
|
Sample request
If the API key is not configured as an environment variable, replace$DASHSCOPE_API_KEYwith your API key:--header "Authorization: Bearer sk-xxx".
Sample response
Upload the file to temporary storage
Replace{data.upload_host}with thedata.upload_hostfrom the credential response.
Request parameters
Location | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
Header | Content-Type | _string_ | No | Submit the form as |
|
form-data | OSSAccessKeyId | _text_ | Yes |
|
|
form-data | policy | _text_ | Yes |
|
|
form-data | Signature | _text_ | Yes |
|
|
form-data | key | _text_ | Yes |
|
|
form-data | x-oss-object-acl | _text_ | Yes |
|
|
form-data | x-oss-forbid-overwrite | _text_ | Yes |
|
|
form-data | success_action_status | _text_ | No | HTTP status code returned on success. Typically |
|
form-data | file | _file_ | Yes | The file to upload. Only one file per request. The |
|
Sample request
Construct the file URL
Concatenate oss:// with the key from the upload request. This URL is valid for 48 hours.
Error codes
If API calls fail, see Error messages for general troubleshooting.
These error codes are specific to temporary file uploads:
HTTP status | Error code | Error message | Cause and resolution |
|---|---|---|---|
400 | invalid_parameter_error | InternalError.Algo.InvalidParameter: The provided URL does not appear to be valid. Ensure it is correctly formatted. | The URL is malformed. Verify the URL format. If using an |
400 | InvalidParameter.DataInspection | The media format is not supported or incorrect for the data inspection. | The request header is missing |
403 | AccessDenied | Invalid according to Policy: Policy expired. | The upload credential has expired. Call the credential API again to get a new one. |
429 | Throttling.RateQuota | Requests rate limit exceeded, please try again later. | The request rate exceeds 100 QPS. Reduce the request frequency, or migrate to OSS for production workloads. |
FAQ
What should I do if an oss:// URL returns an error?
Follow these steps:
- Check the request header. If calling the API over HTTP (curl, Postman, etc.), add
X-DashScope-OssResourceResolve: enableto the request header. Without this header, the server cannot resolve theoss://protocol. The DashScope SDK adds this header automatically. - Check URL validity. The
oss://URL expires 48 hours after upload. If expired, upload the file again to get a new URL.