Skip to main content

sanzaru

sanzaru logo

PyPI version Python versions License CI PyPI downloads

A stateless, lightweight MCP server and agent CLI that wraps OpenAI's Sora Video API, Whisper, GPT-4o Audio, and TTS APIs via the OpenAI Python SDK.

Features

Video Generation (Sora)

  • Create videos with sora-2 or sora-2-pro models
  • Use reference images to guide generation
  • Remix and refine existing videos
  • Download variants (video, thumbnail, spritesheet)

Image Generation

  • Generate images with gpt-image-2 (recommended), gpt-image-1.5, or GPT-5
  • Edit and compose images with up to 16 inputs
  • Iterative refinement via Responses API
  • Automatic resizing for Sora compatibility

Audio Processing

  • Transcription: Whisper and GPT-4o models
  • Audio Chat: Interactive analysis with GPT-4o
  • Text-to-Speech: Multi-voice TTS generation
  • Processing: Format conversion, compression, file management

Podcast Generation

  • Multi-voice podcasts with up to 4 speakers and 10 TTS voices
  • Parallel segment generation with configurable pacing
  • MP3/WAV output with loudness normalization
  • ElevenLabs dialogue render mode: consecutive turns go out together so the model paces them

Simulated Podcasts

  • The conversation is generated, not read — N gpt-realtime agents actually talk to each other
  • Each host hears the others' audio, so they respond to delivery and timing, not to a transcript
  • Pre-production plans acts that record in parallel: a 30-minute episode in ~1 minute
  • Checkpointed per act and resumable; cost ceiling, dry-run projection, per-host stems
  • QC transcribes the rendered audio and judges it against the plan
  • See docs/audio/simulated-podcasts.md

Agent CLI

  • Every capability as a shell command: sanzaru video create, sanzaru image generate, ...
  • One-shot async workflows: create ... -o out.mp4 submits, polls, downloads in one command
  • JSON envelopes on stdout, progress on stderr, deterministic exit codes, resumable waits
  • Concurrent fan-out (multi-prompt image batches, multi-job wait) and arbitrary -o output paths
  • See docs/cli.md — bare sanzaru still runs the MCP server (nothing breaks)

Note: Content guardrails are enforced by OpenAI. This server does not run local moderation.

Requirements

  • Python 3.10+
  • OPENAI_API_KEY environment variable

Media storage (choose one):

# Recommended: unified path (auto-creates videos/, images/, audio/ subdirs)
SANZARU_MEDIA_PATH="/path/to/media"

# Or individual paths (legacy, still supported)
VIDEO_PATH="/path/to/videos"
IMAGE_PATH="/path/to/images"
AUDIO_PATH="/path/to/audio"

Features are auto-detected based on configured paths. Set only what you need.

Quick Start

  1. Clone the repository:

    git clone https://github.com/TJC-LP/sanzaru.git
    cd sanzaru
    
  2. Run the setup script:

    ./setup.sh
    

    The script will:

    • Prompt for your OpenAI API key
    • Create directories and .env configuration
    • Install dependencies with uv sync --all-extras --dev
  3. Start using:

    claude
    

That's it! Claude Code will automatically connect and you can start generating videos, images, and processing audio.

Or skip MCP entirely — the agent CLI

uv tool install sanzaru && export OPENAI_API_KEY=sk-...

# One command: submit Sora job → poll → download → print the file path
sanzaru video create "a tabby cat stretches on a windowsill" --seconds 4 -o ./cat.mp4 | jq -r .result.file.path

# Synchronous image generation (gpt-image-2), batch fan-out, JSONL output
sanzaru image generate "app icon" "hero banner" --quality high -o ./art/

sanzaru capabilities   # machine-readable: what's enabled here

JSON envelopes on stdout, progress on stderr, exit 4 = still-running-and-resumable. Full reference: docs/cli.md.

Installation

Claude Code Plugin (Recommended)

