v0.1.0 — Production Ready

Composable LLM reasoning patterns

More power than one-off prompts, less weight than a framework. Budget-aware execution with zero runtime dependencies.

$ pip install executionkit

See it in action

Run five LLM completions in parallel, get the consensus answer with cost tracking — in three lines.

import os
from executionkit import consensus, Provider
provider = Provider(
"https://api.openai.com/v1",
api_key=os.environ["OPENAI_API_KEY"],
model="gpt-4o-mini",
)
result = await consensus(provider, "Classify this support ticket: ...", num_samples=5)
print(result) # The classification
print(result.cost) # TokenUsage(input_tokens=250, output_tokens=45, llm_calls=5)
print(result.metadata["agreement_ratio"]) # 0.8 — 4 of 5 agreed

Built for production

Three composable patterns that handle the hard parts of LLM reasoning.

🗳️

Consensus Voting

Run N completions in parallel, aggregate via majority or unanimous voting. Whitespace-normalized comparison ensures accuracy.

🔄

Iterative Refinement

Score-guided improvement loop with convergence detection. Built-in prompt injection defense via XML sandboxing.

🔧

Tool-Calling Loop

Think-act-observe ReAct loop with JSON Schema validation. Tool errors become observations, never crash the loop.

💰

Budget Tracking

Per-call and cumulative token usage. Set hard limits with max_cost to prevent runaway spend.

📦

Zero Dependencies

Pure stdlib. Optional httpx for connection pooling. Works anywhere Python 3.11+ runs.

🔌

Any Provider

OpenAI, Ollama, Groq, Together AI, GitHub Models — anything speaking the OpenAI-compatible format.

Compose patterns into pipelines

Chain consensus → refine_loop with pipe(). Costs accumulate automatically.

graph LR
    A[User Prompt] --> B(consensus)
    B --> C(refine_loop)
    C --> D(react_loop)
    D --> E[PatternResult]
    style A fill:#1c2128,stroke:#39d353,color:#e6edf3
    style B fill:#1c2128,stroke:#f0883e,color:#e6edf3
    style C fill:#1c2128,stroke:#f0883e,color:#e6edf3
    style D fill:#1c2128,stroke:#f0883e,color:#e6edf3
    style E fill:#1c2128,stroke:#39d353,color:#e6edf3
Patterns chain via pipe() — each result's value becomes the next prompt
from executionkit import pipe, consensus, refine_loop
from functools import partial
result = await pipe(
provider,
"Explain gradient descent in simple terms.",
consensus,
partial(refine_loop, target_score=0.9),
)
print(result) # Final refined value
print(result.cost) # Cumulative cost across both steps

Works everywhere

Any OpenAI-compatible endpoint. Zero config change between providers.

OpenAI
api.openai.com
Ollama
localhost:11434
Groq
api.groq.com
Together AI
api.together.xyz
GitHub Models
models.inference.ai.azure.com
Any OpenAI-compat
your-endpoint.com