Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rabornkraken/browser2api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

12 Commits

Repository files navigation

browser2api

Turn browser UIs into programmatic image and video generation APIs.

Automates web UIs via Playwright + Chrome CDP -- no API keys or reverse engineering needed.

English | Zhong Wen


Supported Platforms

Jimeng (Ji Meng AI)

Image: Seedream 5.0 -- up to 4 images, 2K/4K
Video: Seedance 2.0 -- 5s/10s, up to 1080p

Google Flow

Image: Imagen 4, Nano Banana 2 -- up to 4 images
Video: Veo 3.1 -- Fast / Quality

Demo

Jimeng -- Image Generation with Seedream 5.0 * "A Shiba Inu eating ramen in a ramen shop, anime style"

jimeng_image_gen.mp4

Google Flow -- Image Generation with Nano Banana 2 * "Shiba eating ramen, anime style"

flow_image_gen.mp4

Google Flow -- Video Generation with Veo 3.1 Fast * "A cat walking through a garden"

flow_video_gen.mp4

Setup

python3 -m venv .venv
source .venv/bin/activate
pip install -e .
playwright install chromium

Requires Python 3.11+ and Google Chrome installed locally.

Quick Start

Jimeng -- Image Generation

python examples/generate.py "A cat in an astronaut suit standing on the moon"
python examples/generate.py "prompt" --model jimeng-5.0 --ratio 1:1 --resolution "Chao Qing 4K"

Models: jimeng-3.0 jimeng-3.1 jimeng-4.0 jimeng-4.1 jimeng-4.5 jimeng-4.6 jimeng-5.0

Jimeng -- Video Generation

python examples/generate_video.py "A cat walking through a garden"
python examples/generate_video.py "City night skyline" --ratio 16:9 --duration 10s --model video-3.0-fast

Models: seedance-2.0-fast seedance-2.0 video-3.5-pro video-3.0-pro video-3.0-fast video-3.0

Google Flow -- Image Generation

python examples/generate_flow.py "A sunset over mountains, digital art"
python examples/generate_flow.py "prompt" --model nano-banana-2 --orientation portrait --count 4

Models: nano-banana-pro nano-banana-2 imagen-4

Google Flow -- Video Generation

python examples/generate_flow_video.py "A cat walking through a garden"
python examples/generate_flow_video.py "prompt" --model veo-3.1-quality --orientation portrait --count 1

Models: veo-3.1-fast veo-3.1-quality veo-2-fast veo-2-quality

How It Works

  1. Launch -- Opens a real Chrome browser via CDP (not Playwright's bundled Chromium) for anti-detection
  2. Login -- Checks for a valid session. If not logged in, opens a headed browser for manual login. Session persists in ~/.browser2api/browser_data/
  3. Generate -- Navigates to the generation page, configures model/settings via UI automation, fills the prompt, clicks submit
  4. Capture -- Intercepts network responses and polls the DOM for generated content
  5. Download -- Downloads results locally

Programmatic Usage

import asyncio
from browser2api import BrowserManager, Platform
from browser2api.platforms.jimeng import JimengClient, JimengModel, JimengRatio

async def main():
bm = BrowserManager()
context, page = await bm.launch_for_login(Platform.JIMENG)

client = JimengClient(
page, context,
output_dir="./output",
model=JimengModel.JIMENG_5_0,
ratio=JimengRatio.RATIO_1_1,
)

result = await client.generate_images("Yi Zhi Mao ", count=4, timeout_seconds=120)
print(f"Status: {result.status.value}")
for img in result.images:
print(f" {img.local_path} ({img.width}x{img.height})")

await bm.close()

asyncio.run(main())
from browser2api.platforms.flow import FlowVideoClient, FlowVideoModel, FlowOrientation

async def generate_flow_video():
bm = BrowserManager()
context, page = await bm.launch_for_login(Platform.FLOW)

client = FlowVideoClient(
page, context,
output_dir="./output",
model=FlowVideoModel.VEO_3_1_FAST,
orientation=FlowOrientation.LANDSCAPE,
)

result = await client.generate_video("A cat walking through a garden", timeout_seconds=300)
print(f"Video: {result.video.local_path} ({result.video.size_bytes:,} bytes)")

await bm.close()

Notes

Jimeng (Ji Meng AI)

  • Member subscription recommended -- Required for video generation and higher daily image quotas.
  • Login -- First run opens a headed Chrome window for manual login. Session is saved and reused.
  • 4K resolution -- Requires membership. Free accounts are limited to 2K.
  • Video generation -- 30-120s depending on model/duration.

Google Flow

  • Google account required -- Must be logged in via the headed browser.
  • Regional availability -- May require a VPN in some regions.
  • Video generation -- 60-120+s depending on model.

Project Structure

src/browser2api/
+-- config.py # Shared constants (DATA_DIR)
+-- types.py # Platform, GenerationStatus, GeneratedImage, GeneratedVideo, etc.
+-- base.py # Abstract base classes
+-- browser.py # BrowserManager, ChromeLauncher, CDP connection
+-- platforms/
+-- jimeng/
| +-- client.py # JimengBaseClient, JimengClient, JimengVideoClient
| +-- enums.py # Models, ratios, resolutions, durations
| +-- selectors.py # CSS selectors and URL constants
| +-- login.py # Cookie-based login handler
+-- flow/
+-- client.py # FlowBaseClient, FlowClient, FlowVideoClient
+-- enums.py # Models, orientations, video models
+-- selectors.py # CSS selectors and URL constants
+-- login.py # Login handler

Disclaimer

This project automates browser interactions with third-party platforms. Use at your own risk.

  • Rate limits -- Avoid aggressive usage. Respect platform rate limits and credit quotas.
  • Session data -- Stored locally in ~/.browser2api/. Keep this directory secure.
  • For personal/research use only -- Do not use for commercial purposes or at scale without permission from the respective platforms.

About

Turn browser UIs into programmatic image and video generation APIs. Automates image generation tools such as Jimeng (Ji Meng AI) and Google Flow via Playwright + Chrome CDP -- no API keys or reverse engineering needed.

Topics

Resources

Readme

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages