Python DALL·E
The API provides three main features:
Overview
The API provides three main features:
- Text-to-image (DALL·E 3 and DALL·E 2)
- Image edit (DALL·E 2 only)
- Image variations (DALL·E 2 only)
1. Image generation
Basic usage
from openai import OpenAI client = OpenAI( base_url="https://api.digislash.com/v1", api_key=key ) response = client.images.generate( model="dall-e-3", prompt="a white siamese cat", size="1024x1024", quality="standard", n=1, ) image_url = response.data[0].urljsonParameters
- Sizes: 1024x1024, 1024x1792, 1792x1024
- Quality: standard (default), hd (DALL·E 3 only)
- Count:
- DALL·E 3: 1 image per request
- DALL·E 2: up to 10 images per request
2. Image edit (DALL·E 2)
Example
from openai import OpenAI client = OpenAI( base_url="https://api.digislash.com/v1", api_key=key ) response = client.images.edit( model="dall-e-2", image=open("sunlit_lounge.png", "rb"), mask=open("mask.png", "rb"), prompt="A sunlit indoor lounge area with a pool containing a flamingo", n=1, size="1024x1024" ) image_url = response.data[0].urljsonRequirements
- Image and mask must be PNG
- Must be square
- File size < 4MB
- Image and mask must share the same dimensions
3. Variations (DALL·E 2)
Example
from openai import OpenAI client = OpenAI( base_url="https://api.digislash.com/v1", api_key=key ) response = client.images.create_variation( model="dall-e-2", image=open("corgi_and_cat_paw.png", "rb"), n=1, size="1024x1024" ) image_url = response.data[0].urljsonRequirements
- PNG format
- Square image
- File size < 4MB
Prompt tips
DALL·E 3
- Prompts are auto-optimized
- You can disable optimization with:
I NEED to test how the tool works with extremely simple prompts. DO NOT add any detail, just use it AS-IS:jsonNotes
Content moderation
- Strict content policy
- Violations return errors
Image URLs
- Valid for 1 hour
- Base64 output is also available
