Authentication
All endpoints require JWT authentication via theAuthorization header:
List Files
Response
Returns an array of file objects. S3 URLs are automatically refreshed if expired.Get Agent Files
Path Parameters
The agent ID
Response
Returns an array of file objects attached to the agent viatool_resources (file_search, code_interpreter).
Get File Configuration
Response
Maximum file size in bytes
Maximum avatar size in bytes
Per-endpoint file configuration
Upload File
Request
Multipart form data with file and metadata fields.The file to upload
Endpoint the file is for (“agents”, “assistants”, “openAI”, etc.)
Agent ID (if attaching to an agent)
Assistant ID (if attaching to an assistant)
Tool resource type: “file_search” or “code_interpreter”
Whether this is a temporary message attachment (true) or permanent agent file (false)
Conversation ID for message attachments
Optional custom file ID (UUID generated if omitted)
Response
Returns the uploaded file object.Permissions
Permanent agent file uploads (message_file=false) require:- User must be agent author OR
- User must have EDIT permission on the agent
- Admin users bypass permission checks
Error Responses
- 400 Bad Request: Invalid file format or exceeds limits
- 403 Forbidden: Insufficient permissions to upload to agent
- 404 Not Found: Agent not found
- 429 Too Many Requests: Rate limit exceeded
- 500 Internal Server Error: Upload failed
Download File
Path Parameters
User ID of the file owner
The file ID
Response
Returns the file as an octet-stream with appropriate headers:Content-Disposition: attachment with filenameContent-Type: application/octet-streamX-File-Metadata: JSON metadata about the file
Error Responses
- 400 Bad Request: File model not available or invalid request
- 403 Forbidden: User lacks access to the file
- 404 Not Found: File not found
- 500 Internal Server Error: Download failed
- 501 Not Implemented: Storage strategy doesn’t support downloads
Download Code Output File
Path Parameters
Code execution session ID (21 characters, base64url)
File ID within the session (21 characters, base64url)
Response
Streams the file content with appropriate headers from the code execution service.Error Responses
- 400 Bad Request: Invalid session_id or fileId
- 500 Internal Server Error: Download failed
- 501 Not Implemented: Storage strategy doesn’t support this operation
Delete Files
Request Body
Array of file objects to delete
Agent ID (for unlinking files from agents)
Assistant ID (for unlinking files from assistants)
Tool resource type: “file_search” or “code_interpreter”
Response
Success message
Permission Handling
- Users can always delete their own files
- Non-owned files require access via agent (EDIT permission for deletion)
- If
agent_idis provided, checks if user has access to delete files via that agent
Error Responses
- 204 No Content: Nothing provided to delete
- 403 Forbidden: User lacks access to delete one or more files
- 500 Internal Server Error: Deletion failed
File Sources
LibreChat supports multiple file storage strategies:| Source | Description |
|---|---|
local | Local filesystem storage |
s3 | AWS S3 bucket |
azure_blob | Azure Blob Storage |
firebase | Firebase Storage |
openai | OpenAI API file storage |
azure | Azure OpenAI file storage |
vectordb | Vector database (for embeddings) |
execute_code | Code execution output files |
mistral_ocr | Mistral OCR processed files |
text | Text extraction service |
document_parser | Document parsing service |
File Contexts
Files can have different contexts indicating their usage:| Context | Description |
|---|---|
message_attachment | Temporary file attached to a message |
agents | File uploaded to an agent’s tool resources |
assistants | File uploaded to an assistant |
assistants_output | File generated by an assistant |
execute_code | Code execution output |
image_generation | Generated image |
avatar | User or agent avatar image |
Common Error Codes
| Status Code | Description |
|---|---|
| 400 | Bad Request - Invalid file format, exceeds limits, or invalid parameters |
| 401 | Unauthorized - Invalid or missing JWT token |
| 403 | Forbidden - User lacks permission to access or modify the file |
| 404 | Not Found - File or agent/assistant not found |
| 429 | Too Many Requests - Rate limit exceeded |
| 500 | Internal Server Error - Upload, download, or deletion failed |
| 501 | Not Implemented - Storage strategy doesn’t support the operation |