Introduction
At a high level, working with the SDK has 3 steps.
- Initializing and creating an SDK object instance.
- Using the SDK instance to access capabilities like Models, Deployments, Files, Fine-Tunes or Completions, and perform operations.
- (Optional) Depending on organization's policies, use Enterprise Control feature of SDK to restrict operations that can be performed.
Initializing the SDK and creating an instance
data(sdk_instance) = zcl_peng_azoai_sdk_factory=>get_instance( )->get_sdk(
api_version = <api_version>
api_base = <AI resource base URL>
api_type = <API Type>
api_key = <AAD token or API Key>
sdkprofile = <Profile ID>
params = <Profile Parameters>
).
Enterprise Control Parameters
For SDK initialization as shown above, the sdkprofile and params are optional parameters. These are used for enterprise control, and will be covered there.
| Parameter Name | Data Type | Required | Description |
|---|---|---|---|
| sdk_instance | zif_peng_azoai_sdk | Yes | Instance of the AI SDK object. |
| api_version | string | Yes | AI Engine API Version. |
| api_base | string | Yes | AI Engine end point |
| api_type | string | Yes | AI Engine and Authentication type. |
| api_key | string | Yes | Bearer token or key for authentication. Specifics depends on AI engine being used. |
api_version
- Azure Open AI
- Open AI
Azure Open AI service APIs are versioned using the api_version parameter. All stable versions follow the YYYY-MM-DD date structure.
caution
Versions with -preview are early preview versions, and should not be used for productive applications.
| Version String | Pre-Defined SDK Value (Optional) |
|---|---|
| 2022-12-01 | zif_peng_azoai_sdk_constants=>c_versions-v_2022_12_01 |
| 2023-03-15-preview | zif_peng_azoai_sdk_constants=>c_versions-v_2023_03_15_preview |
| 2023-05-15 | zif_peng_azoai_sdk_constants=>c_versions-v_2023_05_15 |
| 2023-06-01-preview | zif_peng_azoai_sdk_constants=>c_versions-v_2023_06_01_preview |
| 2023-07-01-preview | zif_peng_azoai_sdk_constants=>c_versions-v_2023_07_01_preview |
| 2023-08-01-preview | zif_peng_azoai_sdk_constants=>c_versions-v_2023_08_01_preview |
| Version String | Pre-Defined SDK Value (Optional) |
|---|---|
| v1 | zif_peng_oai_sdk_constants=>c_versions-v1 |
api_base
- Azure Open AI
- Open AI
This value can be found in the Keys & Endpoint section when examining your resource from the Azure portal.
End Point Format
The Azure Open AI API Base takes the format https://<your resource ID>.openai.azure.com/
An example endpoint is: https://aisdktest.openai.azure.com/.
The Open AI API Base is https://api.openai.com/.
api_type
- Azure Open AI
- Open AI
| Value | Pre-Defined SDK Value (Optional) | Description |
|---|---|---|
| azure | zif_peng_azoai_sdk_constants=>c_apitype-azure | Use Key authentication. The KEY1 or KEY2 from Azure Portal should be passed in api_key parameter |
| azure_ad | zif_peng_azoai_sdk_constants=>c_apitype-azure_ad | Use Azure Active Directory token for authentication. You can read the how-to guide on authenticating with Azure Active Directory. |
| Value | Pre-Defined SDK Value (Optional) | Description |
|---|---|---|
| openai | zif_peng_azoai_sdk_constants=>c_apitype-openai | Use Open AI Token. See Open AI Initial Setup |
api_key
- Azure Open AI
- Open AI
| Value | Notes |
|---|---|
| KEY1 or KEY2 | Key from Azure Portal. The api_type must be set to azure |
| bearer token | Bearer token received from Azure Active Directory . You can read the how-to guide on authenticating with Azure Active Directory. The api_type must be set to azure_ad |
| Value | Description |
|---|---|
| Open AI Token | Use the API access key from API Keys Page |