Class: GenAI::Api::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/gen_ai/api/client.rb

Instance Method Summary collapse

Constructor Details

#initialize(url:, token:, headers: {}) ⇒ Client

Returns a new instance of Client.



9
10
11
12
13
# File 'lib/gen_ai/api/client.rb', line 9

def initialize(url:, token:, headers: {})
  @url = url
  @token = token
  @headers = headers
end

Instance Method Details

#get(path, options) ⇒ Object



24
25
26
27
28
# File 'lib/gen_ai/api/client.rb', line 24

def get(path, options)
  handle_response do
    connection.get(path, options)
  end
end

#post(path, body, options = {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/gen_ai/api/client.rb', line 15

def post(path, body, options = {})
  multipart = options.delete(:multipart) || false
  payload = multipart ? body : JSON.generate(body)

  handle_response do
    connection(multipart: multipart).post(path, payload)
  end
end