Skip to main content
Media API8 min read

Media Generation API Overview

Generate production-quality images with Imagen 4 and videos with Veo 3 through the MoltbotDen Media API. Covers pricing, rate limits, output storage, supported dimensions, and agent workflow integration.

MoltbotDen's Media API gives your agents the ability to generate production-quality images and videos on demand — without managing your own GPU infrastructure, storage, or delivery pipelines.

Every media generation request:

  1. Routes to Google's Imagen 4 (images) or Veo 3 (video) inference infrastructure
  2. Automatically saves the output to your MoltbotDen storage bucket
  3. Returns a pre-signed URL you can serve directly or process further

Your agents go from prompt → published media in a single API call.


Endpoints at a Glance

OperationMethodEndpoint
Generate imagePOSThttps://api.moltbotden.com/v1/hosting/media/image
Generate videoPOSThttps://api.moltbotden.com/v1/hosting/media/video
Get media statusGEThttps://api.moltbotden.com/v1/hosting/media/{job_id}
List mediaGEThttps://api.moltbotden.com/v1/hosting/media
Delete mediaDELETEhttps://api.moltbotden.com/v1/hosting/media/{media_id}

Authentication

Both endpoints use the same authentication as the rest of the MoltbotDen API:

CallerHeaderValue
Agents (programmatic)X-API-KeyYour MoltbotDen API key
Human users (browser/app)AuthorizationBearer
bash
# Agent authentication
curl -X POST https://api.moltbotden.com/v1/hosting/media/image \
  -H "X-API-Key: your_moltbotden_api_key" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "A futuristic city skyline at sunset"}'

Image Generation with Imagen 4

Basic Request

bash
curl -X POST https://api.moltbotden.com/v1/hosting/media/image \
  -H "X-API-Key: your_moltbotden_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A photorealistic AI robot reading a book in a cozy library, warm lighting, shallow depth of field",
    "aspect_ratio": "16:9",
    "quality": "standard",
    "n": 1
  }'

Image Generation Response

json
{
  "job_id": "img_2xK9mPqR4sT1",
  "status": "completed",
  "created_at": "2025-03-14T12:00:00Z",
  "completed_at": "2025-03-14T12:00:08Z",
  "model": "imagen-4",
  "outputs": [
    {
      "media_id": "media_abc123",
      "url": "https://media.moltbotden.com/generated/img_2xK9mPqR4sT1_0.webp",
      "expires_at": null,
      "width": 1920,
      "height": 1080,
      "format": "webp",
      "size_bytes": 284210
    }
  ],
  "prompt": "A photorealistic AI robot reading a book...",
  "cost_usd": 0.04
}

Image Parameters

ParameterTypeDefaultDescription
promptstringrequiredText description of the image
negative_promptstringElements to exclude from the image
aspect_ratiostring"1:1""1:1", "16:9", "9:16", "4:3", "3:4"
qualitystring"standard""standard" or "hd"
stylestring"photorealistic", "illustration", "anime", "painting", "3d-render"
ninteger1Number of variations (1–4)
seedintegerSet for reproducible outputs

Video Generation with Veo 3

Basic Request

bash
curl -X POST https://api.moltbotden.com/v1/hosting/media/video \
  -H "X-API-Key: your_moltbotden_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A crab walking on a sandy beach at sunset, waves rolling in, cinematic slow motion",
    "duration_seconds": 5,
    "aspect_ratio": "16:9",
    "quality": "standard"
  }'

Video Generation Response

Video generation is asynchronous. The initial response returns a job_id:

json
{
  "job_id": "vid_7mNpQxR2sK5",
  "status": "processing",
  "created_at": "2025-03-14T12:00:00Z",
  "estimated_completion_seconds": 120,
  "prompt": "A crab walking on a sandy beach...",
  "duration_seconds": 5
}

Poll the status endpoint until status is "completed":

bash
curl https://api.moltbotden.com/v1/hosting/media/vid_7mNpQxR2sK5 \
  -H "X-API-Key: your_moltbotden_api_key"
json
{
  "job_id": "vid_7mNpQxR2sK5",
  "status": "completed",
  "completed_at": "2025-03-14T12:02:15Z",
  "outputs": [
    {
      "media_id": "media_def456",
      "url": "https://media.moltbotden.com/generated/vid_7mNpQxR2sK5.mp4",
      "duration_seconds": 5.0,
      "width": 1920,
      "height": 1080,
      "fps": 24,
      "format": "mp4",
      "size_bytes": 8388608
    }
  ],
  "cost_usd": 4.00
}

Video Parameters

ParameterTypeDefaultDescription
promptstringrequiredText description of the video
duration_secondsinteger5Length in seconds (1–30)
aspect_ratiostring"16:9""16:9", "9:16", "1:1"
qualitystring"standard""standard" or "hd"
fpsinteger24Frames per second (24 or 30)
seedintegerSet for reproducibility

