Repository navigation
Azathoth 1.7 widens the models a workflow can use. Every provider plugs
into Azathoth the same way, and eleven are reached: OpenRouter, Amazon
Bedrock, the Vercel AI Gateway, servers you run yourself, Ollama,
Anthropic, OpenAI, Google, Mistral, xAI and NanoGPT. Prompt tokens read
from or written to a provider's cache are priced at their own rates, and a
document prices the models a provider does not. A decision step asks a
decision model, such as Jev, typed questions answered with probabilities.
Every provider's embedding models are listed and run, ready for 1.8's
wiki. A model at an effort is a variant of it, named
provider/model@low. A step can replay its model's recorded answers
rather than ask again, and Azathoth says what replay saved across every
workflow. The database schema moves from version 9 to version 10, as
Upgrading From 1.6 below says.
This release changes what the image runs on AWS: the stack's one-off
init task moves its database from schema version 9 to version 10, and
its workers replay as production does. Release validation requires a
release that changes what the stack runs to be deployed to an AWS sandbox
before it ships, and no sandbox was available, so this release was not
deployed. The template was read, the worker run against botocore's
Stubber and the S3 tools against a stand-in for S3, as for every
release; what only a real deployment proves, that the stack's workers run
jobs on real SQS and S3, is unproven for 1.7.0, as what 1.6.0, 1.5.0, 1.4.0
and 1.3.0 left unproven still is
(Release Validation).
Providers
- A provider plugs in as one
ProviderIntegration: the variables it
reads, whether they turn it on, the directory that discovers its models,
and the registry that runs them. The command line and the service API
both reach providers throughprovider_integrations(), OpenRouter then
Bedrock, so a provider added once is reached both ways. A provider that
is on and cannot be used raisesProviderSetupError; Bedrock's errors
derive from it and keep their classes
(ADR 0143). - A model's price may say what a prompt token costs when the provider
reads it from its own prompt cache, and a model's reply says how many of
its prompt tokens were read that way. A cost Azathoth estimates charges
those tokens at the cached rate, or at the full input rate when the price
has none. OpenRouter's replies now say how many tokens it read from
cache. A price or a reply without them is recorded as before
(ADR 0144). - The Vercel AI Gateway is a provider, on when
AI_GATEWAY_API_KEYholds
a key. Its language models are discovered from its catalog as
ai-gateway/<creator>/<model>, priced per million tokens with their
cached rate, and run through its OpenAI-shaped completions; a model that
reads PDFs is sent them. The key, like every provider's added since, is
kept as a secret beside the settings OpenRouter and Bedrock have.
Connecting the Vercel AI Gateway
is the guide (ADR 0144). providers.list, aread_portfoliocall, says which providers an
instance reaches: each provider Azathoth knows, in order, whether the
instance's settings turn it on, the names of the variables it reads and
its guide, never what they hold. It reaches no provider.
azathoth model providersprints it, for a remote with--remote
(ADR 0154).
Models on Your Own Hardware
AZATHOTH_LOCAL_MODELSnames a document that declares servers on your
own hardware, such as vLLM, LM Studio or llama.cpp's server, and the
models each serves: what each costs per million tokens, zero being free
at the margin, its limits, its modalities and its capabilities. A server
that takes a key names the variable that holds it; a document holding a
key, or naming a server or model twice, is refused
(ADR 0145).- Local servers are a provider,
local, on whenAZATHOTH_LOCAL_MODELS
names the document. Each server is asked which models it has loaded, and
each is namedlocal/<server>/<model>: listed as declared, or unpriced
when the document does not declare it, and run through the server's
OpenAI-shaped completions by the name the server knows it by. A server
that cannot be reached lists nothing and says so, without stopping the
command.
Running Models on Your Own Hardware
is the guide (ADR 0145). - Ollama is a provider, on when
AZATHOTH_OLLAMAturns it on, and found
whereOLLAMA_HOSTsays. Its models that complete prompts are listed as
ollama/<model:tag>, with the context length and capabilities Ollama
shows, and run through its OpenAI-shaped completions. They are free at
the margin unless the local models document'sollamasection prices
them. Ollama that cannot be reached lists nothing and says so
(ADR 0145). - A price of zero is free at the margin. A free model is strictly cheaper
than any paid one, so the optimizer substitutes it when it passes, and
two free models are not cheaper than each other. A call to one is spent
as an estimated zero, never an unpriced call.model showsays
free at the marginfor a price of zero, here and on a remote
(ADR 0145).
Declared Prices
AZATHOTH_MODEL_PRICESnames a document that prices models by their full
identifier, for providers whose listings name no price. A declared price
fills in only where a model's provider gives none, and never overrides a
provider's own. The command line and the service API both discover
models throughprovider_directories, which fills the prices in
(ADR 0146).- A model's price may say what a prompt token costs when the provider
writes it to its own cache, and a reply says how many it wrote. An
estimated cost charges those at the write rate, or at the full input rate
when there is none. The AI Gateway's catalog gives the write rate. A
price or a reply without them is recorded as before
(ADR 0146).
Anthropic
- Anthropic is a provider, on when
ANTHROPIC_API_KEYholds a key. Its
models are listed from its own listing asanthropic/<id>, with the
images, PDFs, structured output and limits it gives, and priced by the
prices document. A prompt is sent to its Messages API; documents are
cited when a step asks for native citations, and a prompt that shows a
document or an image asks Anthropic to cache it. Tokens read from and
written to the cache are counted and priced apart.
Connecting Anthropic
is the guide (ADR 0147).
Providers Reached Directly
- OpenAI is a provider, on when
OPENAI_API_KEYholds a key. Every model of
a family that chats in text is listed asopenai/<id>, a text model of
unknown limits; models that embed, speak, transcribe, draw, moderate or
stream audio are not. They run through OpenAI's chat completions, priced
by the prices document, with the tokens OpenAI read from its cache at the
cached rate.
Connecting OpenAI
is the guide (ADR 0148). - Google's Gemini API is a provider, on when
GEMINI_API_KEYholds a key.
Every page of its own listing is read; each model that generates content,
and does not speak, draw, stream audio or run live, is listed as
google/<id>with its input and output limits. They run through Google's
OpenAI-compatible chat completions, priced by the prices document.
Connecting Google
is the guide (ADR 0148). - Mistral is a provider, on when
MISTRAL_API_KEYholds a key. Each model
its listing says chats is listed asmistral/<id>, with vision and tool
use as the listing says and its context length. They run through
Mistral's chat completions, priced by the prices document.
Connecting Mistral
is the guide (ADR 0148). - xAI is a provider, on when
XAI_API_KEYholds a key. Every model its own
listing says answers in text is listed asxai/<id>, reading images where
the listing says it does; those that make images or video are not. Each is
priced as the listing prices it, and the prices document fills in a model
it leaves unpriced. They run through xAI's chat completions, with the
tokens xAI read from its cache at the cached rate.
Connecting xAI
is the guide (ADR 0148,
ADR 0157). - NanoGPT is a provider, on when
NANOGPT_API_KEYholds a key. Every model
its detailed listing does not mark unavailable is listed as
nanogpt/<id>, keeping the maker in NanoGPT's identifier, with its
limits, modalities and capabilities. Each is priced from the listing,
with its cache read and write rates converted from per thousand tokens to
per million. They run through NanoGPT's chat completions.
Connecting NanoGPT
is the guide (ADR 0148).
Decision Steps
- A decision model answers typed questions about one input rather than
completing a prompt: a predicate with the probability that it holds, a
choice with the value chosen and each value's probability, a score on an
ordered scale with each level's probability. Its output modality is
decision, so a step asking for a language model never gets one, and
one asking for decisions gets nothing else. The AI Gateway lists its
decision models, such asai-gateway/typesafe-ai/jev, as text in and
decisions out, priced by their input
(ADR 0150). - A decision model the AI Gateway serves answers at
POST /v1/decisions:
the input as text, or text and a JSON object, and every question in one
request. Answers that do not answer the questions asked, in order, are
refused, and a refused question is kept as a refusal. A decision's cost
is the Gateway's bill, or the model's catalog price without one; a
refused request names its status and the Gateway's error
(ADR 0150). - A decision step asks a decision model typed questions about its input,
rendered from context by a template as a prompt step's is. Its output is
one JSON object keyed by question name, so later steps bind
["queue", "choice"]or["damaged", "probability"]. A refused
question is answeredrefused: true, its other fields null, so its
bindings still resolve. Its model selection must require
decision output, and a prompt step's may not; a decision step whose input
shows content is refused before anything is sent
(ADR 0150). - A decision step is generated, run, benchmarked, optimized and promoted
as a prompt step is, among decision models only: the optimizer
substitutes a cheaper decision model, a promoted step is pinned to the
decision model it ran on, and production falls back only to an approved
decision model. The service API's step readiness names its kind
decision, andworkflow showits type
(ADR 0150). examples/workflows/decision-triage.jsontriages a support ticket with
three questions. Deciding With Decision Models
is the guide
(ADR 0150).
Embedding Models
- An embedding model turns texts into vectors, one per text, all of one
dimension, priced by the tokens it read. Its output modality is
embeddings, and a model's outputs say its kind: a query finds language,
decision or embedding models, never two kinds at once. A registry holds
embedding models beside the others, andcosine_similaritysays how
alike two vectors point
(ADR 0151). - Embedding models reached through an OpenAI-shaped embeddings API share
one client,OpenAICompatibleEmbeddingModel: texts are sent in batches,
the vectors put back in the order of the texts, and a dimension sent
only when asked for. A reply without one vector per text, or of another
dimension than asked, is refused. A call costs the provider's bill when
every batch has one, and the model's input price otherwise
(ADR 0151). - The AI Gateway lists its catalog's embedding models, and OpenRouter
those of its own embeddings listing, each as text in and embeddings out,
priced by its input; a model in both of OpenRouter's listings is listed
once. Both embed through the shared client at their bills: OpenRouter's
usage.cost, and the Gateway'sproviderMetadata.gateway.cost
(ADR 0151). - OpenAI's
text-embedding-models, Mistral's embedding models such as
mistral-embed, Google's models that supportembedContentand do not
chat, and Ollama's models with theembeddingcapability are listed as
embedding models, and embed at each provider's OpenAI-shaped
/embeddings; Google's at most 100 texts a request. A local server's
model declared with"output_modalities": ["embeddings"]embeds on its
server. Ollama's are free at the margin; the others are priced by the
prices document
(ADR 0151). models.embedreturns an embedding model's vectors for a list of texts,
with their dimension, tokens and cost, andazathoth model embedprints
them, or the vectors as JSON. The model need not be authorized. On a
remote it asksrun_workflow, and embeds with the remote's providers.
Embedding Texts
is the guide
(ADR 0151).
Replaying Model Calls
- A step that asks a model may say how it replays its model's recorded
answers, asreplay:slots, from 0 to 999, andscope,modelor
step. With n answers kept, it replays with probability n/(slots+1), so
it always runs fresh some of the time. A call's answers are kept under a
key: the model at its effort, the filled prompt or the decision's
questions, content by its digest, and the output format; scopestep
finds only answers recorded with the step's definition. A tool step
never replays, and a step that does not serializes as steps always did
(ADR 0153). - A step bound to a model names its answer's key as
replay_keyin its
metrics. Each recorded answer is indexed by its key, pointing at the run
and step that hold it, and found latest first, by source, by the asking
run's label and, for scopestep, by the step's definition. An evicted
run's answers are never found again. Schema version 10 adds the
replay_answersandreplay_evicted_runstables
(ADR 0153). - A run replays a step's recorded answers on its first attempt, drawing as
its slots say; a retry asks. A replayed answer names the run and step it
came from asreplayed_fromand costs nothing. Production runs are given
only production's answers, configured runs either; benchmarks and
experiments neither. A run records its answers only when it succeeds,
never those it was given again, and a run judged bad is evicted
(ADR 0153). workflow run --replay slots|latest|offandruns.run(replay=...)say
how a configured run replays: as its steps say, the latest answer for
every step that asks a model whatever its slots, or never, still
recording what it is answered. Production takes no mode
(ADR 0153).workflow replays <WORKFLOW_ID>andruns.replays, aread_runscall,
report each step that asked a model across a workflow's configured and
production runs: answers asked and replayed, what they cost and saved,
with unknown costs counted apart, and how often the model agreed with
itself
(ADR 0153).runs.replay_summary, aread_runscall, sums what replay did in each
workflow with a configured or production run, reading every kept run
once: its runs, the steps that asked a model, the answers asked and
replayed, and what they spent and saved, then the instance's totals.
workflow replayswithout a workflow prints it, and a remote serves it
(ADR 0155).- A run's journal records the replay mode it was told, and
runs.resume
replays in it, so a run started withlatestresumes giving the latest
answers. A journal that names no mode resumes as each step says
(ADR 0155). - Replaying Model Calls
is the guide: letting a step replay, whose answers a run is given,
re-running with--replay latest, taking an answer back, and reading
what replay did
(ADR 0153).
Effort as a Model Variant
- An effort is one of
minimal,low,mediumandhigh, and a model
lists those it takes asefforts. A model at one is a variant of it,
namedprovider/model@low: the catalog returns it, the registry runs
its model asked for that effort, and authorizing a model authorizes
every effort it takes. A fixed selection'seffortnames a variant,
promotion pins the variant a candidate ran, and a step fixed on an effort
its model does not take has no candidate. A selection without one, and a
model that takes none, serialize as they always did
(ADR 0152). - OpenRouter's models that take
reasoningtake every effort, sent as
reasoning.effort; the AI Gateway's take those of their catalog's
effort option, and Ollama's thinking modelslow,mediumandhigh,
sent asreasoning_effort; Anthropic's take those their effort
capability supports, sent asoutput_config.effort; and a local
server's model takes theeffortsthe local models document declares.
Providers whose listings name no efforts list none
(ADR 0152). - A portfolio selection's requirements may name
efforts, and each model
that takes one is then tried as its variants at them, so an experiment
weighs one effort against another. A step's metrics say the effort its
model was asked for; spend, an experiment's steps and a run that cannot
be scored name the variant; and an approved production substitute may be
one
(ADR 0152). azathoth model shownames a model's efforts,azathoth model listmarks
a model that takes any, and the service API's model summary lists them; a
step's details name the effort its model was asked for.
Asking a Model for an Effort
is the guide
(ADR 0152).models.matchingnames what a step would run on: requirements that ask
for efforts match each matching model's variants at the efforts asked
that it takes, in effort order, and no model that takes none, as
candidate generation finds them. A model summary'seffortnames a
variant's, and is None for a model
(ADR 0155).
Stopping a Command
- SIGTERM cancels a command's own tasks and no longer cancels asyncio's. A
command terminated just as a tool's process started, before the
process's pipes connected, waited for ever on Python 3.11 and 3.12; it
now kills the process and exits with status 143 at once
(ADR 0149).
Contributing
- Every commit is signed off by its author, certifying the Developer
Certificate of Origin, asgit commit -sdoes. CI'ssign-offjob
checks each commit a pull request brings and names any that is not;
merge commits and Dependabot's are not checked. CONTRIBUTING.md says
what signing off certifies and how to fix a commit that missed it
(ADR 0156).
Upgrading From 1.6
Upgrade, and run azathoth init as after every upgrade:
python -m pip install --upgrade azathoth-ai
azathoth initpython -m pip install --upgrade azathoth-ai
azathoth initIf you serve workflows with azathoth-mcp, upgrade it in the same command,
as Installing Azathoth shows: 1.7 of it requires 1.7 of
azathoth-ai.
The database schema moves from version 9 to version 10, which adds the
tables that index the answers models gave, for replaying them
(ADR 0153).
An SQLite file is upgraded the first time it is used. A PostgreSQL
database refuses every command until azathoth init has run once, from
any one machine, and 1.6 refuses it after that, so upgrade Azathoth on
every machine first. init keeps everything the database holds.
Nothing a workflow does changes until you change it: a step replays only
once it says it does, asks for an effort only once it names one, and a
provider added in 1.7 is off until its variables are set.
azathoth model providers says which are on. Answers a run is given from
now on are indexed as it finishes, so a step told to replay has none to
give until runs after the upgrade have recorded some.