Skip to main content

POST /v1/files

Upload a file that can be used across various endpoints. The file size limit is 512 MB.

Authentication

Requires provider authentication headers:
x-portkey-provider: openai
Authorization: Bearer YOUR_OPENAI_API_KEY

Request

Headers

x-portkey-provider
string
required
The provider to route the request to (e.g., openai, azure-openai)
Authorization
string
required
Bearer token for the provider API
x-portkey-config
string
Optional config for routing, retries, fallbacks

Body (multipart/form-data)

file
file
required
The file to upload. Supported formats depend on the provider.
purpose
string
required
The intended purpose of the uploaded file. Common values:
  • fine-tune - For fine-tuning training data
  • assistants - For use with assistants
  • batch - For batch API requests

Response

id
string
The file identifier
object
string
The object type, always “file”
bytes
integer
The size of the file in bytes
created_at
integer
Unix timestamp of when the file was created
filename
string
The name of the file
purpose
string
The purpose of the file

Example

curl https://localhost:8787/v1/files \
  -H "x-portkey-provider: openai" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -F purpose="fine-tune" \
  -F file="@training_data.jsonl"

Response Example

{
  "id": "file-abc123",
  "object": "file",
  "bytes": 140,
  "created_at": 1613779121,
  "filename": "training_data.jsonl",
  "purpose": "fine-tune"
}

Error Handling

error
object
Error information if the request fails

Best Practices

Files are processed asynchronously. For large files, use the retrieve endpoint to check the file status before using it.
Files have a maximum size limit of 512 MB. Larger files will be rejected.

List Files

View all uploaded files

Retrieve File

Get file metadata

Delete File

Delete an uploaded file

Build docs developers (and LLMs) love