{"id":24117105,"url":"https://github.com/picsart/picsart-creative-apis-python-sdk","last_synced_at":"2026-03-05T06:30:48.318Z","repository":{"id":271394386,"uuid":"897286484","full_name":"PicsArt/picsart-creative-apis-python-sdk","owner":"PicsArt","description":"Picsart Creative APIs SDK for Python. Includes helper methods and functions for Programmable Image APIs (e.g. Remove Background, Upscale, Enhance, Effects) and the GenAI APIs (e.g. Text2Image, Replace, Expand Image).","archived":false,"fork":false,"pushed_at":"2025-01-09T13:13:44.000Z","size":1641,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-02-28T19:20:13.867Z","etag":null,"topics":["adjust","ai","compress-images","crop-images","editing","effects","filters","generative-ai","image","image-editing-software","image-editor","image-upscale","image2image","photo","remove-background","resize-images","text2image"],"latest_commit_sha":null,"homepage":"https://picsart.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PicsArt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-12-02T11:17:55.000Z","updated_at":"2025-01-09T12:54:27.000Z","dependencies_parsed_at":"2025-01-07T13:24:49.169Z","dependency_job_id":"ecde7d1e-b770-4db4-b904-74691d460143","html_url":"https://github.com/PicsArt/picsart-creative-apis-python-sdk","commit_stats":null,"previous_names":["picsart/picsart-creative-apis-python-sdk"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/PicsArt/picsart-creative-apis-python-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fpicsart-creative-apis-python-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fpicsart-creative-apis-python-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fpicsart-creative-apis-python-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fpicsart-creative-apis-python-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PicsArt","download_url":"https://codeload.github.com/PicsArt/picsart-creative-apis-python-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PicsArt%2Fpicsart-creative-apis-python-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30112215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-05T03:40:26.266Z","status":"ssl_error","status_checked_at":"2026-03-05T03:39:15.902Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["adjust","ai","compress-images","crop-images","editing","effects","filters","generative-ai","image","image-editing-software","image-editor","image-upscale","image2image","photo","remove-background","resize-images","text2image"],"created_at":"2025-01-11T07:38:19.804Z","updated_at":"2026-03-05T06:30:48.300Z","avatar_url":"https://github.com/PicsArt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PICSART CREATIVE APIS Python SDK\n\n## Overview\n\nThe Picsart Python SDK provides seamless access to Picsart Programmable Image APIs and Picsart GenAI APIs, \nenabling developers to enhance and manipulate images with minimal code. \nThe SDK simplifies the integration of advanced image processing features, \nmaking it easy to build creative and AI-driven applications.\n\n## Requirements\nPython 3.9 or higher\n\n## Getting Started\n\n### Installation\nInstall the SDK via pip:\n\n```bash\npip install git+https://github.com/PicsArt/picsart-creative-apis-python-sdk \n```\n\nOr if you want to install a specific version:\n\n```bash\npip install git+https://github.com/PicsArt/picsart-creative-apis-python-sdk@1.0.0\n```\n\n### Create a Client\n\n**Option 1: Using Default Session**\n\nIf the `PICSART_API_KEY` environment variable is set, you can quickly create a client:\n\n```python\nimport picsart_sdk\nfrom picsart_sdk.clients import UploadClient\nfrom picsart_sdk import PicsartAPI\n\nupload_client: UploadClient = picsart_sdk.client(PicsartAPI.UPLOAD)\n```\n\n**Option 2: Passing the PICSART_API_KEY manually**\n\nYou can also pass the API key directly to the API. \nManually passing the API key takes precedence over using the environment variable:\n\n```python\nimport picsart_sdk\nfrom picsart_sdk.clients import UploadClient\nfrom picsart_sdk import PicsartAPI\n\nupload_client: UploadClient = picsart_sdk.client(PicsartAPI.UPLOAD, api_key=\"YOUR-API-KEY\")\n```\n\n\u003e **_NOTE:_** We recommend always using Python type hinting, such as \n\u003e `upload_client: UploadClient = picsart_sdk.client(...)`, \n\u003e to fully leverage IDE autocompletion and improve code readability.\n\n### Features and Examples\n\n#### 1. Uploading an Image\n\n```python\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.api_responses import ApiResponse\nfrom picsart_sdk.clients import UploadClient\n\nupload_client: UploadClient = picsart_sdk.client(PicsartAPI.UPLOAD)\n\nresponse: ApiResponse = upload_client.upload_image(image_path=\"/path/to/image.jpg\")\nprint(response.data.url)\nresponse: ApiResponse = upload_client.upload_image(image_url=\"https://domain.com/file.jpg\")\nprint(response.data.url)\n```\n\n#### 2. Remove Background\n#### Simple remove background using a file or from url\n\n```python\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.clients import RemoveBackgroundClient\nfrom picsart_sdk.api_responses import ApiResponse\n\nclient: RemoveBackgroundClient = picsart_sdk.client(PicsartAPI.REMOVE_BACKGROUND)\n\nresponse: ApiResponse = client.remove_background(image_path=\"./file.jpg\")\nprint(response.data.url)\n\nresponse = client.remove_background(image_url=\"https://domain.com/image.jpg\")\nprint(response.data.url)\n```\n\n#### Advanced Use Case\n\nIn case you want to apply different features available for [remove background](https://docs.picsart.io/reference/image-remove-background), \nyou can pass them as parameters, having the same names.\n\n```python\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.api_responses import ApiResponse\nfrom picsart_sdk.clients import RemoveBackgroundClient\n\nclient: RemoveBackgroundClient = picsart_sdk.client(PicsartAPI.REMOVE_BACKGROUND)\nresponse: ApiResponse = client.remove_background(image_url=\"https://domain.com/image.jpg\", stroke_size=2, stroke_color=\"red\")\nprint(response.data.url)\n```\n\n\u003e You can check the [API Reference](https://docs.picsart.io/reference) \n\u003e to find the available options for any of the supported APIs. \n\n#### 3. Ultra Upscale an Image\n\n**Using synchronous mode** (not feasible for large images)\n\n```python\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.clients import UltraUpscaleClient\nfrom picsart_sdk.api_responses import ApiResponse\nfrom picsart_sdk.clients.requests_models.ultra_upscale_request import UltraUpscaleMode\n\nclient: UltraUpscaleClient = picsart_sdk.client(PicsartAPI.ULTRA_UPSCALE)\nresponse: ApiResponse = client.ultra_upscale(image_path=\"./your-file.jpg\", mode=UltraUpscaleMode.SYNC)\nprint(response.data.url)\n```\n\n**Using asynchronous mode** (_recommended_)\n\n```python\nimport time\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.api_responses import ApiResponse\nfrom picsart_sdk.clients import UltraUpscaleClient\nfrom picsart_sdk.clients.requests_models.ultra_upscale_request import UltraUpscaleMode\n\nclient: UltraUpscaleClient = picsart_sdk.client(PicsartAPI.ULTRA_UPSCALE)\nresponse: ApiResponse = client.ultra_upscale(image_path=\"./your-file.jpg\", mode=UltraUpscaleMode.ASYNC)\ntime.sleep(10)  # depending on the load of the service and the size of the image, the time to process can differ\nresponse: ApiResponse = client.get_result(inference_id=response.inference_id)\nprint(response.data.url)\n```\n\n\u003e To find additional code snippets, explore the [examples](./examples) folder.\n\n\n# HTTP Async Client\nThe SDK includes an async HTTP client built on Python's async implementation, enabling non-blocking API requests for \noptimal performance in high-concurrency applications. \nThe async client mirrors the interface of the synchronous client, making it easy to switch between the two.\n\n```python\nimport asyncio\n\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.clients import AsyncUploadClient\n\nasync def upload_image_async():\n    # Create an async client\n    client: AsyncUploadClient = picsart_sdk.async_client(PicsartAPI.UPLOAD)\n\n    # Upload an image using the async/await syntax\n    response = await client.upload_image(image_path=\"./file.jpg\")\n    print(response.data.url)\n\nasyncio.run(upload_image_async())\n```\n\n# Asynchronous processing\n\nSome Picsart API endpoints support `asynchronous processing`, allowing you to initiate a request that returns an `inference_id`. \nThis enables the client to retrieve the results of the requested operation at a later time using that inference ID.\n\nThe SDK provides a convenient `get_result` method on the client object for fetching the final output of such operations.\n\nPlease refer to the [API Documentation](https://docs.picsart.io/) for details. \n\n```python\nimport time\nimport picsart_sdk\nfrom picsart_sdk import PicsartAPI\nfrom picsart_sdk.clients import UltraUpscaleClient\nfrom picsart_sdk.clients.requests_models.ultra_upscale_request import UltraUpscaleMode\n\nclient: UltraUpscaleClient = picsart_sdk.client(PicsartAPI.ULTRA_UPSCALE)\nresponse1 = client.ultra_upscale(image_path=\"./file.jpg\", mode=UltraUpscaleMode.ASYNC)\nprint(response1)\n# expect something like: ApiResponse(status='queued', data=None, inference_id='6862207a-838c-48c6-ba12-cf6083a9d76e')\n\ntime.sleep(10)\nresponse2 = client.get_result(inference_id=response1.inference_id)\nprint(response2)\n```\n\nThe response would be something like \n\n```python\nApiResponse(\n  status='success', \n  data=ApiResponseData(\n      id='702eb942-62fb-4c73-834b-db189cca923e.png', \n      url='https://cdn.picsart.io/702eb942-62fb-4c73-834b-db189cca923e.png'\n  ), \n  inference_id=None\n)\n```\n\n# SDK Documentation Reference\n\nYou can access the comprehensive [SDK documentation](https://picsart.github.io/picsart-creative-apis-python-sdk/) to explore detailed guides, SDK references, and usage examples.\n\n# Supported APIs\n\nThe SDK supports interactions with the following Picsart APIs\n\n## Image APIs\n- [Upload](https://docs.picsart.io/reference/image-upload)\n- [Remove Background](https://docs.picsart.io/reference/image-remove-background)\n- [Upscale](https://docs.picsart.io/reference/image-upscale)\n- [Ultra Upscale](https://docs.picsart.io/reference/image-ultra-upscale)\n- [Ultra Enhance](https://docs.picsart.io/reference/image-ultra-enhance)\n- [Face Enhancement](https://docs.picsart.io/reference/image-face-enhance)\n- [Effects](https://docs.picsart.io/reference/image-apply-effect)\n- [Effects Previews](https://docs.picsart.io/reference/image-create-effect-previews)\n- [AI Effects](https://docs.picsart.io/reference/image-apply-ai-effect)\n- [Color Transfer](https://docs.picsart.io/reference/image-transfer-color)\n- [Style Transfer](https://docs.picsart.io/reference/image-transfer-style)\n- [Masks](https://docs.picsart.io/reference/image-apply-mask)\n- [Masks Previews](https://docs.picsart.io/reference/image-create-mask-previews)\n- [Adjust](https://docs.picsart.io/reference/image-adjust)\n- [Basic Edit](https://docs.picsart.io/reference/image-edit)\n- [Texture Generator](https://docs.picsart.io/reference/image-generate-texture)\n- [Vectorizer](https://docs.picsart.io/reference/image-vectorize-raster-to-svg)\n- [Surfacemap Image](https://docs.picsart.io/reference/image-surfacemap)\n- [Image Tagging](https://docs.picsart.io/reference/image-tagging)\n- [Image Description](https://docs.picsart.io/reference/image-describer)\n- [Balance](https://docs.picsart.io/reference/image-credits-balance)\n\n## GenAI\n- [Text2Image](https://docs.picsart.io/reference/genai-text2image-1)\n- [Text2Text](https://docs.picsart.io/reference/genai-text2text-completions)\n- [Inpainting](https://docs.picsart.io/reference/genai-image-inpainting)\n- [Outpainting](https://docs.picsart.io/reference/genai-image-outpainting)\n- [Smart Background / Replace Background](https://docs.picsart.io/reference/genai-smart-background)\n- [Expand](https://docs.picsart.io/reference/genai-expand-image)\n- [Bleed](https://docs.picsart.io/reference/genai-generate-image-bleed)\n- [Balance](https://docs.picsart.io/reference/genai-credits-balance)\n\n# Error Handling\n\nThe SDK converts API errors into Python exceptions for easier debugging:\n\n- **ApiError**: Raised for non-20x HTTP responses.\n- **ApiAuthenticationError**: Raised for authentication failures.\n- **ValueError**: Raised for invalid payloads.\n\n# License\n\nPicsart Creative APIs SDK is provided under the MIT license that can be found in the\n[LICENSE](./LICENSE) file.\nBy using, distributing, or contributing to this project, you agree to\nthe terms and conditions of this license.\n\nThis project has some third-party dependencies, each of which may have independent licensing:\n- [httpx](https://github.com/projectdiscovery/httpx), ([MIT](https://github.com/projectdiscovery/httpx/blob/main/LICENSE.md)): Used as a http client\n\n# How to contribute?\n\nIf you like Picsart Creative APIs SDK and would like to contribute to this open-source project, please check the [Contribution\nguide](./CONTRIBUTING.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicsart%2Fpicsart-creative-apis-python-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpicsart%2Fpicsart-creative-apis-python-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpicsart%2Fpicsart-creative-apis-python-sdk/lists"}