Skip to content

AI Render (Kie.ai)

The AI Render feature allows users to generate photorealistic product mood shots from 3D screenshots using the Kie.ai API. It combines the original product photo (from AI Check API) with the 3D model screenshot (with logo) to produce high-quality renders.

The AI Render overlay is accessible from the Spranz Logo Modal (spranz-modal.magiceverse.online). It captures a screenshot of the current 3D product preview, fetches the original product photo, and sends both images to Kie.ai for AI-powered mood shot generation.

Frontend (React Modal) Backend (Express) External APIs
┌─────────────────────┐ ┌──────────────────────┐ ┌─────────────────────┐
│ MagicLogoModal.tsx │──▶│ /api/kie-ai/generate │──▶│ Kie.ai Upload │
│ - Prompt input │ │ - Upload original │ │ Kie.ai createTask │
│ - Polling for result │◀──│ /api/kie-ai/status │◀──│ Kie.ai recordInfo │
│ │ │ - Upload 3D shot │ │ │
│ │──▶│ /api/kie-ai/ │──▶│ AI Check API │
│ │ │ original-image │ │ (port 11010) │
└─────────────────────┘ └──────────────────────┘ └─────────────────────┘

The feature sends two images to each AI model:

  1. Original product photo — fetched from the AI Check API (aicheck-spranz.magiceverse.online, port 11010) via /api/products/image/:variantCode
  2. 3D screenshot with logo — captured from the 3D canvas in the modal

The prompt instructs the AI to use the original photo as the base, take the logo/design placement from the 3D model, and create a mood shot combining both.

ComponentPath
Backend API/mnt/data/magic_omniverse/magic_logo/spranz/backend/src/api/kieai.ts
Frontend Modal/mnt/data/magic_omniverse/magic_modal/spranz/src/components/MagicLogoModal.tsx
CSS Styles/mnt/data/magic_omniverse/magic_modal/spranz/src/styles/MagicLogoModal.css
Frontend Deploy/mnt/data/htdocs/spranz-modal/
ServiceDetails
BackendPort 4055, pm2 process spranz-logo-backend (id 15), runs as adminwayne
FrontendStatic build served by nginx at spranz-modal.magiceverse.online
AI Check APIPort 11010, pm2 process magic-agent-spranz, provides original product images
Kie.ai API Basehttps://api.kie.ai/api/v1/jobs
Kie.ai Uploadhttps://kieai.redpandaai.co/api/file-base64-upload

Generates a photorealistic mood shot from the 3D screenshot and original product photo.

ParameterValue
Model IDnano-banana-2
Input fieldimage_input (array, up to 8 images)
Aspect ratios1:1 (fixed)
Resolution1K (default)
Output formatpng

API payload example:

\{
"model": "nano-banana-2",
"input": \{
"prompt": "The first image is the original product photo...",
"image_input": ["https://tempfile.redpandaai.co/original.png", "https://tempfile.redpandaai.co/3d-screenshot.png"],
"aspect_ratio": "1:1",
"resolution": "1K",
"output_format": "png"
\}
\}

Creates an AI render task. Uploads image(s) to Kie.ai file hosting, then calls createTask.

Request body:

{
"base64Data": "iVBORw0KGgo...",
"originalBase64Data": "iVBORw0KGgo...",
"prompt": "The first image is the original product photo...",
"model": "nano-banana-2",
"aspect_ratio": "1:1",
"resolution": "1K",
"quality": "basic"
}
FieldRequiredDescription
base64DataYesBase64-encoded PNG of the 3D screenshot with logo
originalBase64DataNoBase64-encoded original product photo (from AI Check API)
promptYesText prompt describing desired output
modelNoModel ID (default: nano-banana-2)
aspect_ratioNoAspect ratio (uses model default if omitted)
resolutionNo1K, 2K, or 4K (only for nano-banana models)
qualityNobasic or high (only for seedream model)

When originalBase64Data is provided, both images are uploaded to Kie.ai and sent as an array: [originalUrl, screenshotUrl]. The original image is first so the AI uses it as the primary reference.

Response:

{
"success": true,
"data": {
"taskId": "d98d6cba9ef8b49abad2f96dd7663fb7",
"model": "nano-banana-2"
}
}

Polls Kie.ai recordInfo for task status and result URLs.

Response:

{
"success": true,
"data": {
"state": "success",
"resultUrls": ["https://cdn.kie.ai/result/...png"],
"failMsg": null,
"raw": { }
}
}
StateMeaning
processing / waitingTask is being processed
success / completedResult ready, check resultUrls
fail / failed / errorGeneration failed, check failMsg

GET /api/kie-ai/original-image/:variantCode

Section titled “GET /api/kie-ai/original-image/:variantCode”

Proxies the AI Check API (port 11010) to fetch the original product photo for a given variant code.

Response:

{
"success": true,
"base64": "/9j/4AAQ...",
"mediaType": "image/jpeg",
"variant_code": "376-00.005"
}

The AI Check API looks for images in /mnt/data/pim_data/spranz/ with these filename candidates:

  • {variantCode}_Front.jpg
  • {variantCode}.jpg
  • {variantCode}_Front.png

Returns product material and name from the product_physical_characteristics table in the magic_b2b_brinxx database. Used to auto-generate AI prompts with material context.


All models require publicly accessible image URLs. The flow is:

  1. Frontend captures 3D canvas as base64 PNG
  2. Frontend fetches original product photo via /api/kie-ai/original-image/:variantCode
  3. Backend receives both base64 images and uploads each to Kie.ai file hosting:
    • Endpoint: https://kieai.redpandaai.co/api/file-base64-upload
    • Upload path: magic-everse/screenshots
    • Files auto-delete after 3 days
  4. Kie.ai returns downloadUrl for each image
  5. Both URLs are passed as an array in image_input or image_urls in the createTask call

When the original product image is available, the default prompt is:

The first image is the original product photo, made of {material}. The second image shows the same product as a 3D model with a branded logo/design printed on it. Create a high-end mood shot: take the logo/design placement from the 3D model and apply it to the original product photo. Place the product on a stylish modern office desk with warm wood tints. Clean, elegant minimalist setting with soft natural lighting, shallow depth of field. Photorealistic commercial photography.

When no original image is available (fallback):

High-end luxurious mood shot of this product, made of {material} with branded logo, placed on a stylish modern office desk with warm wood tints. Clean, elegant minimalist setting with soft natural lighting, shallow depth of field, premium lifestyle atmosphere. Photorealistic commercial photography.


The overlay shows:

  • Original Photo (if available) — from AI Check API
  • 3D + Logo — screenshot from 3D canvas
  • Arrow
  • Result — AI-generated mood shot

The mood shot generation goes through these states:

ready → generating → success
→ error
  • Poll every 3 seconds, 45-second progress timer
  • Polling stops on success, fail, or overlay close
ClassPurpose
.ai-render-overlayFull-screen backdrop
.ai-render-modalModal container
.ai-render-imagesImage display container
.ai-render-image-boxIndividual image card
.ai-render-result-boxResult image container
.ai-render-prompt-areaPrompt input area
.ai-render-footerFooter action buttons

Terminal window
cd /mnt/data/magic_omniverse/magic_logo/spranz/backend
# Compile TypeScript to dist/
npx tsc
# Restart pm2 (runs as adminwayne)
sudo -u adminwayne pm2 restart spranz-logo-backend
Terminal window
cd /mnt/data/magic_omniverse/magic_modal/spranz
# Build Vite app
npm run build
# Deploy to web root
cp -r dist/* /mnt/data/htdocs/spranz-modal/

VariableDescription
KIE_AI_API_KEYKie.ai API key (set in pm2 ecosystem config)

IssueCauseFix
All models return same resultBackend not compiled after TS changesRun npx tsc then restart pm2
No original image shownAI Check API down or no image for SKUCheck pm2 logs magic-agent-spranz and /mnt/data/pim_data/spranz/
Credits insufficientKie.ai account balance emptyTop up credits at kie.ai dashboard
No taskId returnedVarious API errorsCheck backend logs: sudo -u adminwayne pm2 logs spranz-logo-backend
Changes not visible in browserFrontend not rebuilt/deployedRun npm run build and copy dist/ to htdocs
Seedream returns error on aspect ratioInvalid ratio for seedream modelOnly use ratios from the supported list (no auto)