AI Open SDKfor Business Central

Request Options

Control temperature, length, timeouts, reasoning, and stop sequences on an AIOS Chat Request.

Short GenerateText overloads use provider defaults. When you need control over the reply, put the prompt on an "AIOS Chat Request", set the options you care about, and pass the request to the client.

Set options on the request

SetOptions.al
Client: Codeunit "AIOS Client";
Request: Record "AIOS Chat Request";
Result: Codeunit "AIOS Generate Result";
begin
    Request.SetSystemMessage('You write short, factual item descriptions.');
    Request.SetPrompt('Describe item 1000, a steel office desk.');
    Request.SetTemperature(0.2);
    Request.SetMaxTokens(300);
    Request.SetTimeout(30000);
    Request.SetMaxRetries(1);

    Result := Client.GenerateText(Model, Request);
end;

"AIOS Chat Request" is a temporary table. Declare it as a local Record variable; it never writes to the database.

Options you do not set are left to the provider. Each tuning option has a matching Clear... procedure (for example ClearTemperature or ClearStopSequences) that returns it to the default.

Options

ProcedureEffectDefault
SetSystemMessage(Text)Instructions the model follows for the whole conversationNone
SetPrompt(Text)The user message for the next callNone
SetTemperature(Decimal)Randomness. Lower is more predictable. 0 is sent as 0Provider default
SetMaxTokens(Integer)Upper limit on the reply length. Values of 0 or less are ignoredProvider default
SetTimeout(Integer)Time limit for each model call, in milliseconds120000
SetMaxRetries(Integer)Extra attempts after a temporary failure. 0 disables retries2
SetReasoning(Enum "AIOS Reasoning Effort")How much the model thinks before answeringProviderDefault
AddStopSequence(Text)Text that ends the reply when the model produces itNone
SetTopP(Decimal)Nucleus samplingProvider default
SetTopK(Integer)Top-K samplingProvider default
SetPresencePenalty(Decimal)Discourages repeating topicsProvider default
SetFrequencyPenalty(Decimal)Discourages repeating wordsProvider default
SetSeed(Integer)Asks the provider for repeatable samplingProvider default

Structured output (SetOutput), tools (SetTools), and attachments (Attach) also live on the request. See Structured output, Tools, and Attachments.

Provider support

Every provider accepts the system message, prompt, temperature, max tokens, timeout, retries, reasoning, and stop sequences. The sampling options differ:

OptionAnthropicOpenAI, OpenCode Zen, OpenAI Compatible
SetTopPYesYes
SetTopKYesNot sent
SetPresencePenalty / SetFrequencyPenaltyNot sentYes
SetSeedNot sentYes

An option that is not sent does not raise an error. Set only what the provider you target supports, so the same request behaves the same way in tests and in production.

Reasoning

SetReasoning asks a reasoning-capable model to think before it answers. Use it for multi-step comparisons or calculations, and leave it at ProviderDefault for short rewrites and summaries, where it only adds latency and cost.

Reasoning.al
Anthropic: Codeunit "AIOS Anthropic";
Client: Codeunit "AIOS Client";
Request: Record "AIOS Chat Request";
Result: Codeunit "AIOS Generate Result";
ApiKey: SecretText;
begin
    Request.SetPrompt('Which of these three quotes is cheapest after discounts? ...');
    Request.SetReasoning("AIOS Reasoning Effort"::Medium);
    Request.SetMaxTokens(8000);

    Result := Client.GenerateText(Anthropic.Model('claude-fable-5', ApiKey), Request);
end;
ValueMeaning
ProviderDefaultSend nothing and let the model decide
NoneDo not ask for reasoning
Minimal, Low, Medium, High, XHighIncreasing reasoning effort

How each provider applies the level:

  • OpenAI: every level is passed through as the matching effort. Use a model that supports reasoning.
  • OpenCode Zen and OpenAI Compatible: only low, medium, and high are available. Minimal becomes low and XHigh becomes high, with a warning.
  • Anthropic: reasoning turns on extended thinking with a budget taken from SetMaxTokens (for example about 30 percent at Medium). While thinking is on, temperature and Top K are dropped, and Top P is kept only between 0.95 and 1. If the budget does not fit under your max tokens, the limit is raised and a warning is added.

Read warnings

When the SDK adjusts or drops an option for the provider, it records a warning instead of failing. Read them from the result while you tune a request, or log them:

ReadWarnings.al
Warnings: JsonArray;
WarningToken: JsonToken;
WarningText: Text;
begin
    Result := Client.GenerateText(Model, Request);
    Warnings := Result.GetWarnings();
    foreach WarningToken in Warnings do begin
        WarningToken.WriteTo(WarningText);
        Session.LogMessage('AIOS-WARN', WarningText, Verbosity::Warning,
            DataClassification::SystemMetadata, TelemetryScope::ExtensionPublisher, 'Category', 'AI');
    end;
end;

Each warning is a JSON object with a type, the feature it concerns, and a readable message.

Reuse a request

A request keeps its options between calls. Call SetPrompt again to send a new user message with the same system message and settings. The prompt is added to the request history, so a reused request is also how you build a conversation. See Conversations.

To start over, use Clear(Request).

On this page