Class: OpenAI::Providers::Azure::Auth Private
- Inherits:
-
Object
- Object
- OpenAI::Providers::Azure::Auth
- Defined in:
- lib/openai/providers/azure.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Method Summary collapse
-
#initialize(base_url:, credential_provider:, authentication:) ⇒ Auth
constructor
private
A new instance of Auth.
- #prepare_request(request) ⇒ Object private
Constructor Details
#initialize(base_url:, credential_provider:, authentication:) ⇒ Auth
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Auth.
43 44 45 46 47 |
# File 'lib/openai/providers/azure.rb', line 43 def initialize(base_url:, credential_provider:, authentication:) @base_url = URI(base_url) @credential_provider = credential_provider @authentication = authentication end |
Instance Method Details
#prepare_request(request) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/openai/providers/azure.rb', line 49 def prepare_request(request) Azure.validate_origin!(request.fetch(:url), @base_url) marker = @authentication == :api_key ? API_KEY_AUTH_MARKER : BEARER_AUTH_MARKER headers = Azure.provider_headers(request, marker: marker) credential = resolve_credential auth_header = if @authentication == :api_key {"api-key" => credential} else {"authorization" => "Bearer #{credential}"} end request.merge(headers: headers.merge(auth_header), provider_auth: marker) end |