Skip to main content

Process Documents with AI in 5 Minutes

Upload a document and extract insights using Gemini.

What You'll Build

Upload PDF → Read Content → Generate Summary

The Workflow

{
"init_params": {
"instruction": "Summarize this document in 3-5 bullet points. Focus on the key findings and conclusions."
},
"step_configs": {
"summarize": {
"model": "gemini-2.0-flash",
"activity": "gemini_file_reader",
"asset_path": "init_params.file_paths[0]",
"prompt_path": "init_params.instruction"
}
},
"steps": ["summarize"]
}

Try It

Option 1: Via API with file upload

curl -X POST "https://flows-api.jetty.io/api/v1/run-sync/your-collection/doc-summary" \
-H "Authorization: Bearer $JETTY_API_TOKEN" \
-F "bakery_host=https://dock.jetty.io" \
-F 'init_params={"instruction": "Summarize this document"}' \
-F "files=@/path/to/document.pdf"

Option 2: Via Jetty UI

  1. Create the task with the workflow above
  2. Run it and upload your file
  3. See the summary in the results

What You'll Learn

1. gemini_file_reader - Process any document

{
"activity": "gemini_file_reader",
"model": "gemini-2.0-flash",
"asset_path": "init_params.file_paths[0]",
"prompt": "Your instruction here"
}

Supported formats: PDF, Word docs, images, text files

2. File upload handling

When you upload files, they're available at:

  • init_params.file_paths[0] - First file
  • init_params.file_paths[1] - Second file
  • etc.

3. Gemini model options

ModelBest For
gemini-2.0-flashFast processing, general documents
gemini-2.5-proComplex analysis, accuracy-critical
gemini-1.5-flashLarge documents (1M+ tokens)

The Output

{
"summarize": {
"outputs": {
"text": "• Key finding 1: The study shows...\n• Key finding 2: Results indicate...\n• Conclusion: The research demonstrates..."
}
}
}

Extract Structured Data

Pull specific information into JSON:

{
"init_params": {
"instruction": "Extract the following from this invoice and return as JSON: invoice_number, date, total_amount, line_items (array of {description, quantity, price})"
},
"step_configs": {
"extract": {
"model": "gemini-2.0-flash",
"activity": "gemini_file_reader",
"asset_path": "init_params.file_paths[0]",
"prompt_path": "init_params.instruction"
}
},
"steps": ["extract"]
}

Chart and Table Extraction

Convert charts to data:

{
"init_params": {},
"step_configs": {
"extract": {
"model": "gemini-2.0-flash",
"activity": "gemini_file_reader",
"asset_path": "init_params.file_paths[0]",
"prompt": "Convert this chart to JSON. Return only valid JSON in format: { \"data\": [...] }. No markdown formatting."
}
},
"steps": ["extract"]
}

Document Translation

Translate while preserving formatting:

{
"init_params": {
"target_language": "Spanish"
},
"step_configs": {
"translate": {
"model": "gemini-2.5-pro",
"activity": "gemini_file_reader",
"asset_path": "init_params.file_paths[0]",
"prompt": "Translate this document to {{ init_params.target_language }}. Preserve all formatting, headings, and structure."
}
},
"steps": ["translate"]
}

Multi-Step Document Pipeline

Summarize, then answer questions:

{
"init_params": {
"questions": [
"What are the main conclusions?",
"What methodology was used?",
"What are the limitations?"
]
},
"step_configs": {
"summarize": {
"model": "gemini-2.0-flash",
"activity": "gemini_file_reader",
"asset_path": "init_params.file_paths[0]",
"prompt": "Provide a comprehensive summary of this document."
},
"qa": {
"model": "gemini-2.0-flash",
"activity": "litellm_chat",
"user_prompt": "Based on this document summary:\n\n{{ summarize.outputs.text }}\n\nAnswer these questions:\n{{ init_params.questions | join('\\n') }}"
}
},
"steps": ["summarize", "qa"]
}

Batch Document Processing

Process multiple documents using fan-out:

{
"init_params": {
"instruction": "Summarize this document in one paragraph."
},
"step_configs": {
"process_all": {
"activity": "list_emit_await",
"items_path": "init_params.file_paths",
"task_reference": {
"task_name": "single-doc-summary"
},
"data_mapping": {
"file_path": "{{ $item }}",
"instruction": "{{ init_params.instruction }}"
}
},
"collect": {
"activity": "extract_from_trajectories",
"trajectory_list_path": "process_all.outputs.trajectory_references",
"extract_keys": {
"file": "init_params.file_path",
"summary": "summarize.outputs.text"
}
}
},
"steps": ["process_all", "collect"]
}

Common Use Cases

Use CasePrompt Template
Contract review"Identify key terms, obligations, and potential risks in this contract."
Resume screening"Extract skills, experience years, and education. Rate fit for [role] on 1-10 scale."
Meeting notes"Extract action items, decisions made, and key discussion points."
Research papers"Summarize methodology, findings, and limitations. List cited sources."
Financial reports"Extract revenue, expenses, profit margins, and key financial metrics."

Next Steps