Skip to content

About

Public examples of Render Workflows in Python built by the Render team

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Latest commit

 

History

145 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Render Workflow Examples (Python)

A curated collection of production-ready workflow examples demonstrating various use cases for Render Workflows. Each example is self-contained, deployment-ready, and showcases different patterns and capabilities.

Overview

These examples demonstrate how to build robust, scalable workflows using Render's Python SDK. All examples follow best practices for production deployments and include comprehensive documentation.

Render Workflows support both Python and TypeScript. This repo contains Python examples using the render package, deployed as Workflow services on Render.

Examples

New to Workflows? Start with Hello World — it covers the core concepts with minimal complexity.

Quick Comparison

Example Use Case Key Patterns Extra Dependencies
Hello World Learn workflow basics with simple number processing Task definition, subtask calling with ctx.run, basic orchestration None
ETL Job Process CSV data with validation and statistics Subtasks, sequential processing, batch operations, data validation None
OpenAI Agent Loop Customer support agent whose loop runs as workflow tasks Tool calling, nested subtasks (3 levels deep), stateful workflows, dynamic orchestration openai
File Processing Batch process multiple file formats in parallel Parallel execution with asyncio.gather(), multi-format handling, aggregation None
Data Pipeline Multi-source customer analytics pipeline Parallel extraction, data enrichment, combining parallel + sequential patterns httpx
File Analyzer API service calling workflow tasks for file analysis Client SDK + Task SDK, workflow slugs, service separation, FastAPI integration fastapi, uvicorn
OpenAI Agents SDK Support-ticket triage agent with handoffs Agents SDK inside a task, fan-out per ticket, typed results, retry only the model task openai-agents
Sandbox Fan-out Run untrusted jobs in parallel, one Render Sandbox per job Sandboxes from a task, deny-all networking, retry in a new sandbox, capped fan-out, cleanup in finally None (render only)
Batch OCR OCR over many scanned PDFs with Tesseract and Poppler Docker-based workflow service, per-task compute plans, fan-out in chunks, error classification httpx, Tesseract, Poppler
Voice Pipeline Answer a recorded voice message with STT, an LLM and TTS One task per step, chaining with ctx.run, audio passed as base64 under the 4 MB argument cap, retry each step and not the orchestrator openai
Web Service API The smallest correct web service in front of a workflow Start a task from an API and return 202, idempotency keys, read status and result by run ID, 400 for bad input fastapi, uvicorn
Idempotent Side Effects Retry an LLM call without repeating a refund credit Separate tasks for the model call and the side effect, idempotency keys from business input, ON CONFLICT DO NOTHING, an injected failure to watch the retry openai, psycopg
Order Saga Checkout that refunds and releases stock when a later step fails Flows with checkpointed steps, replay after a crash, compensating steps, idempotency keys None
Browser Screenshots Check many web pages with headless Chromium Playwright on the native runtime, fan-out with a concurrency cap, retries per URL, small outputs playwright
Monte Carlo Price an option with tens of millions of simulated paths Fan-out across 8c-32g task runs, a process pool per run, reproducible seeds, map-reduce with a confidence interval numpy
Content Moderation Moderate user posts (text and images): approve, flag for review, or reject Fan-out per post with a concurrency cap, retries on the API calls only, policy decisions and permanent errors returned as results openai, httpx2
Webhook Processing Receive GitHub webhooks and process each delivery exactly once Signature verification, fast ack, starting tasks from a web service, dedupe by delivery ID, retries, replay fastapi, uvicorn, psycopg
Product Image Import Bulk-import product images from URLs Fan-out per image with a concurrency cap, Pillow variants (WebP/AVIF) and blurhash, vision-model alt text with structured output, failed rows instead of a failed batch pillow, blurhash, openai
ffmpeg Transcode Video to HLS renditions and thumbnails ffmpeg from the native runtime, per-task compute plan (4c-16g), long timeouts, retry only the transcode task None
Postgres Backfill Fill a new column across a large Postgres table, resumably Flows with one checkpointed step per chunk, per-step retries, idempotent keyset writes, resume after a failed run psycopg
PDF Extraction Extract invoice fields from text-layer PDFs with an LLM Structured Outputs with page numbers, bounded re-prompts, exceptions for review, idempotency keys, Postgres upsert openai, pypdf, psycopg
Pi coding agent Coding agent that fixes a support ticket in a cloned repo TypeScript only: Pi's SDK has no Python package. Points to the TypeScript example None
Claude Agent SDK Support-ticket triage agent with custom tools Agent SDK inside a task, in-process MCP tools, structured output, fan-out per ticket, retry only the model task claude-agent-sdk
AI Chat Turns Chat app where each turn is a workflow task Start a task from a web service, one turn per conversation, idempotency keys, finishing turns after a restart openai-agents, fastapi, psycopg
LLM Evals Compare OpenAI and Anthropic models with an LLM judge Fan-out per model × case, per-provider concurrency cap, structured judge verdicts, scorecard openai, anthropic

