Async Python wrapper for OpenAI and Azure OpenAI image generation APIs.
Project description
Dallify
A clean, async Python wrapper for API-based image generation.
Supported Models:
- DALL-E 2
- DALL-E 3
- GPT-Image 1
Features
- Simple, intuitive API for image generation
- Async/await support
- Type-safe with full type hints
- Environment variable support with python-dotenv
- Support for OpenAI and Azure OpenAI
Installation
pip install imgify
Quick Start
OpenAI
Option 1: Using Environment Variables
Set up your environment:
OPENAI_API_KEY=your-openai-api-key
Then use the client:
import asyncio
from imgify import ImgifyOpenAI
async def main():
async with ImgifyOpenAI() as client:
image = await client.generate(
prompt="A serene mountain landscape"
)
print(f"Image: {image.b64_json[:50]}...")
asyncio.run(main())
Option 2: Passing API Key as Parameter
import asyncio
from imgify import ImgifyOpenAI
async def main():
async with ImgifyOpenAI(api_key="your-openai-api-key") as client:
image = await client.generate(
prompt="A serene mountain landscape"
)
print(f"Image: {image.b64_json[:50]}...")
asyncio.run(main())
asyncio.run(main())
#### Option 2: Passing API Key as Parameter
### Azure OpenAI
#### Option 1: Using Environment Variables
Set up your environment:
```env
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
Then use the client:
import asyncio
from imgify import ImgifyAzure
async def main():
async with ImgifyAzure() as client:
image = await client.generate(
prompt="A futuristic city"
)
print(f"Image: {image.b64_json[:50]}...")
asyncio.run(main())
Option 2: Passing Credentials as Parameters
import asyncio
from imgify import ImgifyAzure
async def main():
async with ImgifyAzure(
api_key="your-azure-openai-api-key",
azure_endpoint="https://your-resource.openai.azure.com/"
) as client:
image = await client.generate(
prompt="A futuristic city"
)
print(f"Image: {image.b64_json[:50]}...")
asyncio.run(main())
from imgify import DallifyAzureOpenAI
async def main(): async with DallifyAzureOpenAI( api_key="your-azure-openai-api-key", azure_endpoint="https://your-resource.openai.azure.com/" ) as client: image = await client.generate( prompt="A futuristic city" ) print(f"Image: {image.b64_json[:50]}...")
asyncio.run(main())
## Environment Variables
### OpenAI
```env
OPENAI_API_KEY=your-openai-api-key
Azure OpenAI
AZURE_OPENAI_API_KEY=your-azure-openai-api-key
AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com/
API
Generate Image as Base64
image = await client.generate(
prompt="A peaceful forest",
model=ImageModelApiName.GPT_IMAGE_1, # default
size=ImageSize.SQUARE_1024, # default
quality=ImageQuality.STANDARD # optional
)
print(image.b64_json)
Available Options
Models
ImageModelApiName.GPT_IMAGE_1(default)ImageModelApiName.DALL_E_2ImageModelApiName.DALL_E_3
Sizes
ImageSize.SQUARE_256(256x256)ImageSize.SQUARE_512(512x512)ImageSize.SQUARE_1024(1024x1024, default)ImageSize.LANDSCAPE_1792(1792x1024)ImageSize.PORTRAIT_1792(1024x1792)
Quality
ImageQuality.STANDARDImageQuality.HD
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file imgify-0.1.0.tar.gz.
File metadata
- Download URL: imgify-0.1.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
123e352c19f65ccfd08728556c1b2d3756ee13ff06f48b8bb7ea7684543411c2
|
|
| MD5 |
2536753c8fe637163b0cef920e37a68f
|
|
| BLAKE2b-256 |
447c220c4bbb4bb893cafb96362f092a9b46bb5de616f74ec004ffb931a700ff
|
File details
Details for the file imgify-0.1.0-py3-none-any.whl.
File metadata
- Download URL: imgify-0.1.0-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
045890d6d93e28f5f6b849cb2f3c6e0e610e40740e47ba9dace8aa10fef70bd4
|
|
| MD5 |
83e5d6ea6bab1e87a52353f53cfdfb28
|
|
| BLAKE2b-256 |
2d98c5bd6d934adcda0e52a06fa6bcf6a89aa994e4931e52f1ceff6a0f05ce1d
|