azure.openai.deployment
Module azure.openai.deployment
ballerinax/azure.openai.deployment Ballerina library
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 run
command to compile and run the Ballerina program.
Clients
azure.openai.deployment: Client
APIs for managing deployments of OpenAI models.
Constructor
Gets invoked to initialize the connector
.
The connector initialization requires setting the API credentials. Create an Azure account, an Azure OpenAI resource and refer this guide to learn how to generate and use tokens
init (ApiKeysConfig apiKeyConfig, string serviceUrl, ConnectionConfig config)
- apiKeyConfig ApiKeysConfig - API keys for authorization
- serviceUrl string - URL of the target service
- config ConnectionConfig {} - The configurations to be used when initializing the
connector
get deployments
function get deployments(string apiVersion) returns DeploymentList|error
Gets the list of deployments owned by the Azure OpenAI resource.
Parameters
- apiVersion string - The requested API version.
Return Type
- DeploymentList|error - Success
post deployments
function post deployments(string apiVersion, Deployment payload) returns Deployment|error
Creates a new deployment for the Azure OpenAI resource according to the given specification.
Parameters
- apiVersion string - The requested API version.
- payload Deployment - The specification of the deployment including the model to deploy and the scale settings.
Return Type
- Deployment|error - The deployment has been successfully created.
get deployments/[string deploymentId]
function get deployments/[string deploymentId](string apiVersion) returns Deployment|error
Gets details for a single deployment specified by the given deployment-id.
Parameters
- apiVersion string - The requested API version.
Return Type
- Deployment|error - Success
delete deployments/[string deploymentId]
Deletes the deployment specified by the given deployment-id.
Parameters
- apiVersion string - The requested API version.
patch deployments/[string deploymentId]
function patch deployments/[string deploymentId](string apiVersion, DeploymentUpdate payload) returns Deployment|error
Updates the mutable details of the deployment with the given deployment-id.
Parameters
- apiVersion string - The requested API version.
- payload DeploymentUpdate - The updated values for the deployment.
Return Type
- Deployment|error - The update process was successfully started.
Records
azure.openai.deployment: ApiKeysConfig
Provides API key configurations needed when communicating with a remote HTTP endpoint.
Fields
- apiKey string - Provide your Cognitive Services Azure OpenAI account key here.
azure.openai.deployment: ClientHttp1Settings
Provides settings related to HTTP/1.x protocol.
Fields
- keepAlive KeepAlive(default http:KEEPALIVE_AUTO) - Specifies whether to reuse a connection for multiple requests
- chunking Chunking(default http:CHUNKING_AUTO) - The chunking behaviour of the request
- proxy ProxyConfig? - Proxy server related options
azure.openai.deployment: ConnectionConfig
Provides a set of configurations for controlling the behaviours when communicating with a remote HTTP endpoint.
Fields
- httpVersion HttpVersion(default http:HTTP_2_0) - The HTTP version understood by the client
- http1Settings ClientHttp1Settings? - Configurations related to HTTP/1.x protocol
- http2Settings ClientHttp2Settings? - Configurations related to HTTP/2 protocol
- timeout decimal(default 60) - The maximum time to wait (in seconds) for a response before closing the connection
- forwarded string(default "disable") - The choice of setting
forwarded
/x-forwarded
header
- poolConfig PoolConfiguration? - Configurations associated with request pooling
- cache CacheConfig? - HTTP caching related configurations
- compression Compression(default http:COMPRESSION_AUTO) - Specifies the way of handling compression (
accept-encoding
) header
- circuitBreaker CircuitBreakerConfig? - Configurations associated with the behaviour of the Circuit Breaker
- retryConfig RetryConfig? - Configurations associated with retrying
- responseLimits ResponseLimitConfigs? - Configurations associated with inbound response size limits
- secureSocket ClientSecureSocket? - SSL/TLS-related options
- proxy ProxyConfig? - Proxy server related options
- validation boolean(default true) - Enables the inbound payload validation functionality which provided by the constraint package. Enabled by default
azure.openai.deployment: Deployment
Deployments manage the reserved quota for Azure OpenAI models and make them available for inference requests.
Fields
- 'object TypeDiscriminator? - Defines the type of an object.
- status State? - The state of a job or item.
- created_at int? - A timestamp when this job or item was created (in unix epochs).
- updated_at int? - A timestamp when this job or item was modified last (in unix epochs).
- id string? - The identity of this item.
- model string - The OpenAI model identifier (model-id) to deploy. Can be a base model or a fine tune.
- owner string? - The owner of this deployment. For Azure OpenAI only "organization-owner" is supported.
- scale_settings ScaleSettings - The scale settings of a deployment. It defines the modes for scaling and the reserved capacity.
- 'error Error? - Error content as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: DeploymentList
Represents a list of deployments.
Fields
- 'object TypeDiscriminator? - Defines the type of an object.
- data Deployment[]? - The list of items.
azure.openai.deployment: DeploymentUpdate
Defines changes to the deployment.
Fields
- model string? - The new OpenAI model identifier (model-id) to be used for this deployment. Can be a base model or a fine tune.
- scale_settings ScaleSettingsUpdate? - The scale settings of a deployment. It defines the modes for scaling and the reserved capacity.
azure.openai.deployment: Error
Error content as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
Fields
- code ErrorCode - Error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
- message string - The message of this error.
- target string? - The location where the error happened if available.
- details Error[]? - The error details if available.
- innererror InnerError? - Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: ErrorResponse
Error response as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
Fields
- 'error Error - Error content as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: InnerError
Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
Fields
- code InnerErrorCode? - Inner error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
- innererror InnerError? - Inner error as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: ProxyConfig
Proxy server configurations to be used with the HTTP client endpoint.
Fields
- host string(default "") - Host name of the proxy server
- port int(default 0) - Proxy server port
- userName string(default "") - Proxy server username
- password string(default "") - Proxy server password
azure.openai.deployment: ScaleSettings
The scale settings of a deployment. It defines the modes for scaling and the reserved capacity.
Fields
- scale_type ScaleType - Defines how scaling operations will be executed.
azure.openai.deployment: ScaleSettingsUpdate
The scale settings of a deployment. It defines the modes for scaling and the reserved capacity.
Fields
- scale_type ScaleType - Defines how scaling operations will be executed.
String types
azure.openai.deployment: ErrorCode
ErrorCode
Error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: InnerErrorCode
InnerErrorCode
Inner error codes as defined in the Microsoft REST guidelines (https://github.com/microsoft/api-guidelines/blob/vNext/Guidelines.md#7102-error-condition-responses).
azure.openai.deployment: ScaleType
ScaleType
Defines how scaling operations will be executed.
azure.openai.deployment: State
State
The state of a job or item.
azure.openai.deployment: TypeDiscriminator
TypeDiscriminator
Defines the type of an object.
Import
import ballerinax/azure.openai.deployment;
Metadata
Released date: over 1 year ago
Version: 1.0.1
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: 2201.4.1
GraalVM compatible: Yes
Pull count
Total: 0
Current verison: 0
Weekly downloads
Keywords
AI/Deployment
Vendor/Microsoft
Cost/Paid
Model Deployment
Azure OpenAI
Contributors
Other versions
1.0.1
1.0.0