AzureAIClient - 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: 1.0.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
To build the Ruby code into a gem:
gem build azureai_client.gemspec
Then either install the gem locally:
gem install ./azureai_client-1.0.0.gem
(for development, run gem install --dev ./azureai_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 'azureai_client', '~> 1.0.0'
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 'azureai_client', :git => 'https://github.com/GIT_USER_ID/GIT_REPO_ID.git'
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Please follow the installation procedure and then run the following code:
# Load the gem
require 'azureai_client'
# Setup authorization
AzureAIClient.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 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' }
end
api_instance = AzureAIClient::DefaultApi.new
deployment_id = 'deployment_id_example' # String |
api_version = '2023-05-15' # String |
chat_completions_create_request = AzureAIClient::ChatCompletionsCreateRequest.new({messages: [AzureAIClient::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 AzureAIClient::ApiError => e
puts "Exception when calling DefaultApi->chat_completions_create: #{e}"
end
All URIs are relative to https://your-resource-name.openai.azure.com/openai
Class | Method | HTTP request | Description |
---|---|---|---|
AzureAIClient::DefaultApi | chat_completions_create | POST /deployments/{deployment-id}/chat/completions | Creates a completion for the chat message |
AzureAIClient::DefaultApi | completions_create | POST /deployments/{deployment-id}/completions | Creates a completion for the provided prompt, parameters and chosen model. |
AzureAIClient::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. |
- AzureAIClient::ChatCompletionsCreate200Response
- AzureAIClient::ChatCompletionsCreate200ResponseChoicesInner
- AzureAIClient::ChatCompletionsCreate200ResponseChoicesInnerMessage
- AzureAIClient::ChatCompletionsCreate200ResponseUsage
- AzureAIClient::ChatCompletionsCreateRequest
- AzureAIClient::ChatCompletionsCreateRequestMessagesInner
- AzureAIClient::ChatCompletionsCreateRequestStop
- AzureAIClient::CompletionsCreate200Response
- AzureAIClient::CompletionsCreate200ResponseChoicesInner
- AzureAIClient::CompletionsCreate200ResponseChoicesInnerLogprobs
- AzureAIClient::CompletionsCreate200ResponseUsage
- AzureAIClient::CompletionsCreateRequest
- AzureAIClient::CompletionsCreateRequestPrompt
- AzureAIClient::CompletionsCreateRequestStop
- AzureAIClient::EmbeddingsCreate200Response
- AzureAIClient::EmbeddingsCreate200ResponseDataInner
- AzureAIClient::EmbeddingsCreate200ResponseUsage
- AzureAIClient::EmbeddingsCreateRequest
- AzureAIClient::EmbeddingsCreateRequestInput
- AzureAIClient::ErrorResponse
- AzureAIClient::ErrorResponseError
Authentication schemes defined for the API:
- Type: OAuth
- Flow: implicit
- Authorization URL: https://login.microsoftonline.com/common/oauth2/v2.0/authorize
- Scopes: N/A
- Type: API key
- API key parameter name: api-key
- Location: HTTP header