ailabtools-sdk 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ailabtools_sdk-0.1.0/PKG-INFO +50 -0
- ailabtools_sdk-0.1.0/README.md +41 -0
- ailabtools_sdk-0.1.0/ailabtools/__init__.py +4 -0
- ailabtools_sdk-0.1.0/ailabtools/client.py +17 -0
- ailabtools_sdk-0.1.0/ailabtools/common.py +26 -0
- ailabtools_sdk-0.1.0/ailabtools/cutout.py +71 -0
- ailabtools_sdk-0.1.0/ailabtools/endpoints.py +110 -0
- ailabtools_sdk-0.1.0/ailabtools/errors.py +17 -0
- ailabtools_sdk-0.1.0/ailabtools/generated/__init__.py +0 -0
- ailabtools_sdk-0.1.0/ailabtools/generated/endpoints.py +1923 -0
- ailabtools_sdk-0.1.0/ailabtools/http.py +64 -0
- ailabtools_sdk-0.1.0/ailabtools/image.py +224 -0
- ailabtools_sdk-0.1.0/ailabtools/portrait.py +251 -0
- ailabtools_sdk-0.1.0/ailabtools/types.py +22 -0
- ailabtools_sdk-0.1.0/ailabtools/utils.py +9 -0
- ailabtools_sdk-0.1.0/ailabtools_sdk.egg-info/PKG-INFO +50 -0
- ailabtools_sdk-0.1.0/ailabtools_sdk.egg-info/SOURCES.txt +23 -0
- ailabtools_sdk-0.1.0/ailabtools_sdk.egg-info/dependency_links.txt +1 -0
- ailabtools_sdk-0.1.0/ailabtools_sdk.egg-info/requires.txt +1 -0
- ailabtools_sdk-0.1.0/ailabtools_sdk.egg-info/top_level.txt +1 -0
- ailabtools_sdk-0.1.0/pyproject.toml +14 -0
- ailabtools_sdk-0.1.0/setup.cfg +4 -0
- ailabtools_sdk-0.1.0/setup.py +13 -0
- ailabtools_sdk-0.1.0/tests/test_credits.py +14 -0
- ailabtools_sdk-0.1.0/tests/test_http_errors.py +46 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ailabtools-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: AILabTools SDK for Python (async)
|
|
5
|
+
Requires-Python: >=3.8
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
Requires-Dist: httpx>=0.27
|
|
8
|
+
Dynamic: requires-python
|
|
9
|
+
|
|
10
|
+
# AILabTools Python SDK (async)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pip install ailabtools-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick Start
|
|
19
|
+
|
|
20
|
+
```py
|
|
21
|
+
import os
|
|
22
|
+
import asyncio
|
|
23
|
+
from ailabtools import AILabClient
|
|
24
|
+
|
|
25
|
+
async def main():
|
|
26
|
+
client = AILabClient(api_key=os.environ["AILAB_API_KEY"])
|
|
27
|
+
credits = await client.common.commonQueryCredits({})
|
|
28
|
+
print(credits.get("data"))
|
|
29
|
+
await client.aclose()
|
|
30
|
+
|
|
31
|
+
asyncio.run(main())
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Parameter Mapping
|
|
35
|
+
|
|
36
|
+
The SDK exposes camelCase parameters, for example `upscaleFactor`, and maps them to API field names such as `upscale-factor` internally.
|
|
37
|
+
|
|
38
|
+
## File Uploads
|
|
39
|
+
|
|
40
|
+
File parameters support file-like objects with a `read` method, or `bytes` / `bytearray`.
|
|
41
|
+
|
|
42
|
+
## Async Tasks
|
|
43
|
+
|
|
44
|
+
Async APIs return `task_id`. Poll results with `commonQueryAsyncTaskResult({"taskId": ...})`.
|
|
45
|
+
|
|
46
|
+
## Testing
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
AILAB_API_KEY=xxx pytest -q
|
|
50
|
+
```
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# AILabTools Python SDK (async)
|
|
2
|
+
|
|
3
|
+
## Installation
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
pip install ailabtools-sdk
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Quick Start
|
|
10
|
+
|
|
11
|
+
```py
|
|
12
|
+
import os
|
|
13
|
+
import asyncio
|
|
14
|
+
from ailabtools import AILabClient
|
|
15
|
+
|
|
16
|
+
async def main():
|
|
17
|
+
client = AILabClient(api_key=os.environ["AILAB_API_KEY"])
|
|
18
|
+
credits = await client.common.commonQueryCredits({})
|
|
19
|
+
print(credits.get("data"))
|
|
20
|
+
await client.aclose()
|
|
21
|
+
|
|
22
|
+
asyncio.run(main())
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Parameter Mapping
|
|
26
|
+
|
|
27
|
+
The SDK exposes camelCase parameters, for example `upscaleFactor`, and maps them to API field names such as `upscale-factor` internally.
|
|
28
|
+
|
|
29
|
+
## File Uploads
|
|
30
|
+
|
|
31
|
+
File parameters support file-like objects with a `read` method, or `bytes` / `bytearray`.
|
|
32
|
+
|
|
33
|
+
## Async Tasks
|
|
34
|
+
|
|
35
|
+
Async APIs return `task_id`. Poll results with `commonQueryAsyncTaskResult({"taskId": ...})`.
|
|
36
|
+
|
|
37
|
+
## Testing
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
AILAB_API_KEY=xxx pytest -q
|
|
41
|
+
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from .types import ClientOptions
|
|
2
|
+
from .http import Requester
|
|
3
|
+
from .common import CommonAPI
|
|
4
|
+
from .image import ImageAPI
|
|
5
|
+
from .portrait import PortraitAPI
|
|
6
|
+
from .cutout import CutoutAPI
|
|
7
|
+
|
|
8
|
+
class AILabClient:
|
|
9
|
+
def __init__(self, api_key: str, base_url: str = "https://www.ailabapi.com", timeout: float = 30.0):
|
|
10
|
+
self._requester = Requester(api_key=api_key, base_url=base_url, timeout=timeout)
|
|
11
|
+
self.common = CommonAPI(self._requester)
|
|
12
|
+
self.image = ImageAPI(self._requester)
|
|
13
|
+
self.portrait = PortraitAPI(self._requester)
|
|
14
|
+
self.cutout = CutoutAPI(self._requester)
|
|
15
|
+
|
|
16
|
+
async def aclose(self):
|
|
17
|
+
await self._requester.aclose()
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
from .http import Requester
|
|
2
|
+
from .utils import map_params
|
|
3
|
+
from .generated.endpoints import (
|
|
4
|
+
CommonQueryAsyncTaskResultParams,
|
|
5
|
+
CommonQueryAsyncTaskResultResponse,
|
|
6
|
+
CommonQueryAsyncTaskResultParamMap,
|
|
7
|
+
validate_commonQueryAsyncTaskResult_params,
|
|
8
|
+
CommonQueryCreditsParams,
|
|
9
|
+
CommonQueryCreditsResponse,
|
|
10
|
+
CommonQueryCreditsParamMap,
|
|
11
|
+
validate_commonQueryCredits_params
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
class CommonAPI:
|
|
15
|
+
def __init__(self, requester: Requester):
|
|
16
|
+
self._requester = requester
|
|
17
|
+
|
|
18
|
+
async def commonQueryAsyncTaskResult(self, params: CommonQueryAsyncTaskResultParams) -> CommonQueryAsyncTaskResultResponse:
|
|
19
|
+
validate_commonQueryAsyncTaskResult_params(params)
|
|
20
|
+
mapped = map_params(params, CommonQueryAsyncTaskResultParamMap)
|
|
21
|
+
return await self._requester.request('GET', '/api/common/query-async-task-result', query=mapped)
|
|
22
|
+
|
|
23
|
+
async def commonQueryCredits(self, params: CommonQueryCreditsParams) -> CommonQueryCreditsResponse:
|
|
24
|
+
validate_commonQueryCredits_params(params)
|
|
25
|
+
mapped = map_params(params, CommonQueryCreditsParamMap)
|
|
26
|
+
return await self._requester.request('GET', '/api/common/query-credits', query=mapped)
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
from .http import Requester
|
|
2
|
+
from .utils import map_params
|
|
3
|
+
from .generated.endpoints import (
|
|
4
|
+
CutoutClothingBackgroundRemovalParams,
|
|
5
|
+
CutoutClothingBackgroundRemovalResponse,
|
|
6
|
+
CutoutClothingBackgroundRemovalParamMap,
|
|
7
|
+
validate_cutoutClothingBackgroundRemoval_params,
|
|
8
|
+
CutoutProductBackgroundRemovalParams,
|
|
9
|
+
CutoutProductBackgroundRemovalResponse,
|
|
10
|
+
CutoutProductBackgroundRemovalParamMap,
|
|
11
|
+
validate_cutoutProductBackgroundRemoval_params,
|
|
12
|
+
CutoutFoodBackgroundRemovalParams,
|
|
13
|
+
CutoutFoodBackgroundRemovalResponse,
|
|
14
|
+
CutoutFoodBackgroundRemovalParamMap,
|
|
15
|
+
validate_cutoutFoodBackgroundRemoval_params,
|
|
16
|
+
CutoutUniversalBackgroundRemovalParams,
|
|
17
|
+
CutoutUniversalBackgroundRemovalResponse,
|
|
18
|
+
CutoutUniversalBackgroundRemovalParamMap,
|
|
19
|
+
validate_cutoutUniversalBackgroundRemoval_params,
|
|
20
|
+
CutoutAvatarExtractionParams,
|
|
21
|
+
CutoutAvatarExtractionResponse,
|
|
22
|
+
CutoutAvatarExtractionParamMap,
|
|
23
|
+
validate_cutoutAvatarExtraction_params,
|
|
24
|
+
CutoutHairExtractionParams,
|
|
25
|
+
CutoutHairExtractionResponse,
|
|
26
|
+
CutoutHairExtractionParamMap,
|
|
27
|
+
validate_cutoutHairExtraction_params,
|
|
28
|
+
CutoutHumanBackgroundRemovalParams,
|
|
29
|
+
CutoutHumanBackgroundRemovalResponse,
|
|
30
|
+
CutoutHumanBackgroundRemovalParamMap,
|
|
31
|
+
validate_cutoutHumanBackgroundRemoval_params
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
class CutoutAPI:
|
|
35
|
+
def __init__(self, requester: Requester):
|
|
36
|
+
self._requester = requester
|
|
37
|
+
|
|
38
|
+
async def cutoutClothingBackgroundRemoval(self, params: CutoutClothingBackgroundRemovalParams) -> CutoutClothingBackgroundRemovalResponse:
|
|
39
|
+
validate_cutoutClothingBackgroundRemoval_params(params)
|
|
40
|
+
mapped = map_params(params, CutoutClothingBackgroundRemovalParamMap)
|
|
41
|
+
return await self._requester.request('POST', '/api/cutout/general/apparel-background-removal', body=mapped, multipart=True)
|
|
42
|
+
|
|
43
|
+
async def cutoutProductBackgroundRemoval(self, params: CutoutProductBackgroundRemovalParams) -> CutoutProductBackgroundRemovalResponse:
|
|
44
|
+
validate_cutoutProductBackgroundRemoval_params(params)
|
|
45
|
+
mapped = map_params(params, CutoutProductBackgroundRemovalParamMap)
|
|
46
|
+
return await self._requester.request('POST', '/api/cutout/general/commodity-background-removal', body=mapped, multipart=True)
|
|
47
|
+
|
|
48
|
+
async def cutoutFoodBackgroundRemoval(self, params: CutoutFoodBackgroundRemovalParams) -> CutoutFoodBackgroundRemovalResponse:
|
|
49
|
+
validate_cutoutFoodBackgroundRemoval_params(params)
|
|
50
|
+
mapped = map_params(params, CutoutFoodBackgroundRemovalParamMap)
|
|
51
|
+
return await self._requester.request('POST', '/api/cutout/general/food-background-removal', body=mapped, multipart=True)
|
|
52
|
+
|
|
53
|
+
async def cutoutUniversalBackgroundRemoval(self, params: CutoutUniversalBackgroundRemovalParams) -> CutoutUniversalBackgroundRemovalResponse:
|
|
54
|
+
validate_cutoutUniversalBackgroundRemoval_params(params)
|
|
55
|
+
mapped = map_params(params, CutoutUniversalBackgroundRemovalParamMap)
|
|
56
|
+
return await self._requester.request('POST', '/api/cutout/general/universal-background-removal', body=mapped, multipart=True)
|
|
57
|
+
|
|
58
|
+
async def cutoutAvatarExtraction(self, params: CutoutAvatarExtractionParams) -> CutoutAvatarExtractionResponse:
|
|
59
|
+
validate_cutoutAvatarExtraction_params(params)
|
|
60
|
+
mapped = map_params(params, CutoutAvatarExtractionParamMap)
|
|
61
|
+
return await self._requester.request('POST', '/api/cutout/portrait/avatar-extraction', body=mapped, multipart=True)
|
|
62
|
+
|
|
63
|
+
async def cutoutHairExtraction(self, params: CutoutHairExtractionParams) -> CutoutHairExtractionResponse:
|
|
64
|
+
validate_cutoutHairExtraction_params(params)
|
|
65
|
+
mapped = map_params(params, CutoutHairExtractionParamMap)
|
|
66
|
+
return await self._requester.request('POST', '/api/cutout/portrait/hairstyle-extraction', body=mapped, multipart=True)
|
|
67
|
+
|
|
68
|
+
async def cutoutHumanBackgroundRemoval(self, params: CutoutHumanBackgroundRemovalParams) -> CutoutHumanBackgroundRemovalResponse:
|
|
69
|
+
validate_cutoutHumanBackgroundRemoval_params(params)
|
|
70
|
+
mapped = map_params(params, CutoutHumanBackgroundRemovalParamMap)
|
|
71
|
+
return await self._requester.request('POST', '/api/cutout/portrait/portrait-background-removal', body=mapped, multipart=True)
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
CommonQueryAsyncTaskResultParams = dict
|
|
2
|
+
CommonQueryAsyncTaskResultResponse = dict
|
|
3
|
+
CommonQueryCreditsParams = dict
|
|
4
|
+
CommonQueryCreditsResponse = dict
|
|
5
|
+
ImageLosslessEnlargementParams = dict
|
|
6
|
+
ImageLosslessEnlargementResponse = dict
|
|
7
|
+
ImageDistortionCorrectionParams = dict
|
|
8
|
+
ImageDistortionCorrectionResponse = dict
|
|
9
|
+
ImageClarityEnhancementParams = dict
|
|
10
|
+
ImageClarityEnhancementResponse = dict
|
|
11
|
+
ImageContrastEnhancementParams = dict
|
|
12
|
+
ImageContrastEnhancementResponse = dict
|
|
13
|
+
ImageColorEnhancementParams = dict
|
|
14
|
+
ImageColorEnhancementResponse = dict
|
|
15
|
+
ImageColoringParams = dict
|
|
16
|
+
ImageColoringResponse = dict
|
|
17
|
+
ImageStyleTransferParams = dict
|
|
18
|
+
ImageStyleTransferResponse = dict
|
|
19
|
+
ImageStyleMigrationParams = dict
|
|
20
|
+
ImageStyleMigrationResponse = dict
|
|
21
|
+
ImageColorMigrationParams = dict
|
|
22
|
+
ImageColorMigrationResponse = dict
|
|
23
|
+
ImageHdColorMigrationParams = dict
|
|
24
|
+
ImageHdColorMigrationResponse = dict
|
|
25
|
+
ImageIntelligentCompositionParams = dict
|
|
26
|
+
ImageIntelligentCompositionResponse = dict
|
|
27
|
+
ImagePhotoEditingParams = dict
|
|
28
|
+
ImagePhotoEditingResponse = dict
|
|
29
|
+
ImageInvisibleImageWatermarkParams = dict
|
|
30
|
+
ImageInvisibleImageWatermarkResponse = dict
|
|
31
|
+
ImageInvisibleTextWatermarkParams = dict
|
|
32
|
+
ImageInvisibleTextWatermarkResponse = dict
|
|
33
|
+
ImageErasureParams = dict
|
|
34
|
+
ImageErasureResponse = dict
|
|
35
|
+
ImageRemoveObjectsParams = dict
|
|
36
|
+
ImageRemoveObjectsResponse = dict
|
|
37
|
+
ImageRemoveObjectsAdvancedParams = dict
|
|
38
|
+
ImageRemoveObjectsAdvancedResponse = dict
|
|
39
|
+
ImageRemoveObjectsProParams = dict
|
|
40
|
+
ImageRemoveObjectsProResponse = dict
|
|
41
|
+
ImageAiObjectReplacerParams = dict
|
|
42
|
+
ImageAiObjectReplacerResponse = dict
|
|
43
|
+
ImageAiImageExtenderParams = dict
|
|
44
|
+
ImageAiImageExtenderResponse = dict
|
|
45
|
+
ImageExposureRatingParams = dict
|
|
46
|
+
ImageExposureRatingResponse = dict
|
|
47
|
+
PortraitFaceFusionParams = dict
|
|
48
|
+
PortraitFaceFusionResponse = dict
|
|
49
|
+
PortraitIntelligentBeautificationParams = dict
|
|
50
|
+
PortraitIntelligentBeautificationResponse = dict
|
|
51
|
+
PortraitIntelligentSkinRetouchingParams = dict
|
|
52
|
+
PortraitIntelligentSkinRetouchingResponse = dict
|
|
53
|
+
PortraitIntelligentFaceSlimmingParams = dict
|
|
54
|
+
PortraitIntelligentFaceSlimmingResponse = dict
|
|
55
|
+
PortraitFacialBeautificationParams = dict
|
|
56
|
+
PortraitFacialBeautificationResponse = dict
|
|
57
|
+
PortraitFacialBeautificationAdvancedParams = dict
|
|
58
|
+
PortraitFacialBeautificationAdvancedResponse = dict
|
|
59
|
+
PortraitFacialBeautificationProParams = dict
|
|
60
|
+
PortraitFacialBeautificationProResponse = dict
|
|
61
|
+
PortraitFacialMakeupParams = dict
|
|
62
|
+
PortraitFacialMakeupResponse = dict
|
|
63
|
+
PortraitFacialFiltersParams = dict
|
|
64
|
+
PortraitFacialFiltersResponse = dict
|
|
65
|
+
PortraitFacialShapingParams = dict
|
|
66
|
+
PortraitFacialShapingResponse = dict
|
|
67
|
+
PortraitExpressionEditingParams = dict
|
|
68
|
+
PortraitExpressionEditingResponse = dict
|
|
69
|
+
PortraitHairstyleEditingParams = dict
|
|
70
|
+
PortraitHairstyleEditingResponse = dict
|
|
71
|
+
PortraitHairstyleEditingProParams = dict
|
|
72
|
+
PortraitHairstyleEditingProResponse = dict
|
|
73
|
+
PortraitLivePhotosParams = dict
|
|
74
|
+
PortraitLivePhotosResponse = dict
|
|
75
|
+
PortraitHitchcockEffectParams = dict
|
|
76
|
+
PortraitHitchcockEffectResponse = dict
|
|
77
|
+
PortraitFacialBlurringParams = dict
|
|
78
|
+
PortraitFacialBlurringResponse = dict
|
|
79
|
+
PortraitFaceAttributeEditingParams = dict
|
|
80
|
+
PortraitFaceAttributeEditingResponse = dict
|
|
81
|
+
PortraitFaceRestorationEnhancementParams = dict
|
|
82
|
+
PortraitFaceRestorationEnhancementResponse = dict
|
|
83
|
+
PortraitLipsColorChangerParams = dict
|
|
84
|
+
PortraitLipsColorChangerResponse = dict
|
|
85
|
+
PortraitSkinDiseaseDetectionParams = dict
|
|
86
|
+
PortraitSkinDiseaseDetectionResponse = dict
|
|
87
|
+
PortraitSkinAnalysisBasicParams = dict
|
|
88
|
+
PortraitSkinAnalysisBasicResponse = dict
|
|
89
|
+
PortraitSkinAnalysisAdvancedParams = dict
|
|
90
|
+
PortraitSkinAnalysisAdvancedResponse = dict
|
|
91
|
+
PortraitSkinAnalysisProfessionalParams = dict
|
|
92
|
+
PortraitSkinAnalysisProfessionalResponse = dict
|
|
93
|
+
PortraitFaceAnalyzerParams = dict
|
|
94
|
+
PortraitFaceAnalyzerResponse = dict
|
|
95
|
+
PortraitFaceAnalyzerAdvancedParams = dict
|
|
96
|
+
PortraitFaceAnalyzerAdvancedResponse = dict
|
|
97
|
+
PortraitTryOnClothesProParams = dict
|
|
98
|
+
PortraitTryOnClothesProResponse = dict
|
|
99
|
+
CutoutFoodBackgroundRemovalParams = dict
|
|
100
|
+
CutoutFoodBackgroundRemovalResponse = dict
|
|
101
|
+
CutoutProductBackgroundRemovalParams = dict
|
|
102
|
+
CutoutProductBackgroundRemovalResponse = dict
|
|
103
|
+
CutoutClothingBackgroundRemovalParams = dict
|
|
104
|
+
CutoutClothingBackgroundRemovalResponse = dict
|
|
105
|
+
CutoutHdHumanBodyBackgroundRemovalParams = dict
|
|
106
|
+
CutoutHdHumanBodyBackgroundRemovalResponse = dict
|
|
107
|
+
CutoutAvatarExtractionParams = dict
|
|
108
|
+
CutoutAvatarExtractionResponse = dict
|
|
109
|
+
CutoutHairExtractionParams = dict
|
|
110
|
+
CutoutHairExtractionResponse = dict
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from typing import Optional, Any
|
|
3
|
+
|
|
4
|
+
@dataclass
|
|
5
|
+
class ErrorDetail:
|
|
6
|
+
status_code: Optional[int] = None
|
|
7
|
+
code: Optional[str] = None
|
|
8
|
+
code_message: Optional[str] = None
|
|
9
|
+
message: Optional[str] = None
|
|
10
|
+
|
|
11
|
+
class AILabApiError(Exception):
|
|
12
|
+
def __init__(self, message: str, detail: Optional[ErrorDetail] = None, request_id: Optional[str] = None, log_id: Optional[str] = None, raw: Any = None):
|
|
13
|
+
super().__init__(message)
|
|
14
|
+
self.detail = detail
|
|
15
|
+
self.request_id = request_id
|
|
16
|
+
self.log_id = log_id
|
|
17
|
+
self.raw = raw
|
|
File without changes
|