Skip to main content

Professional image generation library and OpenAI-compatible API for Google Flow

Project description

Flow Image Local API & Programmatic SDK (Unified)

Python Version License

Arabic Version: README-ar.md | Architecture Details: ARCHITECTURE-ar.md

This repository provides a unified local deployment of Google Flow image generation, exposed via an OpenAI-compatible HTTP API and a high-level programmatic Python SDK.


๐ŸŒŸ Key Features

  1. Guided Setup (/setup): A user-friendly web interface that opens automatically, detects Google Flow login states, and synchronizes tokens without manual copy-pasting.
  2. Integrated Token Updater: A background scheduling service that keeps session tokens alive across multiple profiles, supporting proxy isolation for each profile to prevent footprint leaks.
  3. In-Process Captcha Solver: Resolves reCAPTCHA challenges directly within the same Python process via Playwright/nodriver, eliminating separate bridge servers or port configurations.
  4. Programmatic SDK (FlowSDK): A clean, thread-safe context manager to embed Google Flow image generation directly into other Python applications.
  5. OpenAI-Compatible Endpoints: Seamlessly connects to any third-party AI UI client (e.g., Cherry Studio, Next Chat) using standard URL, API Key, and Model configurations.

๐Ÿš€ Quick Start

1. Installation

Double-click the installer:

install.bat

This will automatically create a .venv, install the package in editable mode, and download the Playwright Chromium browser.

2. Startup

Double-click the launcher:

start-flow-api.bat

This starts the API server on port 8787 and automatically opens the setup interface in your browser.

3. Complete Setup

  1. Log in to Google Flow on the browser window that opens.
  2. Wait for the setup page (http://127.0.0.1:8787/setup) to detect the active session.
  3. Copy the generated API URL, Key, and Model ID displayed on the screen.

๐Ÿ“ก API Reference

Connection Details

  • Base URL: http://127.0.0.1:8787/v1
  • Default API Key: flow-local-key

Endpoints

  • POST /v1/images/generations - Text-to-Image generation
  • POST /v1/images/edits - Image-to-Image generation (watercolor, sketch, etc.)
  • GET /v1/models - List available models and aspect ratios
  • GET /health - Health check status
  • GET /setup - Configuration wizard

๐Ÿ Programmatic Python SDK Usage

You can import and use the SDK directly inside your own Python projects:

import asyncio
from google_flow import FlowSDK

async def main():
    # Option 1: Direct Session Token Override
    async with FlowSDK(st_token="your-session-token", project_id="your-project-id") as sdk:
        image_path = await sdk.generate(
            prompt="A futuristic city in antigravity, neon lights, 4k",
            model="gemini-3.1-flash-image-landscape",
            output_path="output/direct_t2i.png"
        )
        print(f"Image saved to: {image_path}")

    # Option 2: Automatic Profile Selector (Querying local SQLite database)
    async with FlowSDK() as sdk:
        await sdk.select_profile("My_Google_Profile_Name")
        image_path = await sdk.generate(
            prompt="A majestic golden eagle flying over mountains",
            model="gemini-3.1-flash-image-square",
            output_path="output/profile_t2i.png"
        )
        print(f"Image saved to: {image_path}")

if __name__ == "__main__":
    asyncio.run(main())

๐Ÿ“ Repository Structure

flow-image-cli-local-api/
โ”œโ”€โ”€ google_flow/              # Unified core package
โ”‚   โ”œโ”€โ”€ api/               # FastAPI OpenAI web server & static dashboard
โ”‚   โ”œโ”€โ”€ captcha/           # In-process captcha provider integrations
โ”‚   โ”œโ”€โ”€ captcha_service/   # Integrated reCAPTCHA crawler (nodriver/playwright)
โ”‚   โ”œโ”€โ”€ token_updater/     # Automated session renewal daemon
โ”‚   โ”œโ”€โ”€ core/              # Programmatic SDK (FlowSDK) & API client
โ”‚   โ””โ”€โ”€ utils/             # Shared parsing, DB, and proxy utilities
โ”œโ”€โ”€ examples/              # Programmatic usage examples
โ”œโ”€โ”€ release-package/       # Scripts to build clean distribution zip packages
โ”œโ”€โ”€ install.bat            # One-click installer for Windows
โ”œโ”€โ”€ start-flow-api.bat     # One-click launcher for Windows
โ”œโ”€โ”€ API_USAGE.md           # API endpoints & cURL request examples
โ””โ”€โ”€ README.md

๐Ÿ“ฆ Building a Release

To share a clean distribution folder (without .git, .venv, or local output folders) with friends or clients:

  1. Run release-package\build-release-package.bat
  2. Share the generated zip file located at release-package\dist\flow-image-cli-local-api-v1.0.0.zip

๐Ÿ“ License

This project is licensed under the MIT License.

Project details


Download files

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

Source Distribution

google_flow-2.0.0.tar.gz (224.9 kB view details)

Uploaded Source

Built Distribution

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

google_flow-2.0.0-py3-none-any.whl (245.4 kB view details)

Uploaded Python 3

File details

Details for the file google_flow-2.0.0.tar.gz.

File metadata

  • Download URL: google_flow-2.0.0.tar.gz
  • Upload date:
  • Size: 224.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for google_flow-2.0.0.tar.gz
Algorithm Hash digest
SHA256 f9603e9c7aa3b9ae5851027f651d74dc907c91be1ce35252f31247d47b59cfbb
MD5 a3f1644e049b2762dd331c6a7168b79a
BLAKE2b-256 7664f5177f80d18bfc12cf50b53150f39e5ad88d9294e217c2b2e0e0efafb215

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_flow-2.0.0.tar.gz:

Publisher: publish.yml on 3mora2/google-flow

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

File details

Details for the file google_flow-2.0.0-py3-none-any.whl.

File metadata

  • Download URL: google_flow-2.0.0-py3-none-any.whl
  • Upload date:
  • Size: 245.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for google_flow-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 038dd9feecfb88197c91ca6f58ec29e3c581de219389a50b6c18328d0b15e18f
MD5 89fada2935d97101326543042e4fce59
BLAKE2b-256 6ac6a4ca12006692d93fbb2f0370f265662e6b3531b0d3c66b4f74d84316131f

See more details on using hashes here.

Provenance

The following attestation bundles were made for google_flow-2.0.0-py3-none-any.whl:

Publisher: publish.yml on 3mora2/google-flow

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