{"id":27395648,"url":"https://github.com/5eroo/pixai-wrapper","last_synced_at":"2025-04-13T23:15:52.719Z","repository":{"id":229508742,"uuid":"776871309","full_name":"5eroo/PixAI-Wrapper","owner":"5eroo","description":"Python scripts that log into PixAI's website automatically using an account you provide. Then, it uses realtime generation to generate images for you.","archived":false,"fork":false,"pushed_at":"2024-10-02T12:03:57.000Z","size":65,"stargazers_count":4,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T23:15:38.464Z","etag":null,"topics":["ai","aiimagegenerator","pixai","py","py3","python","python3","reverse-engineering","wrapper","wrapper-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/5eroo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-03-24T17:15:36.000Z","updated_at":"2025-04-09T13:39:55.000Z","dependencies_parsed_at":"2024-04-25T23:23:39.666Z","dependency_job_id":"2691bd81-4de8-4c2c-a01b-415056135868","html_url":"https://github.com/5eroo/PixAI-Wrapper","commit_stats":{"total_commits":21,"total_committers":3,"mean_commits":7.0,"dds":0.4285714285714286,"last_synced_commit":"fb36c38841a010060bfb5cf43ab2fc705f51aa22"},"previous_names":["recentaly/pixai-wrapper","itszerrin/pixai-wrapper","5eroo/pixai-wrapper"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5eroo%2FPixAI-Wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5eroo%2FPixAI-Wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5eroo%2FPixAI-Wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/5eroo%2FPixAI-Wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/5eroo","download_url":"https://codeload.github.com/5eroo/PixAI-Wrapper/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248794568,"owners_count":21162615,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["ai","aiimagegenerator","pixai","py","py3","python","python3","reverse-engineering","wrapper","wrapper-api"],"created_at":"2025-04-13T23:15:51.785Z","updated_at":"2025-04-13T23:15:52.711Z","avatar_url":"https://github.com/5eroo.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# PixAI Realtime Image Generation Wrapper\n\n**This is a collection of Python scripts. Together, they can take a prompt input and generates images from PixAI directly. This procedure does NOT cost you credits and you can use an alt too.**\n\nNote: The **Realtime generation** feature is a compromise to not pay tokens but your images are of lesser quality.\n\n---\n\n## 1. Installation:\n\n### 1.1 Copying the Git repository \n```bash\ngit clone https://github.com/Recentaly/PixAI-Wrapper.git\n```\n\n### 1.2 Entering the directory\n```bash\ncd PixAI-Wrapper\n```\n\n## 1.3 Installing Dependencies\n```bash\npip install -r requirements.txt\n```\n\n## 2. Preparation\n\n### 2.1 Create a Python file at root.\n\n### 2.2 Importing required modules\n```py\nfrom res.scripts.generate_images    import get_image_batch\nfrom res.scripts.get_jwt            import get_jwt\n```\n\n(Optional but recommended):\n```py\nfrom res.SaveConfig                 import SaveConfig\n```\n\n---\n\n## 3. Saveconfig (optional)\n\n### 3.1 Initialize the SaveConfig class in your code. Example:\n\nWhen a `SaveConfig` object is passed to the API, the API automatically saves the images. There's an option to Save + Return too. To only return the images from the API, leave `SaveConfig` as `None` when calling `get_image_batch`. \u003cbr\u003e\n\n**Note: Automatically uses the .png file extension**\n\n```py\n# create a SaveConfig object\nsave_config = SaveConfig(\n    save_dir=\"output/images\",\n    save_name=\"image\",\n    force_mkdir=True,\n    additional_return_mode=False,\n    separator=\"-\"\n)\n```\n\n- The `save_dir` (str) is a path to whatever directory you want the images to be saved at.\n- `save_name` (str) is whatever you want the file(s) to be called.\n- `force_mkdir` (bool) if the `save_dir` doesn't exist, forcibly create that directory if `force_mkdir` is True.\n- `additional_return_mode` (bool) If true, also returns a `List` of images while also saving them at the specified directory.\n- `separator` (str) The separator between the `save_name` and the Image's index.\n\nFor example, if I have this code and generated, let's say, 4 images..\n\n```py\n# create a SaveConfig object\nsave_config = SaveConfig(\n    save_dir=\"output/images\",\n    save_name=\"generated-image\",\n    force_mkdir=True,\n    additional_return_mode=False,\n    separator=\"_\"\n)\n```\n\nThe images would be saved like this:\n```\ngenerated-image_0.png\ngenerated-image_1.png\ngenerated-image_2.png\ngenerated-image_3.png\n```\n\n---\n\n## Getting the JWT\n\nHere's example code to fetch your JWT.\n\n```py\n jwt: str = get_jwt(\n  email=\"\u003cyour pixai email here\u003e\",\n  password=\"\u003cyour pixai password here\u003e\"\n)\n```\n\nThis will return a jwt of type string. Now you may actually use the function to gather the images\n\n## 4. Fetching a batch of images\n\n### 4.1 Compiling the parameters\n\nTo gather images, simply call the ``get_image_batch`` function after you've imported it.\n\nParameters:\n\n- prompt: str = The prompt to generate the images from\n- negative_prompt: str = The negative prompt to generate the image from\n- size: tuple[int, int]: Width x Height of the image. it is generally recommended to keep this at 512x512 For speed and a higher chance of getting a result.\n- __jwt: str = The JWT.\n- _n: int = Number of images to generate | defaults to one\n- _seed: int = The seed to generate the image with. Defaults to a None and lets PixAI decide.\n- _saveConfig: SaveConfig = Optional SaveConfig if you want to save the images quickly and easily\n\nReturns:\n\n- if a `SaveConfig` is provided, and `_saveConfig.additional_return_mode` is true, it saves the images and returns a `List[Image]` object. Image is inherited from PIL.\n- If `_saveConfig.additional_return_mode` is False, the API returns `None`\n- If no `SaveConfig` is provided, it return `List[Image]` object. Image is inherited from PIL.\n\n### 4.2 Calling the function\n\nBelow is an example of how to generate images of a dog. The negative prompt is one I found and is useful to generate high quality results.\n\n```py\n\"\"\"\nThe images automatically saved under 'output/images' as 'image-0.png'. The API didn't return anything because additional_return_mode is False.\n\"\"\"\n\nsave_config = SaveConfig(\n    save_dir=\"output/images\",\n    save_name=\"image\",\n    force_mkdir=True,\n    additional_return_mode=False,\n    separator=\"-\"\n)\n\nimage_outputs = get_image_batch(\n    prompt=\"1dog. White. Fluffly. Looking at the camera.\",\n    negative_prompt=\"nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, abstract\",\n    size=(512, 512),\n    _n=1,\n    __jwt=__jwt,\n    _saveConfig=save_config\n)\n```\n\n### (4.3) Handling returned images\n\nThe Images are basic `Image` objects of the [Image](https://pillow.readthedocs.io/en/stable/reference/Image.html) module.\n\nOutput:\n\n![Output_image_example_dog](https://i.imgur.com/msk40mQ.png)\n\n---\n\n## Example code:\n\n```py\nfrom res.scripts.get_jwt            import get_jwt\nfrom res.scripts.generate_images    import get_image_batch\nfrom res.SaveConfig                 import SaveConfig\n\n# create a SaveConfig object\nsave_config = SaveConfig(\n    save_dir=\"output/images\",\n    save_name=\"image\",\n    force_mkdir=True,\n    additional_return_mode=True,\n    separator=\"-\"\n)\n\nif __name__ == '__main__':\n\n    __jwt: str = get_jwt(\n        email=\"xxxxxxxx\", # input your actual email here\n        password=\"xxxxxx\" # input your actual password here\n    )\n\n    image_outputs = get_image_batch(\n        prompt=\"1cat. Yellow. Aggressive. Angry. Hissing at the camera. Best quality. Masterpiece. Best anatomy. Open mouth.\",\n        negative_prompt=\"nsfw, lowres, (bad), text, error, fewer, extra, missing, worst quality, jpeg artifacts, low quality, watermark, unfinished, displeasing, oldest, early, chromatic aberration, signature, extra digits, artistic error, username, scan, abstract\",\n        size=(512, 512),\n        _n=1,\n        __jwt=__jwt,\n        _saveConfig=save_config\n    )\n\n    # we can run the for loop because the API class is set to additionally return the images again \n    for image in image_outputs:\n        image.show()\n```\n\nOutput:\n\n![Aggressive_cat_example](https://i.imgur.com/VOneDA2.png)\n\n### Auto-claiming your daily credits\n\nTo auto-claim your daily credits, first import the code to claim credits\n\n```py\nfrom res.scripts.claim_credits      import claim_daily_credits\n```\n\nThen, call the `claim_daily_credits` function\n\n```py\nclaim_daily_credits(\n    jwt # you need your jwt from above\n)\n```\n\nYou will only get an error if something went wrong. It will tell you in the console if it was able to claim your daily credits or if you already claimed them.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5eroo%2Fpixai-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F5eroo%2Fpixai-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F5eroo%2Fpixai-wrapper/lists"}