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 name | AI Open SDK OpenAI |
| Factory | "AIOS OpenAI" |
| Provider id | openai |
| Text | Yes (/chat/completions) |
| Image | Yes (/images/generations) |
| Default base URL | https://api.openai.com/v1 |
Dependencies
Your extension depends on:
- AI Open SDK (core)
- 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
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
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
| Procedure | Behavior |
|---|---|
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 / BindImageModel | Soft-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.