Module: Anthropic::Api::Concerns::Requestable

Included in:
Base
Defined in:
lib/anthropic/api/concerns/requestable.rb

Overview

Provides helpers for sending API requests

Instance Method Summary collapse

Instance Method Details

#additional_headersObject



21
22
23
# File 'lib/anthropic/api/concerns/requestable.rb', line 21

def additional_headers
  {}.merge(beta_headers)
end

#beta_headersObject



25
26
27
28
29
30
31
32
# File 'lib/anthropic/api/concerns/requestable.rb', line 25

def beta_headers
  return {} unless beta

  header = beta_config['header']
  raise Anthropic::Api::InvalidBetaConfigurationError, "Missing header: #{beta}" unless header

  header
end

#post(params) ⇒ Object



9
10
11
# File 'lib/anthropic/api/concerns/requestable.rb', line 9

def post(params)
  Anthropic::Client::Standard.post(uri, params, additional_headers)
end

#post_as_stream(params) ⇒ Object



13
14
15
# File 'lib/anthropic/api/concerns/requestable.rb', line 13

def post_as_stream(params, &)
  Anthropic::Client::Streaming.post(uri, params, additional_headers, &)
end

#uriObject



17
18
19
# File 'lib/anthropic/api/concerns/requestable.rb', line 17

def uri
  "#{Anthropic.api_host}#{version_config['endpoint']}"
end