Tradução de apoio para consulta. Código e identificadores técnicos preservados. Consultar referência original ↗
Recuperar arquivo
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/{file_id}:
get:
operationId: retrieveFile
summary: Retrieve file
description: Retrieve file details by file ID.
parameters:
- name: file_id
in: path
required: true
description: The ID of the file to retrieve.
schema:
type: string
example: file-batch-xxx
responses:
"200":
description: File details retrieved successfully
content:
application/json:
schema:
$ref: "#/components/schemas/FileObject"
example:
id: file-batch-xxx
bytes: 27
created_at: 1722480306
filename: test.txt
object: file
purpose: batch
status: processed
status_details: null
x-codeSamples:
- lang: python
label: Python
source: |-
import os
from openai import OpenAI
client = OpenAI(
api_key=os.getenv("DASHSCOPE_API_KEY"),
base_url="https://maas.qwencloudapi.com/compatible-mode/v1",
)
file = client.files.retrieve(
file_id="file-batch-xxx"
)
print(file.model_dump_json())
- lang: javascript
label: Node.js
source: |-
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.DASHSCOPE_API_KEY,
baseURL: "https://maas.qwencloudapi.com/compatible-mode/v1",
});
const file = await client.files.retrieve(
"file-batch-xxx"
);
console.log(file);
- lang: curl
label: cURL
source: |-
curl "https://maas.qwencloudapi.com/compatible-mode/v1/files/file-batch-xxx" \
-H "Authorization: Bearer $DASHSCOPE_API_KEY"
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