ai.generate(ctx, key, generation, { once, then, within }) submits one
generation to the catalog entry’s pack, in your mutation’s transaction.
The continuation declares result: ai.result and decodes it with
ai.answer(key, result).
bijection/notes.ts
{ system, messages, maxOutputTokens, temperature, output },
all but messages optional. Messages carry text, images and documents as
bytes (base64), never URLs a provider would fetch; the model must declare
the images or documents capability. output: { name, schema } asks for
one structured value, with schema from jsonSchema(type). It is decoded
as answer.structured and must be checked before use: typed
tasks do that for you.
within defaults to the pack’s contract. ai.request(key, generation)
answers the operation and body a generation would send, without sending
it.
Read the result
Each answers a
Result. A refused task passes its code through:
Unknown (the call may have happened, and is never resent), Expired,
Withdrawn or Failed. An answer the library cannot decode is Failed.
ai.cost(key, usage) answers the list-price cost in micro-USD.