Module: Anthropic

Defined in:
lib/anthropic.rb,
lib/anthropic/version.rb,
lib/anthropic/api/base.rb,
lib/anthropic/client/base.rb,
lib/anthropic/api/messages.rb,
lib/anthropic/bootstrapper.rb,
lib/anthropic/api/completions.rb,
lib/anthropic/client/standard.rb,
lib/anthropic/client/streaming.rb,
lib/anthropic/api/concerns/requestable.rb,
lib/anthropic/api/concerns/validatable.rb

Overview

Namespace for anthropic-rb gem

Defined Under Namespace

Modules: Api, Bootstrapper, Client

Constant Summary collapse

VERSION =
'0.6.0'

Class Method Summary collapse

Class Method Details

.api_hostObject



32
33
34
# File 'lib/anthropic.rb', line 32

def self.api_host
  @api_host || ENV.fetch('ANTHROPIC_API_HOST', 'https://api.anthropic.com')
end

.api_host=(api_host = nil) ⇒ Object



36
37
38
# File 'lib/anthropic.rb', line 36

def self.api_host=(api_host = nil)
  @api_host = api_host
end

.api_keyObject



24
25
26
# File 'lib/anthropic.rb', line 24

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

.api_key=(api_key = nil) ⇒ Object



28
29
30
# File 'lib/anthropic.rb', line 28

def self.api_key=(api_key = nil)
  @api_key = api_key
end

.api_versionObject



40
41
42
# File 'lib/anthropic.rb', line 40

def self.api_version
  @api_version || ENV.fetch('ANTHROPIC_API_VERSION', '2023-06-01')
end

.api_version=(api_version = nil) ⇒ Object



44
45
46
# File 'lib/anthropic.rb', line 44

def self.api_version=(api_version = nil)
  @api_version = api_version
end

.betasObject



48
49
50
# File 'lib/anthropic.rb', line 48

def self.betas
  @betas
end

.completionsObject



56
57
58
# File 'lib/anthropic.rb', line 56

def self.completions
  Anthropic::Api::Completions.new
end

.messagesObject



60
61
62
# File 'lib/anthropic.rb', line 60

def self.messages(...)
  Anthropic::Api::Messages.new(...)
end

.resetObject



18
19
20
21
22
# File 'lib/anthropic.rb', line 18

def self.reset
  @api_key = nil
  @api_host = nil
  @api_version = nil
end

.setup {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

  • _self (Anthropic)

    the object that the method was called on



12
13
14
15
16
# File 'lib/anthropic.rb', line 12

def self.setup
  yield self
  @betas = Bootstrapper.load_betas
  @versions = Bootstrapper.load_versions
end

.versionsObject



52
53
54
# File 'lib/anthropic.rb', line 52

def self.versions
  @versions
end