Skip to content
中文

Upload a file

POST/anthropic/v1/files● Supported

Official Anthropic docs ↗

Request body

  • filestringrequired◐ Partially supported

    Body param: The file to upload. Only the final path component of the part's filename is kept; an absent or empty filename is replaced with unnamed plus the extension for the file's stored mime_type, when known.

    Text, PDF and PNG uploads are accepted. Types are detected from content; arbitrary binary data is not supported.

  • expires_in_secondsnumberoptional◐ Partially supported

    Body param: Seconds from upload until the file expires and its bytes become permanently unavailable. Must be between 3600 (one hour) and 7776000 (ninety days).

    The form field supports 3600–7776000 seconds; as a query parameter it returns 400 asking you to send it in the form.

Returns

200

SDK 0.128.0 sends form file and optional form expires_in_seconds (3600–7776000 seconds). Any other form field, including purpose, returns 400 invalid_request_error such as "purpose: Extra inputs are not permitted". The only accepted query parameter is the SDK's beta; other query parameters return 400, and a query expires_in_seconds is told to move into the form. Uploads are stored as user_data. anthropic-workspace-id is not supported and returns 400.

Errors follow the Anthropic format — see error codes

Request

curl
curl https://api.deepraxis.com/anthropic/v1/files \
  -H "x-api-key: $PRAXIS_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -F "file=@pixel.png"
Python
from anthropic import Anthropic

client = Anthropic(
    base_url="https://api.deepraxis.com/anthropic",
    api_key="$PRAXIS_API_KEY",
)

file = client.files.upload(
    file=open("pixel.png", "rb"),
)
TypeScript
import Anthropic from "@anthropic-ai/sdk";
import fs from "node:fs";

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

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

Response 200

{
  "id": "file_dp_01M42FVDJD8QGPRQ0059E7V056",
  "type": "file",
  "filename": "pixel.png",
  "mime_type": "image/png",
  "size_bytes": 70,
  "created_at": "2026-10-04T03:38:18.651Z",
  "expires_at": null,
  "downloadable": false
}

Response

HTTP 200

File uploaded

application/json

Name Type Description
id string Unique object identifier. The format and length of IDs may change over time.
created_at string RFC 3339 datetime string representing when the file was created.
filename string Original filename of the uploaded file.
mime_type string MIME type of the file.
size_bytes number Size of the file in bytes.
type string Object type. For files, this is always "file".
downloadable boolean Whether the file can be downloaded.
expires_at null | string RFC 3339 datetime string representing when the file will expire and become unavailable for download. Null if the file does not expire. For files uploaded with expires_in_seconds, this is the upload time plus that value.
scope null | object The scope of this file, indicating the context in which it was created (e.g., a session).
scope.id string The ID of the scoping resource (e.g., the session ID).
scope.type string The type of scope (e.g., "session").