Skip to main content

Interface: AiMapSpec<TIn, TOut>

Defined in: packages/workflow-engine/src/core/step-ai.ts:32

Type Parameters​

TIn​

TIn

TOut​

TOut

Properties​

auto?​

optional auto?: 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?​

optional batchAbove?: number


batch?​

optional batch?: object

Defined in: packages/workflow-engine/src/core/step-ai.ts:55

onExpiry?​

optional onExpiry?: "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?​

optional onReclaim?: 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?​

optional options?: BatchOptions

pollEvery?​

optional pollEvery?: string | number

Poll cadence for the batch status wait. Defaults to "60s".

provider?​

optional provider?: AIBatchProvider

timeout?​

optional timeout?: string | number

Non-sliding deadline for the batch wait. Defaults to "24h".


itemId?​

optional itemId?: (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?​

optional maxTokens?: 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?​

optional policy?: "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​

TextInput


realtime?​

optional realtime?: object

Defined in: packages/workflow-engine/src/core/step-ai.ts:81

budget?​

optional budget?: 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?​

optional concurrency?: number

In-process concurrency for realtime calls. Defaults to 10.

minDelayMs?​

optional minDelayMs?: 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?​

optional retries?: number

Durable retries after a thrown model call (step.run retries). Defaults to 1.

retryDelayMs?​

optional retryDelayMs?: string | number

Delay before a durable retry. Defaults to 0.


repair?​

optional repair?: 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?​

optional schema?: 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?​

optional stream?: 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?​

optional system?: string

Defined in: packages/workflow-engine/src/core/step-ai.ts:44


temperature?​

optional temperature?: number

Defined in: packages/workflow-engine/src/core/step-ai.ts:46