Introduction
Upload files to use with the Incredible agentic model. This system uses pre-signed upload URLs for fast, direct client-to-storage uploads that bypass your server, then automatically processes files to extract metadata and content.Best Practice: Upload Once, Reuse ForeverUpload files once during setup or when users first add them. Store the
file_id and reuse it across unlimited chat requests. Avoid re-uploading the same file repeatedly—this wastes time and resources.Quick Start
The Flow:- Request an upload URL → get
file_idandupload_url - Upload file directly to storage using the URL (fast, no server bottleneck)
- Confirm upload → triggers automatic processing
- Store the
file_idand reuse it in unlimited chat requests
- Fast uploads: Files go directly to storage, not through your API server
- Upload once, use many times: After uploading, reference files by ID in unlimited chat requests—no need to re-upload
- Automatic processing: Files are analyzed on confirmation (PDFs get OCR’d, CSVs parsed, images analyzed)
- Efficient & cost-effective: Each file is processed once, then instantly available for all future requests
Complete Flow Example
Upload Once, Use Many Times
Building a File Library System
Here’s how to implement a proper file management system that uploads once and reuses forever:- Check before uploading: Always check if file already exists in your database
- Store file_ids permanently: Save them alongside user data
- Show file library to users: Let them see and select previously uploaded files
- Reuse indefinitely: Never re-upload the same file
File Processing
Files are automatically processed when you call/confirm-upload. Here’s what happens for each file type:
| File Type | Processing | Metadata Extracted |
|---|---|---|
| CSV | Parse structure | Columns, row count, data types, preview |
| Excel (.xlsx, .xls) | Parse sheets | Sheet names, columns per sheet, row counts |
| OCR text extraction | Page count, extracted text, text length | |
| Images (.png, .jpg, .gif, .webp) | Analyze dimensions | Width, height, format, file size |
| JSON | Parse structure | Keys, depth, structure overview |
| Text (.txt, .md) | Read content | Character count, line count, preview |
Supported File Types
✅ Spreadsheets:.csv, .xlsx, .xls✅ Documents:
.pdf, .txt, .md✅ Data:
.json, .xml
File Size Limits:
- Maximum file size: 50 MB
- For larger files, contact support
Using Files in Chat Completions
After uploading and confirming files once, attach them to any number of messages usingfile_ids:
Reuse Files Across SessionsThe same
file_id can be used:- In multiple messages within a conversation
- Across different conversations
- By the same user indefinitely
- No expiration—files remain available until deleted
- File metadata (columns, row counts, structure)
- Content previews (first rows of CSV, PDF text excerpts)
- Full file access in the sandboxed Python environment
Best Practices
-
🔄 Upload once, reuse forever (MOST IMPORTANT):
- Upload files once when users first add them or during setup
- Store the
file_idin your database or application state - Reuse the same
file_idacross unlimited chat requests - Never re-upload the same file—this is inefficient and unnecessary
-
💾 Persist file_ids:
- Save
file_idvalues in your database alongside user data - Build a file management system in your app to track uploaded files
- Display previously uploaded files to users so they can reuse them
- Save
-
⏱️ Upload proactively:
- Upload files during onboarding or when users first connect data sources
- Process files in the background, not during chat sessions
- This ensures files are ready instantly when users start conversations
-
✓ Wait for confirmation: Always call
/confirm-uploadbefore using the file in chat - ⏰ Handle upload URL expiry: Request new URLs if upload takes longer than 60 seconds
- 📝 Set correct Content-Type: Helps with proper file processing
- 📏 Check file size: Validate size client-side before requesting upload URL
Security & Privacy
- Authentication required: All endpoints require valid API key (except the pre-signed upload URL itself)
- File isolation: Users can only access their own files
- Temporary URLs: Upload URLs expire quickly to prevent unauthorized access
- Sandboxed execution: Files are processed in isolated environments
- No file sharing: Files are private to the uploading user
Related Documentation
- Chat Completion API - Using files in chat completions
- OCR API - PDF text extraction details
- Integrations API - Working with integration outputs