step.ai is - the step
API for model calls, embeddings, and agent loops. See
AI steps for the full reference, or the
AI quickstart to run your first one end to end.
The building block
The unit is a single augmented model call - an LLM with tools and structured output. In Duraton that isstep.ai.generate:
"classify", so on replay the workflow skips it and reuses the saved
answer. Composing calls means composing checkpoints:
The agent loop
When the model should decide its own next step - call a tool, look at the result, call another - usestep.ai.loop. Each turn is a durable step and each tool call is a durable step, so a long-running
agent survives a restart and resumes at the last committed turn instead of starting over.
handler or another workflow. A workflow tool becomes a linked child run -
a full durable run with its own retries and steps - so the agent can delegate real work, not just call
a function. That linkage is what makes the orchestrator pattern below durable end to end.
Agent patterns
Anthropic’s Building effective agents distinguishes composable workflows (the model follows a fixed structure) from agents (the model directs itself). Each maps onto Duraton primitives, and because every model call is a step, each becomes crash-safe for free.The pattern names and definitions below are Anthropic’s; the mapping to
step.ai is the durable
implementation.Prompt chaining
Decompose a task into a fixed sequence of calls, each consuming the previous one’s output. Every call is its own step, so a failure in the third link resumes from the saved output of the second.Routing
Classify the input, then send it to a specialized follow-up. Classify with a structuredgenerate,
then branch to the workflow that handles that class:
Parallelization
Run independent calls at once and aggregate the results (sectioning), or run the same call several times and combine the answers (voting). Fan out withPromise.all - each branch is its own durable
step and the run joins when all have committed:
Orchestrator-workers
A central model breaks a task down, delegates to workers, and synthesizes the results. This isstep.ai.loop with workflow tools: the loop is the orchestrator, each workflow tool is a worker,
and every delegation is a linked child run that retries and checkpoints on its own.
Evaluator-optimizer
One call generates, another evaluates and feeds back, in a loop until the check passes. For a single output against a schema,generate’s built-in durable
re-ask is this pattern - validate is the
evaluator and each re-ask is a durable step:
step.ai.loop and stop
when the evaluator is satisfied.
Keeping it replay-safe
The model results are memoized, but the code around them - yourturn, validate, and stop
functions, and any branching on a result - runs again on every replay. Keep them deterministic (a pure
function of their inputs) so a resumed run takes the same path it took the first time. The
durable-execution rules for regular steps apply unchanged.