VisionCraftAPI


NameVisionCraftAPI JSON
Version 1.0.8 PyPI version JSON
download
home_pagehttps://github.com/Belyashik2K/VisionCraftAPI
SummaryFully async python wrapper for VisionCraft API
upload_time2024-04-17 12:49:48
maintainerNone
docs_urlNone
authorBelyashik2K
requires_pythonNone
licenseMIT license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ![photo (4)](https://github.com/Belyashik2K/VisionCraftAPI/assets/126521808/fa32e4fa-37bd-47a7-9574-bbc02191796b)
# VisionCraft API
> Fully async python wrapper for [VisionCraft API](https://api.visioncraft.top/docs)

## Installing

    pip install VisionCraftAPI

## Features
* Fully async methods
* Important methods return Pydantic model as result for easier interaction with data
* Full exception handling
* Full [documentation](https://vision.b2k.tech/) is available

## Usage
```python
import asyncio
import aiohttp

from VisionCraftAPI import VisionCraftClient

async def generate_xl_image(client: VisionCraftClient,
                            prompt: str,
                            model: str,
                            sampler: str,
                            image_count: int):
    images = await client.generate_xl_image(
        prompt=prompt,
        model=model,
        sampler=sampler,
        image_count=image_count
    )
    
    print('Images generated! Saving it...')
    # Download and save the generated images
    async with aiohttp.ClientSession() as session:
        for i, image_url in enumerate(images):
            async with session.get(image_url) as image_response:
                image_data = await image_response.read()
                # Save the image locally
                with open(f"generated_image_{i}.png", "wb") as f:
                    f.write(image_data)
                    
async def main():
    # Set your API key
    api_key = "YOUR_API_KEY"
    # Create a VisionCraftClient instance
    client = VisionCraftClient(api_key=api_key)
    
    # Get all SDXL models and samplers
    models = await client.get_xl_models()
    samplers = await client.get_xl_samplers()

    # Generate an image with the first model and sampler
    await generate_xl_image(client=client,
                            prompt='A beautiful sunset',
                            model=models[0],
                            sampler=samplers[0],
                            image_count=4)
            
if __name__ == '__main__':
    asyncio.run(main())
```

## Docs
> Go to https://vision.b2k.tech/ for more information about SDK

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Belyashik2K/VisionCraftAPI",
    "name": "VisionCraftAPI",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": null,
    "author": "Belyashik2K",
    "author_email": "work@belyashik2k.ru",
    "download_url": "https://files.pythonhosted.org/packages/5f/e8/2f7c170a0292ed9ea1e05d1ee6e0aa2eedef022c6b1b1c377b090570ef3a/visioncraftapi-1.0.8.tar.gz",
    "platform": null,
    "description": "![photo (4)](https://github.com/Belyashik2K/VisionCraftAPI/assets/126521808/fa32e4fa-37bd-47a7-9574-bbc02191796b)\r\n# VisionCraft API\r\n> Fully async python wrapper for [VisionCraft API](https://api.visioncraft.top/docs)\r\n\r\n## Installing\r\n\r\n    pip install VisionCraftAPI\r\n\r\n## Features\r\n* Fully async methods\r\n* Important methods return Pydantic model as result for easier interaction with data\r\n* Full exception handling\r\n* Full [documentation](https://vision.b2k.tech/) is available\r\n\r\n## Usage\r\n```python\r\nimport asyncio\r\nimport aiohttp\r\n\r\nfrom VisionCraftAPI import VisionCraftClient\r\n\r\nasync def generate_xl_image(client: VisionCraftClient,\r\n                            prompt: str,\r\n                            model: str,\r\n                            sampler: str,\r\n                            image_count: int):\r\n    images = await client.generate_xl_image(\r\n        prompt=prompt,\r\n        model=model,\r\n        sampler=sampler,\r\n        image_count=image_count\r\n    )\r\n    \r\n    print('Images generated! Saving it...')\r\n    # Download and save the generated images\r\n    async with aiohttp.ClientSession() as session:\r\n        for i, image_url in enumerate(images):\r\n            async with session.get(image_url) as image_response:\r\n                image_data = await image_response.read()\r\n                # Save the image locally\r\n                with open(f\"generated_image_{i}.png\", \"wb\") as f:\r\n                    f.write(image_data)\r\n                    \r\nasync def main():\r\n    # Set your API key\r\n    api_key = \"YOUR_API_KEY\"\r\n    # Create a VisionCraftClient instance\r\n    client = VisionCraftClient(api_key=api_key)\r\n    \r\n    # Get all SDXL models and samplers\r\n    models = await client.get_xl_models()\r\n    samplers = await client.get_xl_samplers()\r\n\r\n    # Generate an image with the first model and sampler\r\n    await generate_xl_image(client=client,\r\n                            prompt='A beautiful sunset',\r\n                            model=models[0],\r\n                            sampler=samplers[0],\r\n                            image_count=4)\r\n            \r\nif __name__ == '__main__':\r\n    asyncio.run(main())\r\n```\r\n\r\n## Docs\r\n> Go to https://vision.b2k.tech/ for more information about SDK\r\n",
    "bugtrack_url": null,
    "license": "MIT license",
    "summary": "Fully async python wrapper for VisionCraft API",
    "version": "1.0.8",
    "project_urls": {
        "Homepage": "https://github.com/Belyashik2K/VisionCraftAPI"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5fe82f7c170a0292ed9ea1e05d1ee6e0aa2eedef022c6b1b1c377b090570ef3a",
                "md5": "80931160dd7c7316190d81e2aadcfbd0",
                "sha256": "8c5e5b8d4ce643afe96e0a44a75f839f456db61224800ea7a35b0216081a1184"
            },
            "downloads": -1,
            "filename": "visioncraftapi-1.0.8.tar.gz",
            "has_sig": false,
            "md5_digest": "80931160dd7c7316190d81e2aadcfbd0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 10080,
            "upload_time": "2024-04-17T12:49:48",
            "upload_time_iso_8601": "2024-04-17T12:49:48.715025Z",
            "url": "https://files.pythonhosted.org/packages/5f/e8/2f7c170a0292ed9ea1e05d1ee6e0aa2eedef022c6b1b1c377b090570ef3a/visioncraftapi-1.0.8.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-17 12:49:48",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Belyashik2K",
    "github_project": "VisionCraftAPI",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "visioncraftapi"
}
        
Elapsed time: 0.40307s