Skip to content

Upload Files

Upload files for use with AI models and document processing.

Endpoint

POST /v1/files

Authentication

Authorization: Bearer gw_prod_...

Request

Headers

HeaderRequiredDescription
AuthorizationYesBearer token with API key
Content-TypeYesmultipart/form-data

Body Parameters

ParameterTypeRequiredDescription
filefileYesFile to upload
purposestringYesPurpose of file (see below)
metadataobjectNoCustom metadata

File Purposes

PurposeDescriptionMax Size
assistantsFor use with assistants512 MB
fine-tuneTraining data1 GB
batchBatch API input100 MB
documentDocument processing/OCR50 MB
audioAudio transcription25 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

StatusDescription
uploadedFile uploaded, not processed
processingFile being processed
processedProcessing complete
errorProcessing failed

Supported File Types

Documents

ExtensionMIME TypeMax Size
.pdfapplication/pdf50 MB
.docxapplication/vnd.openxmlformats-officedocument.wordprocessingml.document50 MB
.docapplication/msword50 MB
.txttext/plain10 MB
.mdtext/markdown10 MB
.htmltext/html10 MB
.csvtext/csv50 MB
.xlsxapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheet50 MB

Audio

ExtensionMIME TypeMax Size
.mp3audio/mpeg25 MB
.mp4audio/mp425 MB
.m4aaudio/m4a25 MB
.wavaudio/wav25 MB
.webmaudio/webm25 MB

Images

ExtensionMIME TypeMax Size
.pngimage/png20 MB
.jpgimage/jpeg20 MB
.gifimage/gif20 MB
.webpimage/webp20 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

CodeDescription
400Invalid file type or purpose
401Invalid API key
413File too large
415Unsupported media type
429Rate limit exceeded
507Storage quota exceeded

See Also

Built with reliability in mind.