How it works
The API is a thin facade over the same single round-trip the chat uses:- It’s a single-turn, no-tools call. You send a prompt (and optionally files); Logic AI returns text. It does not run the agentic tool loop (no SOQL/DML tools) — that lives in the chat experience.
- Each call is one gateway round-trip and debits credits from your org’s balance, exactly like a chat message.
- The model and attribution for a call come from a registered source, not from the request — see Source Registration.
The three entry points
| Method | Returns | Use when |
|---|---|---|
invoke(request) | LogicAISchema.Response | You’re in a context where a synchronous callout is allowed (e.g. a Queueable, @future, an LWC/aura action, an anonymous Apex script) and you want the reply back inline. |
invokeJson(request) | String (the Response as JSON) | You just want a string to hand off — e.g. into a Flow text variable. |
invokeAsync(request) | Id (the session id, or null) | You’re somewhere a synchronous callout is blocked — a Flow, a trigger, or after DML. The call runs off-transaction; poll the session for the result. |
Namespace
All symbols are in the managed-package namespacelai: lai.LogicAI, lai.LogicAISchema.Request, lai.LogicAISchema.Response. The examples in these pages include the lai. prefix.
Before you start
- Your org must be connected and provisioned — the same setup the chat needs (see the Quickstart). If the workspace isn’t ready yet, calls return a
503. - Register your source once and store the returned id — you pass it on every call. See Source Registration.
- Decide how you’ll handle failures —
invokenever throws for gateway/credit/validation problems; it reports them on the response. See Errors & Status Codes.

