AI Open SDKfor Business Central

OpenAI

Chat and image models through the AI Open SDK OpenAI extension.

AI Open SDK OpenAI is a Business Central app that depends on AI Open SDK (core) and exposes the "AIOS OpenAI" factory.

App nameAI Open SDK OpenAI
Factory"AIOS OpenAI"
Provider idopenai
TextYes (/chat/completions)
ImageYes (/images/generations)
Default base URLhttps://api.openai.com/v1

Dependencies

Your extension depends on:

  1. AI Open SDK (core)
  2. AI Open SDK OpenAI

Before the first call, an administrator must agree to the AI Open SDK OpenAI notice on the Privacy Notices Status page, and users need the AIOS OpenAI User permission set. See Getting Started.

Generate text

GenerateText.al
OpenAI: Codeunit "AIOS OpenAI";
Client: Codeunit "AIOS Client";
Result: Codeunit "AIOS Generate Result";
ApiKey: SecretText;
begin
    Result := Client.GenerateText(
        OpenAI.Model('gpt-5.6-sol', ApiKey),
        'Hello');
    Message(Result.Output());
end;

Generate image

GenerateImage.al
OpenAI: Codeunit "AIOS OpenAI";
Client: Codeunit "AIOS Client";
ImageResult: Codeunit "AIOS Generate Image Result";
ApiKey: SecretText;
begin
    ImageResult := Client.GenerateImage(
        OpenAI.ImageModel('gpt-image-2', ApiKey),
        'A blueprint of a warehouse');
end;

For size, quality, count, and other options, build an "AIOS Image Request" and call Client.GenerateImage(Model, Request).

Factory API

ProcedureBehavior
Model(ModelId, KeyValue)Sets the API key and returns "AIOS Language Model"
Model(ModelId)Returns a chat model using a key from SetApiKey
ImageModel(ModelId, KeyValue)Sets the API key and returns "AIOS Image Model"
ImageModel(ModelId)Returns an image model using a key from SetApiKey
SetApiKey(KeyValue)Stores the OpenAI API key as SecretText
SetBaseUrl(Url)Overrides the API base (default https://api.openai.com/v1)
GetName()Returns openai
BindLanguageModel / BindImageModelSoft-bind; returns false when model id or key is missing

Use SetBaseUrl for compatible gateways that speak the OpenAI HTTP shape under a different host.

Keys

Load the key into SecretText from Isolated Storage or a setup table. Authorization uses Bearer with the SecretText overload.

On this page