Skip to content
中文

Retrieve an upload

GET/file/v1/uploads/{upload_id}● Supported

Request parameters

  • upload_idstringrequired

    path: Upload identifier returned by create; the upload must belong to your organization.

Returns

200 upload

After a break, query this endpoint for the parts already received (part_number, bytes, sha256), resend only the missing ones, then complete. Pending uploads expire after 7 days; an expired or cancelled upload answers 409.

Errors follow the OpenAI format — see error codes

Request

curl
curl https://api.deepraxis.com/file/v1/uploads/upload_123 \
  -H "Authorization: Bearer $PRAXIS_API_KEY"
Python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.deepraxis.com/file/v1",
    api_key="$PRAXIS_API_KEY",
)

import math
import requests

base = str(client.base_url).rstrip("/")
headers = {"Authorization": f"Bearer {client.api_key}"}
status = requests.get(f"{base}/uploads/upload_123", headers=headers).json()
received = {part["part_number"] for part in status["received_parts"]}
missing = [n for n in range(1, math.ceil(status["bytes"] / status["part_size"]) + 1) if n not in received]
for number in missing:
    with open(f"part-{number}.txt", "rb") as data:
        requests.post(f"{base}/uploads/upload_123/parts", headers=headers, params={"part_number": number}, files={"data": data}).raise_for_status()
print("resume missing parts:", missing)
TypeScript
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.deepraxis.com/file/v1",
  apiKey: "$PRAXIS_API_KEY",
});

const base = client.baseURL.replace(/\/$/, "");
const headers = { Authorization: `Bearer ${client.apiKey}` };
const status = await (await fetch(`${base}/uploads/upload_123`, { headers })).json() as { bytes: number; part_size: number; received_parts: Array<{ part_number: number }> };
const received = new Set(status.received_parts.map(part => part.part_number));
const missing = Array.from({ length: Math.ceil(status.bytes / status.part_size) }, (_, index) => index + 1).filter(number => !received.has(number));
const { readFile } = await import("node:fs/promises");
for (const number of missing) {
  const form = new FormData();
  form.set("data", new Blob([await readFile(`part-${number}.txt`)]));
  await fetch(`${base}/uploads/upload_123/parts?part_number=${number}`, { method: "POST", headers, body: form });
}
console.log("resume missing parts:", missing);

Response 200

{
  "id": "upload_Sw7H9iz1WYJyYmmLhpBWTnRJ",
  "object": "upload",
  "bytes": 11534336,
  "created_at": 1793475080,
  "expires_at": 1793478680,
  "filename": "document.txt",
  "purpose": "user_data",
  "status": "pending",
  "mime_type": "text/plain",
  "file": null,
  "error": null
}

Response

HTTP 200

The upload state plus part_size and the received_parts list; complete once every part is present.

application/json

Name Type Description
id string Upload identifier returned by create. Use this value for parts, complete and cancel.
object string Object type; upload identifies an upload session.
bytes integer Declared size of the complete file in bytes.
created_at integer Creation time as Unix seconds.
expires_at integer Expiry time as Unix seconds; unfinished uploads expire after 7 days.
filename string Filename supplied when creating the upload.
purpose string File purpose: user_data for conversation attachments, assistants for assistant files, vision for images.
status string Upload state: pending accepts parts; completed has a file; cancelled was cancelled; expired exceeded its seven-day lifetime.
file object | null Present after complete. A file with status uploaded is still processing; poll files.retrieve until processed before use.
file.id string File identifier: file- followed by 24 base62 characters. Use the ID returned by upload or list.
file.bytes integer The size of the file, in bytes.
file.created_at integer The Unix timestamp (in seconds) for when the file was created.
file.expires_at integer | null The Unix timestamp (in seconds) for when the file will expire.
file.filename string The name of the file.
file.object string The object type, which is always file.
file.purpose string Upload purpose. Image references in conversations require user_data.
file.status string Deprecated. The current status of the file, which can be either uploaded, processed, or error.
file.mime_type string Content-detected MIME type.
file.scope object | null Session scope for session outputs; null for other files.
file.relative_path string Path within the session output directory; present for session outputs.
file.revision integer Session output revision; present for session outputs.
file.state string processing is not yet usable; active is ready; expired cannot be read.
file.source string upload is user-provided, generated is platform-produced, session is a session output.
file.sha256 string Content digest, prefixed sha256:. Available after processing completes.
part_size integer | null Fixed part length in bytes for a fixed-size upload, or null for a general upload. Send exactly this many bytes per numbered part except for the final remainder.
received_parts array<object> Parts the upload already holds, in resume order: numbered parts by number, then a general upload's parts by arrival. Query GET /file/v1/uploads/{upload_id} after a break and resend only the numbers missing here.
received_parts[].part_number integer | null Fixed part number, or null for a part of a general upload.
received_parts[].id string Part identifier to pass to complete for this content.
received_parts[].bytes integer Accepted length of this part in bytes.
received_parts[].sha256 string Part content digest prefixed sha256:.
mime_type string Declared MIME type, verified during assembly.
error object | null Assembly failure, or null if no failure is recorded.
error.code string File service error code identifying the assembly failure.
error.message string Explanation of why assembly failed.