Upload a local file to free temporary storage and get an oss:// URL for multimodal, image, video, or audio models.
When you call multimodal, image, video, or audio models, you often need to pass a file URL. QwenCloud provides free temporary storage: upload a local file, get a URL, and use that URL in the model call. The URL is valid for 48 hours.
When you call the API with curl, Postman, or any other HTTP client, follow these rules:
You can also use the DashScope Python or Java SDK.
The code samples and CLI above perform the following three steps for you. This section documents each step.
Prerequisites
Get an API key and set it as an environment variable.
Request
The following uses the Singapore (ap-southeast-1) endpoint. For another region, replace ap-southeast-1 and use an API key from that region. See Regions and endpoints.
Request parameters
Response parameters
Request example
Response example
Prerequisites
Request parameters
Response
A successful call returns no content.
Request example
The file URL is
If a call fails, see Error messages. The following status codes are specific to this feature.
Check the following:
File storage and access are managed at the QwenCloud account level, and API keys are only credentials for that account.
Different API keys under the same account work. API keys from different accounts cannot read the file because accounts are isolated.
Make sure the API key used for upload and the API key used for the model call belong to the same QwenCloud account.
Temporary storage is available in Singapore (
ap-southeast-1), China North 2 (Beijing) (cn-beijing), and China (Hong Kong) (cn-hongkong).Usage limits
- Files are bound to a model: You must specify a model name when uploading, and the model must be the same model you call later. Different models cannot share a file. Each model also has its own file size limit; a file that exceeds the limit fails to upload.
- Files are bound to an account: The API key used for upload and the API key used for the model call must belong to the same QwenCloud account. The uploaded file can be used only by that account and that model. Other accounts and other models cannot read it.
- Files expire after 48 hours: Uploaded files are deleted automatically after 48 hours. Finish your model calls within that window.
- Uploaded files are write-only: After upload, you cannot query, modify, or download the file. It can be used only as a URL parameter in a model call.
- Upload policy rate limit: The upload policy endpoint is limited to 100 QPS per account and model. Requests above the limit fail.
- A temporary URL expires after 48 hours and cannot be renewed. Do not use it in production.
- The upload policy endpoint is limited to 100 QPS without quota increases. Do not use it for production workloads, high concurrency, or load testing.
- For production, use durable storage such as Alibaba Cloud OSS so that files remain available and rate limits do not apply.
How it works
- Get a temporary URL: Upload an image, video, or audio file as described in Step 1, and get a URL that starts with
oss://. - Call the model: Pass the temporary URL as described in Step 2. This step is required; otherwise the request fails.
Step 1: Get a temporary URL
- Option 1: Upload with code
- Option 2: Upload with the CLI
The Python and Java samples below handle the upload for you. Specify the model and the file, and the sample returns the temporary URL.PrerequisitesGet an API key, then set the API key as an environment variable.
Sample code
- Python
- Java
EnvironmentInput parametersOutput
- Python 3.8 or later is recommended.
- Install the dependencies:
api_key: QwenCloud API key.model_name: The model that will use the file, such asqwen3-vl-plus.file_path: Path to the local file to upload (image, video, or audio).
When you call a model over HTTP with a temporary URL, you must add the
X-DashScope-OssResourceResolve: enable request header. See Call over HTTP.Step 2: Call a model with the temporary URL
Requirements
- File format: The URL must be generated as described above and must start with
oss://. - File not expired: The URL must be used within 48 hours of upload.
- Same model: The model you call must be exactly the model you specified during upload.
- Same account: The API key used for the model call must belong to the same QwenCloud account as the API key used for upload.
Option 1: Call over HTTP
When you call the API with curl, Postman, or any other HTTP client, follow these rules:
- With a temporary URL, you must add
X-DashScope-OssResourceResolve: enableto the request headers. - Without this header, the service cannot resolve the
oss://URL and the request fails. For the error message, see Error codes.
- Request example
- Response example
This example calls
qwen3-vl-plus to describe an image.Replace
oss://... with your temporary URL, or the request fails.Option 2: Call with the DashScope SDK
You can also use the DashScope Python or Java SDK.
- Pass the URL directly: Pass the
oss://URL as the file parameter in the SDK call. - No header handling: The SDK adds the required header automatically.
Not every model supports SDK calls. Check the model's API reference. The OpenAI SDK is not supported.
- Python
- Java
PrerequisitesInstall DashScope Python SDK version
1.24.0 or later.Sample codeThis example calls qwen3-vl-plus to describe an image. The code applies to the qwen-vl and omni model families.- Request example
- Response example
Replace
oss://... in the image parameter with your temporary URL, or the request fails.Appendix: API details
The code samples and CLI above perform the following three steps for you. This section documents each step.
Step 1: Get an upload policy
Prerequisites
Get an API key and set it as an environment variable.
Request
The following uses the Singapore (ap-southeast-1) endpoint. For another region, replace ap-southeast-1 and use an API key from that region. See Regions and endpoints.
The upload policy endpoint is limited to 100 QPS per QwenCloud account and model, and temporary storage cannot be expanded. For production or high-concurrency workloads, use a storage service such as Alibaba Cloud OSS.
| Location | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
| Header | Content-Type | string | Yes | Request content type: application/json. | application/json |
| Header | Authorization | string | Yes | QwenCloud API key, prefixed with Bearer. | Bearer sk-ws-xxx |
| Query | action | string | Yes | Action to perform. Use getPolicy. | getPolicy |
| Query | model | string | Yes | Name of the model that will use the file. | qwen3-vl-plus |
| Field | Type | Description | Example |
|---|---|---|---|
| request_id | string | Unique request identifier. | 7574ee8f-...-11c33ab46e51 |
| data | object | Upload policy. | - |
| data.policy | string | Upload policy. | eyJl...1ZSJ9XX0= |
| data.signature | string | Signature of the upload policy. | g5K...d40= |
| data.upload_dir | string | Directory for the uploaded file. | dashscope-instant/xxx/2026-10-22/xxxx |
| data.upload_host | string | Host to which the file is uploaded. | https://dashscope-file-mgr-prod.oss-ap-southeast-1.aliyuncs.com |
| data.expire_in_seconds | string | Policy validity in seconds. After it expires, call this endpoint again for a new policy. | 300 |
| data.max_file_size_mb | string | Maximum file size in MB. The value depends on the model. | 1024 |
| data.capacity_limit_mb | string | Daily upload capacity for the account, in MB. | 999999999 |
| data.oss_access_key_id | string | Access key used for the upload. | LTAxxx |
| data.x_oss_object_acl | string | Access control for the uploaded file. private means private. | private |
| data.x_oss_forbid_overwrite | string | Whether a file with the same name can be overwritten. true means it cannot. | true |
If the API key is not set as an environment variable, replace
$DASHSCOPE_API_KEY with the key, for example --header "Authorization: Bearer sk-ws-xxx".Step 2: Upload the file to temporary storage
Prerequisites
- You have an upload policy.
- The upload policy has not expired. If it has, call Step 1 again for a new policy.
To check the validity period, read
data.expire_in_secondsin the Step 1 response.
Replace
{data.upload_host} with the data.upload_host value from Step 1.| Location | Field | Type | Required | Description | Example |
|---|---|---|---|---|---|
| Header | Content-Type | string | No | Form submissions use multipart/form-data. The browser or HTTP client adds boundary automatically. | multipart/form-data; boundary=9431149156168 |
| form-data | OSSAccessKeyId | text | Yes | The data.oss_access_key_id value from Step 1. | LTAm5xxx |
| form-data | policy | text | Yes | The data.policy value from Step 1. | g5K...d40= |
| form-data | Signature | text | Yes | The data.signature value from Step 1. | Sm/tv7DcZuTZftFVvt5yOoSETsc= |
| form-data | key | text | Yes | The data.upload_dir value from Step 1, followed by /<file name>. | dashscope-instant/xxx/2026-10-22/xxx/cat.png |
| form-data | x-oss-object-acl | text | Yes | The data.x_oss_object_acl value from Step 1. | private |
| form-data | x-oss-forbid-overwrite | text | Yes | The data.x_oss_forbid_overwrite value from Step 1. | true |
| form-data | success_action_status | text | No | Use 200 so the endpoint returns HTTP 200 after a successful upload. | 200 |
| form-data | file | file | Yes | The file or text content. Upload one file per request. file must be the last form field; the other fields can appear in any order. | file=@"/tmp/cat.png" |
Step 3: Build the file URL
The file URL is oss:// followed by the key you used in Step 2. The URL is valid for 48 hours.
Error codes
If a call fails, see Error messages. The following status codes are specific to this feature.
| HTTP status | Error code | Error message | Meaning |
|---|---|---|---|
| 400 | invalid_parameter_error | InternalError.Algo.InvalidParameter: The provided URL does not appear to be valid. Ensure it is correctly formatted. | Invalid URL. Check the URL. For a temporary file URL, make sure the request includes the X-DashScope-OssResourceResolve: enable header. |
| 400 | InvalidParameter.DataInspection | The media format is not supported or incorrect for the data inspection. | Possible causes: (1) the request header is missing X-DashScope-OssResourceResolve: enable; (2) the image format does not meet the model's requirements. For details, see Error messages. |
| 403 | AccessDenied | Invalid according to Policy: Policy expired. | The upload policy expired. Call the upload policy endpoint again for a new policy. |
| 429 | Throttling.RateQuota | Requests rate limit exceeded, please try again later. | The request rate exceeded the limit. The upload policy endpoint allows 100 QPS per account and model. Lower the request rate or move to your own storage service such as OSS. |
FAQ
Why does a call with an oss:// URL fail?
Check the following:
- Request header: If you call the API over HTTP (curl, Postman), you must add
X-DashScope-OssResourceResolve: enableto the headers. Without it, the service cannot resolve the OSS internal protocol. See Call over HTTP. - URL validity: An
oss://URL is temporary. Make sure it was created within the last 48 hours. If it expired, upload the file again.