GLM Design to Code

new opus

Vision model-powered design-to-code generator. Convert designs to working multi-framework code using GLM-5V-Turbo. Accepts images, text descriptions, HTML files, or URLs.

✏️

CREATE

Any input to working multi-file code. HTML/CSS, React 18, Flutter Web.

🔍

REVIEW

Compare original design with generated result. Score 1-10 with actionable feedback.

🔧

FIX

Apply review feedback to improve generated code automatically.

Input Types

Image

PNG, JPG, WebP, or GIF screenshot. The most common input — export from Figma, Sketch, or take a screenshot.

✏️

Text Description

Natural language description of the desired UI. Example: “Dark landing page with hero section and pricing cards”.

📄

HTML

Existing HTML file to convert or improve. Useful for migrating legacy pages to React or Flutter.

🔗

URL

Public URL — Playwright takes a screenshot automatically, then converts. Great for cloning existing pages.

Note

Input type is auto-detected from the argument: file extension for images/HTML, URL pattern for URLs, quoted text for descriptions.

Quick reference

FieldValue
Command/brewcode:glm-design-to-code
Arguments<input> [--framework html|react|flutter|custom] [--profile max|optimal|efficient]
Input typesImage, text description, HTML file, URL (auto-detected)
Modelopus
Vision modelGLM-5V-Turbo (Z.ai / OpenRouter)

Quick Start

# From an image
/brewcode:glm-design-to-code screenshot.png

# From a text description
/brewcode:glm-design-to-code "Dark landing page with hero section and pricing cards"

# From an existing HTML file
/brewcode:glm-design-to-code existing-page.html --framework react

# From a URL (auto-screenshots via Playwright)
/brewcode:glm-design-to-code https://example.com/landing

Pipeline Flow

  1. Parse input

    Detect type (image/text/HTML/URL), framework, profile, provider from arguments

  2. API key setup

    Check .env, validate against provider API, save on success

  3. Build payload

    Base64-encode image + load system prompt (profile) + framework context into JSON

  4. Send to GLM

    glm-5v-turbo via Z.ai or OpenRouter, retry on transient failures, 10min timeout

  5. Extract files

    Parse ===FILE:=== markers from response, create directory structure

  6. Build and verify

    npm run build (React), flutter build web (Flutter), or serve static HTML

  7. Review cycle

    Optional: screenshot result, compare with original, score, fix, iterate

Benchmark Results

Our research tested GLM-5V-Turbo across three frameworks with the same design mockup:

FrameworkScoreFilesBuildCost
HTML/CSS9.5/103N/A~$0.032
React 188.0/1019Vite 218ms~$0.035
Flutter Web9.0/10 (Claude)10flutter build web~$0.032

Tip

Average cost per design-to-code conversion: ~$0.03. Using the free glm-4.6v-flash model for development iterations costs nothing.

Design2Code Benchmark Comparison

GLM-5V-Turbo

94.8 Design2Code benchmark score. CogViT architecture, optimized for design-to-code conversion.

✏️

Claude Opus 4.6

77.3 Design2Code benchmark score. General-purpose multimodal model.

Warning

Design2Code scores are self-reported by Z.ai. No independent verification has been published as of April 2026. Treat as directional, not definitive.

Our Research Results

Score: 9.5/10 — 3 files generated, no build step needed.

  • Cost: ~$0.032 per conversion
  • Pixel-perfect colors, spacing, and typography
  • CSS custom properties for theming
  • Responsive layout out of the box

Score: 8.0/10 — 19 files generated, Vite build in 218ms.

  • Cost: ~$0.035 per conversion
  • Component decomposition into Header, Sidebar, Content
  • CSS Modules for scoped styling
  • Minor issues: some hardcoded values, missing hover states

Score: 9.0/10 — 10 files generated, flutter build web.

  • Cost: ~$0.032 per conversion
  • Clean widget hierarchy with theme constants
  • Auto-fix needed: Color(xFF...)Color(0xFF...)
  • Native-feel scrolling and layout

GLM Models

ModelVisionPrice (in/out per 1M)ContextBest For
glm-5v-turboImage+Video$1.20 / $4.00202KProduction quality
glm-4.6v-flashImageFREE131KDevelopment and testing
glm-4.6vImage+Video$0.30 / $0.90131KBudget production

Note

GLM-5V-Turbo uses CogViT architecture with 94.8 Design2Code benchmark score. Available via Z.ai direct API or OpenRouter.

