AI Open SDKfor Business Central

Mock Provider

Test AI-dependent AL without network or API keys.

"AIOS Mock" ships in AI Open SDK (core). It is an in-memory provider for text and image generation: no HTTP and no API keys.

Use it in automated tests and local development to keep AI-dependent code deterministic.

With Mock you can test:

  • Run tests without secrets or network access
  • Keep failures reproducible
  • Structured output and tool loops without a live provider

Setup

  1. Depend on AI Open SDK (core).
  2. Queue the response, error, or tool call you want to test.
  3. Bind Mock.Model(...) or Mock.ImageModel(...) and call "AIOS Client".
GenerateText.al
Mock: Codeunit "AIOS Mock";
Client: Codeunit "AIOS Client";
Result: Codeunit "AIOS Generate Result";
begin
    Mock.SetNextResponse('Hello from mock');
    Result := Client.GenerateText(Mock.Model('mock-model'), 'Hello');
end;

The queued response comes back verbatim, which is what makes assertions stable:

Hello from mock

So the test asserts on a known value rather than on whatever a live model happened to say:

Assert.AreEqual('Hello from mock', Result.Output(), 'Unexpected output');

Image: Mock.SetNextImageBase64(...) then Client.GenerateImage(Mock.ImageModel(...), ...).

For tool-loop tests, SetNextToolCallThenResponse queues a tool call followed by a final response. See Mock provider for the available test responses.

To test failure handling, queue an error with SetNextError or temporary failures with SetFailuresBeforeSuccess. See Error handling and Retries.

On this page