No release in over a year
Azure OpenAI APIs for completions and search
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.6, >= 3.6.0

Runtime

>= 1.0.1, < 3.0
 Project Readme

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 OpenAPI Generator project:

  • API version: 2023-05-15
  • Package version: 0.0.4
  • Build package: org.openapitools.codegen.languages.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-0.0.4.gem

(for development, run gem install --dev ./azure_openai_client-0.0.4.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', '~> 0.0.4'

Install from Git

If the Ruby gem is hosted at a git repository: https://github.com/etsenake/azure-openai-client, then add the following in the Gemfile:

gem 'azure_openai_client', :git => 'https://github.com/etsenake/azure-openai-client.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['apiKey'] = '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['apiKey'] = 'Bearer'
  # Configure faraday connection
  config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' }

  # Configure OAuth2 access token for authorization: bearer
  config.access_token = 'YOUR ACCESS TOKEN'
  # Configure a proc to get access tokens in lieu of the static access_token configuration
  config.access_token_getter = -> { 'YOUR TOKEN GETTER PROC' } 
  # Configure faraday connection
  config.configure_faraday_connection { |connection| 'YOUR CONNECTION CONFIG PROC' }
end

api_instance = AzureOpenaiClient::DefaultApi.new
deployment_id = 'deployment_id_example' # String | 
api_version = '2023-05-15' # String | 
chat_completions_create_request = AzureOpenaiClient::ChatCompletionsCreateRequest.new({messages: [AzureOpenaiClient::ChatCompletionsCreateRequestMessagesInner.new({role: 'system', content: 'content_example'})]}) # ChatCompletionsCreateRequest | 

begin
  #Creates a completion for the chat message
  result = api_instance.chat_completions_create(deployment_id, api_version, chat_completions_create_request)
  p result
rescue AzureOpenaiClient::ApiError => e
  puts "Exception when calling DefaultApi->chat_completions_create: #{e}"
end

Documentation for API Endpoints

All URIs are relative to https://your-resource-name.openai.azure.com/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

Documentation for Authorization

Authentication schemes defined for the API:

bearer

apiKey

  • Type: API key
  • API key parameter name: api-key
  • Location: HTTP header