Class: Getimg::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/getimg/client.rb,
lib/getimg/client/models.rb,
lib/getimg/client/account.rb,
lib/getimg/client/enhancements.rb,
lib/getimg/client/stable_diffusion.rb,
lib/getimg/client/stable_diffusion_xl.rb

Overview

Client for the getimg API

Defined Under Namespace

Classes: Account, Enhancements, Models, StableDiffusion, StableDiffusionXl

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil) ⇒ Client

Returns a new instance of Client.



22
23
24
# File 'lib/getimg/client.rb', line 22

def initialize(api_key = nil)
  @api_key = api_key || ENV["GETIMG_API_LEY"]
end

Instance Method Details

#accountObject



42
43
44
# File 'lib/getimg/client.rb', line 42

def 
  @account ||= Account.new(self)
end

#enhancementsObject



38
39
40
# File 'lib/getimg/client.rb', line 38

def enhancements
  @enhancements ||= Enhancements.new(self)
end

#get(path, options = {}) ⇒ Object



46
47
48
49
# File 'lib/getimg/client.rb', line 46

def get(path, options = {})
  options = default_request_options.merge({query: options})
  handle_response(self.class.get(path, options))
end

#modelsObject



26
27
28
# File 'lib/getimg/client.rb', line 26

def models
  @models ||= Models.new(self)
end

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



51
52
53
54
# File 'lib/getimg/client.rb', line 51

def post(path, options = {}, headers = {})
  options = default_request_options(headers).merge({body: options.to_json})
  handle_response(self.class.post(path, options))
end

#stable_diffusionObject



30
31
32
# File 'lib/getimg/client.rb', line 30

def stable_diffusion
  @stable_diffusion ||= StableDiffusion.new(self)
end

#stable_diffusion_xlObject



34
35
36
# File 'lib/getimg/client.rb', line 34

def stable_diffusion_xl
  @stable_diffusion_xl ||= StableDiffusionXl.new(self)
end