diff --git a/lib/openai/client.rb b/lib/openai/client.rb index 02db6417..2bfddd02 100644 --- a/lib/openai/client.rb +++ b/lib/openai/client.rb @@ -77,14 +77,14 @@ class Client < OpenAI::Transport::BaseClient # Creates and returns a new client for interacting with the API. # - # @param base_url [String, nil] Override the default base URL for the API, e.g., `"https://api.example.com/v2/"` - # # @param api_key [String, nil] Defaults to `ENV["OPENAI_API_KEY"]` # # @param organization [String, nil] Defaults to `ENV["OPENAI_ORG_ID"]` # # @param project [String, nil] Defaults to `ENV["OPENAI_PROJECT_ID"]` # + # @param base_url [String, nil] Override the default base URL for the API, e.g., `"https://api.example.com/v2/"` + # # @param max_retries [Integer] Max number of retries to attempt after a failed retryable request. # # @param timeout [Float] @@ -93,10 +93,10 @@ class Client < OpenAI::Transport::BaseClient # # @param max_retry_delay [Float] def initialize( - base_url: nil, api_key: ENV["OPENAI_API_KEY"], organization: ENV["OPENAI_ORG_ID"], project: ENV["OPENAI_PROJECT_ID"], + base_url: nil, max_retries: DEFAULT_MAX_RETRIES, timeout: DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: DEFAULT_INITIAL_RETRY_DELAY, @@ -105,7 +105,7 @@ def initialize( base_url ||= "https://api.openai.com/v1" if api_key.nil? - raise ArgumentError.new("api_key is required") + raise ArgumentError.new("api_key is required, and can be set via environ: \"OPENAI_API_KEY\"") end headers = { diff --git a/rbi/lib/openai/client.rbi b/rbi/lib/openai/client.rbi index 5f320546..41d82819 100644 --- a/rbi/lib/openai/client.rbi +++ b/rbi/lib/openai/client.rbi @@ -69,10 +69,10 @@ module OpenAI # Creates and returns a new client for interacting with the API. sig do params( - base_url: T.nilable(String), api_key: T.nilable(String), organization: T.nilable(String), project: T.nilable(String), + base_url: T.nilable(String), max_retries: Integer, timeout: Float, initial_retry_delay: Float, @@ -81,14 +81,14 @@ module OpenAI .returns(T.attached_class) end def self.new( - # Override the default base URL for the API, e.g., `"https://api.example.com/v2/"` - base_url: nil, # Defaults to `ENV["OPENAI_API_KEY"]` api_key: ENV["OPENAI_API_KEY"], # Defaults to `ENV["OPENAI_ORG_ID"]` organization: ENV["OPENAI_ORG_ID"], # Defaults to `ENV["OPENAI_PROJECT_ID"]` project: ENV["OPENAI_PROJECT_ID"], + # Override the default base URL for the API, e.g., `"https://api.example.com/v2/"` + base_url: nil, # Max number of retries to attempt after a failed retryable request. max_retries: DEFAULT_MAX_RETRIES, timeout: DEFAULT_TIMEOUT_IN_SECONDS, diff --git a/sig/openai/client.rbs b/sig/openai/client.rbs index a7a4533d..6b95a137 100644 --- a/sig/openai/client.rbs +++ b/sig/openai/client.rbs @@ -45,10 +45,10 @@ module OpenAI private def auth_headers: -> ::Hash[String, String] def initialize: ( - ?base_url: String?, ?api_key: String?, ?organization: String?, ?project: String?, + ?base_url: String?, ?max_retries: Integer, ?timeout: Float, ?initial_retry_delay: Float,