Class: VeniceClient::GenerateImageRequest
- Inherits:
-
Object
- Object
- VeniceClient::GenerateImageRequest
- Defined in:
- lib/venice_client/models/generate_image_request.rb
Defined Under Namespace
Classes: EnumAttributeValidator
Instance Attribute Summary collapse
-
#cfg_scale ⇒ Object
CFG scale parameter.
-
#embed_exif_metadata ⇒ Object
Embed prompt generation information into the image’s EXIF metadata.
-
#format ⇒ Object
The image format to return.
-
#height ⇒ Object
Height of the generated image.
-
#hide_watermark ⇒ Object
Whether to hide the Venice watermark.
-
#inpaint ⇒ Object
This feature is deprecated and was disabled on May 19th, 2025.
-
#lora_strength ⇒ Object
Lora strength for the model.
-
#model ⇒ Object
The model to use for image generation.
-
#negative_prompt ⇒ Object
A description of what should not be in the image.
-
#prompt ⇒ Object
The description for the image.
-
#return_binary ⇒ Object
Whether to return binary image data instead of base64.
-
#safe_mode ⇒ Object
Whether to use safe mode.
-
#seed ⇒ Object
Random seed for generation.
-
#steps ⇒ Object
Number of inference steps.
-
#style_preset ⇒ Object
An image style to apply to the image.
-
#width ⇒ Object
Width of the generated image.
Class Method Summary collapse
-
._deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ GenerateImageRequest
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ GenerateImageRequest
Initializes the object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/venice_client/models/generate_image_request.rb', line 151 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `VeniceClient::GenerateImageRequest` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `VeniceClient::GenerateImageRequest`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'cfg_scale') self.cfg_scale = attributes[:'cfg_scale'] end if attributes.key?(:'embed_exif_metadata') self. = attributes[:'embed_exif_metadata'] else self. = false end if attributes.key?(:'format') self.format = attributes[:'format'] else self.format = 'webp' end if attributes.key?(:'height') self.height = attributes[:'height'] else self.height = 1024 end if attributes.key?(:'hide_watermark') self.hide_watermark = attributes[:'hide_watermark'] else self.hide_watermark = false end if attributes.key?(:'inpaint') self.inpaint = attributes[:'inpaint'] end if attributes.key?(:'lora_strength') self.lora_strength = attributes[:'lora_strength'] end if attributes.key?(:'model') self.model = attributes[:'model'] else self.model = nil end if attributes.key?(:'negative_prompt') self.negative_prompt = attributes[:'negative_prompt'] end if attributes.key?(:'prompt') self.prompt = attributes[:'prompt'] else self.prompt = nil end if attributes.key?(:'return_binary') self.return_binary = attributes[:'return_binary'] else self.return_binary = false end if attributes.key?(:'safe_mode') self.safe_mode = attributes[:'safe_mode'] else self.safe_mode = true end if attributes.key?(:'seed') self.seed = attributes[:'seed'] else self.seed = 0 end if attributes.key?(:'steps') self.steps = attributes[:'steps'] else self.steps = 20 end if attributes.key?(:'style_preset') self.style_preset = attributes[:'style_preset'] end if attributes.key?(:'width') self.width = attributes[:'width'] else self.width = 1024 end end |
Instance Attribute Details
#cfg_scale ⇒ Object
CFG scale parameter. Higher values lead to more adherence to the prompt.
19 20 21 |
# File 'lib/venice_client/models/generate_image_request.rb', line 19 def cfg_scale @cfg_scale end |
#embed_exif_metadata ⇒ Object
Embed prompt generation information into the image’s EXIF metadata.
22 23 24 |
# File 'lib/venice_client/models/generate_image_request.rb', line 22 def @embed_exif_metadata end |
#format ⇒ Object
The image format to return. WebP are smaller and optimized for web use. PNG are higher quality but larger in file size.
25 26 27 |
# File 'lib/venice_client/models/generate_image_request.rb', line 25 def format @format end |
#height ⇒ Object
Height of the generated image. Each model has a specific height and width divisor listed in the widthHeightDivisor constraint in the model list endpoint.
28 29 30 |
# File 'lib/venice_client/models/generate_image_request.rb', line 28 def height @height end |
#hide_watermark ⇒ Object
Whether to hide the Venice watermark. Venice may ignore this parameter for certain generated content.
31 32 33 |
# File 'lib/venice_client/models/generate_image_request.rb', line 31 def hide_watermark @hide_watermark end |
#inpaint ⇒ Object
This feature is deprecated and was disabled on May 19th, 2025. A revised in-painting API will be launched in the near future.
34 35 36 |
# File 'lib/venice_client/models/generate_image_request.rb', line 34 def inpaint @inpaint end |
#lora_strength ⇒ Object
Lora strength for the model. Only applies if the model uses additional Loras.
37 38 39 |
# File 'lib/venice_client/models/generate_image_request.rb', line 37 def lora_strength @lora_strength end |
#model ⇒ Object
The model to use for image generation.
40 41 42 |
# File 'lib/venice_client/models/generate_image_request.rb', line 40 def model @model end |
#negative_prompt ⇒ Object
A description of what should not be in the image. Character limit is model specific and is listed in the promptCharacterLimit constraint in the model list endpoint.
43 44 45 |
# File 'lib/venice_client/models/generate_image_request.rb', line 43 def negative_prompt @negative_prompt end |
#prompt ⇒ Object
The description for the image. Character limit is model specific and is listed in the promptCharacterLimit setting in the model list endpoint.
46 47 48 |
# File 'lib/venice_client/models/generate_image_request.rb', line 46 def prompt @prompt end |
#return_binary ⇒ Object
Whether to return binary image data instead of base64.
49 50 51 |
# File 'lib/venice_client/models/generate_image_request.rb', line 49 def return_binary @return_binary end |
#safe_mode ⇒ Object
Whether to use safe mode. If enabled, this will blur images that are classified as having adult content.
52 53 54 |
# File 'lib/venice_client/models/generate_image_request.rb', line 52 def safe_mode @safe_mode end |
#seed ⇒ Object
Random seed for generation. If not provided, a random seed will be used.
55 56 57 |
# File 'lib/venice_client/models/generate_image_request.rb', line 55 def seed @seed end |
#steps ⇒ Object
Number of inference steps. The following models have reduced max steps from the global max: venice-sd35: 30 max steps, hidream: 50 max steps, fluently-xl: 50 max steps, flux-dev: 30 max steps, flux-dev-uncensored-11: 30 max steps, flux-dev-uncensored: 30 max steps, lustify-sdxl: 50 max steps, pony-realism: 50 max steps, stable-diffusion-3.5: 30 max steps. These constraints are exposed in the model list endpoint for each model.
58 59 60 |
# File 'lib/venice_client/models/generate_image_request.rb', line 58 def steps @steps end |
#style_preset ⇒ Object
An image style to apply to the image. Visit docs.venice.ai/api-reference/endpoint/image/styles for more details.
61 62 63 |
# File 'lib/venice_client/models/generate_image_request.rb', line 61 def style_preset @style_preset end |
#width ⇒ Object
Width of the generated image. Each model has a specific height and width divisor listed in the widthHeightDivisor constraint in the model list endpoint.
64 65 66 |
# File 'lib/venice_client/models/generate_image_request.rb', line 64 def width @width end |
Class Method Details
._deserialize(type, value) ⇒ Object
Deserializes the data based on type
576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 |
# File 'lib/venice_client/models/generate_image_request.rb', line 576 def self._deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = VeniceClient.const_get(type) klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
111 112 113 |
# File 'lib/venice_client/models/generate_image_request.rb', line 111 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
116 117 118 |
# File 'lib/venice_client/models/generate_image_request.rb', line 116 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/venice_client/models/generate_image_request.rb', line 89 def self.attribute_map { :'cfg_scale' => :'cfg_scale', :'embed_exif_metadata' => :'embed_exif_metadata', :'format' => :'format', :'height' => :'height', :'hide_watermark' => :'hide_watermark', :'inpaint' => :'inpaint', :'lora_strength' => :'lora_strength', :'model' => :'model', :'negative_prompt' => :'negative_prompt', :'prompt' => :'prompt', :'return_binary' => :'return_binary', :'safe_mode' => :'safe_mode', :'seed' => :'seed', :'steps' => :'steps', :'style_preset' => :'style_preset', :'width' => :'width' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 |
# File 'lib/venice_client/models/generate_image_request.rb', line 552 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
143 144 145 146 147 |
# File 'lib/venice_client/models/generate_image_request.rb', line 143 def self.openapi_nullable Set.new([ :'inpaint', ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/venice_client/models/generate_image_request.rb', line 121 def self.openapi_types { :'cfg_scale' => :'Float', :'embed_exif_metadata' => :'Boolean', :'format' => :'String', :'height' => :'Integer', :'hide_watermark' => :'Boolean', :'inpaint' => :'Object', :'lora_strength' => :'Integer', :'model' => :'String', :'negative_prompt' => :'String', :'prompt' => :'String', :'return_binary' => :'Boolean', :'safe_mode' => :'Boolean', :'seed' => :'Integer', :'steps' => :'Integer', :'style_preset' => :'String', :'width' => :'Integer' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 |
# File 'lib/venice_client/models/generate_image_request.rb', line 516 def ==(o) return true if self.equal?(o) self.class == o.class && cfg_scale == o.cfg_scale && == o. && format == o.format && height == o.height && hide_watermark == o.hide_watermark && inpaint == o.inpaint && lora_strength == o.lora_strength && model == o.model && negative_prompt == o.negative_prompt && prompt == o.prompt && return_binary == o.return_binary && safe_mode == o.safe_mode && seed == o.seed && steps == o.steps && style_preset == o.style_preset && width == o.width end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
647 648 649 650 651 652 653 654 655 656 657 658 659 |
# File 'lib/venice_client/models/generate_image_request.rb', line 647 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#eql?(o) ⇒ Boolean
539 540 541 |
# File 'lib/venice_client/models/generate_image_request.rb', line 539 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
545 546 547 |
# File 'lib/venice_client/models/generate_image_request.rb', line 545 def hash [cfg_scale, , format, height, hide_watermark, inpaint, lora_strength, model, negative_prompt, prompt, return_binary, safe_mode, seed, steps, style_preset, width].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
# File 'lib/venice_client/models/generate_image_request.rb', line 254 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new if !@cfg_scale.nil? && @cfg_scale > 20 invalid_properties.push('invalid value for "cfg_scale", must be smaller than or equal to 20.') end if !@cfg_scale.nil? && @cfg_scale <= 0 invalid_properties.push('invalid value for "cfg_scale", must be greater than 0.') end if !@height.nil? && @height > 1280 invalid_properties.push('invalid value for "height", must be smaller than or equal to 1280.') end if !@height.nil? && @height <= 0 invalid_properties.push('invalid value for "height", must be greater than 0.') end if !@lora_strength.nil? && @lora_strength > 100 invalid_properties.push('invalid value for "lora_strength", must be smaller than or equal to 100.') end if !@lora_strength.nil? && @lora_strength < 0 invalid_properties.push('invalid value for "lora_strength", must be greater than or equal to 0.') end if @model.nil? invalid_properties.push('invalid value for "model", model cannot be nil.') end if !@negative_prompt.nil? && @negative_prompt.to_s.length > 1500 invalid_properties.push('invalid value for "negative_prompt", the character length must be smaller than or equal to 1500.') end if @prompt.nil? invalid_properties.push('invalid value for "prompt", prompt cannot be nil.') end if @prompt.to_s.length > 1500 invalid_properties.push('invalid value for "prompt", the character length must be smaller than or equal to 1500.') end if @prompt.to_s.length < 1 invalid_properties.push('invalid value for "prompt", the character length must be greater than or equal to 1.') end if !@seed.nil? && @seed > 999999999 invalid_properties.push('invalid value for "seed", must be smaller than or equal to 999999999.') end if !@seed.nil? && @seed < -999999999 invalid_properties.push('invalid value for "seed", must be greater than or equal to -999999999.') end if !@steps.nil? && @steps > 50 invalid_properties.push('invalid value for "steps", must be smaller than or equal to 50.') end if !@steps.nil? && @steps <= 0 invalid_properties.push('invalid value for "steps", must be greater than 0.') end if !@width.nil? && @width > 1280 invalid_properties.push('invalid value for "width", must be smaller than or equal to 1280.') end if !@width.nil? && @width <= 0 invalid_properties.push('invalid value for "width", must be greater than 0.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
623 624 625 |
# File 'lib/venice_client/models/generate_image_request.rb', line 623 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
629 630 631 632 633 634 635 636 637 638 639 640 641 |
# File 'lib/venice_client/models/generate_image_request.rb', line 629 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
617 618 619 |
# File 'lib/venice_client/models/generate_image_request.rb', line 617 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 |
# File 'lib/venice_client/models/generate_image_request.rb', line 330 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' return false if !@cfg_scale.nil? && @cfg_scale > 20 return false if !@cfg_scale.nil? && @cfg_scale <= 0 format_validator = EnumAttributeValidator.new('String', ["jpeg", "png", "webp"]) return false unless format_validator.valid?(@format) return false if !@height.nil? && @height > 1280 return false if !@height.nil? && @height <= 0 return false if !@lora_strength.nil? && @lora_strength > 100 return false if !@lora_strength.nil? && @lora_strength < 0 return false if @model.nil? return false if !@negative_prompt.nil? && @negative_prompt.to_s.length > 1500 return false if @prompt.nil? return false if @prompt.to_s.length > 1500 return false if @prompt.to_s.length < 1 return false if !@seed.nil? && @seed > 999999999 return false if !@seed.nil? && @seed < -999999999 return false if !@steps.nil? && @steps > 50 return false if !@steps.nil? && @steps <= 0 return false if !@width.nil? && @width > 1280 return false if !@width.nil? && @width <= 0 true end |