lai. These are global symbols: signatures are permanent and only ever added to, never changed — so code you write against them keeps working across package upgrades.
LogicAI methods
register
source returns the same id.
source— a stable, short identifier for the caller, e.g.'NightlySync'. Required.model— the AI model this source runs on. Must be a catalogued gateway model; leave blank to use the org default model.- Throws
LogicAI.LogicAIExceptionif the source is blank or the model isn’t recognised.
register(String source) that registers on the org default model.
See Source Registration for the full picture.
invoke
res.success / res.statusCode / res.error instead. Must be called from a context that permits synchronous callouts (Queueable, @future, controller action, anonymous Apex).
invokeJson
invoke, but returns the Response serialised to JSON. Handy for handing a single string to a Flow text variable.
invokeAsync
- A session is never created here. Pass a
sessionIdon the request to have the reply persisted onto thatBot_Session__c(poll itsBot_Message__crows for the result); the returnedIdis that same session id. - With no
sessionId, the call is fire-and-forget — it runs but the reply isn’t persisted, and the method returnsnull. - Unlike
invoke,invokeAsyncvalidates up front and will throwLogicAI.LogicAIExceptionfor a bad request or an unregistered/disabled source, so the caller fails fast on their own transaction rather than silently in the async job.
LogicAISchema.Request fields
Construct with new lai.LogicAISchema.Request() or new lai.LogicAISchema.Request(prompt).
Deprecated fields:modelandagentare no longer honoured — the model and attribution now come from the registered source. They remain on the class only for binary compatibility; any value you set is ignored. Pass the model toregister(...)instead.
Content blocks (files)
To send a PDF or image, populatecontentBlocks with Anthropic content-block maps. When set, prompt is appended as a trailing text block unless one is already at the end of the list.
'type' => 'image' with a media_type like image/jpeg.
LogicAISchema.Response fields
Response also exposes toJson(), which serialises it to pretty-printed JSON (this is what invokeJson returns).
Governor-limit notes
- Each
invokeperforms one HTTP callout. It counts against the standard 100-callouts-per-transaction limit. invokemust run where callouts are allowed. In synchronous trigger/Flow contexts, useinvokeAsync.- Callout timeouts are set generously (120s) because model responses can take time — size your transactions accordingly.

