Interface: AiMapSpec<TIn, TOut>
Defined in: packages/workflow-engine/src/core/step-ai.ts:32
Type Parameters
TIn
TIn
TOut
TOut
Properties
auto?
optionalauto?:object
Defined in: packages/workflow-engine/src/core/step-ai.ts:54
auto uses batch at or above this item count (default 20) when the model supports it.
batchAbove?
optionalbatchAbove?:number
batch?
optionalbatch?:object
Defined in: packages/workflow-engine/src/core/step-ai.ts:55
onExpiry?
optionalonExpiry?:"fail"|"partial"
What to do when the batch fails or the wait times out: "fail"
(default) throws AiMapBatchFailedError; "partial" returns every
item as failed with that error.
onReclaim?
optionalonReclaim?:BatchReclaimPolicy
What a replayed submit does when the worker that submitted died before the ledger recorded it.
"adopt" (default) searches the provider for the batch carrying this
step's external key and continues from it; when the transport has no
field the engine can stamp and search (Anthropic Message Batches,
OpenRouter) it throws BatchNotAdoptableError rather than paying for a
second batch. "resubmit" restores the pre-1.0.0-alpha.9 behaviour:
submit again and leave the first batch orphaned and billed.
options?
optionaloptions?:BatchOptions
pollEvery?
optionalpollEvery?:string|number
Poll cadence for the batch status wait. Defaults to "60s".
provider?
optionalprovider?:AIBatchProvider
timeout?
optionaltimeout?:string|number
Non-sliding deadline for the batch wait. Defaults to "24h".
itemId?
optionalitemId?: (item,index) =>string
Defined in: packages/workflow-engine/src/core/step-ai.ts:48
Stable per-item id used to key the durable step. Defaults to ${index}; must be unique.
Parameters
item
TIn
index
number
Returns
string
maxTokens?
optionalmaxTokens?:number
Defined in: packages/workflow-engine/src/core/step-ai.ts:45
model
model:
ModelKey
Defined in: packages/workflow-engine/src/core/step-ai.ts:33
policy?
optionalpolicy?:"auto"|"realtime"|"batch"
Defined in: packages/workflow-engine/src/core/step-ai.ts:52
Execution policy. Defaults to "auto".
prompt
prompt: (
item,index) =>TextInput
Defined in: packages/workflow-engine/src/core/step-ai.ts:34
Parameters
item
TIn
index
number
Returns
realtime?
optionalrealtime?:object
Defined in: packages/workflow-engine/src/core/step-ai.ts:81
budget?
optionalbudget?:number
Maximum model calls (including repairs) per stage invocation. Exceeding
it before an item's first call throws AiMapBudgetExceededError; a
repair that would exceed it returns the item as failed instead.
concurrency?
optionalconcurrency?:number
In-process concurrency for realtime calls. Defaults to 10.
minDelayMs?
optionalminDelayMs?:string|number
Minimum spacing between model calls on one concurrency slot: after a
slot finishes an item it waits this long before taking the next one.
Per slot, not global — with concurrency: 4 and minDelayMs: "1s"
the map makes up to four calls per second. Replaces hand-written
cooldowns between items.
retries?
optionalretries?:number
Durable retries after a thrown model call (step.run retries). Defaults to 1.
retryDelayMs?
optionalretryDelayMs?:string|number
Delay before a durable retry. Defaults to 0.
repair?
optionalrepair?:object
Defined in: packages/workflow-engine/src/core/step-ai.ts:50
Repair passes after a schema failure. Defaults to { attempts: 1 }.
attempts
attempts:
number
schema?
optionalschema?:ZodType<TOut,unknown,$ZodTypeInternals<TOut,unknown>>
Defined in: packages/workflow-engine/src/core/step-ai.ts:36
When set, each item is validated against this schema and repaired on failure.
stream?
optionalstream?:boolean
Defined in: packages/workflow-engine/src/core/step-ai.ts:43
Run realtime items through ctx.ai.streamText instead of
generateText/generateObject, collecting the streamed text. schema
still applies: the collected text is parsed as JSON and validated, with
the usual repair pass. The batch path ignores this flag.
system?
optionalsystem?:string
Defined in: packages/workflow-engine/src/core/step-ai.ts:44
temperature?
optionaltemperature?:number
Defined in: packages/workflow-engine/src/core/step-ai.ts:46