Ir al contenido
Developer Preview — APIs and language features may change before 1.0

Lesson 1: Your First Machine

Esta página aún no está disponible en tu idioma.

You get 150 emails a day. What if you could describe your triage decision once and have it happen automatically?

Here is a machine that classifies an email:

machine classify_email
accepts
subject as text
sender as text
behaves
ask classify, using: "anthropic:claude-haiku-4"
with task "Is this email urgent, routine, or ignorable?\n\nSubject: ${input.subject}\nFrom: ${input.sender}"
returns
priority as text
reason as text
verifies
test "classifies an urgent email"
assuming classify {priority: "urgent", reason: "Server outage reported by operations team"}
given {subject: "URGENT: Server is down", sender: "[email protected]"}
expect {priority: "urgent", reason: "Server outage reported by operations team"}

That is the whole thing. The machine itself is a handful of lines; the verifies block below it proves the logic with a mocked AI response, so the test is deterministic and free.

machine classify_email names it.

accepts names the two pieces of the email this machine reads. Every input. you write has to appear here first; a machine cannot quietly reach for data it never asked for.

ask classify produces an intent to call an AI model. The runtime mediates this intent (checking governance, recording the decision) before execution. using: "anthropic:claude-haiku-4" picks a fast, cheap model (good for classification).

with task is the instruction. ${input.subject} and ${input.sender} are placeholders that get filled in with the actual email when it runs.

returns says what comes back: a priority and a reason.

In Koda, type:

/run classify_email

Give it a subject like “URGENT: Server is down” from “[email protected]”.

You will see something like:

priority: "urgent"
reason: "Server outage reported by operations team, requires immediate attention"

Try a few more. “Weekly newsletter” from “[email protected]”. “Quick question about the project” from a colleague. Watch how the classification changes.

You described what you wanted (classify email priority), pointed it at an AI model, and ran it. No Python. No API keys to manage. No HTTP requests to write.

Behind the scenes, mashin:

  • Called the Claude API with your email data
  • Parsed the structured response
  • Tracked the cost ($0.0003 for this run)
  • Logged every step with timing and token counts
  • Created a tamper-proof audit record

You did not ask for any of that. It is built in.

That audit record is the third thing you should look at, right after the answer. Open the run in Koda and you will see the receipt: what was asked, which model it went to, the governance decision that allowed the call, the cost, and the timing. The same run that classified your email also produced the account of how it did so.

This is the shape you will see after every run for the rest of this course: the ask, the decision, the cost. Later lessons show how those records chain together so they cannot be edited after the fact. For now, just notice that the answer and the record of the answer arrive together, and you did not write a line of logging to get it.

Haiku is the cheapest model. At 150 emails per day, this machine costs about $0.05/day. Less than a dollar a month.

You will see the exact cost after every run. No surprises.

This machine works, but its contract is thin. Nothing says the subject is mandatory, nothing declares what the machine hands back to whoever called it, and the model can put any text at all in priority. In the next lesson, you will tighten all three. That turns a prototype into something you can rely on.

Next: Inputs, Outputs, and Structure →