This picks up where the Quickstart leaves off - it assumes you already
have a project, an API key, and a connected runner. If you don’t, start there first.
1. Add an AI step
ctx.step.ai.generate makes a model call a durable step: its
result is recorded once under the step id, so a retry after a crash returns the saved result instead
of calling - and paying for - the model again.
runner.ts
2. Set your provider key
The built-in provider is Anthropic. Your runner makes the model call, so the key stays with your runner - Duraton meters tokens but never sees your key, your prompt, or the response. Set it in the runner’s environment:Duraton is bring-your-own-keys. Omit
apiKey on the call and the provider SDK reads its
conventional env var (ANTHROPIC_API_KEY); pass apiKey per call to override it. Either way the
key is used for that one call and is never recorded in the run history.This page is the SDK path - your own runner, your own key. A workflow built without code has no
runner to hold an env var, so it resolves a key you add once under
Credentials instead - same guarantee, same “used for one call, never
recorded” rule, different placement.
3. Trigger it and watch spend land
Send the event your workflow listens for - with the SDK client, or over the REST API:- TypeScript
- REST API
Read it over MCP
An AI agent reading your project sees the same rollup: Duraton exposes the AI spend summary as theai_spend MCP tool, so an assistant can pull window totals and the by-model /
by-workflow breakdowns without the console.
Next steps
AI steps
generate, wrap, embed, and loop - the full step.ai reference.
AI agents
Durable agent loops and the classic patterns, made crash-safe.
Cost controls
Cap and throttle model spend per run and per workflow.
AI observability
Token and cost rollups, sessions, and traces for every run.