ballerinax/azure.openai.deployment Ballerina library

1.0.2

Overview

The Azure OpenAI Deployments API connector(https://learn.microsoft.com/en-us/rest/api/cognitiveservices/azureopenaistable/deployments/) OpenAPI specification.

The Azure OpenAI Deployments REST API endpoints will deploy OpenAI models in Azure OpenAI resource.

Key Features

  • Programmatic access to create and manage resources via REST API
  • Send and publish data through the API
  • Manage user accounts and profiles
  • Secure authentication with API key or OAuth support

Prerequisites

Quickstart

To use the Azure OpenAI Deployment connector in your Ballerina application, update the .bal file as follows:

Step 1: Import connector

Import the ballerinax/azure.openai.deployment module into the Ballerina project.

Copy
import ballerinax/azure.deployment;

Step 2: Create a new connector instance

Create and initialize a deployment:Client with the obtained apiKey and a serviceUrl from the azure OpenAI resource

Copy
final deployment:Client deploymentClient = check new (
    apiKeyConfig = {auth: {apiKey: apiKey}},
    serviceUrl = serviceUrl
);

Step 3: Invoke connector operation

  1. Now you can use the operations available within the connector.

Note: that they are in the form of remote operations.

Following is an example on deploying text-davinci-002 model:

Copy
model_deployment:Deployment deploymentPayload = {
    model: "text-davinci-002",
    scale_settings: {
        scale_type: "standard"
    }
};

model_deployment:Deployment modelDeployRes = check deploymentClient->/deployments.post("2022-12-01", deploymentPayload);
  1. Use bal run command to compile and run the Ballerina program.

Import

import ballerinax/azure.openai.deployment;Copy

Other versions

Metadata

Released date: 2 days ago

Version: 1.0.2

License: Apache-2.0


Compatibility

Platform: any

Ballerina version: 2201.8.0

GraalVM compatible: Yes


Pull count

Total: 35

Current verison: 0


Weekly downloads


Source repository


Keywords

Type/Connector

AI/Deployment

Vendor/Microsoft

Area/AI & Machine Learning

Cost/Paid

Model Deployment

Azure OpenAI


Contributors