Install as a plugin — auto-configures the MCP server + includes prompting guidance:

/plugin marketplace add TJC-LP/sanzaru

Requires OPENAI_API_KEY and SANZARU_MEDIA_PATH environment variables to be set.

Quick Install

# All features
uv add "sanzaru[all]"

# Specific features
uv add "sanzaru[audio]"       # With audio support
uv add "sanzaru[elevenlabs]"  # ElevenLabs as a second TTS provider
uv add sanzaru                # Base (video + image only)
Alternative Installation Methods

From Source

git clone https://github.com/TJC-LP/sanzaru.git
cd sanzaru
uv sync --all-extras

Claude Desktop

Add to your claude_desktop_config.json:

{
  "mcpServers": {
    "sanzaru": {
      "command": "uvx",
      "args": ["sanzaru[all]"],
      "env": {
        "OPENAI_API_KEY": "your-api-key-here",
        "SANZARU_MEDIA_PATH": "/absolute/path/to/media"
      }
    }
  }
}

Or from source:

{
  "mcpServers": {
    "sanzaru": {
      "command": "uv",
      "args": ["run", "--directory", "/path/to/sanzaru", "sanzaru"]
    }
  }
}

Codex MCP

# Using uvx (from PyPI)
codex mcp add sanzaru \
  --env OPENAI_API_KEY="sk-..." \
  --env SANZARU_MEDIA_PATH="$HOME/sanzaru-media" \
  -- uvx "sanzaru[all]"

Manual Setup

uv venv
uv sync

# Set required environment variables
export OPENAI_API_KEY=sk-...
export SANZARU_MEDIA_PATH=~/sanzaru-media

# Run server (stdio for MCP clients)
uv run sanzaru

# Or HTTP mode (for remote access)
uv run sanzaru --transport http --port 8000

Available Tools

Category Tools Description
Video create_video, get_video_status, download_video, list_videos, list_local_videos, delete_video, remix_video Generate and manage Sora videos with optional reference images
Image generate_image, edit_image, create_image, get_image_status, download_image Generate with gpt-image-2 (default, sync) or GPT-5 (polling)
Reference list_reference_images, prepare_reference_image Manage and resize images for Sora compatibility
Audio transcribe_audio, chat_with_audio, create_audio, convert_audio, compress_audio, list_audio_files, get_latest_audio, transcribe_with_enhancement Transcription, analysis, TTS (OpenAI or ElevenLabs), and file management
Podcast generate_podcast Multi-voice podcast generation with parallel TTS and audio stitching; speakers may mix TTS providers
Simulated Podcast simulate_podcast Realtime agents converse from a rundown — parallel acts, checkpointing, cost ceiling, QC
Media view_media Interactive media player via MCP App protocol

Full API documentation: See docs/api-reference.md

Basic Workflows

Generate a Video

# Create video from text
video = create_video(
    prompt="A serene mountain landscape at sunrise",
    model="sora-2",
    seconds="8",
    size="1280x720"
)

# Poll for completion
status = get_video_status(video.id)

# Download when ready
download_video(video.id, filename="mountain_sunrise.mp4")

Generate with Reference Image

# 1. Generate reference image (gpt-image-2, synchronous)
generate_image(
    prompt="futuristic pilot in mech cockpit",
    size="1536x1024",
    filename="pilot.png"
)

# 2. Prepare for video (resize to Sora dimensions)
prepare_reference_image("pilot.png", "1280x720", resize_mode="crop")

# 3. Animate
video = create_video(
    prompt="The pilot looks up and smiles",
    size="1280x720",
    input_reference_filename="pilot_1280x720.png"
)

Audio Transcription

# List available audio files
files = list_audio_files(format="mp3")

# Transcribe
result = transcribe_audio("interview.mp3")

# Or analyze with GPT-4o
analysis = chat_with_audio(
    "meeting.mp3",
    user_prompt="Summarize key decisions and action items"
)

