Sign inSign up

kruxia/kruxiaflow

By kruxia

•Updated about 1 month ago

AI-native durable workflow engine with built-in LLM cost tracking. Single binary, runs everywhere.

Image
0

4.3K

kruxia/kruxiaflow repository overview

⁠Kruxia Flow

AI-native durable workflows that run everywhere

A lightweight, high-performance workflow engine designed for AI applications. Track every token, cache intelligently, and never exceed your LLM budget. Single Rust binary (7.5MB), 63MB Docker image, PostgreSQL as the only dependency.

⁠Quick Start

# Start Kruxia Flow with PostgreSQL and Redis
docker compose up -d

# Or run the image directly (provide your own PostgreSQL)
docker run -d \
  -e DATABASE_URL=postgres://user:pass@host:5432/kruxiaflow \
  -e KRUXIAFLOW_CLIENT_ID=my-client \
  -e KRUXIAFLOW_CLIENT_SECRET=my-secret \
  -p 8080:8080 \
  kruxia/kruxiaflow:latest serve

For a complete setup with examples:

git clone https://github.com/kruxia/kruxiaflow.git
cd kruxiaflow
./docker up --examples

API docs are available at http://localhost:8080/api/v1/docs.

⁠What is Kruxia Flow?

Kruxia Flow is a durable execution engine — workflows survive crashes, retries are automatic, and state is persistent. It combines workflow orchestration with AI-native features: LLM cost tracking, budget enforcement, multi-provider model fallback, and token streaming.

⁠Key Features
  • Durable Execution — Workflows persist state in PostgreSQL with event sourcing. Automatic recovery and retry on crashes. Exactly-once semantics for activity execution.
  • LLM Cost Tracking — Real-time cost estimation before running LLM activities. Per-activity and per-workflow budget limits with automatic enforcement.
  • Budget-Aware Model Fallback — Specify a list of models in priority order; automatically falls back to cheaper models when budget is constrained.
  • Multi-Provider LLM Support — Anthropic (Claude), OpenAI (GPT), Google (Gemini), Ollama (self-hosted).
  • Token Streaming — Real-time LLM token streaming via WebSocket with per-token cost tracking.
  • Result Caching — Redis-backed caching of activity results to avoid redundant LLM calls.
  • DAG Workflows — YAML-defined directed acyclic graphs with parallel fan-out/fan-in execution.
  • Human-in-the-Loop — Signal activities to pause workflows for user input.
  • Language-Agnostic Workers — HTTP worker protocol lets any language implement custom activities.
  • Python SDK — pip install kruxiaflow

⁠Image Details

DetailValue
Base Imagedistroless/cc-debian12:nonroot
Image Size63MB
Binary Size7.5MB
Rust Version1.90+
Architecturelinux/amd64
Usernonroot (non-root by default)

⁠CLI Commands

The kruxiaflow binary supports multiple subcommands:

CommandDescription
serveStart all services (API + Orchestrator + Worker)
apiRun only the API server
orchestratorRun only the orchestrator
workerRun only the activity worker
migrateRun database migrations
seed-clientCreate OAuth client credentials (idempotent)
seed-llmLoad LLM pricing catalog
healthHealth check probe
statusWorkflow execution status monitoring
versionShow version info

⁠Environment Variables

⁠Required
VariableDescription
POSTGRES_PASSWORDPostgreSQL password
KRUXIAFLOW_CLIENT_IDOAuth client ID
KRUXIAFLOW_CLIENT_SECRETOAuth client secret
⁠Optional
VariableDefaultDescription
DATABASE_URL(see below)PostgreSQL connection string
KRUXIAFLOW_PORT8080API server port
KRUXIAFLOW_WORKER_COUNT20Number of worker threads
KRUXIAFLOW_CACHE_PROVIDERredisCache backend (redis/memory)
KRUXIAFLOW_REDIS_URL—Redis connection URL
KRUXIAFLOW_LOG_LEVELinfoLog level (trace/debug/info/warn/error)
KRUXIAFLOW_WORKER_POLL_INTERVAL_MS100Worker poll frequency (ms)
ANTHROPIC_API_KEY—Anthropic API key (for Claude)
OPENAI_API_KEY—OpenAI API key
GOOGLE_API_KEY—Google API key (for Gemini)

⁠Dependencies

  • Required: PostgreSQL 17+
  • Optional: Redis 7.4+ (for activity result caching)

⁠Performance

Benchmarked against industry-standard workflow engines (January 2026):

MetricKruxia FlowTemporalAirflow
Throughput (wf/sec)93668
P99 Latency0.9–1.5s0.5–2.7s6–22s
Peak Memory328MB425MB7.2GB
Docker Image63MB~500MB~1GB+

⁠Example Workflow

name: content_moderation
activities:
  - key: moderate
    activity_name: llm_prompt
    parameters:
      model: anthropic/claude-sonnet-4-5-20250929
      prompt: "Review this content for policy violations: {{INPUT.content}}"
      max_tokens: 500
    settings:
      budget:
        limit_usd: 0.50
        action: abort

See the examples directory⁠ for 10+ production-ready workflows covering HTTP requests, parallel execution, LLM cost tracking, model fallback, caching, agentic loops, token streaming, and more.

Tag summary

Content type

Image

Digest

sha256:b4b43f857…

Size

14.7 MB

Last updated

3 months ago

docker pull kruxia/kruxiaflow