Class: ActiveGenie::Config::Providers::OpenaiConfig

Inherits:
ProviderBase
  • Object
show all
Defined in:
lib/active_genie/configs/providers/openai_config.rb

Overview

Configuration class for the OpenAI API client. Manages API keys, organization IDs, URLs, model selections, and client instantiation.

Instance Attribute Summary

Attributes inherited from ProviderBase

#organization

Instance Method Summary collapse

Methods inherited from ProviderBase

#initialize, #to_h, #valid?

Constructor Details

This class inherits a constructor from ActiveGenie::Config::Providers::ProviderBase

Instance Method Details

#api_keyString?

Retrieves the API key. Falls back to the OPENAI_API_KEY environment variable if not set.

Returns:

  • (String, nil)

    The API key.



14
15
16
# File 'lib/active_genie/configs/providers/openai_config.rb', line 14

def api_key
  @api_key || ENV.fetch('OPENAI_API_KEY', nil)
end

#api_urlString

Retrieves the base API URL for OpenAI API. Defaults to ‘api.openai.com/v1’.

Returns:

  • (String)

    The API base URL.



21
22
23
# File 'lib/active_genie/configs/providers/openai_config.rb', line 21

def api_url
  @api_url || 'https://api.openai.com/v1'
end

#default_modelObject



25
26
27
# File 'lib/active_genie/configs/providers/openai_config.rb', line 25

def default_model
  @default_model || 'gpt-5-mini'
end

#valid_model?(model) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/active_genie/configs/providers/openai_config.rb', line 29

def valid_model?(model)
  model.include?('gpt')
end