Pebblely Fashion API Documentation

Sign up for a Pebblely Fashion API account

Pebblely provides an API for individuals and companies that are considering processing large volumes of on-model fashion photos.

Sign up here to get an access token and 20 free credits.

ℹ️
If you are looking to generate product photos, check out our Pebblely API.

Authentication

All Pebblely API queries require a valid access token, which you can obtain by signing up for API access.

Include your token as a X-Pebblely-Access-Token header on all API queries.


CORS

At the moment, accessing the API via client-side will return a CORS error. Instead, you should access the API via server-side instead, which should resolve the CORS issue, as well as keep your API key secure.


Endpoints

All Pebblely API endpoints follow the following format:

https://fashion-api.pebblely.com/api_v1/{endpoint}
Copy

By default, all API keys are rate-limited at 1 query per second. The latency for each endpoint varies, see the specific endpoint for more details. Contact us if you have specific requirements around rate-limiting and latencies.

Each API query consumes 1 credit.

Note that there is a maximum file size of 5MB for all images uploaded.


Get Credits

GET /utils/credits

Retrieves the number of remaining credits for an account.

Response

Response:    # "credits" - Number of credits remaining    credits: int
Copy

Example

get_credits.py
import requestsendpoint_url = "https://fashion-api.pebblely.com/api_v1/utils/credits"response = requests.get(    endpoint_url,    headers={        "X-Pebblely-Access-Token": "<YOUR ACCESS TOKEN>",    },)remaining_credits = response.json()["credits"]
Copy

Get Themes

GET /utils/themes

Retrieves the list of themes and their respective thumbnails.

Response

Response:    # List of Theme objects, where each object comprises the following keys and values    #   "label": str - Label of theme    #   "thumbnail": str - Sample thumbnail URL    List[Dict[str, str]]
Copy

Example

get_themes.py
import requestsendpoint_url = "https://fashion-api.pebblely.com/api_v1/utils/themes"response = requests.get(    endpoint_url)themes = response.json()print(len(themes)) # Should print number of themesprint(themes[0]["label"]) # Should print "Streets"
Copy

Create Background

POST /generate/virtual_pose

Use the virtual_pose endpoint with a photo of a top to create a photo of a model posing in your top.

This endpoint takes ~20 seconds for a 1024 by 1024 input image.

Request body

RequestBody:    # "cloth_image" - A photo of the top apparel, see example below    cloth_image: str = ""    # "theme" - One of ["Streets", "Beach", "Rooftop", "Home", "Park", "Cafe"]    theme: str = None    # "prompt" - Custom prompt describing the model, including gender, ethnicity, age, and/or the background    # If a `theme` is supplied, this will be used in addition to the theme    prompt: str = "Black hair, beautiful female model posing in jeans"    # "negative_prompt" - A list of comma-separated attributes that should be discouraged from the image    negative_prompt: str = ""    # "background_color" - Hex string representing a color e.g. "#FFFFFF"    background_color: str = None    # "height", "width" - Height and width of image, up to a maximum of 2048    # If only one dimension is provided, the other dimension defaults to the same value and a square image will be generated    height: int = 1024    width: int = 1024
Copy

Response

Response:    # "data" - Base64 representation of the resulting image    data: str    # "credits" - Number of remaining credits    credits: int
Copy

Example

virtual_pose.py
import base64import ioimport requestsfrom PIL import Imageendpoint_url = "https://fashion-api.pebblely.com/api_v1/generate/virtual_pose"response = requests.post(    endpoint_url,    headers={        "Content-Type": "application/json",        "X-Pebblely-Access-Token": "<YOUR ACCESS TOKEN>",    },    json={        "cloth_image": "<YOUR APPAREL IMAGE URL OR BASE64>",        "theme": "Streets",        "prompt": "Blue hair Japanese female model",    })# Process Base64 output and save locally image_b64 = response.json()["data"]image_encoded = image_b64.encode("utf-8")image_bytes = io.BytesIO(base64.b64decode(image_encoded))image = Image.open(image_bytes)image.save("image.jpg")
Copy