Skip to content
中文

Upload a file

POST/file/v1/files◐ Partial

Official OpenAI docs ↗

Request body

  • filestringrequired

    File bytes in one multipart file part, not a filename or file ID. The file must be nonempty and at most 100000000 bytes; its content determines the MIME type.

  • purposestringrequired

    Purpose label stored with the file: user_data, assistants or vision. The label is stored and returned unchanged; assistants follows the same rules as user_data. The vision purpose accepts only PNG, JPEG, GIF and WebP images. Conversation image references require user_data.

    values user_dataassistantsvision
  • expires_afterobjectoptional

    Optional expiry relative to created_at. Files without an expiry persist until deleted.

    Expand sub-fields (2)
    • anchorstringrequired

      Creation timestamp from which expiry is measured. Send created_at as the multipart field expires_after[anchor].

      values created_at
    • secondsintegerrequired

      Lifetime in seconds after creation, from 3600 through 7776000. Send as expires_after[seconds].

Returns

200 file

Supports PDF; DOCX / XLSX / PPTX; PNG / JPEG / GIF / WebP; MP3 / WAV / FLAC / OGG / M4A; MP4 / WebM; UTF-8 JSON / NDJSON / CSV / Markdown / plain text. Purposes are user_data / assistants / vision. Limit 100000000 bytes. Empty, unsupported, invalid-purpose and oversized uploads return 400. Use Uploads for files over 100 MB. Set expiry with expires_after[anchor] and expires_after[seconds], or with praxis[expires_in_seconds]; the two settings are mutually exclusive.

Errors follow the OpenAI format — see error codes

Request

curl
curl https://api.deepraxis.com/file/v1/files \
  -H "Authorization: Bearer $PRAXIS_API_KEY" \
  -F "purpose=user_data" \
  -F "file=@pixel.png"
Python
from openai import OpenAI

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

file = client.files.create(
    file=open("pixel.png", "rb"),
    purpose="user_data",
)
TypeScript
import OpenAI from "openai";
import fs from "node:fs";

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

const file = await client.files.create({
  file: fs.createReadStream("pixel.png"),
  purpose: "user_data",
});

Response 200

{
  "id": "file_dp_01M41EAAJ35TB1BK663PKJQD81",
  "object": "file",
  "bytes": 70,
  "created_at": 1791049935,
  "filename": "pixel.png",
  "purpose": "user_data",
  "status": "processed",
  "status_details": null,
  "mime_type": "image/png",
  "downloadable": true
}

Response

HTTP 200

OK

application/json

Name Type Description
id string File identifier: file- followed by 24 base62 characters. Use the ID returned by upload or list.
bytes integer The size of the file, in bytes.
created_at integer The Unix timestamp (in seconds) for when the file was created.
expires_at integer | null The Unix timestamp (in seconds) for when the file will expire.
filename string The name of the file.
object string The object type, which is always file.
purpose string Upload purpose. Image references in conversations require user_data.
status string Deprecated. The current status of the file, which can be either uploaded, processed, or error.
mime_type string Content-detected MIME type.
scope object | null Session scope for session outputs; null for other files.
scope.type string Kind of scope; always session.
scope.id string Id of the session the file belongs to.
relative_path string Path within the session output directory; present for session outputs.
revision integer Session output revision; present for session outputs.
state string processing is not yet usable; active is ready; expired cannot be read.
source string upload is user-provided, generated is platform-produced, session is a session output.
sha256 string Content digest, prefixed sha256:. Available after processing completes.