What makes it a workflow and not a prompt
A single prompt asks once. A workflow runs an ordered list of steps, and each step sees the previous answer, so the output of one call becomes the context for the next.
That shape covers most internal automation: classify a request, then draft a reply, then score the draft, then file it. The hard part is not the ordering, it is the model access, and that is what a gateway handles.
The data shape
A workflow is a list of steps. Each step is a name, a prompt, and an optional model. A prompt can reference {input}, the workflow input, and {previous}, the last answer:
const steps = [
{ name: "classify", prompt: "Classify this as urgent or not: {input}" },
{ name: "draft", prompt: "Write a short reply for: {previous}" },
{ name: "check", prompt: "Does this reply promise anything we cannot do? {previous}" },
]Each step returns its own answer, so you can keep the intermediate results for an audit trail instead of only the final text.
Run it
The official starter runs the list in order and sums the token usage:
import { runWorkflow } from "anyrouter-workflow"
const { steps, usage } = await runWorkflow({
input: "My payouts have been failing for 3 days",
steps,
})
for (const step of steps) console.log(step.name, step.output)
console.log(usage)The starter lives in the AnyRouterHQ/anyrouter-workflow repo, with tests that pin the official endpoint.
Get the starterPut a human in the loop
Because each step is a separate call, a workflow can stop between steps. Write the intermediate answer somewhere a person can read, wait for approval, then continue with the next step using the approved text as {previous}.
That is the whole pattern for approvals, escalations and review queues. You do not need a workflow engine, you need a place to store the state between calls.
Which model for each step
The default is anyrouter/auto, which routes to a capable model. Pin a cheaper model on the high-volume step, such as a classification, and a stronger model on the step that writes the customer-facing text.
Free models are $0 per token on Go and up, with no daily cap, which makes a high-volume step cheap. AnyRouter retries a failed upstream, so a step does not need its own retry loop.
Pick a plan and start
Go is $2 a month for $4 in credits.
Pro is $10 a month for $20 in credits.
Pro+ is $45 a month for $100 in credits.
Max is $100 a month for $300 in credits.
Create an account, pay on the next screen, then call the model.