Loading...
Loading...
Deterministic default-avatar generator per user.
npx skill4agent add picsart/gen-ai-skills dev-avatar-service1. user.photo_url → return as-is
2. cache.get(seed) → return stored AI avatar URL
3. gen-ai generate → store URL + return
4. initials on brand color → SVG fallback (no credits)
5. static /default.png → last resortgen-ai models info recraftv4
gen-ai pricing recraftv4
gen-ai generate -m recraftv4 -p "illustrated avatar, seed abc123" \
--aspect-ratio 1:1 --dry-run --debugMath.random()SEED="u_482c91"
# Pick palette + mood from the seed, not from RNG
HUE=$(printf "%s" "$SEED" | shasum | cut -c1-2) # 0-255 from hash
gen-ai generate -m recraftv4 \
-p "illustrated profile avatar, round frame, abstract humanoid silhouette, HSL hue ${HUE}, friendly neutral expression, flat vector, centered composition, studio background" \
--aspect-ratio 1:1 \
--negative-prompt "text, watermark, letters, realistic face, specific person" \
--save-to-drive --drive-folder avatars \
--json --no-input | jq -r '.url'const initials = name.split(' ').map(p => p[0]).slice(0, 2).join('').toUpperCase();
const hue = parseInt(sha1(seed).slice(0, 2), 16);
const svg = `<svg viewBox="0 0 64 64"><rect width="64" height="64" fill="hsl(${hue} 70% 45%)"/><text x="32" y="40" text-anchor="middle" font-size="28" fill="#fff" font-family="system-ui">${initials}</text></svg>`;/avatar/:seedgen-ai batch run avatars-backfill.json -c 4 -o ./avatars-out{
"defaults": {
"model": "recraftv4",
"aspectRatio": "1:1",
"negativePrompt": "text, watermark, letters, realistic face, specific person"
},
"jobs": [
{ "id": "u_482c91", "prompt": "illustrated profile avatar, round frame, flat vector, hue 42, friendly neutral, studio background" },
{ "id": "u_91ac3b", "prompt": "illustrated profile avatar, round frame, flat vector, hue 128, calm expression, studio background" },
{ "id": "u_7de119", "prompt": "illustrated profile avatar, round frame, flat vector, hue 201, warm smile, studio background" }
]
}./avatars-out/<user-id>.webpresults.json| Sub-task | Model | Why |
|---|---|---|
| Illustrated / vector / flat avatars | | Clean, consistent, cheap — ideal default |
| Photoreal portrait (synthetic, generic person) | | Best faces; use with generic descriptors only |
| Pixel-art avatars | | Lowest credits, stylistic control |
| Stylize an uploaded real photo (opt-in) | | Edit model preserves identity |
| Cheap draft / style exploration | | Lowest per-call cost |
| Identity-locked variants across sizes | | Same face across multiple avatars |
gen-ai models --mode imageV=2text, watermark, letters, realistic face of specific person--save-to-drive --drive-folder avatars/avatar/:random| Pitfall | Fix |
|---|---|
| Regenerated avatar looks different on every refresh | Non-deterministic prompt — hash the seed, derive attributes, no RNG/timestamps |
| Cache never invalidates after restyle | Version the prompt template ( |
| AI renders real-looking faces resembling celebrities | Add |
| Text or watermarks appear in the avatar | Add |
| Bot traffic burns credit budget | Rate-limit per IP; allow only authed users to hit the generator; fallback to initials for anons |
| Gen-ai 429s cause broken avatar UI | SVG initials fallback must be the last step in the chain |
| Batch backfill half-fails | |
| Different avatar style across the app | Commit the prompt template; never let callers pass raw prompts |
gen-ai whoami--debug| Task | Credits | Time |
|---|---|---|
| 1 avatar (Recraft V4, illustrated) | 1-2 | ~4-8s |
| 1 avatar (Flux 2 Pro, photoreal) | 3-5 | ~10-15s |
| 1 avatar (Gemini 3.1 Flash, draft) | 1 | ~3-5s |
| Initials SVG fallback | 0 | <1ms |
| Cache read (KV/Redis hit) | 0 | ~2-5ms |
| Batch of 500 at concurrency 4 | ~750-1000 | ~15-20 min |
gen-ai-use.md--json --no-inputjqgen-ai-batch.mdgen-ai-workflows.mddev-og-image-service