Skip to main content
Logic AI ships a small, stable global Apex API so your own code — Apex classes, Flows, triggers, batch jobs, scheduled jobs — can send a prompt to Logic AI and get a reply back, using the same gateway, credits, and per-org AI workspace as the chat UI. Use it to embed AI into your org’s automation: summarise a record on update, draft a reply in a Flow, classify inbound cases in a trigger, run a nightly enrichment batch, and so on.

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

Full signatures and field-by-field details are in the Apex API Reference.

Namespace

All symbols are in the managed-package namespace lai: lai.LogicAI, lai.LogicAISchema.Request, lai.LogicAISchema.Response. The examples in these pages include the lai. prefix.

Before you start

  1. 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.
  2. Register your source once and store the returned id — you pass it on every call. See Source Registration.
  3. Decide how you’ll handle failures — invoke never throws for gateway/credit/validation problems; it reports them on the response. See Errors & Status Codes.