An AI image generation toolkit based on the xAI Grok API.
- 🎨 Image Generation: Generate AI images using the xAI Grok API.
- 💻 Multiple Interfaces: Support for both Command Line Interface (CLI) and Graphical User Interface (GUI).
- 🌐 Proxy Support: Configurable proxy settings for users in mainland China.
- ⏰ Automation: Scheduled tasks with built-in email notifications.
- 📝 Logging: Comprehensive logging and robust error handling.
- 🔒 Secure Configuration: Safe management of sensitive data via environment variables.
- Python 3.10 or higher
- uv package manager (recommended)
# Install uv (if not already installed)
curl -LsSf https://astral.sh/uv/install.sh | sh
# Clone the repository
git clone https://github.com/sihuangtech/grok-studio.git
cd grok-studio
# Create virtual environment and install dependencies
uv venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
uv pip install -e .# Clone the repository
git clone https://github.com/sihuangtech/grok-studio.git
cd grok-studio
# Create virtual environment
python -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
# Install dependencies
pip install -e .- Copy the example configuration file:
cp .env.example .env- Edit the
.envfile with your settings:
# Required: xAI API Key
XAI_API_KEY=your_api_key_here
# Optional: Proxy configuration (Required for users in mainland China)
PROXY_HTTP=http://127.0.0.1:7890
PROXY_HTTPS=http://127.0.0.1:7890- Obtain your xAI API Key:
- Visit the xAI Console
- Sign up and create an API key.
It is recommended to use uv run to execute the project:
# Generate a single image
uv run . --cli generate --prompt "A beautiful cat in a tree"
# Generate multiple images
uv run . --cli generate --prompt "A sunset over mountains" --count 3
# Specify output directory
uv run . --cli generate --prompt "Abstract art" --output ./my-images
# Use base64 format
uv run . --cli generate --prompt "Futuristic city" --format b64_json
# Show help
uv run . --cli --help# Start GUI (Default)
uv run .
# Or explicitly specify GUI mode
uv run . --gui- Create a
jobs.yamlconfiguration file:
jobs:
- id: daily_cat_image
prompt: "A beautiful cat"
cron: "0 9 * * *" # Daily at 9:00 AM
count: 1
email_recipients:
- user@example.com- Start the scheduler:
uv run . --scheduler --jobs jobs.yamluv pip install -e ".[dev]"# Run all tests
pytest
# Run unit tests
pytest tests/unit/
# Run property tests
pytest tests/property/
# View code coverage
pytest --cov=. --cov-report=htmlxai-studio/
├── api/ # API Client and Proxy handler
├── cli/ # Command Line Interface
├── config/ # Configuration management
├── core/ # Core generation logic
├── gui/ # Graphical User Interface
├── scheduler/ # Task scheduling and Email sender
├── utils/ # Utility functions and Logger
├── tests/ # Test suite
│ ├── unit/ # Unit tests
│ └── property/ # Property-based tests
├── .env.example # Configuration template
├── pyproject.toml # Project metadata and dependencies
└── README.md # Project documentation
A: Visit the xAI Console, register an account, and create a new key.
A: You need to configure a proxy. Set PROXY_HTTP and PROXY_HTTPS in your .env file.
A: By default, they are saved in the ./output directory. You can change this via the OUTPUT_DIR setting in .env or the --output parameter in the CLI.
A: Logs are saved in ./logs/xai-studio.log by default. This can be customized via the LOG_FILE setting in .env.
A: The toolkit supports JPG and PNG formats.
This project is licensed under the MIT License.
Issues and Pull Requests are welcome!
SK Studio
- 🌐 Official Website
- 💬 Discord Server
- 🐧 QQ Group