Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
Carregar arquivo
Esta interface é principalmente para compatibilidade com cenários históricos. Recomenda-se priorizar a interface de arquivo compatível com OpenAI.
OpenAPI
openapi: 3.1.0
info:
title: QwenCloud File API
description: Upload and manage files for document analysis or batch processing.
version: 1.0.0
servers:
- url: https://maas.qwencloudapi.com/compatible-mode/v1
description: Singapore
security:
- BearerAuth: []
paths:
/files:
post:
operationId: uploadFile
summary: Upload file
description: Upload a file for document analysis or batch processing. You can store up to 10,000 files and 100 GB total. Files never expire.
requestBody:
required: true
content:
multipart/form-data:
schema:
$ref: "#/components/schemas/UploadFileRequest"
responses:
"200":
description: File uploaded successfully
content:
application/json:
schema:
$ref: "#/components/schemas/FileObject"
example:
id: file-fe-xxx
bytes: 2055
created_at: 1729065448
filename: test.txt
object: file
purpose: file-extract
status: processed
status_details: null
x-codeSamples:
- lang: python
label: Python
source: |-
import os
from pathlib import Path
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
# Upload for document analysis
file_object = client.files.create(
file=Path("test.txt"),
purpose="file-extract"
)
print(file_object.model_dump_json())
- lang: javascript
label: Node.js
source: |-
import OpenAI from "openai";
import fs from "fs";
const client = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1",
});
const fileObject = await client.files.create({
file: fs.createReadStream("test.txt"),
purpose: "file-extract",
});
console.log(fileObject);
- lang: curl
label: cURL
source: |-
curl -X POST "https://maas.qwencloudapi.com/compatible-mode/v1/files" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY" \
-F 'file=@"test.txt"' \
-F 'purpose="file-extract"'
components:
securitySchemes:
BearerAuth:
type: http
scheme: bearer
description: QwenCloud API Key. Create one in the [console](https://home.qwencloud.com/api-keys).
schemas:
UploadFileRequest:
type: object
required:
- file
- purpose
properties:
file:
type: string
format: binary
description: The file to upload.
purpose:
type: string
enum:
- file-extract
- batch
description: |-
The intended use of the file.
- `file-extract`: Document analysis. Max 150 MB. Supported formats: TXT, DOCX, PDF, XLSX, EPUB, MOBI, MD, CSV, JSON, BMP, PNG, JPG/JPEG, GIF, scanned PDFs.
- `batch`: Batch processing. Max 500 MB. JSONL format ([Batch file requirements](/developer-guides/text-generation/batch#input-file-format)).
FileObject:
type: object
properties:
id:
type: string
description: Unique file identifier.
example: file-fe-xxx
bytes:
type: integer
description: File size in bytes.
example: 2055
created_at:
type: integer
description: Unix timestamp (seconds) when the file was created.
example: 1729065448
filename:
type: string
description: The uploaded filename.
example: test.txt
object:
type: string
enum:
- file
description: Always `file`.
purpose:
type: string
description: "File purpose. Valid values: `batch`, `file-extract`, `batch_output`."
example: file-extract
status:
type: string
description: Current file status.
example: processed
status_details:
type: string
nullable: true
description: Additional status details. `null` when no details available.
ListFilesResponse:
type: object
properties:
object:
type: string
enum:
- list
description: Always `list`.
data:
type: array
description: List of file objects.
items:
$ref: "#/components/schemas/FileObject"
has_more:
type: boolean
description: Whether a next page exists.
DeleteFileResponse:
type: object
properties:
object:
type: string
enum:
- file
description: Always `file`.
deleted:
type: boolean
description: Whether the deletion succeeded.
id:
type: string
description: The deleted file's ID.
example: file-batch-xxx