Note: There is a newer version (1.0.1) of this package available. Click here to view docs for the latest version.
Module azure.openai.deployment
ballerinax/azure.openai.deployment Ballerina library
1.0.0
Overview
This is a generated connector from Azure OpenAI Deployments API OpenAPI specification.
The Azure OpenAI Deployments REST API endpoints will deploy OpenAI models in Azure OpenAI resource.
Prerequisites
- Create an Azure account.
- Create an Azure OpenAI resource.
- Obtain the tokens. Refer to Azure OpenAI Authentication guide to learn how to generate and use tokens.
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.
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
final deployment:Client deploymentClient = check new ( apiKeyConfig = {auth: {apiKey: apiKey}}, serviceUrl = serviceUrl );
Step 3: Invoke connector operation
- 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:
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);
- Use
bal runcommand to compile and run the Ballerina program.