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).
| Field | Type | Required | Notes |
|---|---|---|---|
registrationId | Id | Yes | The id returned by LogicAI.register(...). Identifies the source that supplies the model and attribution. The API will not run without it. |
prompt | String | Yes* | The user’s prompt / instruction. *Required unless you supply contentBlocks. |
sessionId | Id | No | Continue an existing Bot_Session__c conversation. When null, the call is a stateless one-shot. |
systemPrompt | String | No | System-prompt override. When blank, a minimal default is used — the full chat system prompt is intentionally not applied here. |
contentBlocks | List<Object> | No | Structured content blocks for the user message — required for anything other than plain text (PDFs, images). See below. |
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
| Field | Type | Notes |
|---|---|---|
success | Boolean | true when the call succeeded; false when error is populated. |
statusCode | Integer | HTTP-style code — see Errors & Status Codes. |
text | String | The assistant’s text reply. |
sessionId | Id | The session used. Null for a stateless one-shot. |
inputTokens | Integer | Input tokens consumed. |
outputTokens | Integer | Output tokens produced. |
credits | Decimal | Credits consumed by this call (gateway-reported). |
error | String | Human-readable message when success == false. |
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.

