Appearance
Upload Files
Upload files for use with AI models and document processing.
Endpoint
POST /v1/filesAuthentication
Authorization: Bearer gw_prod_...Request
Headers
| Header | Required | Description |
|---|---|---|
Authorization | Yes | Bearer token with API key |
Content-Type | Yes | multipart/form-data |
Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
file | file | Yes | File to upload |
purpose | string | Yes | Purpose of file (see below) |
metadata | object | No | Custom metadata |
File Purposes
| Purpose | Description | Max Size |
|---|---|---|
assistants | For use with assistants | 512 MB |
fine-tune | Training data | 1 GB |
batch | Batch API input | 100 MB |
document | Document processing/OCR | 50 MB |
audio | Audio transcription | 25 MB |
Examples
Basic Upload
bash
curl -X POST https://api.gateflow.ai/v1/files \
-H "Authorization: Bearer gw_prod_..." \
-F "file=@document.pdf" \
-F "purpose=document"Python
python
import openai
client = openai.OpenAI(
base_url="https://api.gateflow.ai/v1",
api_key="gw_prod_..."
)
with open("document.pdf", "rb") as f:
file = client.files.create(
file=f,
purpose="document"
)
print(f"File ID: {file.id}")
print(f"Status: {file.status}")With Metadata
python
import requests
with open("contract.pdf", "rb") as f:
response = requests.post(
"https://api.gateflow.ai/v1/files",
headers={"Authorization": "Bearer gw_prod_..."},
files={"file": f},
data={
"purpose": "document",
"metadata": '{"client": "acme", "type": "contract", "year": "2026"}'
}
)
file = response.json()
print(f"File ID: {file['id']}")Upload for Document Processing
python
# Upload document for OCR and vector storage
file = client.files.create(
file=open("report.pdf", "rb"),
purpose="document",
extra_body={
"gateflow": {
"process": True, # Enable OCR processing
"vectorize": True, # Add to vector store
"detect_pii": True, # Scan for PII/PHI
"collection": "legal-docs" # Target collection
}
}
)
print(f"File ID: {file.id}")
print(f"Processing: {file.status}")Upload Audio for Transcription
python
file = client.files.create(
file=open("meeting.mp3", "rb"),
purpose="audio",
extra_body={
"gateflow": {
"auto_transcribe": True,
"language": "en",
"speaker_diarization": True
}
}
)Response
json
{
"id": "file-abc123",
"object": "file",
"bytes": 1024000,
"created_at": 1708099200,
"filename": "document.pdf",
"purpose": "document",
"status": "uploaded",
"status_details": null,
"metadata": {
"client": "acme",
"type": "contract"
},
"gateflow": {
"processing": true,
"process_id": "proc_xyz789"
}
}Status Values
| Status | Description |
|---|---|
uploaded | File uploaded, not processed |
processing | File being processed |
processed | Processing complete |
error | Processing failed |
Supported File Types
Documents
| Extension | MIME Type | Max Size |
|---|---|---|
.pdf | application/pdf | 50 MB |
.docx | application/vnd.openxmlformats-officedocument.wordprocessingml.document | 50 MB |
.doc | application/msword | 50 MB |
.txt | text/plain | 10 MB |
.md | text/markdown | 10 MB |
.html | text/html | 10 MB |
.csv | text/csv | 50 MB |
.xlsx | application/vnd.openxmlformats-officedocument.spreadsheetml.sheet | 50 MB |
Audio
| Extension | MIME Type | Max Size |
|---|---|---|
.mp3 | audio/mpeg | 25 MB |
.mp4 | audio/mp4 | 25 MB |
.m4a | audio/m4a | 25 MB |
.wav | audio/wav | 25 MB |
.webm | audio/webm | 25 MB |
Images
| Extension | MIME Type | Max Size |
|---|---|---|
.png | image/png | 20 MB |
.jpg | image/jpeg | 20 MB |
.gif | image/gif | 20 MB |
.webp | image/webp | 20 MB |
GateFlow Extensions
Auto-Processing
python
file = client.files.create(
file=open("document.pdf", "rb"),
purpose="document",
extra_body={
"gateflow": {
"process": True,
"ocr_model": "mistral-document-ai",
"vectorize": True,
"embedding_model": "text-embedding-3-large",
"chunk_size": 1000,
"chunk_overlap": 200
}
}
)Data Classification
python
file = client.files.create(
file=open("medical_record.pdf", "rb"),
purpose="document",
extra_body={
"gateflow": {
"classification": "phi", # public, internal, confidential, restricted, phi
"detect_pii": True,
"compliance_regime": "hipaa"
}
}
)Errors
| Code | Description |
|---|---|
| 400 | Invalid file type or purpose |
| 401 | Invalid API key |
| 413 | File too large |
| 415 | Unsupported media type |
| 429 | Rate limit exceeded |
| 507 | Storage quota exceeded |
See Also
- List Files - List uploaded files
- File Operations - Get, delete, download
- Document Ingestion - Processing guide