Skip to main content

WhatsApp Meta AI (wa-meta-ai)

PyPI CI Python 3.11+ MIT License FastAPI MCP Playwright

An open-source REST API, CLI, Python SDK, and MCP server for two-way interaction with Meta AI on WhatsApp Web — send text or reference-image prompts, auto-continue batched replies (15+ images), convert .webp → .png/.jpg, save clean images directly into your project folder, and clear chat history between series using your own WhatsApp account.

Disclaimer: Uses Playwright to automate official WhatsApp Web in Chromium. Use responsibly with built-in cooldown/jitter (WA_COOLDOWN_SEC, WA_JITTER_SEC) and preferably on a secondary WhatsApp number.


Why This Exists

  • WhatsApp Web does not index Meta AI generated images into "Media, links, and docs" (0 items) and offers no bulk-select/download UI.
  • Meta AI images are delivered inline as full-resolution (1600×1600 / 1920×1280 / 1184×2096) mmg.whatsapp.net/..._n.enc URLs with Content-Type: application/octet-stream — even though the payload is plain browser-decodable WebP.
  • wa-meta-ai automates the entire loop cleanly: prompt (with optional reference image) → settle detection → magic-byte sniffing → PNG/JPG conversion → clean deduplicated output.

Features

  • Two-Way Prompting (POST /generate): Send a prompt (plus optional ref_image) to Meta AI, wait for all generated images to settle, and download full-resolution files.
  • Reference Image (ref_image): Attach a local photo (Photos & videos) along with your prompt for consistent character/style variations.
  • Auto-Continue Batches (target_count): Automatically sends "continue" across batched Meta AI replies until target_count unique images are saved.
  • Batch Series Runner (POST /generate/batch): Run a list of scene prompts into series subfolders with optional clear_after: true.
  • Clean Output (output_dir): Save directly into any project folder with zero metadata clutter by default (WA_SAVE_MANIFEST=false) and SHA-256 filename deduplication.
  • Async Jobs & Webhooks: Pass ?async=true (or async_mode: true) for 202 Accepted + job_id, poll GET /jobs/{job_id}, or receive webhook_url POST callbacks.
  • OpenAI-Compatible Endpoint (POST /v1/images/generations): Drop-in backend for tools using OpenAI's images.generate() (url or b64_json).
  • Built-in MCP Server (wa-meta-ai mcp): Exposes auth_status, generate_images, generate_batch, extract_history, clear_chat, and list_media to AI agents (Antigravity, Claude Desktop, Cursor, etc.).
  • Self-Serve QR Dashboard (GET /): Live auto-refreshing QR setup page + Swagger docs at /docs.

Quick Start

1. Install

pip install wa-meta-ai

(All Python dependencies install automatically. Uses your existing Google Chrome, or auto-installs Chromium on first launch if needed.)

2. Start the Server

wa-meta-ai serve
  • Open http://127.0.0.1:8000/ (or the opened Chrome window) and scan the WhatsApp Web QR code once.
  • Your session persists in wa_profile/ (local ./wa_profile if present, otherwise ~/.wa-meta-ai/profile).
  • Interactive API docs: http://127.0.0.1:8000/docs

Usage Examples

REST API (POST /generate)

curl -X POST http://127.0.0.1:8000/generate \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Place this same person in a sunlit European cafe wearing a beige trench coat",
    "ref_image": "portrait.png",
    "output_dir": "./assets/cafe_series",
    "format": "png",
    "target_count": 2
  }'

CLI

wa-meta-ai generate "Generate 4 cyberpunk street scenes" --series cyberpunk --format png
wa-meta-ai generate "Neon rain portrait" --ref portrait.png --target-count 2
wa-meta-ai extract --chat "Meta AI" --scrolls 30 --format png
wa-meta-ai clear

OpenAI Python SDK Drop-In

from openai import OpenAI

client = OpenAI(base_url="http://127.0.0.1:8000/v1", api_key="unused")
res = client.images.generate(prompt="Cute futuristic robot", n=2)
print(res.data[0].url)

MCP Server (mcp_config.json)

Add to Antigravity / Claude Desktop / Cursor:

{
  "mcpServers": {
    "wa-meta-ai": {
      "command": "wa-meta-ai",
      "args": ["mcp"]
    }
  }
}

If wa-meta-ai serve is already running, wa-meta-ai mcp automatically proxies calls through it so Chrome's profile is never locked by two processes.

Optional: Docker (Headless Linux / VPS)

docker compose up --build -d
# Open http://127.0.0.1:8000/ to scan the WhatsApp QR code

API Endpoints

Method Endpoint Description
GET / Self-serve QR setup & status dashboard
GET /health Service & WhatsApp auth status
GET /auth/status READY | NEEDS_QR | DISCONNECTED
GET /auth/qr Live PNG screenshot of WhatsApp Web QR code
POST /generate Send prompt (+ optional ref_image), wait & download media
POST /generate/batch Run a list of prompts sequentially (clear_after supported)
GET /jobs / /jobs/{id} List or poll async generation jobs
POST /extract Scroll chat history upward & download inline media
POST /chat/clear Clear Meta AI chat between series
GET /media / /media/{file} List or fetch saved media
POST /v1/images/generations OpenAI-compatible image generation endpoint

Configuration (.env)

Copy .env.example to .env — loaded automatically by python-dotenv:

Variable Default Description
WA_HOST 127.0.0.1 Server bind host
WA_PORT 8000 Server port
WA_DOWNLOADS_DIR ~/Downloads/wa-meta-ai Default output folder when output_dir isn't passed
WA_SAVE_MANIFEST false Write manifest.json alongside images (false = images only)
WA_DEFAULT_FORMAT png Output image format (png, jpg, webp, original)
WA_COOLDOWN_SEC 2.0 Minimum delay between prompts
WA_JITTER_SEC 1.5 Random extra delay (0..WA_JITTER_SEC)
WA_META_AI_API_KEY "" Optional X-API-Key / Bearer token
WA_HEADLESS false Run Chromium headless

License

MIT

Metadata

Release files for wa-meta-ai 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for wa-meta-ai 0.1.1
File Size Uploaded Provenance Actions
wa_meta_ai-0.1.1.tar.gz 27.1 kB Without provenance Details for wa_meta_ai-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for wa-meta-ai 0.1.1
File Interpreter ABI Platform Actions
wa_meta_ai-0.1.1-py3-none-any.whl Python 3 none any Details for wa_meta_ai-0.1.1-py3-none-any.whl

Total release size: 52.1 kB

Release files / wa_meta_ai-0.1.1.tar.gz

Download URL wa_meta_ai-0.1.1.tar.gz
Size 27.1 kB
Tags Source
SHA-256 checksum
How to use checksums
c591bea97c2e734498b6f48815090e2a93a30b891f760c6d846a5eccdfda28fa
BLAKE2b-256 checksum
How to use checksums
8dd5bb86c7ef476a0c532b79aced415fd2a54d97a2f4172634ecdc44bdfd4935
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Release files / wa_meta_ai-0.1.1-py3-none-any.whl

Download URL wa_meta_ai-0.1.1-py3-none-any.whl
Size 25.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2ee5ae8273ccb6cd4056a7f203e0ef0e68b055c9d8166f9a5bcb4d06aad41136
BLAKE2b-256 checksum
How to use checksums
a66c3cb808e6730b6c54fd43b48309e5b1c9938c2c11f0d26ccabffaa14b50c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.9

Security for wa-meta-ai 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page