Upload a file
/openai/v1/files◐ PartialRequest body
filestringrequiredThe File object (not file name) to be uploaded.
Verified to take effect.
purposestringrequired◐ Partially supportedThe file purpose: user_data, assistants or vision (vision accepts only PNG, JPEG, GIF or WebP images). Other OpenAI purposes such as batch, fine-tune and evals are not supported and return 400 PURPOSE_UNSUPPORTED.
Supports user_data, assistants and vision; batch, fine-tune, evals and other values return 400.
expires_afterobjectoptionalThe expiration policy for a file. By default, files with
purpose=batchexpire after 30 days and all other files are persisted until they are manually deleted.anchor=created_at and seconds=3600–2592000.
Expand sub-fields (2)
anchorstringrequiredAnchor timestamp after which the expiration policy applies. Supported anchors:
created_at.secondsintegerrequiredThe number of seconds after the anchor time that the file will expire. Must be between 3600 (1 hour) and 2592000 (30 days).
Returns
200 file
Upload one file, up to 100 MB (100000000 bytes), using streaming multipart/form-data. Supported content-detected types: PDF; DOCX, XLSX, PPTX; PNG, JPEG, GIF, WebP; MP3, WAV, FLAC, OGG, M4A; MP4, WebM; UTF-8 JSON, NDJSON, CSV, Markdown and plain text. Purposes: user_data, assistants, vision. Other purposes and empty/unsupported/oversized files return 400. Use Uploads for files larger than 100 MB. expires_after accepts anchor created_at and seconds 3600–2592000. Only form file, purpose, expires_after[anchor] and expires_after[seconds] are accepted; any other form field or any query parameter returns 400 invalid_request_error "Unrecognized request argument supplied: <name>" with param naming it.
Errors follow the OpenAI format — see error codes
Request
curl
curl https://api.deepraxis.com/openai/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/openai/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/openai/v1",
apiKey: "$PRAXIS_API_KEY",
});
const file = await client.files.create({
file: fs.createReadStream("pixel.png"),
purpose: "user_data",
});Response 200
{
"id": "file_dp_01M41EAAEQ3N9T5T1D5Y6PYXNB",
"object": "file",
"bytes": 70,
"created_at": 1791049935,
"filename": "pixel.png",
"purpose": "user_data",
"status": "processed",
"status_details": null
}Response
HTTP 200
OK
application/json
| Name | Type | Description |
|---|---|---|
| id | string | The file identifier, which can be referenced in the API endpoints. |
| 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 | 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 | The intended purpose of the file. Supported values are assistants, assistants_output, batch, batch_output, fine-tune, fine-tune-results, vision, and user_data. |
| status | string | Deprecated. The current status of the file, which can be either uploaded, processed, or error. |
| status_details | string | Deprecated. For details on why a fine-tuning training file failed validation, see the error field on fine_tuning.job. |