Skip to content

A versatile xAI Grok image generation suite featuring a user-friendly GUI, a powerful CLI, and an automated scheduler with built-in email notifications.

License

Notifications You must be signed in to change notification settings

sihuangtech/grok-studio

Repository files navigation

xAI Studio

English | 简体中文

An AI image generation toolkit based on the xAI Grok API.

Features

  • 🎨 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.

System Requirements

  • Python 3.10 or higher
  • uv package manager (recommended)

Installation

Using uv (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 .

Using pip

# 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 .

Configuration

  1. Copy the example configuration file:
cp .env.example .env
  1. Edit the .env file 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
  1. Obtain your xAI API Key:

Usage

It is recommended to use uv run to execute the project:

Command Line Interface (CLI)

# 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

Graphical User Interface (GUI)

# Start GUI (Default)
uv run .

# Or explicitly specify GUI mode
uv run . --gui

Scheduled Tasks

  1. Create a jobs.yaml configuration 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
  1. Start the scheduler:
uv run . --scheduler --jobs jobs.yaml

Development

Install Development Dependencies

uv pip install -e ".[dev]"

Running Tests

# Run all tests
pytest

# Run unit tests
pytest tests/unit/

# Run property tests
pytest tests/property/

# View code coverage
pytest --cov=. --cov-report=html

Project Structure

xai-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

FAQ

Q: How do I get an xAI API key?

A: Visit the xAI Console, register an account, and create a new key.

Q: How do users in mainland China use this?

A: You need to configure a proxy. Set PROXY_HTTP and PROXY_HTTPS in your .env file.

Q: Where are the generated images saved?

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.

Q: How can I view the logs?

A: Logs are saved in ./logs/xai-studio.log by default. This can be customized via the LOG_FILE setting in .env.

Q: What image formats are supported?

A: The toolkit supports JPG and PNG formats.

License

This project is licensed under the MIT License.

Contributing

Issues and Pull Requests are welcome!

Contact

SK Studio

Links

About

A versatile xAI Grok image generation suite featuring a user-friendly GUI, a powerful CLI, and an automated scheduler with built-in email notifications.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages