AI

Run AI agents that ask a human before the risky moves, resume after a crash without re-paying the model, and record what every call cost.

A model call is slow, expensive, and can fail halfway. ctx.step.ai makes it a durable step: the call runs once, its result is recorded under the step id, and a retry after a crash returns the saved result instead of paying for the model again.

New here? The Quickstart gets you a project, a key, and a connected runner in five steps. The AI quickstart picks up from there.

AI spend and observability in the console
const { text } = await ctx.step.ai.generate("classify", {
  model: "claude-opus-4-8",
  prompt: `Classify this ticket: ${subject}`,
});

Your provider key stays with you

The model call happens in your runner, with your provider SDK and your key. Duraton records the call's metadata (model, token counts, latency) and never receives your prompt, the response text, or your API key: apiKey is passed per call into the provider client and is never persisted by the SDK or sent to Duraton. Omit it and the provider SDK reads its conventional env var (ANTHROPIC_API_KEY).

export ANTHROPIC_API_KEY="sk-ant-..."

Where to go next

On this page