Class: ReveAI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/reve_ai/client.rb

Overview

HTTP client for the Reve image generation API.

Provides access to all Reve API endpoints through resource objects. Configure globally via configure or pass parameters directly to the constructor.

Examples:

Using global configuration

ReveAI.configure do |config|
  config.api_key = ENV["REVE_AI_API_KEY"]
end

client = ReveAI::Client.new
result = client.images.create(prompt: "A cat wearing a hat")

Using per-instance configuration

client = ReveAI::Client.new(
  api_key: "your-key",
  timeout: 60
)

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key: nil, **options) ⇒ Client

Creates a new Reve API client.

Examples:

client = ReveAI::Client.new(api_key: "your-api-key")

Parameters:

  • api_key (String, nil) (defaults to: nil)

    API key (defaults to global config or ENV)

  • options (Hash)

    Additional configuration options

Options Hash (**options):

  • :base_url (String)

    Base URL for API requests

  • :timeout (Integer)

    Request timeout in seconds

  • :open_timeout (Integer)

    Connection timeout in seconds

  • :max_retries (Integer)

    Number of retry attempts

  • :logger (Logger)

    Logger instance for debugging

  • :debug (Boolean)

    Enable debug logging

Raises:



45
46
47
48
# File 'lib/reve_ai/client.rb', line 45

def initialize(api_key: nil, **options)
  @configuration = build_configuration(api_key, options)
  validate_configuration!
end

Instance Attribute Details

#configurationConfiguration (readonly)

Returns Configuration instance for this client.

Returns:



28
29
30
# File 'lib/reve_ai/client.rb', line 28

def configuration
  @configuration
end

Instance Method Details

#http_clientHTTP::Client

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns the HTTP client for making API requests.

Returns:



78
79
80
# File 'lib/reve_ai/client.rb', line 78

def http_client
  @http_client ||= HTTP::Client.new(configuration)
end

#imagesResources::Images

Returns the Images resource for image generation operations.

Examples:

Generate an image

result = client.images.create(prompt: "A sunset over mountains")
puts result.base64 # Base64 encoded PNG

Edit an image

result = client.images.edit(
  edit_instruction: "Make the sky more blue",
  reference_image: base64_encoded_image
)

Remix images

result = client.images.remix(
  prompt: "Combine <img>1</img> and <img>2</img> into one scene",
  reference_images: [image1_base64, image2_base64]
)

Returns:

See Also:



70
71
72
# File 'lib/reve_ai/client.rb', line 70

def images
  @images ||= Resources::Images.new(self)
end