Overview
Request a pre-signed upload URL for direct client-to-storage uploads. This endpoint generates a uniquefile_id and temporary upload URL that allows you to upload files directly to storage without going through the API server.
Authentication
All Files API endpoints require authentication via Bearer token in the Authorization header.Request
Request Body
- filename string (required) — Name of the file to upload, including extension (e.g.,
"report.pdf","data.csv")
Response
Success Response
Field Reference
- success boolean — Always
truefor successful requests - file_id string (UUID) — Unique identifier for this file. Save this to use in chat completions.
- upload_url string — Pre-signed URL for uploading the file. Expires in ~60 seconds.
- storage_path string — Internal storage path (for reference only)
Important Notes
-
💾 Save the file_id (CRITICAL): Store the
file_idimmediately in your database or application state. This is your permanent reference to the file—you’ll reuse it across unlimited chat requests. Upload once, use forever. -
🔄 Reuse, don’t re-upload: The
file_idis permanent. Once you have it:- Use it in unlimited chat completions
- No need to ever upload the same file again
- Store it alongside user data for easy reuse
- Build a file library in your app showing previously uploaded files
-
⏰ URL Expiration: The
upload_urlexpires after approximately 60 seconds. If your upload takes longer, request a new URL. - 🔓 No Authentication Required for Upload: The upload URL itself is pre-signed, so you don’t need to include your API key when uploading to the URL.
-
📝 File Extension: The filename should include the proper file extension (e.g.,
.pdf,.csv,.png) to ensure correct processing.
Next Steps
After receiving the upload URL:-
Upload the file to the
upload_urlusing a PUT request with raw file bytes → See Upload File to Storage - Confirm the upload to trigger processing → See Confirm Upload
- Use the file_id in your chat completions → See Chat Completion API
Error Responses
Missing Filename
400 Bad Request
Authentication Required
401 Unauthorized
Invalid API Key
403 Forbidden