AILabTools SDK - Async Python SDK for AI Image APIs
Official async Python SDK for AILabTools AI Image APIs.
Build AI-powered photo editing features with simple API calls: background removal, image upscaling, object removal, face retouching, hairstyle changer, age and gender swap, cartoon avatar generation, skin analysis, virtual try-on, and more.
- Install the AILabTools async Python SDK from PyPI:
pip install ailabtools-sdk - Import in Python:
from ailabtools import AILabClient - 87 current APIs plus 6 legacy-compatible endpoints
- Supports file and in-memory uploads, async tasks, and temporary result URLs
- Get started with the AILabTools Developer Console
Requirements
- Python 3.8 or later
Installation
Install the Python SDK:
pip install ailabtools-sdk
Import it in Python:
from ailabtools import AILabClient
Note: The PyPI package name is
ailabtools-sdk, while the Python import name isailabtools.
Quick Start
1. Get your API key
Create or copy your API key from the AILabTools Developer Console.
export AILAB_API_KEY="your_api_key_here"
2. Remove an image background
import os
import asyncio
from ailabtools import AILabClient
async def main():
client = AILabClient(api_key=os.environ["AILAB_API_KEY"])
with open("./photo.jpg", "rb") as image:
result = await client.background.remove({
"image": image,
"returnForm": "whiteBK",
})
print(result["data"]["image_url"])
await client.aclose()
asyncio.run(main())
The SDK uses camelCase parameters and maps them automatically to API field names. For example, upscaleFactor maps to upscale-factor, and returnForm maps to return_form.
Popular Use Cases
| Popular API | Typical use case | SDK method | Try online |
|---|---|---|---|
| Cartoon Yourself API | Create cartoon portraits and avatars from photos. | client.portrait.portraitCartoonYourself() |
Try Cartoon Yourself online |
| Change Facial Expressions API | Edit smiles, grins, sadness, and other facial expressions. | client.portrait.portraitExpressionEditing() |
Try Change Facial Expressions online |
| Hairstyle Changer Premium API | Preview preset hairstyles or transfer a hairstyle from a reference image. | client.portrait.portraitHairstyleEditingPremium() |
Try Hairstyle Changer online |
| Try on Clothes Premium API | Generate high-quality virtual clothing try-on results. | client.portrait.portraitTryOnClothesPremium() |
Try Virtual Clothes Try-On online |
| Skin Analyze Pro API | Analyze skin condition, texture, tone, acne, pores, and wrinkles. | client.portrait.portraitSkinAnalysisProfessional() |
Try AI Skin Analyzer online |
| Face Beauty Pro API | Apply advanced portrait beautification and face shaping. | client.portrait.portraitFacialBeautificationPro() |
Try Retouch Portraits online |
| AI Face Swap API | Swap a face into a target portrait while preserving the scene. | client.portrait.portraitAIFaceSwap() |
Try AI Face Swap online |
| AI Breast Expansion API | Apply a controlled bust-area adjustment to a portrait. | client.portrait.portraitAIBreastExpansion() |
Try AI Breast Expansion online |
Browse more demos in AILabTools AI Portrait Tools and AILabTools AI Image Tools.
View the complete AILabTools SDK API index.
Common Developer-Friendly Aliases
Both full API method names and short aliases are supported. For example, client.background.remove() calls the same Universal Background Removal API as client.cutout.cutoutUniversalBackgroundRemoval().
| API | Full method | Alias |
|---|---|---|
| Universal Background Removal | client.cutout.cutoutUniversalBackgroundRemoval() |
client.background.remove() |
| Image Upscaler | client.image.imageLosslessEnlargement() |
client.image.upscale() |
| Remove Objects | client.image.imageRemoveObjects() |
client.image.remove_objects() |
| Hairstyle Changer Pro | client.portrait.portraitHairstyleEditingPro() |
client.portrait.change_hairstyle() |
| Smart Beauty | client.portrait.portraitIntelligentBeautification() |
client.portrait.retouch() |
View the complete method and alias reference.
File Uploads
File parameters support file-like objects with a read method, or bytes / bytearray.
Async Task Example
Some APIs return task_id for long-running image generation or enhancement jobs. Use wait_for_task to poll until the task succeeds, fails, or times out.
task = await client.portrait.change_hairstyle({
"taskType": "async",
"image": image,
"hairStyle": "BuzzCut",
"color": "blonde",
})
task_id = task.get("task_id") or task.get("data", {}).get("task_id")
result = await client.wait_for_task(
task_id,
interval=5,
timeout=300,
raise_on_failed=True,
)
print(result.get("data"))
API Reference
- AILabTools API Documentation
- Get your AILabTools API key
- AILabTools SDK Documentation
- Node.js SDK on npm
- AILabTools SDK on GitHub
- SDK examples
Error Handling
API errors raise AILabApiError, which includes troubleshooting fields such as request_id and log_id.
try:
with open("./photo.jpg", "rb") as image:
result = await client.background.remove({
"image": image,
"returnForm": "whiteBK",
})
print(result["data"]["image_url"])
except Exception as error:
print("AILabTools API Error:", error)
# Send request_id and log_id to support if you need help.
Testing
AILAB_API_KEY=xxx pytest -q
License
MIT
Metadata
Release files for ailabtools-sdk 0.5.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| ailabtools_sdk-0.5.4.tar.gz | 27.7 kB | Without provenance | Details for ailabtools_sdk-0.5.4.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ailabtools_sdk-0.5.4-py3-none-any.whl | Python 3 | none | any | Details for ailabtools_sdk-0.5.4-py3-none-any.whl |
Total release size: 53.5 kB
Release files / ailabtools_sdk-0.5.4.tar.gz
| Download URL | ailabtools_sdk-0.5.4.tar.gz |
|---|---|
| Size | 27.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
492c41722a126dbed2038ebba195ef252209669b1e610800bea1d6f2b7681909
|
|
BLAKE2b-256 checksum How to use checksums |
d07442ee973f3143edb922cc895d75f6aa1160a93e679549113631b4f46aa550
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / ailabtools_sdk-0.5.4-py3-none-any.whl
| Download URL | ailabtools_sdk-0.5.4-py3-none-any.whl |
|---|---|
| Size | 25.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c81fecc4f378318cb1ceb13352b178b5302dac322e1f41566a5916dd6c679210
|
|
BLAKE2b-256 checksum How to use checksums |
826edb9e2d808fb7be6e69d640f3f4a2bd9241b0995371b4ccc55d1f35f382e9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Security for ailabtools-sdk 0.5.4
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.