Metadata-Version: 2.4
Name: imageapiai
Version: 1.0.0
Summary: Official Python SDK for ImageAPI AI - Generate and refine AI images with simple API calls.
Author-email: ImageAPI AI <support@imageapiai.com>
License: MIT
Project-URL: Homepage, https://imageapiai.com
Project-URL: Documentation, https://imageapiai.com/docs
Project-URL: Showcase, https://imageapiai.com/showcase
Project-URL: Dashboard, https://imageapiai.com/dashboard
Project-URL: Source, https://github.com/your-github-username/imageapiai-python
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

ImageAPI AI Python SDK
======================

Official Python SDK for [**ImageAPI AI**](https://imageapiai.com/ "null"). Easily generate high-quality AI images, adjust dimensions and quality presets, refine prompts for 0 credits, and manage your account credit balance.

🚀 Getting Started
------------------

### 1\. Get an API Key

Sign up at [**ImageAPI.ai Dashboard**](https://imageapiai.com/dashboard "null") to retrieve your secret API key (`sk_live_...`).

### 2\. View Community Showcase

Explore community-generated creations on our [**Showcase Gallery**](https://imageapiai.com/showcase "null").

📦 Installation
---------------

Install the package via `pip`:

```
pip install imageapiai

```

💻 Usage & Examples
-------------------

### 1\. Initialize the Client

```
from imageapiai import ImageAPI

client = ImageAPI(api_key="sk_live_your_secret_api_key_here")

```

### 2\. Generate a New Image

Pass a `prompt` along with optional parameters like `width`, `height`, and `quality` (`'low'`, `'medium'`, `'high'`):

```
try:
    result = client.generate(
        prompt="A futuristic cybernetic tiger in a neon rainy street, 8k render",
        width=1024,
        height=1024,
        quality="high"  # 'low' | 'medium' (default) | 'high'
    )

    print("Image Generation Succeeded!")
    print("Generation ID:", result["data"]["prompt_id"])
    print("Image URL:", result["data"]["image_url"])
except Exception as e:
    print("Generation Error:", str(e))

```

### 3\. Refine / Retry an Existing Image

Refine an existing image prompt by passing additional modifications or prompt updates without having to re-type the original base prompt:

```
try:
    result = client.refine(
        parent_prompt_id="gen_1234567890",  # Original parent generation ID
        prompt_update="Make it daytime, add golden sunlight highlights",  # Prompt update
        width=1024,
        height=768,
        quality="high"
    )

    print("Updated Image URL:", result["data"]["image_url"])
except Exception as e:
    print("Refine Error:", str(e))

```

### 4\. Check Credit Balance & Account Profile

```
try:
    # Retrieve account profile & remaining credits
    profile = client.get_profile()
    print("Remaining Credits:", profile["data"]["credit_balance"])
    print("Subscription Status:", profile["data"]["subscription_status"])

    # Fetch generation history
    history = client.get_history()
    print("Total Historical Images:", len(history["data"]))
except Exception as e:
    print("Account Check Error:", str(e))

```

📖 SDK Reference
----------------

### `ImageAPI(api_key, base_url="https://imageapiai.com")`

Creates a new client instance.

### `client.generate(prompt=None, width=None, height=None, quality="medium", parent_prompt_id=None, prompt_update=None)`

Generates a new AI image or updates an existing one.

-   **Parameters:**

    -   `prompt` *(str, optional)*: Text prompt describing the desired image.

    -   `width` *(int, optional)*: Image width in pixels.

    -   `height` *(int, optional)*: Image height in pixels.

    -   `quality` *(str, optional)*: Quality preset. Allowed values: `'low'`, `'medium'`, `'high'` (Default: `'medium'`).

    -   `parent_prompt_id` *(str, optional)*: Parent generation ID when refining an existing image.

    -   `prompt_update` *(str, optional)*: Modifications to apply to the parent prompt.

### `client.refine(parent_prompt_id, prompt_update, width=None, height=None, quality="medium")`

Convenience method for refining an existing image generation ID for 0 credits.

-   **Parameters:**

    -   `parent_prompt_id` *(str)*: ID of original generation.

    -   `prompt_update` *(str)*: Modifications to apply.

    -   `width` *(int, optional)*: Image width in pixels.

    -   `height` *(int, optional)*: Image height in pixels.

    -   `quality` *(str, optional)*: Quality preset (`'low'`, `'medium'`, `'high'`).

### `client.get_profile()`

Fetches user account details, credit balance, and active subscription status.

### `client.get_history()`

Returns a list of all historical image generations for the account.

🔗 Links & Resources
--------------------

-   **Homepage:** [imageapiai.com](https://imageapiai.com/ "null")

-   **Dashboard & Keys:** [imageapiai.com/dashboard](https://imageapiai.com/dashboard "null")

-   **Image Showcase:** [imageapiai.com/showcase](https://imageapiai.com/showcase "null")

-   **API Documentation:** [imageapiai.com/docs](https://imageapiai.com/docs "null")

-   **PyPI Package:** [pypi.org/project/imageapiai](https://pypi.org/project/imageapiai/ "null")

📄 License
----------

[MIT](https://gemini.google.com/app/LICENSE "null") © [ImageAPI AI](https://imageapiai.com/ "null")
