Skip to main content
All integrationsBackground Jobs

Temporal Integration

Durable workflow orchestration for complex, multi-step AI pipelines.

The kit ships Celery + Redis for background jobs, which covers most async LLM/RAG workloads well. Temporal is a heavier alternative worth considering when workflows involve many steps, long-running human-in-the-loop waits, or need guaranteed exactly-once execution semantics.

Setup in 4 steps

  1. 1Run a Temporal server (Temporal Cloud or self-hosted) alongside your existing stack
  2. 2Install the temporalio Python SDK in your worker service
  3. 3Model multi-step pipelines (ingest → embed → review → notify) as a Temporal workflow instead of chained Celery tasks
  4. 4Keep simpler single-step background jobs on Celery — no need to migrate everything

What's included

  • Built-in retries, timeouts, and state persistence across long-running workflow steps
  • Handles human-in-the-loop waits (e.g. approval steps) cleanly with workflow signals
  • Full execution history for debugging complex multi-step AI pipelines
  • Coexists with Celery — use Temporal for orchestration-heavy flows, Celery for simple jobs

Code example

example.py
# app/workflows/document_pipeline.py
from temporalio import workflow

@workflow.defn
class DocumentPipeline:
    @workflow.run
    async def run(self, doc_id: str) -> str:
        await workflow.execute_activity(ingest_document, doc_id, start_to_close_timeout=300)
        await workflow.execute_activity(extract_structured_data, doc_id, start_to_close_timeout=300)
        await workflow.execute_activity(notify_completion, doc_id, start_to_close_timeout=30)
        return "complete"

Full documentation: /docs/background-jobs

Temporal integration pre-wired and ready.

FastAPI AI Kit ships with Temporal configured out of the box. No manual setup required.

Ready to ship your AI backend this weekend?

Join developers who skipped weeks of boilerplate and went straight to building.

Read the docs
No subscriptions · One-time payment · Lifetime updates