Class: StabilityAI::Client
- Inherits:
-
Object
- Object
- StabilityAI::Client
- Defined in:
- lib/stabilityai/client.rb
Class Method Summary collapse
- .delete(path:) ⇒ Object
- .get(path:) ⇒ Object
- .json_post(path:, parameters:) ⇒ Object
- .multipart_post(path:, parameters: nil) ⇒ Object
Instance Method Summary collapse
- #account ⇒ Object
- #balance ⇒ Object
- #engines ⇒ Object
-
#images ⇒ Object
StabilityAI::Client.multipart_post(path: “/image-to-image”, parameters: parameters) end.
-
#initialize(access_token: nil, organization_id: nil, folder: nil, engine_id: nil, uri_base: nil, request_timeout: nil) ⇒ Client
constructor
A new instance of Client.
- #text_to_image(parameters: {}) ⇒ Object
Constructor Details
#initialize(access_token: nil, organization_id: nil, folder: nil, engine_id: nil, uri_base: nil, request_timeout: nil) ⇒ Client
Returns a new instance of Client.
3 4 5 6 7 8 9 10 11 |
# File 'lib/stabilityai/client.rb', line 3 def initialize(access_token: nil, organization_id: nil, folder: nil, engine_id: nil, uri_base: nil, request_timeout: nil) StabilityAI.configuration.access_token = access_token if access_token StabilityAI.configuration.organization_id = organization_id if organization_id StabilityAI.configuration.engine_id = engine_id if engine_id StabilityAI.configuration.folder = folder if folder StabilityAI.configuration.uri_base = uri_base if uri_base StabilityAI.configuration.request_timeout = request_timeout if request_timeout end |
Class Method Details
.delete(path:) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/stabilityai/client.rb', line 63 def self.delete(path:) HTTParty.delete( uri(path: path), headers: headers, timeout: request_timeout ) end |
.get(path:) ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/stabilityai/client.rb', line 37 def self.get(path:) HTTParty.get( get_uri(path: path), headers: headers, timeout: request_timeout ) end |
.json_post(path:, parameters:) ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/stabilityai/client.rb', line 45 def self.json_post(path:, parameters:) HTTParty.post( uri(path: path), headers: headers, body: parameters&.to_json, timeout: request_timeout ) end |
.multipart_post(path:, parameters: nil) ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/stabilityai/client.rb', line 54 def self.multipart_post(path:, parameters: nil) HTTParty.post( uri(path: path), headers: headers.merge({ "Content-Type" => "multipart/form-data" }), body: parameters, timeout: request_timeout ) end |
Instance Method Details
#account ⇒ Object
29 30 31 |
# File 'lib/stabilityai/client.rb', line 29 def account StabilityAI::Client.get(path: "/user/account") end |
#balance ⇒ Object
33 34 35 |
# File 'lib/stabilityai/client.rb', line 33 def balance StabilityAI::Client.get(path: "/user/balance") end |
#engines ⇒ Object
25 26 27 |
# File 'lib/stabilityai/client.rb', line 25 def engines StabilityAI::Client.get(path: "/engines/list") end |
#images ⇒ Object
StabilityAI::Client.multipart_post(path: “/image-to-image”, parameters: parameters) end
21 22 23 |
# File 'lib/stabilityai/client.rb', line 21 def images @images ||= StabilityAI::Images.new end |
#text_to_image(parameters: {}) ⇒ Object
13 14 15 |
# File 'lib/stabilityai/client.rb', line 13 def text_to_image(parameters: {}) StabilityAI::Client.json_post(path: "/text-to-image", parameters: parameters) end |