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
Metadata
Release files for imgify 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| imgify-0.1.0.tar.gz | 4.0 kB | Without provenance | Details for imgify-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| imgify-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for imgify-0.1.0-py3-none-any.whl |
Total release size: 9.5 kB
Release files / imgify-0.1.0.tar.gz
| Download URL | imgify-0.1.0.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
123e352c19f65ccfd08728556c1b2d3756ee13ff06f48b8bb7ea7684543411c2
|
|
BLAKE2b-256 checksum How to use checksums |
447c220c4bbb4bb893cafb96362f092a9b46bb5de616f74ec004ffb931a700ff
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.2
|
Release files / imgify-0.1.0-py3-none-any.whl
| Download URL | imgify-0.1.0-py3-none-any.whl |
|---|---|
| Size | 5.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
045890d6d93e28f5f6b849cb2f3c6e0e610e40740e47ba9dace8aa10fef70bd4
|
|
BLAKE2b-256 checksum How to use checksums |
2d98c5bd6d934adcda0e52a06fa6bcf6a89aa994e4931e52f1ceff6a0f05ce1d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.2
|
Security for imgify 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.