Class: Copyleaks::CopyleaksAiImageDetectionRequestModel

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb

Overview

Request model for Copyleaks AI image detection. The request body is a JSON object containing the image to analyze.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base64, file_name, model, sandbox = false) ⇒ CopyleaksAiImageDetectionRequestModel

Initialize a new CopyleaksAiImageDetectionRequestModel

Parameters:

  • base64 (String)

    The base64-encoded image data to be analyzed for AI generation

  • file_name (String)

    The name of the image file including its extension

  • model (String)

    The AI detection model to use for analysis

  • sandbox (Boolean) (defaults to: false)

    Use sandbox mode to test integration (default: false)



16
17
18
19
20
21
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 16

def initialize(base64, file_name, model, sandbox = false)
  @base64 = base64
  @file_name = file_name
  @model = model
  @sandbox = sandbox
end

Instance Attribute Details

#base64String

The base64-encoded image data to be analyzed for AI generation.

Requirements:

  • Minimum 512×512px, maximum 16 megapixels, less than 32MB

  • Supported formats: PNG, JPEG, BMP, WebP, HEIC/HEIF

Examples:

“aGVsbG8gd29ybGQ=”

Returns:

  • (String)

    Base64-encoded image data



31
32
33
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 31

def base64
  @base64
end

#file_nameString

The name of the image file including its extension.

Requirements:

  • Supported extensions: .png, .bmp, .jpg, .jpeg, .webp, .heic, .heif

  • Maximum 255 characters

Examples:

“my-image.png”

Returns:

  • (String)

    Image file name



41
42
43
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 41

def file_name
  @file_name
end

#modelString

The AI detection model to use for analysis. You can use either the full model name or its alias.

Available models:

  • AI Image 1 Ultra: “ai-image-1-ultra-01-09-2025” (full name) or “ai-image-1-ultra” (alias) AI image detection model. Produces an overlay of the detected AI segments.

Examples:

“ai-image-1-ultra-01-09-2025” or “ai-image-1-ultra”

Returns:

  • (String)

    Model name or alias



52
53
54
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 52

def model
  @model
end

#sandboxBoolean

Use sandbox mode to test your integration with the Copyleaks API without consuming any credits.

Submit images for AI detection and get returned mock results, simulating Copyleaks’ API functionality to ensure you have successfully integrated the API. This feature is intended to be used for development purposes only. Default value is false.

Examples:

false

Returns:

  • (Boolean)

    Sandbox mode flag



63
64
65
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 63

def sandbox
  @sandbox
end

Instance Method Details

#to_hashHash

Convert the model to a hash for JSON serialization

Returns:

  • (Hash)

    Hash representation of the model



68
69
70
71
72
73
74
75
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 68

def to_hash
  {
    base64: @base64,
    fileName: @file_name,
    model: @model,
    sandbox: @sandbox
  }
end

#to_json(*args) ⇒ String

Convert the model to JSON

Returns:

  • (String)

    JSON representation of the model



80
81
82
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 80

def to_json(*args)
  to_hash.to_json(*args)
end

#validate!Object

Validate the model data

Raises:

  • (ArgumentError)

    If required fields are missing or invalid



87
88
89
90
91
92
93
94
# File 'lib/copyleaks/models/imageDetection/requests/CopyleaksAiImageDetectionRequestModel.rb', line 87

def validate!
  raise ArgumentError, 'base64 is required' if @base64.nil? || @base64.empty?
  raise ArgumentError, 'file_name is required' if @file_name.nil? || @file_name.empty?
  raise ArgumentError, 'model is required' if @model.nil? || @model.empty?
  
  validate_file_name!
  validate_file_size!
end