Skip to Content
Media GatewayJimeng Provider

Jimeng Provider

The jimeng provider is a self-contained module at src/providers/jimeng/ with zero external MCP dependencies.

File Structure

src/providers/jimeng/ β”œβ”€β”€ index.ts Public API (bootstrap, auth, generation functions) β”œβ”€β”€ api.ts jimengPost() β€” sidecar-first, browser fallback β”œβ”€β”€ browser-client.ts Puppeteer-based browser client (fallback) β”œβ”€β”€ session-cache.ts Session persistence (~/.jimeng/session.json) β”œβ”€β”€ config.ts Constants, model maps, resolution maps β”œβ”€β”€ schemas.ts Zod validation schemas β”œβ”€β”€ upload.ts Image upload to ImageX CDN β”œβ”€β”€ tools/ β”‚ β”œβ”€β”€ image.ts Image generation handlers β”‚ β”œβ”€β”€ video.ts Video generation handlers β”‚ β”œβ”€β”€ credits.ts Credits management β”‚ β”œβ”€β”€ history.ts Generation status polling β”‚ └── assets.ts Asset listing └── utils/ β”œβ”€β”€ crypto.ts UUID, CRC32, MD5 sign β”œβ”€β”€ url.ts URL building utilities └── video.ts Video URL extraction

Authentication Flow

POST /auth/jimeng/qr POST /auth/login OAuth initiate + get QR QR code base64 qr_base64 QR image Scan QR with Douyin app OAuth code Exchange code for session Session cookies (365 days) Save cookies.json GET /auth/jimeng/qr/poll GET /auth/poll confirmed Login successful User Express Sidecar Douyin
POST /auth/jimeng/qr POST /auth/login OAuth initiate + get QR QR code base64 qr_base64 QR image Scan QR with Douyin app OAuth code Exchange code for session Session cookies (365 days) Save cookies.json GET /auth/jimeng/qr/poll GET /auth/poll confirmed Login successful User Express Sidecar Douyin
  1. POST /auth/jimeng/qr β€” Express checks if sidecar is up, calls sidecar /auth/login, returns QR as base64 PNG
  2. User scans QR with Douyin app
  3. GET /auth/jimeng/qr/poll β€” polls sidecar /auth/poll, returns confirmed when done
  4. Sidecar saves cookies to jimeng-sign-service/cookies.json (365-day validity)
  5. All subsequent API calls route through sidecar automatically

API Call Flow

Yes No/Fail jimengPost url, body Extract path from URL sidecarAvailable? POST sidecar:3457/proxy sign + a_bogus + msToken jimeng API Browser client Puppeteer page.evaluate Return response
Yes No/Fail jimengPost url, body Extract path from URL sidecarAvailable? POST sidecar:3457/proxy sign + a_bogus + msToken jimeng API Browser client Puppeteer page.evaluate Return response
Last updated on