Frameworks

Best score: 9.5/10 — Pure static output. No build step needed.

  • Semantic HTML5 with index.html entry point
  • CSS in separate files with custom properties
  • JS for interactive elements
  • Perfect for landing pages, dashboards, documentation

Score: 8.0/10 — Component-based architecture with CSS Modules.

  • JSX components in separate files
  • CSS Modules (.module.css) for styling
  • Vite build (218ms average)
  • App.jsx root component

Score: 9/10 — Dart widgets with theme system.

  • StatelessWidget components
  • Theme constants in lib/theme.dart
  • flutter build web compilation
  • Auto-fix: Color(xFF...) to Color(0xFF...)

Quality Profiles

Maximum

Pixel-perfect reproduction. Exact colors, spacing, typography. 13 quality requirements. ~32K output tokens.

Optimal

Good quality, balanced cost. Correct colors, proportions, layout. 8 requirements. ~16K tokens.

Efficient

Fast generation. Basic layout and colors. 4 requirements. ~8K tokens.

Providers

Recommended. Direct API access with system message caching (80% discount on repeated prompts).

  • Endpoint: https://api.z.ai/api/paas/v4/chat/completions
  • Auth: ZAI_API_KEY environment variable
  • All GLM models available including free tier

Alternative. Unified API with fallback routing.

  • Endpoint: https://openrouter.ai/api/v1/chat/completions
  • Auth: OPENROUTER_API_KEY environment variable
  • Model IDs prefixed with z-ai/ (e.g., z-ai/glm-5v-turbo)

Usage Examples

# Basic -- HTML/CSS output from screenshot
/brewcode:glm-design-to-code screenshot.png

# React with optimal quality
/brewcode:glm-design-to-code mockup.png --framework react --profile optimal

# Flutter via OpenRouter
/brewcode:glm-design-to-code design.png --framework flutter --provider openrouter
# Generate from a description
/brewcode:glm-design-to-code "Minimalist dashboard with sidebar and dark theme"

# React component from description
/brewcode:glm-design-to-code "Pricing page with 3 tiers" --framework react
# Convert legacy HTML to React
/brewcode:glm-design-to-code old-page.html --framework react

# Improve existing HTML with max quality
/brewcode:glm-design-to-code landing.html --profile max
# Clone a live page (Playwright auto-screenshot)
/brewcode:glm-design-to-code https://example.com/landing

# Clone as Flutter
/brewcode:glm-design-to-code https://stripe.com/pricing --framework flutter
# Compare original design with generated result
/brewcode:glm-design-to-code --review original.png result-screenshot.png
# Fix specific issues
/brewcode:glm-design-to-code --fix "sidebar too narrow, wrong green color"

# Fix from review file
/brewcode:glm-design-to-code --fix --review-file review.json

Options

FlagDefaultDescription
--frameworkhtmlTarget: html, react, flutter, custom
--profilemaxQuality: max, optimal, efficient
--providerzaiAPI: zai, openrouter
--modelautoOverride model ID
--output./d2c-outputOutput directory
--reviewEnter REVIEW mode (accepts 2 images)
--fixEnter FIX mode (accepts feedback text)
--review-filePath to review JSON for FIX mode

External Resources

📄

Z.ai Documentation

Official GLM-5V-Turbo API guide with vision request examples and model capabilities.

docs.z.ai/guides/vlm/glm-5v-turbo

🔗

OpenRouter Model Page

Model routing, pricing, and availability for GLM-5V-Turbo on OpenRouter.

openrouter.ai/z-ai/glm-5v-turbo

🔍

BenchLM Comparison

Side-by-side benchmark comparison of Claude Opus 4.6 vs GLM-5V-Turbo.

benchlm.ai/compare/claude-opus-4-6-vs-glm-5-turbo

The Decoder Article

Coverage of GLM-5V-Turbo’s design-to-code capabilities and benchmark results.

the-decoder.com

Research Methodology

Our benchmarks used a controlled methodology:

  • Same mockup across all frameworks (dark-theme documentation page)
  • Frozen prompts — identical prompts per quality profile
  • Fixed API params — temperature 0.2, top_p 0.85, max_tokens 32768
  • Dual evaluation — Claude Opus + GLM-4.6v-flash scoring independently
  • Playwright verification — automated screenshots at 1280x800 viewport