Documentation
¶
Overview ¶
Package tryiton is the official Go SDK for the TryItOn virtual try-on API.
See https://docs.tryiton.now for the full API reference.
Index ¶
- Constants
- Variables
- type Client
- func (c *Client) GetCredits(ctx context.Context) (*Credits, error)
- func (c *Client) GetStatus(ctx context.Context, jobID string) (*Status, error)
- func (c *Client) TryOnClothes(ctx context.Context, p ClothesParams) (string, error)
- func (c *Client) TryOnHairstyle(ctx context.Context, p HairstyleParams) (string, error)
- func (c *Client) TryOnTattoo(ctx context.Context, p TattooParams) (string, error)
- func (c *Client) WaitForResult(ctx context.Context, jobID string, pollInterval time.Duration) ([]string, error)
- type ClothesParams
- type Credits
- type Error
- type HairstyleParams
- type JobError
- type Option
- type Status
- type TattooParams
Constants ¶
const DefaultBaseURL = "https://tryiton.now/api/v1"
DefaultBaseURL is the production API base URL.
Variables ¶
var Haircuts = []string{
"Afro", "BobCut", "BowlCut", "BoxBraids", "BuzzCut", "Chignon", "CombOver",
"CornrowBraids", "CurlyBob", "CurlyShag", "DoubleBun", "Dreadlocks", "FauxHawk",
"FishtailBraid", "LongCurly", "LongHairTiedUp", "LongHimeCut", "LongStraight",
"LongTwintails", "LongWavy", "LongWavyCurtainBangs", "ManBun", "MessyTousled",
"PixieCut", "Pompadour", "Ponytail", "ShortCurlyPixie", "ShortTwintails",
"ShoulderLengthHair", "Spiky", "TexturedFringe", "TwinBraids", "Updo", "WavyShag",
}
Haircuts lists the supported `haircut` values for hairstyle try-on.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a TryItOn API client. Create one with New.
func (*Client) GetCredits ¶
GetCredits fetches your current credit balance.
func (*Client) TryOnClothes ¶
TryOnClothes puts a garment or accessory on a person and returns the job id.
func (*Client) TryOnHairstyle ¶
TryOnHairstyle restyles a person's hair and returns the job id.
func (*Client) TryOnTattoo ¶
TryOnTattoo inks a design onto skin and returns the job id.
type ClothesParams ¶
type ClothesParams struct {
ModelImage string `json:"model_image"`
GarmentImage string `json:"garment_image"`
Category string `json:"category,omitempty"`
Subcategory string `json:"subcategory,omitempty"`
Mode string `json:"mode,omitempty"`
NumSamples int `json:"num_samples,omitempty"`
OutputFormat string `json:"output_format,omitempty"`
Seed int `json:"seed,omitempty"`
SegmentationFree *bool `json:"segmentation_free,omitempty"`
GarmentPhotoType string `json:"garment_photo_type,omitempty"`
ModerationLevel string `json:"moderation_level,omitempty"`
}
ClothesParams are the inputs for a clothing/accessory try-on. Image fields accept a public URL or a base64 data URL. Category is one of: auto, clothing, eyewear, footwear, headwear, jewelry, accessories, others. clothing, jewelry, and accessories require a Subcategory.
type Credits ¶
type Credits struct {
OnDemand int `json:"on_demand"`
Subscription int `json:"subscription"`
Purchased int `json:"purchased"`
Reserved int `json:"reserved"`
}
Credits is your credit balance.
type Error ¶
type Error struct {
// Status is the HTTP status code, or 0 for a runtime job failure.
Status int
// Name is the API error name, e.g. "OutOfCredits" or "ProcessingError".
Name string
// Message is the human-readable message.
Message string
}
Error is returned for API-level errors and runtime (job) failures.
type HairstyleParams ¶
type HairstyleParams struct {
FaceImage string `json:"face_image"`
Haircut string `json:"haircut"`
HairColor string `json:"hair_color,omitempty"`
}
HairstyleParams are the inputs for a hairstyle try-on.
type Option ¶
type Option func(*Client)
Option configures a Client.
func WithHTTPClient ¶
WithHTTPClient supplies a custom *http.Client (e.g. with a timeout).
type Status ¶
type Status struct {
Status string `json:"status"` // "processing" | "completed" | "failed"
Output []string `json:"output"`
Error *JobError `json:"error"`
}
Status is a job's status snapshot.
type TattooParams ¶
type TattooParams struct {
BodyImage string `json:"body_image"`
DesignImage string `json:"design_image"`
Placement string `json:"placement,omitempty"`
}
TattooParams are the inputs for a tattoo try-on.