Intent methods
Every intent carries a few fluent methods. Which ones depends on the tier:
| Tier | What it is | Methods |
|---|---|---|
Askable<T> |
a raw extractor or call intent — resolvable only through ask |
.withRetry(n) · .withProvider(nameOrProvider) · .withParams({…}) |
Intent<T> |
what calling an infer function returns — also PromiseLike<T> |
the three above, plus .withTimeout(ms) · .detached() |
On any intent
Section titled “On any intent”export infer function tuned(.text: string) { const a = ask (..`the title`<string>).withRetry(2); const b = ask (..`the body`<string>).withProvider("careful"); const c = ask (..`a creative tagline`<string>).withParams({ temperature: 0.9, maxOutputTokens: 200 }); return { a, b, c };}.withRetry(n)—nextra whole-ask attempts, flat, no backoff. Unrelated to the provider-levelwithRetrycombinator, which retries the wire call — see Resilience. On a call intent the callee runs again on every attempt, so only use it on idempotent targets..withProvider(nameOrProvider)— the dynamic form ofask with; accepts a configured name or aNolaProviderobject..withParams({ temperature, maxOutputTokens, providerOptions })— wire knobs, shallow-merged per field over anything already set on the intent;providerOptionsmerges per key. Params are part of the ask fingerprint, so two asks that differ only in params never share a replay entry — see Record and replay.
On the intent an infer function returns
Section titled “On the intent an infer function returns”These two act when the intent roots an invocation, which is why they are typically used from plain TypeScript:
export interface Person { name: string; age: number }
export infer function extractPerson(.message: string) { return ask ..`the person described in the text`<Person>;}import { extractPerson } from "./person.tsi";
const text = "Alice Smith, 32, is a staff engineer at Acme Corp.";const person = await extractPerson(text).withTimeout(30_000);const loose = await extractPerson(text).detached(); // do not inherit the caller frame's contextconsole.log(person, loose);.withTimeout(ms)— the per-invocation timeout when this intent roots the invocation; overridesask.timeoutMsfrom the config;0disables. It bounds provider round trips only — see Ask options..detached()— resolve without inheriting the caller frame’s context. Useful when one infer function asks another and you do not want the caller’s contextual parameters composed into the callee’s prompts.
Clone semantics
Section titled “Clone semantics”Every method returns a clone — the original intent stays unstarted — and an intent resolves at most once. Chain what you need, then resolve the result.
Next: TypeScript interop