AI Open SDKfor Business Central

Client API

Generate text and images from Business Central AL.

"AIOS Client" is the public entry point.

Text generation

For a simple prompt:

Result := Client.GenerateText(Model, 'Summarize this customer note');
Message := Result.Output();

Use an "AIOS Chat Request" when the call needs more than a prompt:

  • GenerateText(Model, System, Prompt) adds a system instruction.
  • GenerateText(Model, Request) uses the prompt and options on the request.
  • GenerateText(Model, Request, OutputRecRef) writes structured output to a record.
  • GenerateText(Model, Request, ToolSet) lets the model use tools before answering, with up to 5 steps.
  • GenerateText(Model, Request, ToolSet, MaxSteps) does the same with your own step limit.
  • GenerateText(Model, Request, ToolSet, MaxSteps, OutputRecRef) combines tools with record output.

Returns "AIOS Generate Result" and raises an error on failure. See Error handling.

To tune the call, see Request options. For follow-up prompts, see Conversations.

Result accessors

MethodMeaning
Output()Generated text or validated JSON
HasToolCalls() / GetToolCalls()Tool calls returned by the model
StoppedAtStepLimit()The tool loop needs more steps to finish
GetStepCount()Number of generation steps
GetTotalInputTokens(), GetTotalOutputTokens()Token usage for the generation

See Generation result for the complete result surface.

Image generation

  • GenerateImage(Model, Prompt)
  • GenerateImage(Model, Request)

Returns "AIOS Generate Image Result" with GetImages(), GetUsage(), GetResponseCalls().

OpenAI and Mock ship image models today.

Lifecycle events

Integration events on "AIOS Client":

  • OnBeforeGenerate
  • OnBeforeLanguageModelCall
  • OnAfterLanguageModelCall
  • OnAfterGenerate (success only)

Use OnBeforeGenerate to adjust a request before it is sent, and OnAfterGenerate to react after a successful call. The language-model events are useful when an extension needs to observe or customize an individual model call.

See also API: AIOS Client.

On this page