1. Hello World

The simplest possible workflow — learn the fundamentals through simple number processing.

  • Ultra-simple task definitions
  • Clear ctx.run subtask examples
  • Subtasks in loops demonstration
  • Multi-step workflow orchestration
  • Heavily commented code explaining every pattern

If you're new to Render Workflows, start here. No CSV files, no APIs, no databases — just pure workflow patterns.

View Hello World Example →

2. ETL Job

Complete Extract, Transform, Load pipeline — process customer data from CSV files with validation, cleaning, and statistical analysis.

  • CSV data extraction with retry logic
  • Record validation and error tracking
  • Batch processing with subtasks
  • Statistical aggregation
  • Comprehensive error handling

View ETL Job Example →

3. OpenAI Agent Loop

Intelligent conversational agent — a customer support bot that can answer questions, look up orders, and process refunds.

  • Multi-turn conversations with context
  • Dynamic tool/function calling
  • Stateful workflow management
  • Integration with the OpenAI Responses API (model set by OPENAI_MODEL)
  • Extensible tool framework

View OpenAI Agent Loop Example →

4. File Processing

Parallel file processing — batch process files from storage, analyze content, and generate consolidated reports.

  • Multi-format support (CSV, JSON, text)
  • Parallel file processing
  • Automatic content analysis
  • Report generation
  • Format-specific insights

View File Processing Example →

5. Data Pipeline

Multi-source data pipeline — build customer analytics by combining data from user service, transaction service, and analytics platform.

  • Multi-source parallel extraction
  • Data enrichment with external APIs
  • Complex transformations
  • User segmentation
  • Aggregate insights generation

View Data Pipeline Example →

6. File Analyzer

Complete Client SDK + Task SDK integration — a file analysis API with separate workflow and API services.

  • Two-service architecture: Workflow service (Task SDK) + API service (Client SDK)
  • Workflow slug pattern ({service-slug}/{task-name} routing)
  • Client SDK usage for calling workflow tasks remotely
  • File analysis pipeline: Parse → Statistics → Trends → Insights
  • FastAPI integration with HTTP endpoints triggering workflow tasks

The only example that shows both Task SDK and Client SDK together — ideal for understanding how to build APIs that call workflow tasks.

View File Analyzer Example →

7. OpenAI Agents SDK

Run an agent built with the OpenAI Agents SDK as a workflow task: a support-ticket triage agent that hands off to Billing or Technical Support.

  • Agents SDK agent with tools and handoffs, running inside one task run
  • Typed agent output returned as JSON-safe task results
  • One task run per ticket with ctx.run and asyncio.gather
  • Errors a retry can't fix returned as results instead of raised

The SDK runs the agent loop inside a single task. Compare with OpenAI Agent, where every model call and tool call is its own task.

View OpenAI Agents SDK Example →

8. Sandbox Fan-out

Run untrusted code safely — a batch of jobs, each a Python script and an input CSV, runs in parallel with one Render Sandbox per job.

  • Create, use, and terminate sandboxes from a workflow task with the Render SDK
  • Copy a job's files into a sandbox and its result back out
  • Block all outbound network access for untrusted code
  • Raise on a nonzero exit code so Render retries the job in a new sandbox
  • Cap how many sandboxes run at once, and keep failed jobs in the batch summary

View Sandbox Fan-out Example →

9. Batch OCR

