Skip to main content

ImageAPI AI Python SDK

Official Python SDK for ImageAPI AI. 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 to retrieve your secret API key (sk_live_...).

2. View Community Showcase

Explore community-generated creations on our Showcase Gallery.

📦 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

📄 License

MIT © ImageAPI AI

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

imageapiai-1.0.0.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

imageapiai-1.0.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file imageapiai-1.0.0.tar.gz.

File metadata

  • Download URL: imageapiai-1.0.0.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for imageapiai-1.0.0.tar.gz
Algorithm Hash digest
SHA256 e23befa4ebadb43e0663534c5676f7b8b868a6ba263315f9a56abd1d6bf533e0
MD5 559a4fa52c707d213cfeba1feb89b84d
BLAKE2b-256 2b8fecc8b9cd344e75d50b34298a8f4ddb8aca3fd526c13f5a91f002f4d974cb

See more details on using hashes here.

File details

Details for the file imageapiai-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: imageapiai-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for imageapiai-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cae9241ca7a1461aab3a401ccb9a3b82bc4b7c8273435012b60a3ba47d50e615
MD5 d2a8dde68bf6303b007fe93ebdfd36ea
BLAKE2b-256 b05e06c523ab76f512b7afc2571c6bc45f2a0121fde7781a63ded4df7e1efcc2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page