docs: add file upload to kickoff guide, clarify flow state population, all languages

- Added new "File Uploads" section to kickoff-crew.mdx with multipart,
  JSON URL, and separate upload + kickoff examples
- Clarified that file-typed fields in flow state schema signal the
  Platform UI to render file dropzones
- Updated flows.mdx File Inputs section to show state population pattern
- Updated files.mdx With Flows section with state schema example
- Applied all changes to en, ar, ko, pt-BR translations

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Alex
2026-04-06 00:34:05 -07:00
committed by Joao Moura
parent f01f33de69
commit 50c4b6e99f
12 changed files with 316 additions and 64 deletions

View File

@@ -117,20 +117,28 @@ task = Task(
### With Flows
Pass files to flows, which automatically inherit to crews:
File-typed fields (`File`, `ImageFile`, `PDFFile`) in your flow's state schema serve as the signal to the Platform UI. When deployed, these fields render as file upload dropzones. Files can also be passed via `input_files` in the API.
```python
from crewai.flow.flow import Flow, start
from crewai_files import ImageFile
from crewai_files import File, ImageFile
from pydantic import BaseModel
class AnalysisFlow(Flow):
class MyState(BaseModel):
document: File # Renders as file dropzone in Platform UI
cover_image: ImageFile # Image-specific dropzone
title: str = ""
class AnalysisFlow(Flow[MyState]):
@start()
def analyze(self):
# Files are automatically populated in state
content = self.state.document.read()
return self.analysis_crew.kickoff()
flow = AnalysisFlow()
result = flow.kickoff(
input_files={"image": ImageFile(source="data.png")}
input_files={"document": File(source="report.pdf")}
)
```

View File

@@ -343,27 +343,28 @@ By providing both unstructured and structured state management options, CrewAI F
### 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:
When using structured state, you can include file-typed fields using classes from `crewai-files`. File-typed fields in your flow state serve as the signal to the Platform—they automatically render as file upload dropzones in the Run tab UI and get populated when files are uploaded via the Platform or passed via `input_files` in the API.
```python
from crewai.flow.flow import Flow, start
from crewai_files import ImageFile, PDFFile
from crewai_files import File, ImageFile, PDFFile
from pydantic import BaseModel
class OnboardingState(BaseModel):
document: PDFFile # File upload
cover_image: ImageFile # Image upload
title: str = "" # Text input
class MyState(BaseModel):
document: File # Renders as file dropzone in Platform
title: str = ""
class OnboardingFlow(Flow[OnboardingState]):
class MyFlow(Flow[MyState]):
@start()
def process_upload(self):
# Access files directly from state
print(f"Processing: {self.state.title}")
return self.state.document
def process(self):
# File object is automatically populated in state
# when uploaded via Platform UI or passed via API
content = self.state.document.read()
print(f"Processing {self.state.title}: {len(content)} bytes")
return content
```
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.
When deployed on **CrewAI Platform**, file-typed fields (`File`, `ImageFile`, `PDFFile` from `crewai-files`) automatically render as file upload dropzones in the UI. Users can drag and drop files, which are then populated into your flow's state.
**Kicking off with files via API:**

View File

@@ -86,6 +86,60 @@ curl -H "Authorization: Bearer YOUR_CREW_TOKEN" https://your-crew-url.crewai.com
Your bearer token is available on the Status tab of your crew's detail page.
## File Uploads
When your crew or flow includes file-typed state fields (using `ImageFile`, `PDFFile`, or `File` from `crewai-files`), these fields automatically render as file upload dropzones in the Run tab UI. Users can drag and drop files directly, and the Platform handles storage and delivery to your agents.
### Multipart Kickoff (Recommended)
Send files directly with the kickoff request using `multipart/form-data`:
```bash
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'inputs={"title": "Report"}' \
-F 'document=@/path/to/file.pdf'
```
Files are automatically stored and converted to file objects. The agent receives the file with provider-specific optimization (inline base64, file upload API, or URL reference depending on the LLM provider).
### JSON Kickoff with File URLs
If you have files already hosted at URLs, pass them via `input_files`:
```bash
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{
"inputs": {"title": "Report"},
"input_files": {"document": "https://example.com/file.pdf"}
}'
```
### Separate Upload + Kickoff
Upload files first, then reference them by URL:
```bash
# Step 1: Upload
curl -X POST https://your-deployment.crewai.com/files \
-H 'Authorization: Bearer YOUR_TOKEN' \
-F 'file=@/path/to/file.pdf' \
-F 'field_name=document'
# Returns: {"url": "https://...", "field_name": "document"}
# Step 2: Kickoff with URL
curl -X POST https://your-deployment.crewai.com/kickoff \
-H 'Authorization: Bearer YOUR_TOKEN' \
-H 'Content-Type: application/json' \
-d '{"inputs": {"title": "Report"}, "input_files": {"document": "https://..."}}'
```
<Note type="info">
File uploads work the same way for both crews and flows. Define file-typed fields in your state schema, and the Platform UI and API will handle uploads automatically.
</Note>
### Checking Crew Health
Before executing operations, you can verify that your crew is running properly: