azure_openai_client
AzureOpenaiClient - the Ruby gem for the Azure OpenAI Service API
Azure OpenAI APIs for completions and search
This SDK is automatically generated by the Swagger Codegen project:
- API version: 2023-05-15
- Package version: 1.0.0
- Build package: io.swagger.codegen.v3.generators.ruby.RubyClientCodegen
Installation
Build a gem
To build the Ruby code into a gem:
gem build azure_openai_client.gemspec
Then either install the gem locally:
gem install ./azure_openai_client-1.0.0.gem
(for development, run gem install --dev ./azure_openai_client-1.0.0.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'azure_openai_client', '~> 1.0.0'
Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/GIT_USER_ID/GIT_REPO_ID, then add the following in the Gemfile:
gem 'azure_openai_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
Include the Ruby code directly
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Getting Started
Please follow the installation procedure and then run the following code:
# Load the gem
require 'azure_openai_client'
# Setup authorization
AzureOpenaiClient.configure do |config|
# Configure API key authorization: apiKey
config.api_key['api-key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['api-key'] = 'Bearer'
# Configure OAuth2 access token for authorization: bearer
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = AzureOpenaiClient::DefaultApi.new
body = AzureOpenaiClient::ChatCompletionsBody.new # ChatCompletionsBody |
deployment_id = 'deployment_id_example' # String |
api_version = 'api_version_example' # String |
begin
#Creates a completion for the chat message
result = api_instance.chat_completions_create(body, deployment_id, api_version)
p result
rescue AzureOpenaiClient::ApiError => e
puts "Exception when calling DefaultApi->chat_completions_create: #{e}"
end
# Setup authorization
AzureOpenaiClient.configure do |config|
# Configure API key authorization: apiKey
config.api_key['api-key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['api-key'] = 'Bearer'
# Configure OAuth2 access token for authorization: bearer
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = AzureOpenaiClient::DefaultApi.new
body = AzureOpenaiClient::DeploymentidCompletionsBody.new # DeploymentidCompletionsBody |
deployment_id = 'deployment_id_example' # String |
api_version = 'api_version_example' # String |
begin
#Creates a completion for the provided prompt, parameters and chosen model.
result = api_instance.completions_create(body, deployment_id, api_version)
p result
rescue AzureOpenaiClient::ApiError => e
puts "Exception when calling DefaultApi->completions_create: #{e}"
end
# Setup authorization
AzureOpenaiClient.configure do |config|
# Configure API key authorization: apiKey
config.api_key['api-key'] = 'YOUR API KEY'
# Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil)
#config.api_key_prefix['api-key'] = 'Bearer'
# Configure OAuth2 access token for authorization: bearer
config.access_token = 'YOUR ACCESS TOKEN'
end
api_instance = AzureOpenaiClient::DefaultApi.new
body = nil # Hash |
deployment_id = 'deployment_id_example' # String | The deployment id of the model which was deployed.
api_version = 'api_version_example' # String |
begin
#Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms.
result = api_instance.(body, deployment_id, api_version)
p result
rescue AzureOpenaiClient::ApiError => e
puts "Exception when calling DefaultApi->embeddings_create: #{e}"
end
Documentation for API Endpoints
All URIs are relative to https://endpoint/openai
Class | Method | HTTP request | Description |
---|---|---|---|
AzureOpenaiClient::DefaultApi | chat_completions_create | POST /deployments/deployment-id/chat/completions | Creates a completion for the chat message |
AzureOpenaiClient::DefaultApi | completions_create | POST /deployments/deployment-id/completions | Creates a completion for the provided prompt, parameters and chosen model. |
AzureOpenaiClient::DefaultApi | embeddings_create | POST /deployments/deployment-id/embeddings | Get a vector representation of a given input that can be easily consumed by machine learning models and algorithms. |
Documentation for Models
- AzureOpenaiClient::ChatCompletionsBody
- AzureOpenaiClient::DeploymentidCompletionsBody
- AzureOpenaiClient::DeploymentidEmbeddingsBody
- AzureOpenaiClient::DeploymentsdeploymentidchatcompletionsMessages
- AzureOpenaiClient::ErrorResponse
- AzureOpenaiClient::ErrorResponseError
- AzureOpenaiClient::InlineResponse200
- AzureOpenaiClient::InlineResponse2001
- AzureOpenaiClient::InlineResponse2001Data
- AzureOpenaiClient::InlineResponse2001Usage
- AzureOpenaiClient::InlineResponse2002
- AzureOpenaiClient::InlineResponse2002Choices
- AzureOpenaiClient::InlineResponse2002Message
- AzureOpenaiClient::InlineResponse2002Usage
- AzureOpenaiClient::InlineResponse200Choices
- AzureOpenaiClient::InlineResponse200Logprobs
- AzureOpenaiClient::InlineResponse200Usage
- AzureOpenaiClient::OneOfchatCompletionsBodyStop
- AzureOpenaiClient::OneOfdeploymentidCompletionsBodyPrompt
- AzureOpenaiClient::OneOfdeploymentidCompletionsBodyStop
Documentation for Authorization
apiKey
- Type: API key
- API key parameter name: api-key
- Location: HTTP header
bearer
- Type: OAuth
- Flow: implicit
- Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
- Scopes: