Cursorhero Docs

AI Features Overview

How chat, image, and video generation work, and which provider powers which route.

Two AI surfaces

This project exposes AI in two different ways that ship independently:

1. Cursor-generator (main product)

The cursor-generator pipeline uses Kie.ai (GPT Image 2 at 1K) for text-to-image and image-to-image generation. The route is /api/cursor-generator/generate-all (and /generate-preview). See lib/cursor-generator/generator.ts and lib/ai-providers/kie.ts. Background removal is performed client-side with @imgly/background-removal (no server token needed).

2. Demo routes (optional)

The /api/chat, /api/image/generate, and /api/video/* routes power the /demo marketing pages. They use Volcano Engine (Doubao) and are independent from the cursor-generator pipeline. Skip them in production if you are not shipping the demo pages.

SurfaceProviderModelEndpoint
Cursor-generator (image)Kie.aiGPT Image 2 (1K)/api/cursor-generator/generate-all
Demo chatVolcano Enginedoubao-1-5-thinking-pro-250415/api/chat/stream
Demo imageVolcano Enginedoubao-seededit-3-0-i2i-250628/api/image/generate
Demo videoVolcano Enginedoubao-seedance-1-0-pro-250528/api/video/generate

Configuration

# Cursor-generator (required for the main product)
KIE_API_KEY="your-kie-api-key"
KIE_API_BASE_URL="https://api.kie.ai"
KIE_IMAGE_MODEL="gpt-image-2-5-flare-image-to-image"
KIE_TEXT_MODEL="gpt-image-2-5-flare-text-to-image"
KIE_IMAGE_RESOLUTION="1K"

# Demo routes only — skip if not shipping /demo
# VOLCANO_ENGINE_API_KEY="your-volcano-engine-api-key"
# VOLCANO_ENGINE_API_URL="https://ark.cn-beijing.volces.com/api/v3"

Architecture

lib/
├── ai-providers/
│   └── kie.ts                    # cursor-generator image gen
├── cursor-generator/
│   ├── generator.ts              # main pipeline
│   └── image-processor.ts        # client-side bg removal
└── volcano-engine/               # demo routes only
    ├── config.ts
    ├── chat.ts
    ├── image.ts
    └── video.ts

Credit Integration

Every AI operation follows the deduct-first, refund-on-failure pattern:

  1. Check if user has enough credits
  2. Deduct credits from balance
  3. Call AI API
  4. If API fails, refund credits automatically

Replacing the cursor-generator provider

To swap Kie.ai for another image provider:

  1. Replace the call site in lib/cursor-generator/generator.ts
  2. Update lib/ai-providers/ (keep the same generateImage(prompt, imageUrl) signature)
  3. Update environment variables in lib/env.ts and .env.example
  4. Keep the same credit deduction pattern

On this page