Baton.Flow.Workers.LLM (Baton v0.27.4)

Copy Markdown View Source

Generic LLM worker driven by a portable flow node specification.

Transport

A node's config["transport"] chooses how its call is made:

  • "live" (the default) — one synchronous model call, seconds.
  • "batch" — the provider's Message Batches API: roughly half the token cost, hours of latency. See Baton.LLMStep's batch engine and the batch mode guide.

Two optional siblings tune the batch path, both in seconds: config["poll_interval"] and config["batch_deadline"]. Anything unset falls back to Baton.LLMStep's own defaults.

config: %{
  "model" => "claude-sonnet-4-20250514",
  "user_prompt" => %{"body" => "..."},
  "transport" => "batch",
  "poll_interval" => 600
}

A code-defined step fixes its transport at compile time (use Baton.LLMStep, mode: :batch) because it is one module with one purpose. This worker is the opposite: it serves every llm node in every definition, so the choice has to be read from the node on each attempt. Baton.Flow.Validator checks it before a definition compiles, so a misspelled transport is rejected up front rather than silently running live.

Note that everything else in config is the host's business — prompts, bindings, adapters, schemas — and Baton neither validates nor interprets it. transport is the one key the library itself reads.