Skip to main content
The synchronous methods (invoke, invokeJson) are designed to never throw for gateway, credit, or validation problems. Instead they return a Response with success = false, a statusCode, and a human-readable error. The async method (invokeAsync) is the exception — it validates up front and throws so the caller fails fast.

Status codes

Response.statusCode is an HTTP-style code:

Handling failures with invoke

Always check success before using text:

Exceptions

The only method that throws for these conditions is invokeAsync, which validates the request and resolves the source synchronously (before enqueuing) so problems surface on your transaction rather than disappearing into the async job. It throws:
register(...) also throws lai.LogicAI.LogicAIException — for a blank source name or an unknown model. invoke / invokeJson catch everything internally, so you don’t need a try/catch around them for gateway or credit failures — only ordinary Apex exceptions (e.g. hitting a governor limit in your own surrounding code) can escape.

Common messages and what to do