Read the text out of many scanned PDFs, one task run per document, on a workflow service that builds from a Dockerfile.

  • Docker-based workflow service with Tesseract and Poppler installed
  • Orchestrator on flex, OCR task on 2c-4g
  • Documents passed by reference (a URL or a file name), never as bytes
  • Bad input returned as a failed result, killed processes and network errors raised so Render retries them

View Batch OCR Example →

10. Voice Pipeline

Answer a recorded voice message: speech-to-text, a support agent's reply, and text-to-speech, each running as its own task.

  • One task per step (transcribe, reply, synthesize), chained by an orchestrator with ctx.run
  • Audio passed between tasks as base64, sized to stay under the 4 MB argument cap
  • Each step retries on its own; the orchestrator doesn't retry
  • A sample voice message and a client script that saves the spoken reply

View Voice Pipeline Example →

11. Web Service API

The smallest correct way to put a web service in front of a workflow: a FastAPI service starts a task and reports its status. The task builds a report from bundled data, so it needs no API keys.

  • POST /jobs starts the task with a client-supplied idempotency key and returns 202 with the run ID
  • GET /jobs/{run_id} returns the run's status and result, or 404
  • Bad input gets a 400 and never becomes a task run
  • No database: Render keeps results for 30 days

View Web Service API Example →

12. Idempotent Side Effects

A refund flow that drafts its decision with OpenAI and then issues a refund credit exactly once, even when the task that issues it fails after the write and Render retries it.

  • The model call and the side effect are separate tasks with their own retries
  • The idempotency key comes from the account and order, not the run or attempt
  • Postgres INSERT ... ON CONFLICT DO NOTHING on that key, plus the same key for providers like Stripe
  • A switch that fails the credit task once, right after the write, to watch the retry skip it

View Idempotent Side Effects Example →

13. Order Saga

A checkout built as a flow: reserve inventory, charge the payment, create the shipment, and undo the finished steps in reverse when a later one fails for good.

  • @app.flow and ctx.step, with each step's result checkpointed
  • A simulated crash after the charge: Render replays the flow and the finished steps aren't run again
  • Compensating steps (refund, release) that run newest first, after a declined card or a carrier outage
  • Idempotency keys on every call that changes something, and on the flow run

The payment and shipping services are in-process fakes, so it runs with no accounts or keys.

View Order Saga Example →

14. Browser Screenshots

Check many web pages with headless Chromium: one task run per URL records the status code, title, load time, console errors and broken images, and takes a screenshot.

  • Playwright's headless Chromium installed at build time into the project, no Docker image
  • One task run per URL, with a concurrency cap in code (Render has no per-task cap)
  • Retries per URL for timeouts and 5xx; bad URLs and unknown hosts come back as results
  • Small outputs back (a 320 px JPEG thumbnail per page); shows where a real app would upload full screenshots to object storage

View Browser Screenshots Example →

15. Monte Carlo

Price an Asian call option by simulating tens of millions of price paths with numpy, fanned out across 8 CPU / 32 GB task runs.

  • The chunk task on 8c-32g, using all 8 CPUs through a process pool; the orchestrator on flex
  • Reproducible seeds per block of paths, so a fanned-out run and a single run return the same price
  • Map-reduce over task runs into a price with a 95% confidence interval and a Black-Scholes check
  • Measured on Render: 50 million paths in 198 s on one flex run, 13.4 s across four 8c-32g runs
  • Safe retries on the pure, deterministic chunk task; none on the fan-out

View Monte Carlo Example →

16. Content Moderation

Moderate user-generated posts with the OpenAI moderation endpoint: each post runs in its own task run, a two-threshold policy approves, flags for review, or rejects it, and flagged posts get a short note for the human reviewer.

  • One task run per post with ctx.run and asyncio.gather, capped by a semaphore
  • Retries on the tasks that call OpenAI or download images; the fan-out task doesn't retry
  • Policy decisions and errors a retry can't fix (missing image, unknown model) returned as results
  • A conditional second step: only flagged posts get a reviewer note from a chat model

View Content Moderation Example →

17. Webhook Processing

A GitHub webhook receiver that answers in milliseconds and leaves the work to a workflow task.

  • Verifies X-Hub-Signature-256 against the raw body
  • Stores each delivery in Postgres and starts a task with only the delivery ID
  • A redelivery of a processed delivery is a no-op, and a retried task can't apply a delivery twice
  • Replays deliveries that were stored but never processed

