---
id: object/codeunit/7771
type: object
title: Codeunit 7771 "Azure OpenAI"
summary: Codeunit 7771 "Azure OpenAI" in System Application (System.AI). 19 public procedures. Present since at least BC23, still in BC30, changed in BC24-29.
tier: official
language: en
tags:
  - codeunit
  - system application
versions:
  introduced: null
  last_changed: "29"
  deprecated: null
review:
  state: derived
  by: null
  at: null
  flags: []
generated:
  at: "2026-10-11T00:31:51.816Z"
  pipeline: 0.2.0
  prompts: {}
  input_hash: ca68baef80ac2bde495defcb482275ccc2a7648061b0b25d365d1f29d399619c
evidence:
  - kind: code
    url: https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/AI/src/Azure%20OpenAI/AzureOpenAI.Codeunit.al
    title: src/System Application/App/AI/src/Azure OpenAI/AzureOpenAI.Codeunit.al (releases/29.x)
    date: null
    commit: ea08af5ef2d6a9b5c5af4a029288abbe2c883220
    t: null
    quote: null
links:
  learn: []
  objects: []
  features: []
  topics: []
  localizations: []
  videos: []
  posts: []
  guidelines: []
  changes:
    - change/bcapps/9969
    - change/bcapps/10205
object_type: codeunit
object_id: 7771
name: Azure OpenAI
namespace: System.AI
app: System Application
extends: null
first_version: "23"
last_version: "30"
present_in:
  - "23"
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
  - "30"
changed_in:
  - "24"
  - "25"
  - "26"
  - "27"
  - "28"
  - "29"
source_major: "29"
obsolete: null
countries: []
ms_search_form_ids: []
counts:
  fields: 0
  procedures: 19
  events: 0
  subscribers: 0
relations:
  out: 0
  referenced_by: 0
  pages: 0
  extended_by: 0
  event_subscribers: 0
  calls: 1
  called_by: 21
  implements: 0
---

# Codeunit 7771 "Azure OpenAI"

> Codeunit 7771 "Azure OpenAI" in System Application (System.AI). 19 public procedures. Present since at least BC23, still in BC30, changed in BC24-29.

