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)
Metadata
Release files for microsoftdesigner 0.0.13
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 |
|---|---|---|---|---|
| microsoftdesigner-0.0.13.tar.gz | 17.7 kB | Without provenance | Details for microsoftdesigner-0.0.13.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| microsoftdesigner-0.0.13-py3-none-any.whl | Python 3 | none | any | Details for microsoftdesigner-0.0.13-py3-none-any.whl |
Total release size: 37.6 kB
Release files / microsoftdesigner-0.0.13.tar.gz
| Download URL | microsoftdesigner-0.0.13.tar.gz |
|---|---|
| Size | 17.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11ba6a8db281bd30e8947da23537122680386ad9c743e8ed5c3cf00d686acad0
|
|
BLAKE2b-256 checksum How to use checksums |
e3d876b9501b78d9541382212c9d048306852c91d619c7a2cf58a8b893b35b3a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-1018-oracle
|
Release files / microsoftdesigner-0.0.13-py3-none-any.whl
| Download URL | microsoftdesigner-0.0.13-py3-none-any.whl |
|---|---|
| Size | 19.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3a1543e8eb46bfe42b6ea457528e7fcda61381c42c45734af627dbaa27d74af3
|
|
BLAKE2b-256 checksum How to use checksums |
410a34cb4df39d0b9d1d3cadb44583ea565286b8d799e0a66271b0bcd937852e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.0.1 CPython/3.10.12 Linux/6.8.0-1018-oracle
|
Security for microsoftdesigner 0.0.13
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.