Microsoft Designer API
A Python library for generating images using Microsoft Designer's API.
Installation
pip install microsoftdesigner
Configuration
Create a .env file in your project root with:
USER_ID=your_user_id_here
AUTH_TOKEN=your_auth_token_here
Command Line Usage
python -m microsoftdesigner --help
options:
-h, --help show this help message and exit
--user_id USER_ID User ID (or set MSDESIGNER_USER_ID env var)
--auth_token AUTH_TOKEN
Authentication token (or set MSDESIGNER_AUTH_TOKEN env var)
--prompt PROMPT Image generation prompt
--save_path SAVE_PATH
Path to save generated images (default: images)
--resolution {1024x1024,1024x1792,1792x1024}
Image resolution (default: 1024x1024)
--boost_count BOOST_COUNT
Boost count for generation quality (default: 1)
--seed SEED Random seed for reproducible results (optional)
Python Usage
Basic example:
from microsoftdesigner.gen_images import create_img
from dotenv import load_dotenv
import os
load_dotenv() # Load environment variables from .env file
# Get credentials from environment
user_id = os.getenv("USER_ID")
auth_token = os.getenv("AUTH_TOKEN")
# Generate images
image_paths = create_img(
user_id=user_id,
auth_token=auth_token,
prompt="a beautiful sunset over mountains",
save_path="images", # Optional: defaults to 'images'
resolution="1024x1024", # Optional: 1024x1024, 1024x1792, 1792x1024
boost_count=1, # Optional: enhance generation quality (default: 1)
seed=42 # Optional: set for reproducible results
)
# Example output: list of paths like
# ['images/1024x1024/123e4567-e89b-12d3-a456-426614174000.jpg',
# 'images/1024x1024/987fcdeb-51d3-12d3-a456-426614174000.jpg', ...]
print(f"Generated images saved to: {image_paths}")
Getting Started
- Create/login to your Microsoft Designer account
- Open browser developer tools (F12) and go to Network tab
- Generate an image using any prompt in Microsoft Designer
- In the Network tab, find the POST request to
/DallE.ashx - From the request headers, copy:
UserIdheader value → set as USER_IDAuthorizationheader value → set as AUTH_TOKEN
- Save these values in your .env file or pass them directly to the API
Important Notes
- Authentication: Auth tokens expire after 24 hours - you'll need to refresh them
- Resolutions: Only use supported resolutions:
- Square: 1024x1024
- Portrait: 1024x1792
- Widescreen: 1792x1024
- File Organization: Generated images are automatically saved in resolution-specific subfolders:
images/ ├── 1024x1024/ ├── 1024x1792/ └── 1792x1024/ - Error Handling: The API will return an empty list if you've run out of credits (403 error)
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
microsoftdesigner-0.0.13.tar.gz
(17.7 kB
view details)
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 microsoftdesigner-0.0.13.tar.gz.
File metadata
- Download URL: microsoftdesigner-0.0.13.tar.gz
- Upload date:
- Size: 17.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-1018-oracle
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
11ba6a8db281bd30e8947da23537122680386ad9c743e8ed5c3cf00d686acad0
|
|
| MD5 |
ab6e41461cf2971b1333497a1e504a6c
|
|
| BLAKE2b-256 |
e3d876b9501b78d9541382212c9d048306852c91d619c7a2cf58a8b893b35b3a
|
File details
Details for the file microsoftdesigner-0.0.13-py3-none-any.whl.
File metadata
- Download URL: microsoftdesigner-0.0.13-py3-none-any.whl
- Upload date:
- Size: 19.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-1018-oracle
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3a1543e8eb46bfe42b6ea457528e7fcda61381c42c45734af627dbaa27d74af3
|
|
| MD5 |
8ae2826397f83e9d1187c975ec3ed8a1
|
|
| BLAKE2b-256 |
410a34cb4df39d0b9d1d3cadb44583ea565286b8d799e0a66271b0bcd937852e
|