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:
- Submit a try-on to the
/tryon/clothesendpoint. - Wait for the job to finish (the SDK polls
/status/<id>for you). - Read the output image URLs.
Install
gem install tryitonRequires 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}"
endPrefer to poll yourself? Call client.get_status(job_id) in a loop instead of
wait_for_result.
Try-On PHP Quickstart
Run a virtual try-on in PHP using the official tryiton/tryiton SDK: submit a job, wait for completion, and read the output image URLs.
Try-On Go Quickstart
Run a virtual try-on in Go using the official tryiton-go SDK: submit a job, wait for completion, and read the output image URLs.