class Anthropic::Client
def initialize(
-
max_retry_delay
(Float
) -- -
initial_retry_delay
(Float
) -- -
timeout
(Float
) -- -
max_retries
(Integer
) -- Max number of retries to attempt after a failed retryable request. -
base_url
(String, nil
) -- Override the default base URL for the API, e.g., -
auth_token
(String, nil
) -- Defaults to `ENV["ANTHROPIC_AUTH_TOKEN"]` -
api_key
(String, nil
) -- Defaults to `ENV["ANTHROPIC_API_KEY"]`
def initialize( api_key: ENV["ANTHROPIC_API_KEY"], auth_token: ENV["ANTHROPIC_AUTH_TOKEN"], base_url: ENV["ANTHROPIC_BASE_URL"], max_retries: self.class::DEFAULT_MAX_RETRIES, timeout: self.class::DEFAULT_TIMEOUT_IN_SECONDS, initial_retry_delay: self.class::DEFAULT_INITIAL_RETRY_DELAY, max_retry_delay: self.class::DEFAULT_MAX_RETRY_DELAY ) base_url ||= "https://api.anthropic.com" headers = { "anthropic-version" => "2023-06-01" } @api_key = api_key&.to_s @auth_token = auth_token&.to_s super( base_url: base_url, timeout: timeout, max_retries: max_retries, initial_retry_delay: initial_retry_delay, max_retry_delay: max_retry_delay, headers: headers ) @completions = Anthropic::Resources::Completions.new(client: self) @messages = Anthropic::Resources::Messages.new(client: self) @models = Anthropic::Resources::Models.new(client: self) @beta = Anthropic::Resources::Beta.new(client: self) end