System Application · System.AI · BC23-30 · [source at ea08af5e](https://github.com/microsoft/BCApps/blob/ea08af5ef2d6a9b5c5af4a029288abbe2c883220/src/System%20Application/App/AI/src/Azure%20OpenAI/AzureOpenAI.Codeunit.al) · facts from BC29

## Properties

| Property | Value |
|---|---|
| Access | Public |

## Procedures

- `IsEnabled(CopilotCapability: Enum "Copilot Capability"): Boolean`: Checks if the Azure OpenAI API is enabled for the environment and if the capability is active on the environment.
- `IsEnabled(CopilotCapability: Enum "Copilot Capability"; Silent: Boolean): Boolean`: Checks if the Azure OpenAI API is enabled for the environment and if the capability is active on the environment.
- `IsEnabled(CopilotCapability: Enum "Copilot Capability"; Silent: Boolean; AppId: Guid): Boolean`: Checks if the Azure OpenAI API is enabled for the environment and if the capability is active on the environment.
- `IsAuthorizationConfigured(ModelType: Enum "AOAI Model Type"): Boolean`: Checks if the Azure OpenAI API authorization is configured for the environment.
- `IsInitialized(CopilotCapability: Enum "Copilot Capability"; ModelType: Enum "AOAI Model Type"): Boolean`: Checks if the Azure OpenAI API is enabled for the environment and authorization is configured for the modeltype.
- `GetFastPrompt(ConfigKey: Text; var Response: Codeunit "AOAI Fast Prompt Response"): Boolean`: Resolves fast prompt settings using a configuration key.
- `SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; Endpoint: Text; Deployment: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)` (obsolete 26.0: Using Managed AI resources now requires different input parameters. Use the other overload for SetManagedResourceAuthorization instead.): Sets the managed Azure OpenAI API authorization to use for a specific model type. This will send the Azure OpenAI call to the deployment specified in , and will use the other parameters to verify that you have access to Azure OpenAI.
- `SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; AOAIAccountName: Text; ApiKey: SecretText; ManagedResourceDeployment: Text)` (obsolete 28.0: Using Managed AI resources now requires only Model Type & Deployment Text as input parameters. Use the other overload for SetManagedResourceAuthorization instead. AOAIAccountName & ApiKey are ignored in the current version of SetManagedResourceAuthorization.): Sets the managed Azure OpenAI API authorization to use for a specific model type. This will send the Azure OpenAI call to the deployment specified in , and will use the other parameters to verify that you have access to Azure OpenAI.
- `SetManagedResourceAuthorization(ModelType: Enum "AOAI Model Type"; ManagedResourceDeployment: Text)`: Sets the managed Azure OpenAI API authorization to use for a specific model type. This will send the Azure OpenAI call to the deployment specified in , and will use the other parameters to verify that you have access to Azure OpenAI.
- `SetAuthorization(ModelType: Enum "AOAI Model Type"; Endpoint: Text; Deployment: Text; ApiKey: SecretText)`: Sets the Azure OpenAI API authorization to use for a specific model type and endpoint.
- `SetAuthorization(ModelType: Enum "AOAI Model Type"; Deployment: Text)`: Sets the Azure OpenAI API authorization to use for a specific model type.
- `GenerateTextCompletion(Prompt: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text` (obsolete 29.0: Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.): Generates a text completion given a prompt.
- `GenerateTextCompletion(Prompt: SecretText; AOAICompletionParams: Codeunit "AOAI Text Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text` (obsolete 29.0: Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.): Generates a completion given a prompt and completion parameters.
- `GenerateTextCompletion(Metaprompt: SecretText; Prompt: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text` (obsolete 29.0: Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.): Generates a text completion given a prompt.
- `GenerateTextCompletion(Metaprompt: SecretText; Prompt: SecretText; AOAICompletionParams: Codeunit "AOAI Text Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): Text` (obsolete 29.0: Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead.): Generates a completion given a prompt and completion parameters.
- `GenerateEmbeddings(Input: SecretText; var AOAIOperationResponse: Codeunit "AOAI Operation Response"): List of [Decimal]`: Generates embeddings given an input.
- `GenerateChatCompletion(var AOAIChatMessages: Codeunit "AOAI Chat Messages"; var AOAIOperationResponse: Codeunit "AOAI Operation Response")`: Generates a chat completion given a list of chat messages.
- `GenerateChatCompletion(var AOAIChatMessages: Codeunit "AOAI Chat Messages"; AOAIChatCompletionParams: Codeunit "AOAI Chat Completion Params"; var AOAIOperationResponse: Codeunit "AOAI Operation Response")`: Generates a chat completion given a list of chat messages and completion parameters.
- `SetCopilotCapability(CopilotCapability: Enum "Copilot Capability")`: Sets the copilot capability that the API is running for.

## Calls

From the extracted call graph of BC29 (graphify-al on the snapshot checkout): calls whose target is known from a declared type or an `Object::"Name"` argument. Interface dispatch and calls through events are not counted, so the list is not complete.

- [Codeunit 7772 "Azure OpenAI Impl"](../codeunit/7772.md) (9 calls: `GenerateChatCompletion → GenerateChatCompletion`, `GenerateEmbeddings → GenerateEmbeddings`, `GetFastPrompt → GetFastPrompt`, …)

## Called by

- [Codeunit 324 "No. Series Copilot Impl."](../codeunit/324.md) (6 calls: `GenerateAndReviewToolCompletionWithRetry → GenerateChatCompletion`, `GenerateNoSeries → GenerateChatCompletion`, `GenerateNoSeries → IsEnabled`, …)
- [Codeunit 4402 "SOA Output Message Setup"](../codeunit/4402.md) (6 calls: `AddSignatureToMessageBody → GenerateChatCompletion`, `AddSignatureToMessageBody → SetAuthorization`, `AddSignatureToMessageBody → SetCopilotCapability`, …)
- [Codeunit 7275 "Sales Lines Suggestions Impl."](../codeunit/7275.md) (5 calls: `AICall → GenerateChatCompletion`, `AICall → IsEnabled`, `AICall → SetAuthorization`, …)
- [Codeunit 7330 "Item Subst. Suggestion Impl."](../codeunit/7330.md) (5 calls: `AICall → GenerateChatCompletion`, `AICall → IsEnabled`, `AICall → SetAuthorization`, …)
- [Codeunit 2012 "Entity Text Impl."](../codeunit/2012.md) (4 calls: `GenerateCompletion → GenerateChatCompletion`, `GenerateCompletion → SetAuthorization`, `GenerateCompletion → SetCopilotCapability`, …)
- [Codeunit 7251 "Bank Acc. Rec. Trans. to Acc."](../codeunit/7251.md) (4 calls: `GetCompletionResponse → GenerateChatCompletion`, `GetMostAppropriateGLAccountNos → IsEnabled`, `GetMostAppropriateGLAccountNos → SetAuthorization`, …)
- [Codeunit 4399 "SOA Annotation"](../codeunit/4399.md) (3 calls: `CheckIfMessageRelevant → GenerateChatCompletion`, `CheckIfMessageRelevant → SetAuthorization`, `CheckIfMessageRelevant → SetCopilotCapability`)
- [Codeunit 4417 "SOA Item Selector"](../codeunit/4417.md) (3 calls: `TrySelectBestMatchingItems → GenerateChatCompletion`, `TrySelectBestMatchingItems → SetAuthorization`, `TrySelectBestMatchingItems → SetCopilotCapability`)
- [Codeunit 4421 "SOA Attachment MLLM"](../codeunit/4421.md) (3 calls: `TryExtractAttachmentContent → GenerateChatCompletion`, `TryExtractAttachmentContent → SetAuthorization`, `TryExtractAttachmentContent → SetCopilotCapability`)
- [Codeunit 4596 "SOA Broader Item Search"](../codeunit/4596.md) (3 calls: `AICall → GenerateChatCompletion`, `AICall → SetAuthorization`, `AICall → SetCopilotCapability`)
- [Codeunit 6331 "Sustainability Chat Completion"](../codeunit/6331.md) (3 calls: `GenerateChatCompletion → GenerateChatCompletion`, `GenerateChatCompletion → SetAuthorization`, `GenerateChatCompletion → SetCopilotCapability`)
- [Codeunit 7774 "Copilot Capability Impl"](../codeunit/7774.md) (2 calls: `GetCopilotCapabilityInfo → IsEnabled`, `GetCopilotCapabilityStatus → IsEnabled`)
- [Page 6991 "Expense Agent Setup Wizard"](../page/6991.md) (2 calls: `OnOpenPage → IsEnabled`, `ValidateCapabilityIsEnabled → IsEnabled`)
- [Codeunit 2011 "Entity Text AOAI Settings"](../codeunit/2011.md) (1 call: `IsEnabled → IsEnabled`)
- [Codeunit 4584 "SOA Recovery"](../codeunit/4584.md) (1 call: `RunSOARecovery → IsEnabled`)
- [Codeunit 4586 "SOA Dispatcher"](../codeunit/4586.md) (1 call: `CanRunTask → IsEnabled`)
- [Codeunit 6299 "Sustainability AI"](../codeunit/6299.md) (1 call: `AICall → IsEnabled`)
- [Codeunit 6938 "EA Agent Dispatcher"](../codeunit/6938.md) (1 call: `CanRunTask → IsEnabled`)
- [Page 3304 "Payables Agent Setup"](../page/3304.md) (1 call: `OnOpenPage → IsEnabled`)
- [Page 4350 "Custom Agent Setup"](../page/4350.md) (1 call: `OnOpenPage → IsEnabled`)
- [Page 4400 "SOA Setup"](../page/4400.md) (1 call: `OnOpenPage → IsEnabled`)

## Recent changes

- 2026-08-20 [#9969 Add AL fast prompt interface and wrappers](../../changes/bcapps/9969.md) (main, BC30, feature)
- 2026-08-17 [#10205 Deprecate Text Completion API in AI SDK (work item 621038)](../../changes/bcapps/10205.md) (main, BC30, obsoletion)

## Across versions

- Present in: BC23-30
- Changed (declaration) in: BC24-29

## Deprecations

- procedure SetManagedResourceAuthorization: Pending 26.0 (#if not CLEAN26), "Using Managed AI resources now requires different input parameters. Use the other overload for SetManagedResourceAuthorization instead."
- procedure SetManagedResourceAuthorization: Pending 28.0 (#if not CLEAN28), "Using Managed AI resources now requires only Model Type & Deployment Text as input parameters. Use the other overload for SetManagedResourceAuthorization instead. AOAIAccountName & ApiKey are ignored in the current version of SetManagedResourceAuthorization."
- procedure GenerateTextCompletion: Pending 29.0 (#if not CLEAN29), "Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead."
- procedure GenerateTextCompletion: Pending 29.0 (#if not CLEAN29), "Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead."
- procedure GenerateTextCompletion: Pending 29.0 (#if not CLEAN29), "Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead."
- procedure GenerateTextCompletion: Pending 29.0 (#if not CLEAN29), "Text completion models are retired by Azure OpenAI. Use GenerateChatCompletion instead."

Source: AL metadata extracted from the code (names, ids, signatures, properties); no code bodies (D10).

## Ask your agent

Procedure bodies are not stored here (D10). The call sections above are our own, per object, from the BC29 call graph. For a procedure body or the calls of one procedure, ask bc-code-atlas (external, by Stefan Maron, MIT; default corpus w1-28), which the bc-observatory plugin connects: `bcatlas_resolve_node(object_type: "codeunit", object_name: "Azure OpenAI")`, then `bcatlas_get_procedure_body` or `bcatlas_get_neighbors` on the returned id.
