ALL MEMOS Download .docx

Feedback: Cache AI-generated assets on S3, never regenerate

Date: 2026-05-09

Source: Harnoor (explicit, durable rule)

Confidence: explicit · durable

Rule

ANY file generated by a paid AI service (ElevenLabs audio, gpt-image-1 images, gpt-5/Bedrock long-form text, Veo 3 video, future PDF/Word generators, etc.) is a one-shot expense. Once it's saved to S3, never pay to regenerate it.

How to apply (every generator must follow this pattern)


def gen_or_fetch(s3_key: str, generator_fn):
    """Generate-once, cache-on-S3 pattern. Use everywhere."""
    s3 = boto3.client("s3")
    try:
        s3.head_object(Bucket=BUCKET, Key=s3_key)
        return f"https://{BUCKET}.s3.{REGION}.amazonaws.com/{s3_key}"  # already exists, skip
    except s3.exceptions.ClientError as e:
        if e.response["Error"]["Code"] != "404":
            raise
    # Doesn't exist — generate, upload, return URL
    bytes_blob = generator_fn()
    s3.put_object(Bucket=BUCKET, Key=s3_key, Body=bytes_blob, ContentType=mime, ACL="public-read")
    return f"https://{BUCKET}.s3.{REGION}.amazonaws.com/{s3_key}"

S3 key naming convention to enable cache hits:

Asset types this covers

| Type | Service | Cost-per-gen | Cache-on-S3 mandate |

|---|---|---|---|

| Audio narration | ElevenLabs | $0.10–0.50/file | YES |

| Cartoon images | OpenAI gpt-image-1 | $0.10–0.20 | YES |

| AI video clips | Veo 3 / Sora | $0.10–1.00/sec | YES |

| Long-form text essays | Claude Sonnet/Opus | $0.01–0.10 | YES |

| PDFs (reports, advisor memos) | local Python (cheap) but still cache | $0 | YES (cheap to gen but slow to render) |

| Word/.docx | local Python | $0 | YES |

| Charts / SVGs | local | $0 | OPTIONAL |

When NOT to cache

Existing assets already following this rule

Existing generators that need patching to add this pattern

Provider preference order (image) — updated 2026-05-10 16:00

All three working. Pick by use-case:

| Tier | Provider | Best for | Cost/img | Quality | Status |

|---|---|---|---|---|---|

| A — Daily volume | OpenAI gpt-image-1 (medium) | Lambda nightly content, share cards, app heroes — auto-recharge handles cost | $0.04 | ★★★★ | ✅ live |

| B — Top quality | Google Imagen 4 (imagen-4.0-generate-001) | Marketing assets, Product Hunt launch, premium gallery / hero-of-hero shots | $0.04 | ★★★★★ | ✅ live (paid tier active 2026-05-10) |

| C — Bedrock fallback | AWS Bedrock Nova Canvas | If OpenAI/Gemini both unavailable | $0.04 | ★★★½ | ⚠️ LEGACY-inactive (1 console click to revive) |

Default routing: OpenAI for daily/volume (Tier A) since it has auto-recharge and works. Switch to Imagen 4 for any "this must be amazing" hero shot. Bedrock only as fallback.

Routing rule:

CLI wrappers:

Provider preference order (video) — updated 2026-05-10 16:00

| Tier | Provider | Best for | Cost/clip | Quality | Status |

|---|---|---|---|---|---|

| A — Default | Google Veo 3 (veo-3.0-generate-001, :predictLongRunning) | Hero clips for MIRROR / VISION / SUMMON / OMEN / ECHO daily content + marketing | ~$0.50–1.50 (4–8 sec) | ★★★★★ (with synced audio, cinematic) | ✅ live (paid tier active 2026-05-10) |

| B — Fallback | AWS Bedrock Nova Reel v1.1 | If Gemini quota exhausted | ~$0.75 | ★★★ (no audio, 1280x720) | ⚠️ LEGACY (1 console click to revive) |

Daily-content video budget: at Veo 3 ~$1/clip × 5 apps × 30 days = ~$150/mo for full Manifest+Mirror video pipeline. Decide per-app whether the cinematic upgrade is worth it.

CLI wrapper: F:/TITAN/scripts/gemini_video.py (built; needs model name confirmed as veo-3.0-generate-001 and method :predictLongRunning).

Smoke test results 2026-05-10 16:00


Imagen 4 (1024x1024)    → 1080 KB PNG saved ✅
Veo 3 (4 sec, 16:9)     → 1172 KB MP4 in ~30 sec ✅
Nano Banana             → returns no image (likely content-filter quirk on test prompt; secondary)
gemini-2.5-flash text   → free tier, working