Generate a Podcast

generate_podcast(script={
    "title": "AI Weekly",
    "speakers": [
        {"id": "host", "name": "Alex", "voice": "nova"},
        {"id": "guest", "name": "Sam", "voice": "echo"}
    ],
    "segments": [
        {"speaker": "host", "text": "Welcome to AI Weekly!"},
        {"speaker": "guest", "text": "Thanks for having me."}
    ]
})

Simulate a Podcast (no script — the agents talk)

# 1. Plan it. Cheap, and the JSON is yours to edit.
sanzaru podcast rundown "why TTS providers drop sentence tails" \
  --acts 3 -m 6 --host "Avery" --host "Rory:cedar:You chased the bug." \
  -o rundown.json

# 2. See what it would cost. Records nothing.
sanzaru podcast simulate @rundown.json --dry-run

# 3. Record it. Acts run in parallel and each is checkpointed as it lands.
sanzaru podcast simulate @rundown.json --model gpt-realtime-2.1-mini \
  --max-cost 2.00 --stems -o ep1.mp3

# Interrupted? The run id is on stderr from the start.
sanzaru podcast simulate --resume 6f1a9c02

Documentation

Transport Modes

Mode Command Use Case
stdio (default) uv run sanzaru Claude Desktop, Claude Code, local MCP clients
HTTP uv run sanzaru --transport http Remote access, Databricks Apps, web clients

Storage Backends

Backend Config Use Case
Local (default) SANZARU_MEDIA_PATH=/path/to/media Development, local deployments
Databricks STORAGE_BACKEND=databricks Databricks Apps with Unity Catalog Volumes

The Databricks backend supports per-user storage isolation via the user_context module, enabling multi-tenant deployments where each user's media is stored under their own volume prefix.

See CLAUDE.md for full configuration details.

Performance

Fully asynchronous architecture with proven scalability:

  • ✅ 32+ concurrent operations verified
  • ✅ 8-10x speedup for parallel tasks
  • ✅ Non-blocking I/O with aiofiles + anyio
  • ✅ Python 3.14 free-threading ready

See docs/async-optimizations.md for technical details.

License

MIT

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanzaru-0.9.1.tar.gz (324.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sanzaru-0.9.1-py3-none-any.whl (351.6 kB view details)

Uploaded Python 3

File details

Details for the file sanzaru-0.9.1.tar.gz.

File metadata

  • Download URL: sanzaru-0.9.1.tar.gz
  • Upload date:
  • Size: 324.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sanzaru-0.9.1.tar.gz
Algorithm Hash digest
SHA256 55bd70a31da1e0ebc46b43d827875f788dcba4f11fc52db59ce9f6386e592070
MD5 045af3bc63307722d1a1059860670fd2
BLAKE2b-256 ef2512b519cf7d5078edd455942fe5125cc68df0300b5621e2e82ab905d6c69e

See more details on using hashes here.

Provenance

The following attestation bundles were made for sanzaru-0.9.1.tar.gz:

Publisher: publish-to-pypi.yml on TJC-LP/sanzaru

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file sanzaru-0.9.1-py3-none-any.whl.

File metadata

  • Download URL: sanzaru-0.9.1-py3-none-any.whl
  • Upload date:
  • Size: 351.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/7.0.0 CPython/3.13.14

File hashes

Hashes for sanzaru-0.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 540002b8ce04660c4bd14bb68ead98837b2eeebd0ec8af878a62f79fcd433f2e
MD5 4b43ce38f9515e0f63333982a89517bd
BLAKE2b-256 3eaa3bc004f490d4cd8b7a054175aa172881eda90979d661b9b451eb71cce7e0

See more details on using hashes here.

Provenance

The following attestation bundles were made for sanzaru-0.9.1-py3-none-any.whl:

Publisher: publish-to-pypi.yml on TJC-LP/sanzaru

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page