It needs Postgres. Locally, a script sends signed test deliveries; once deployed, GitHub sends real ones.

View Webhook Processing Example →

18. Product Image Import

Import product images from a list of URLs: resized JPEG, WebP and AVIF variants, a blurhash placeholder, and alt text from an OpenAI vision model.

  • One process_image and one generate_alt_text task run per image, fanned out with a concurrency cap
  • Pillow on Render's native runtime, no Docker image
  • Retries on the tasks that download or call the model, none on the fan-out
  • Bad URLs and files that aren't images come back as failed rows in the manifest
  • Small outputs only (variant sizes, blurhash, a tiny thumbnail); shows where a real app would upload variants to object storage

View Product Image Import Example →

19. ffmpeg Transcode

Turn source videos into HLS renditions (720p, 480p, 360p) and thumbnails with ffmpeg, one task run per video.

  • ffmpeg and ffprobe from Render's native runtime, no Docker image
  • The transcode task on 4c-16g with a 3-hour timeout; the fan-out task on flex
  • Retries on the transcode task only, none on the fan-out
  • Videos in by URL, small outputs back (base64 thumbnails, rendition sizes); shows where a real app would upload to object storage

View ffmpeg Transcode Example →

20. Postgres Backfill

Fill a new column across a large Postgres table in keyset chunks, as a flow where every chunk is a checkpointed step.

  • One ctx.step per chunk, so finished chunks are recorded and never redone by a retry or replay
  • Per-step retries: a failed chunk retries on its own
  • Idempotent writes (WHERE new_column IS NULL), so a chunk that runs twice writes nothing the second time
  • Progress in a Postgres table, and resuming a run that stopped partway from its last committed chunk

View Postgres Backfill Example →

21. PDF Extraction

Extract structured invoice fields from text-layer PDFs with an LLM inside a task, and save the results to Postgres.

  • Text layer read page by page with pypdf, from a URL or a bundled file
  • OpenAI Structured Outputs where every field carries the page it came from
  • Bounded re-prompts inside the task when the answer fails validation
  • Missing required fields and totals that don't add up returned as exceptions for review
  • A client that starts one run per document with an idempotency key and upserts each result into Postgres

View PDF Extraction Example →

22. Pi coding agent (TypeScript only)

Run the Pi coding agent inside a workflow task: clone a repository, fix the bug behind a support ticket, and return the change as a patch or a pushed branch.

Pi's SDK runs in Node.js and has no Python package, so this example lives in the TypeScript examples repository. The folder here points to it.

View Pi coding agent Example →

23. Claude Agent SDK

Run an agent built with the Claude Agent SDK as a workflow task: a support-ticket triage agent that checks orders and accounts with custom tools and returns a structured resolution.

  • Agent SDK agent with custom tools from an in-process MCP server, running inside one task run
  • Structured output returned as JSON-safe task results
  • A temporary working directory per run, and no built-in tools
  • One task run per ticket with ctx.run and asyncio.gather
  • Errors a retry can't fix returned as results instead of raised

The SDK runs the agent loop inside a single task. Compare with OpenAI Agent, where every model call and tool call is its own task.

View Claude Agent SDK Example →

24. AI Chat Turns

A chat app where each turn of a conversation runs as a workflow task: a FastAPI service stores messages in Postgres, a task writes each reply, and the API learns when the reply is ready.

  • Web service starts a task per turn and returns 202 right away
  • One turn at a time per conversation, enforced in Postgres
  • Idempotency keys on the task run and on the agent's write tool
  • Turns in flight when the API restarts still get recorded

View AI Chat Turns Example →

25. LLM Evals

Compare models on the same dataset: every model answers every support ticket in its own task run, an LLM judge grades each answer, and a parent task returns a scorecard per model.

  • One task run per model × case with ctx.run and asyncio.gather
  • A semaphore per provider caps model calls in flight, to stay under rate limits
  • Structured outputs from both OpenAI and Anthropic, including the judge's verdict
  • Retries on the model-calling tasks only; errors a retry can't fix returned as results

View LLM Evals Example →

About

Public examples of Render Workflows in Python built by the Render team

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages