Class: VeniceClient::GenerateImageRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/venice_client/models/generate_image_request.rb

Defined Under Namespace

Classes: EnumAttributeValidator

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ GenerateImageRequest

Initializes the object



139
140
141
142
143
144
145
146
147
148
149
150
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
# File 'lib/venice_client/models/generate_image_request.rb', line 139

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
  attributes = attributes.each_with_object({}) { |(k, v), h|
    if (!self.class.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: " + self.class.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']
  end

  if attributes.key?(:'negative_prompt')
    self.negative_prompt = attributes[:'negative_prompt']
  end

  if attributes.key?(:'prompt')
    self.prompt = attributes[:'prompt']
  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_scaleObject

CFG scale parameter. Higher values lead to more adherence to the prompt.



17
18
19
# File 'lib/venice_client/models/generate_image_request.rb', line 17

def cfg_scale
  @cfg_scale
end

#embed_exif_metadataObject

Embed prompt generation information into the image’s EXIF metadata.



20
21
22
# File 'lib/venice_client/models/generate_image_request.rb', line 20

def 
  
end

#formatObject

The image format to return. WebP are smaller and optimized for web use. PNG are higher quality but larger in file size.



23
24
25
# File 'lib/venice_client/models/generate_image_request.rb', line 23

def format
  @format
end

#heightObject

Height of the generated image. Each model has a specific height and width divisor listed in the widthHeightDivisor constraint in the model list endpoint.



26
27
28
# File 'lib/venice_client/models/generate_image_request.rb', line 26

def height
  @height
end

#hide_watermarkObject

Whether to hide the Venice watermark. Venice may ignore this parameter for certain generated content.



29
30
31
# File 'lib/venice_client/models/generate_image_request.rb', line 29

def hide_watermark
  @hide_watermark
end

#inpaintObject

This feature is deprecated and was disabled on May 19th, 2025. A revised in-painting API will be launched in the near future.



32
33
34
# File 'lib/venice_client/models/generate_image_request.rb', line 32

def inpaint
  @inpaint
end

#lora_strengthObject

Lora strength for the model. Only applies if the model uses additional Loras.



35
36
37
# File 'lib/venice_client/models/generate_image_request.rb', line 35

def lora_strength
  @lora_strength
end

#modelObject

The model to use for image generation.



38
39
40
# File 'lib/venice_client/models/generate_image_request.rb', line 38

def model
  @model
end

#negative_promptObject

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.



41
42
43
# File 'lib/venice_client/models/generate_image_request.rb', line 41

def negative_prompt
  @negative_prompt
end

#promptObject

The description for the image. Character limit is model specific and is listed in the promptCharacterLimit setting in the model list endpoint.



44
45
46
# File 'lib/venice_client/models/generate_image_request.rb', line 44

def prompt
  @prompt
end

#return_binaryObject

Whether to return binary image data instead of base64.



47
48
49
# File 'lib/venice_client/models/generate_image_request.rb', line 47

def return_binary
  @return_binary
end

#safe_modeObject

Whether to use safe mode. If enabled, this will blur images that are classified as having adult content.



50
51
52
# File 'lib/venice_client/models/generate_image_request.rb', line 50

def safe_mode
  @safe_mode
end

#seedObject

Random seed for generation. If not provided, a random seed will be used.



53
54
55
# File 'lib/venice_client/models/generate_image_request.rb', line 53

def seed
  @seed
end

#stepsObject

Number of inference steps. The following models have reduced max steps from the global max: venice-sd35: 30 max steps, flux-dev: 30 max steps, flux-dev-uncensored: 30 max steps, stable-diffusion-3.5: 30 max steps. These constraints are exposed in the model list endpoint for each model.



56
57
58
# File 'lib/venice_client/models/generate_image_request.rb', line 56

def steps
  @steps
end

#style_presetObject

An image style to apply to the image. Visit docs.venice.ai/api-reference/endpoint/image/styles for more details.



59
60
61
# File 'lib/venice_client/models/generate_image_request.rb', line 59

def style_preset
  @style_preset
end

#widthObject

Width of the generated image. Each model has a specific height and width divisor listed in the widthHeightDivisor constraint in the model list endpoint.



62
63
64
# File 'lib/venice_client/models/generate_image_request.rb', line 62

def width
  @width
end

Class Method Details

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# File 'lib/venice_client/models/generate_image_request.rb', line 87

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



308
309
310
# File 'lib/venice_client/models/generate_image_request.rb', line 308

def self.build_from_hash(attributes)
  new.build_from_hash(attributes)
end

.openapi_nullableObject

List of attributes with nullable: true



131
132
133
134
135
# File 'lib/venice_client/models/generate_image_request.rb', line 131

def self.openapi_nullable
  Set.new([
    :'inpaint',
  ])
end

.openapi_typesObject

Attribute type mapping.



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/venice_client/models/generate_image_request.rb', line 109

def self.openapi_types
  {
    :'cfg_scale' => :'Object',
    :'embed_exif_metadata' => :'Object',
    :'format' => :'Object',
    :'height' => :'Object',
    :'hide_watermark' => :'Object',
    :'inpaint' => :'Object',
    :'lora_strength' => :'Object',
    :'model' => :'Object',
    :'negative_prompt' => :'Object',
    :'prompt' => :'Object',
    :'return_binary' => :'Object',
    :'safe_mode' => :'Object',
    :'seed' => :'Object',
    :'steps' => :'Object',
    :'style_preset' => :'Object',
    :'width' => :'Object'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
# File 'lib/venice_client/models/generate_image_request.rb', line 272

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

#_deserialize(type, value) ⇒ Object

Deserializes the data based on type



338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
# File 'lib/venice_client/models/generate_image_request.rb', line 338

def _deserialize(type, value)
  case type.to_sym
  when :DateTime
    DateTime.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
    VeniceClient.const_get(type).build_from_hash(value)
  end
end

#_to_hash(value) ⇒ Hash

Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value



407
408
409
410
411
412
413
414
415
416
417
418
419
# File 'lib/venice_client/models/generate_image_request.rb', line 407

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

#build_from_hash(attributes) ⇒ Object

Builds the object from hash



315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
# File 'lib/venice_client/models/generate_image_request.rb', line 315

def build_from_hash(attributes)
  return nil unless attributes.is_a?(Hash)
  self.class.openapi_types.each_pair do |key, type|
    if 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[self.class.attribute_map[key]].is_a?(Array)
        self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) })
      end
    elsif !attributes[self.class.attribute_map[key]].nil?
      self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]]))
    elsif attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key)
      self.send("#{key}=", nil)
    end
  end

  self
end

#eql?(o) ⇒ Boolean

See Also:

  • `==` method


295
296
297
# File 'lib/venice_client/models/generate_image_request.rb', line 295

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.



301
302
303
# File 'lib/venice_client/models/generate_image_request.rb', line 301

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_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?



237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/venice_client/models/generate_image_request.rb', line 237

def list_invalid_properties
  invalid_properties = Array.new
  if @model.nil?
    invalid_properties.push('invalid value for "model", model cannot be nil.')
  end

  if @prompt.nil?
    invalid_properties.push('invalid value for "prompt", prompt cannot be nil.')
  end

  invalid_properties
end

#to_bodyHash

to_body is an alias to to_hash (backward compatibility)



383
384
385
# File 'lib/venice_client/models/generate_image_request.rb', line 383

def to_body
  to_hash
end

#to_hashHash

Returns the object in the form of hash



389
390
391
392
393
394
395
396
397
398
399
400
401
# File 'lib/venice_client/models/generate_image_request.rb', line 389

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_sString

Returns the string representation of the object



377
378
379
# File 'lib/venice_client/models/generate_image_request.rb', line 377

def to_s
  to_hash.to_s
end

#valid?Boolean

Check to see if the all the properties in the model are valid



252
253
254
255
256
257
258
# File 'lib/venice_client/models/generate_image_request.rb', line 252

def valid?
  format_validator = EnumAttributeValidator.new('Object', ['jpeg', 'png', 'webp'])
  return false unless format_validator.valid?(@format)
  return false if @model.nil?
  return false if @prompt.nil?
  true
end