TryItOn
Guides

Try-On Ruby Quickstart

Run a virtual try-on in Ruby using the official tryiton SDK: submit a job, wait for completion, and read the output image URLs.

This quickstart uses the official tryiton Ruby SDK to:

  1. Submit a try-on to the /tryon/clothes endpoint.
  2. Wait for the job to finish (the SDK polls /status/<id> for you).
  3. Read the output image URLs.

Install

gem install tryiton

Requires Ruby 2.6 or later. See all libraries on the SDKs page.

Minimal example

This example uses URLs for the model and garment images. You can also pass a base64 data URL (data:image/png;base64,...) for either image.

require "tryiton"

client = Tryiton::Client.new(api_key: ENV["TRYITON_API_KEY"])

begin
  # 1. Submit the try-on
  job_id = client.try_on_clothes(
    model_image: "https://example.com/model.jpg",
    garment_image: "https://example.com/garment.jpg",
    category: "clothing",
    subcategory: "tops"
  )
  puts "Job started: #{job_id}"

  # 2. Wait for completion (polls status until done)
  urls = client.wait_for_result(job_id)

  # 3. Read the result image URLs (valid for 72 hours)
  puts "Result: #{urls.first}"
rescue Tryiton::Error => e
  # e.status (HTTP code) and e.error_name (e.g. "OutOfCredits") are available
  warn "Failed (#{e.status} #{e.error_name}): #{e.message}"
end

The same pattern works for the other models — call client.try_on_hairstyle(...) or client.try_on_tattoo(...) instead. See Hairstyle and Tattoo.

Prefer to poll yourself? Call client.get_status(job_id) in a loop instead of wait_for_result.

On this page