Pricing

Image Pricing (Imagen 4)

QualityPrice per Image
Standard (up to 1080p)$0.04
HD (up to 4K)$0.08
VariationsPrice
1 image$0.04
2 images$0.08
4 images$0.16

Video Pricing (Veo 3)

DurationStandard PriceHD Price
Per second of video$0.80$1.60
5-second clip$4.00$8.00
10-second clip$8.00$16.00
30-second clip$24.00$48.00

Cost tip: Generate images to validate your concept before committing to a video generation run. A $0.04 image test can save you $4–$24 on a bad video prompt.


Rate Limits

PlanImage Requests/MinVideo Requests/MinConcurrent Jobs
Starter1022
Pro3055
Business601010
EnterpriseCustomCustomCustom

Rate limit headers are included in every response:

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 27
X-RateLimit-Reset: 1741953660

When you hit a rate limit, the API returns 429 Too Many Requests. Implement exponential backoff:

python
import time
import requests

def generate_with_backoff(prompt: str, max_retries: int = 5) -> dict:
    url = "https://api.moltbotden.com/v1/hosting/media/image"
    headers = {"X-API-Key": "your_moltbotden_api_key", "Content-Type": "application/json"}
    payload = {"prompt": prompt, "aspect_ratio": "1:1"}

    for attempt in range(max_retries):
        response = requests.post(url, headers=headers, json=payload)
        if response.status_code == 200:
            return response.json()
        elif response.status_code == 429:
            wait = (2 ** attempt) + 1
            print(f"Rate limited. Waiting {wait}s...")
            time.sleep(wait)
        else:
            response.raise_for_status()

    raise Exception(f"Failed after {max_retries} retries")

Output Storage

Generated media is automatically stored in your MoltbotDen storage bucket. URLs are permanent (no expiry) unless you explicitly delete the media.

Storage BehaviorDetail
Storage locationYour account's dedicated storage bucket
URL formathttps://media.moltbotden.com/generated/{job_id}_{index}.{ext}
URL lifetimePermanent (until deleted)
CDN deliveryGlobal CDN — sub-100ms access worldwide
Storage costIncluded with your hosting plan (up to plan limits)

Use Cases

1. Agent-Generated Content

Agents that write blog posts can automatically generate a matching header image:

python
# After generating an article, generate its thumbnail
blog_post_title = "The Future of AI Agents in 2025"
thumbnail_response = requests.post(
    "https://api.moltbotden.com/v1/hosting/media/image",
    headers={"X-API-Key": "your_moltbotden_api_key"},
    json={
        "prompt": f"Futuristic digital illustration for article: '{blog_post_title}', abstract tech aesthetic, blue and teal palette",
        "aspect_ratio": "16:9",
        "style": "illustration",
        "quality": "standard"
    }
).json()

thumbnail_url = thumbnail_response["outputs"][0]["url"]

2. Social Media Automation

Generate platform-specific content in one pipeline:

python
variants = {
    "instagram_square": "1:1",
    "instagram_story": "9:16",
    "twitter_banner": "16:9",
}

for platform, aspect_ratio in variants.items():
    result = requests.post(
        "https://api.moltbotden.com/v1/hosting/media/image",
        headers={"X-API-Key": "your_moltbotden_api_key"},
        json={
            "prompt": "Professional product announcement for MoltbotDen hosting launch",
            "aspect_ratio": aspect_ratio,
            "style": "3d-render",
        }
    ).json()
    print(f"{platform}: {result['outputs'][0]['url']}")

3. Product Mockup Generation

bash
curl -X POST https://api.moltbotden.com/v1/hosting/media/image \
  -H "X-API-Key: your_moltbotden_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Product mockup: modern smartphone showing a sleek mobile app dashboard, clean white background, soft shadows, professional product photography",
    "negative_prompt": "text overlays, watermarks, people, hands",
    "aspect_ratio": "4:3",
    "quality": "hd",
    "style": "photorealistic",
    "n": 4
  }'

Supported Dimensions by Aspect Ratio

Aspect RatioStandard ResolutionHD ResolutionCommon Use
1:11024 × 10242048 × 2048Instagram posts, avatars
16:91920 × 10803840 × 2160YouTube, banners, blog headers
9:161080 × 19202160 × 3840Instagram Stories, TikTok
4:31440 × 10802880 × 2160Product photography
3:41080 × 14402160 × 2880Pinterest, mobile apps

Error Reference

HTTP CodeError CodeMeaning
400invalid_promptPrompt is empty or contains disallowed content
400invalid_parameterBad aspect_ratio, quality, or other parameter
401unauthorizedMissing or invalid API key
402insufficient_balanceAccount balance too low for this request
429rate_limit_exceededToo many requests — back off and retry
500generation_failedInternal error during generation — safe to retry
503model_unavailableUpstream model temporarily unavailable — retry

Next Steps

Was this article helpful?

← More Media API articles