# Try-On Python Quickstart

Below is a minimal Python snippet to demonstrate how to:

1. **POST** to the `/v1/tryon/clothes` endpoint with your input data.
2. **Poll** the `/v1/status/<ID>` endpoint until the job is completed.
3. **Retrieve** the final results from the `"output"` field.

***

#### Minimal Python Example <a href="#minimal-python-example" id="minimal-python-example"></a>

This example shows a simple request using URLs for the model and garment images. You can also modify the code to upload local images by converting them to Base64 format.&#x20;

```python
import os
import time
import requests
 
# 1. Set up the API key and base URL
API_KEY = os.getenv("TRYITON_API_KEY")
BASE_URL = "https://tryiton.now/api/v1"
 
# 2. POST request to initialize the try-on
input_data = {
    "model_image": "https://example.com/path/to/model.png",
    "garment_image": "https://example.com/path/to/garment.png"
}
headers = {"Content-Type": "application/json", "Authorization": f"Bearer {API_KEY}"}
run_response = requests.post(f"{BASE_URL}/tryon/clothes", json=input_data, headers=headers)
run_data = run_response.json()
job_id = run_data.get("id")
print("Job started, ID:", job_id)
 
# 3. Poll status
while True:
    status_response = requests.get(f"{BASE_URL}/status/{job_id}", headers=headers)
    status_data = status_response.json()
 
    if status_data["status"] == "completed":
        print("Job completed.")
        # 4. The "output" field contains the final image URLs
        print(status_data["output"])
        break
 
    elif status_data["status"] == "processing":
        print("Job status:", status_data["status"])
        time.sleep(3)
 
    else:
        print("Job failed:", status_data.get("error"))
        break
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.tryiton.now/guides/try-on-python-quickstart.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
