Azathoth

Empirical optimization for context-aware AI workflows.
Azathoth is an open-source engine for building LLM workflows by composing
them rather than coding them, improving them with measured evidence rather
than intuition, and running them in production on your own infrastructure.
You describe a workflow as a JSON document:
- prompt steps that state model requirements instead of naming models;
- tool steps;
- child workflows, loops and maps;
- the dependencies, conditions and failure policies between them.
Azathoth runs it and benchmarks it. It searches for the models that pass your
benchmark at the latency and cost you target. It deploys only what you
deliberately promote, and runs it from a queue, a container or your own
program.
define ──► run ──► benchmark ──► optimize ──► promote ──► invoke production
Workflows Are Composed, Not Coded
Most LLM workflows are programs: prompts in source files, models as
constants, control flow as code. Every change, whether a new model, a
reworded prompt or an extra review step, goes through engineering.
Azathoth makes building a workflow a composition activity. That moves LLM
workflows out of engineering and into the hands of the teams who run and own
them:
- platform and DevOps teams operate workflows like infrastructure: versioned
revisions, explicit promotion, production state and an audit trail of
every invocation;
- domain experts define what a good answer is, as benchmark cases, exact
or judged by a model, and Azathoth measures every candidate against them;
- engineers write tools: small, versioned, tested units of
deterministic work that workflows compose.
Writing code should be for tools, not for LLM workflows.
Quickstart
Install it in a virtual environment. The install guide
explains why a venv, and gives the Windows commands:
python3 -m venv .venv
source .venv/bin/activate
python -m pip install azathoth-ai
azathoth --version
azathoth init
azathoth init creates the database and installs the standard tools that
ship in the package: run_workflow, loop_workflow and map_workflow
compose workflows from other workflows; json_select, json_object,
json_merge and validate_json reshape and check the JSON that passes
between steps; chunk_text, join_text and render_template split, join
and fill in text; split_s3_object and read_s3_object work with data in
S3 too large to pass between steps; and segment_pdf divides a PDF into
segments a model can cite.
Then take a workflow through its whole life, from a clone of this
repository. It needs no model and no API key:
git clone https://github.com/EldritchInc/azathoth.git
cd azathoth
azathoth tool import examples/tools/word-count.json
azathoth tool import examples/tools/word-count-process.json
azathoth workflow import examples/workflows/redundant-word-count.json
azathoth workflow run a1000000-0000-4000-8000-000000000001 --input '"that is not dead which can eternal lie"' --output result
azathoth benchmark import examples/benchmarks/word-count.json
azathoth benchmark run b1000000-0000-4000-8000-000000000001 --workflow a1000000-0000-4000-8000-000000000001
azathoth workflow promote a1000000-0000-4000-8000-000000000001
azathoth workflow invoke a1000000-0000-4000-8000-000000000001 --input '"and with strange aeons even death may die"' --output result
azathoth workflow runs a1000000-0000-4000-8000-000000000001
The workflow counts words twice, with two different tools, so either can
fail and the other still answers. workflow run runs it as configured. It
prints 8. The benchmark measures it against its cases:
Cases Run: 1
Cases Passed: 1
Passed (exact): 1/1
workflow promote makes this revision production, and workflow invoke
runs production, which prints {"result": 8}. workflow runs lists the
evidence: one run of each kind, production, benchmark and configured,
each with its steps, attempts and outputs recorded.
To add a model, benchmark it and let the optimizer find a cheaper one that
still passes, follow
Getting Started.
Documentation
| Guide |
What it covers |
| Installing Azathoth |
Python, a venv, pip install, checking it works, on macOS and Windows; optionally PostgreSQL and tracing |
| Running in a Container |
The container image: a database volume or PostgreSQL, keys, jobs over stdin, a read-only root |
| Running on AWS |
Queue workers on Fargate behind SQS, from one CloudFormation template |
| Serving Workflows Over MCP |
Promoted workflows as tools for Claude Desktop, IDEs and agents, over stdio or HTTP behind your identity provider |
| Reading Documents and Citing Them |
A PDF divided into segments, answered from with a citation behind each answer, every citation checked and exported as Web Annotations |
| Calling MCP Tools |
A step calling a tool another MCP server serves, pinned to its schemas, over stdio or HTTP |
| Sharing Workflows Through a Remote |
A remote other instances push workflows, tools and benchmarks to and pull from, with tokens, restricted data, the container and Fargate |
| Connecting OpenRouter |
An API key, finding and authorizing models, adding judges |
| Connecting Amazon Bedrock |
AWS credentials, the IAM policy, pricing Bedrock models and authorizing them |
| Getting Started |
One workflow from import to production |
| Examples Tour |
Every example, from a word count to a novel |
| Concepts |
How Azathoth is put together, and why |
| CLI Reference |
Every command, its options and its output |
| Architecture Decisions |
The ADRs behind each boundary |
| Changelog |
What each release changed, and how to upgrade |
| Contributing |
Working on Azathoth itself |
| Releasing |
How a release is validated and published |
Examples
The examples
are complete, importable workflows, each with its benchmarks and end-to-end
tests:
- word count: tools, redundancy, and benchmark cases made from corrected
runs;
- classify sentiment: the whole lifecycle in one step;
- child workflow, countdown loop and word count map: composing
workflows;
- ticket triage: conditional routing to specialists, and a cheaper
classifier found by the optimizer;
- workflow writer: a workflow that writes workflows and validates them;
- code review: three concurrent reviewers, merged by code rather than a
model;
- novel: nested loops that plan, draft, edit and revise a book;
- large file: a file of any size in S3, split into chunks, counted by a
map and summed.
What Azathoth Does
- Composes workflows from prompt, tool and child-workflow steps. Steps can
depend on each other, pass values by name or as constants, run
conditionally, retry, and fail in a controlled way. Child workflows, loops
and maps run through standard tools that ship in the package.
- Separates intent from models. Steps state requirements, and Azathoth
chooses from the models you have authorized among those OpenRouter and
Amazon Bedrock currently offer.
- Records everything: every run, step, attempt, prompt, reply, token and
cost, as durable evidence, and traces it with OpenTelemetry when asked.
- Benchmarks workflows with exact, normalized, schema and model-judged
semantic cases.
- Optimizes by trying strictly cheaper authorized models, step by step,
and ranking candidates on quality, reliability, latency and cost. The
report shows which model each step of the winner used.
- Promotes deliberately. Production runs only what was explicitly
promoted, on exact models, with a revision history and an invocation log.
Optimizing never deploys anything by itself.
- Runs in production: from versioned job requests that replay rather than
repeat, in a signed container image, or as a fleet of queue workers on AWS
that share one PostgreSQL database. A run interrupted by a deploy or a lost
machine resumes from its journal.
- Takes inputs by value or by reference, from files or S3, and keeps the
content each run was given. Data too large for an input stays in S3 and is
worked in chunks.
- Serves workflows to AI clients.
azathoth-mcp offers the promoted
workflows you list as MCP tools, to Claude Desktop, IDEs and agents, over
stdio or over HTTP behind your identity provider, a scope per tool. Every
call is a recorded invocation that names who made it.
- Calls MCP tools. A step can call a tool another MCP server serves, as
it calls any tool. The tool is pinned to its schemas, so a server that
changes it stops the step rather than receiving arguments it no longer
accepts.
Azathoth is also a typed Python library. The
package READMEs
document each subsystem.
Design Principles
Persist what should happen. Compose what can execute. Record what
actually happened. Change production deliberately.
- Evidence over intuition. A candidate is better only once it has been
measured as better.
- Composition over code. Workflows are documents; code lives in tools.
- Provider independence. Workflows describe model requirements; providers
are attached at run time.
- Explicit production authority. Production is what you promoted, not the
latest optimizer winner or the cheapest model.
- Immutable records. Configuration, runs, evaluations and deployments are
never rewritten.
Concepts
explains each of these in depth.
Project Status
Azathoth 1.5 supports Python 3.11, 3.12 and 3.13 on Linux, macOS and
Windows, all tested in CI. It runs models on OpenRouter and Amazon Bedrock,
keeps its state in SQLite or PostgreSQL, ships as a signed container image
for amd64 and arm64, and deploys to AWS from one CloudFormation template. It
reads PDFs and images and cites the passages its answers came from, serves
promoted workflows to AI clients over MCP with azathoth-mcp, and calls
tools other MCP servers serve. It records who made every revision, keeps
restricted data to the models declared private, and shares workflows, tools
and benchmarks between instances through a remote. Everything its command
line does, from production and rollback to benchmarks, optimization and
goals, is a call of its service API, which says what an instance spent and
what changed between two revisions. The local editor,
azathoth-ui, drives it through
that API.
The changelog
lists what each release added.
Within 1.x, these stay compatible: workflow, tool and job documents, the
CLI's commands and the output it documents, the database schema, which
azathoth init migrates forward, the service API, azathoth.api, and the
remote protocol, so instances and remotes of different 1.x releases keep
sharing. Each grows only by additions; anything removed waits for 2.0,
after a minor release that warns of it. The rest of the Python API is typed
and documented, but may change in a minor release.
Commercial Support and Pilots
Eldritch, Inc. builds and supports Azathoth. For help putting workflows
into production, a pilot on your own data, or support for a deployment,
see Work With Us.
License
Azathoth is licensed under the
MIT License.