docs: Add file upload support documentation for flows

Document how to use crewai-files types in flow state for file uploads,
including CrewAI Platform integration with automatic file upload UI.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex
2026-03-28 23:39:30 -07:00
parent bce10f5978
commit 202ca028d6
2 changed files with 34 additions and 0 deletions

View File

@@ -134,6 +134,10 @@ result = flow.kickoff(
)
```
<Note type="info" title="CrewAI Platform Integration">
When deployed on CrewAI Platform, `ImageFile`, `PDFFile`, and other file-typed fields in your flow state automatically get a file upload UI. Users can drag and drop files directly in the Platform interface. Files are stored securely and passed to agents using provider-specific optimizations (inline base64, file upload APIs, or URL references depending on the provider).
</Note>
### With Standalone Agents
Pass files directly to agent kickoff:

View File

@@ -341,6 +341,36 @@ flow.kickoff()
By providing both unstructured and structured state management options, CrewAI Flows empowers developers to build AI workflows that are both flexible and robust, catering to a wide range of application requirements.
### File Inputs
When using structured state, you can include file-typed fields using classes from `crewai-files`. This enables file uploads as part of your flow's input:
```python
from crewai.flow.flow import Flow, start
from crewai_files import ImageFile, PDFFile
from pydantic import BaseModel
class OnboardingState(BaseModel):
document: PDFFile # File upload
cover_image: ImageFile # Image upload
title: str = "" # Text input
class OnboardingFlow(Flow[OnboardingState]):
@start()
def process_upload(self):
# Access files directly from state
print(f"Processing: {self.state.title}")
return self.state.document
```
When deployed on **CrewAI Platform**, file-typed fields automatically render as file upload dropzones in the UI. Users can drag and drop files, which are then passed to your flow.
**Kicking off with files via API:**
- **Multipart**: `POST /kickoff/multipart` with files embedded in the request
- **Separate upload**: `POST /files` first to upload files, then `POST /kickoff` with the returned URLs
API users can also pass URL strings directly to file-typed fields—Pydantic coerces them automatically.
## Flow Persistence
The @persist decorator enables automatic state persistence in CrewAI Flows, allowing you to maintain flow state across restarts or different workflow executions. This decorator can be applied at either the class level or method level, providing flexibility in how you manage state persistence.