Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions lib/openai/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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,
Expand All @@ -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 = {
Expand Down
6 changes: 3 additions & 3 deletions rbi/lib/openai/client.rbi
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion sig/openai/client.rbs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down