AI Media StudioDocs
GitHubGet API key
API ReferenceCLIMCPSkills

API Documentation

Generate images and videos programmatically using our REST API. Authenticate with your API key and use the current model IDs from your workspace.

Quick Start
Get started with the API in minutes
1

Get your API Key

Go to Workspace Settings → API tab to create an API key.

2

Make your first request

Use the example below to generate your first image:

curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A beautiful sunset over mountains",
    "model": "openai/gpt-image-2",
    "n": 1
  }'
3

Discover current model IDs

Use the GET endpoints below to retrieve the currently available image and video models, including their default settings.

curl -X GET https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY"
curl -X GET https://app.ai-media-studio.com/api/v1/videos/generate \
  -H "Authorization: Bearer YOUR_API_KEY"
Authentication

All API requests require authentication. Include your API key in the request headers using one of these methods:

Bearer Token (Recommended)

Authorization: Bearer YOUR_API_KEY

X-API-Key Header

X-API-Key: YOUR_API_KEY

Security Note: Keep your API key secret. Never expose it in client-side code or public repositories. API keys are bound to workspaces, so all team members share the same credit pool.

Generate Images
POST /api/v1/images/generate

Request Parameters

ParameterTypeDefaultDescription
prompt
Required
string-The text description of the image you want to generate
modelstringopenai/gpt-image-2The AI model to use for generation
image_urlsstring[]-Reference image URLs for image-to-image editing (max 10). When provided, uses /edit endpoint.
ninteger1Number of images to generate (1-8)
sizestring1024x1024Image dimensions (e.g., 1024x1024, 1792x1024)
output_formatstringpngOutput format: png, jpeg, or webp
make_publicbooleanfalseMake the generated image publicly shareable
style_slugstring-Apply a style preset to enhance your prompt. Use the same style slugs available in the UI (e.g., anime-style, cyberpunk-style, watercolor-style)

Model-Specific Parameters

Fal.ai Models (fal-ai/nano-banana-2)
aspect_ratiostring-Aspect ratio: auto, 21:9, 16:9, 3:2, 4:3, 5:4, 1:1, 4:5, 3:4, 2:3, or 9:16. Takes precedence over size.
resolutionstring-Output resolution: 0.5K, 1K, 2K, or 4K
seedinteger-Seed for deterministic outputs
safety_tolerancestring6Safety tolerance level: "1" (strictest) to "6" (least strict)
limit_generationsbooleantrueLimit generations from each prompt round to one
enable_web_searchbooleanfalseAllow model web search for current generation
sync_modebooleanfalseReturn media as data URI and skip request history output
Fal Models (fal-ai/gpt-image-1.5)
qualitystringautoImage quality: auto, standard, or hd
backgroundstringautoBackground type: auto, transparent, or opaque
stylestring-Image style: natural or vivid

Response

{
  "success": true,
  "images": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "url": "https://cdn.ai-media-studio.com/workspaces/.../image.png",
      "status": "completed"
    }
  ],
  "credits_used": 20,
  "credits_remaining": 980
}

Public Sharing

Set make_public: true to make the generated image publicly shareable. The response will include a share_url that anyone can access without authentication.

Request:
curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A stunning landscape photo",
    "model": "openai/gpt-image-2",
    "make_public": true
  }'
Response with share_url:
{
  "success": true,
  "images": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "url": "https://cdn.ai-media-studio.com/workspaces/.../image.png",
      "share_url": "https://app.ai-media-studio.com/shared/media/550e8400-e29b-41d4-a716-446655440000",
      "status": "completed"
    }
  ],
  "credits_used": 20,
  "credits_remaining": 980
}

Image-to-Image (Edit Mode)

Provide image_urlsto edit or transform existing images. The API will automatically use the model's edit endpoint (e.g., openai/gpt-image-2/edit).

Single Image Edit:
curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Add a rainbow to the sky",
    "image_urls": ["https://example.com/your-image.jpg"],
    "model": "openai/gpt-image-2",
    "size": "1024x1024"
  }'
Multiple Reference Images (max 10):
curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Combine these images into a beautiful collage",
    "image_urls": [
      "https://example.com/image1.jpg",
      "https://example.com/image2.jpg"
    ],
    "model": "openai/gpt-image-2"
  }'

Note: When using image-to-image mode, the aspect_ratiodefaults to "auto" to preserve the original image proportions. You can override this by specifying a different aspect ratio.

Style Presets

Use style_slugto apply a style preset to your prompt - the same styles available when creating images in the UI. Your prompt will be automatically enhanced with the style's configuration to achieve the desired artistic effect.

Example with Style:
curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A samurai warrior standing on a cliff",
    "style_slug": "anime-style",
    "size": "1024x1536",
    "quality": "high"
  }'
Response (includes style_applied):
{
  "success": true,
  "images": [
    {
      "id": "550e8400-e29b-41d4-a716-446655440000",
      "url": "https://cdn.ai-media-studio.com/workspaces/.../image.png",
      "status": "completed"
    }
  ],
  "credits_used": 20,
  "credits_remaining": 980,
  "style_applied": "anime-style"
}

How to find style slugs:Go to the image creation page in the UI and browse the available styles. The style slug is typically the style name in lowercase with hyphens (e.g., "Anime Style" → anime-style). Styles work with both text-to-image and image-to-image requests.

Generate Videos
POST /api/v1/videos/generate

Request Parameters

ParameterTypeDefaultDescription
prompt
Required
string-The text description of the video you want to generate
modelstringfal-ai/veo3.1/fastThe exact video model ID to use. Call GET /api/v1/videos/generate to see what is currently available.
durationinteger-Requested duration in seconds. The API snaps to the closest supported duration for the selected model.
aspect_ratiostring-Output aspect ratio, for example 16:9 or 9:16
audiobooleanfalseEnable audio generation when supported by the selected model
make_publicbooleanfalseMake the generated video publicly shareable
image_urlstring-Required for image-to-video models
image_urlsstring[]-Required for reference-to-video models
first_frame_urlstring-Required for first-last-frame video models, or as the start image for supported reference workflows
last_frame_urlstring-Required for first-last-frame video models
extend_video_urlstring-Required for extend-video models
cfg_scalenumber-Classifier-free guidance scale when supported
negative_promptstring-Negative prompt when supported
resolutionstring-Resolution when supported by the selected model
enhance_promptboolean-Enable provider prompt enhancement when supported
auto_fixboolean-Enable provider auto-fix when supported
seedinteger-Seed for deterministic outputs when supported
safety_tolerancestring-Safety tolerance level: "1" (strictest) to "6" (least strict)

Examples

Text-to-Video:
curl -X POST https://app.ai-media-studio.com/api/v1/videos/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cinematic drone shot flying through snowy mountains at sunrise",
    "model": "fal-ai/veo3.1/fast",
    "duration": 4,
    "aspect_ratio": "16:9"
  }'
Image-to-Video:
curl -X POST https://app.ai-media-studio.com/api/v1/videos/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Turn this still image into a slow cinematic reveal",
    "model": "fal-ai/veo3.1/fast/image-to-video",
    "duration": 6,
    "image_url": "https://example.com/keyframe.png"
  }'

Response

{
  "success": true,
  "video": {
    "id": "550e8400-e29b-41d4-a716-446655440000",
    "url": "https://v3.fal.media/files/.../output.mp4",
    "status": "completed",
    "model": "fal-ai/veo3.1/fast",
    "duration": 4,
    "aspect_ratio": "16:9",
    "audio": false
  },
  "credits_used": 120,
  "credits_remaining": 880
}

Model discovery: Call GET /api/v1/videos/generate to retrieve the currently available video models, their credit costs, and default settings. The same pattern works for images with GET /api/v1/images/generate.

Available Models
Current image and video model IDs from your database
Loading models...
Available Styles
Style presets you can use with the style_slug parameter
Loading styles...
Code Examples
Example requests in different languages

Basic Request

curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A beautiful sunset over mountains",
    "model": "openai/gpt-image-2",
    "n": 1
  }'

With Style Preset

curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A samurai warrior standing on a cliff",
    "style_slug": "anime-style",
    "size": "1024x1536",
    "quality": "high"
  }'

With Model Options (Fal.ai)

curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A futuristic cityscape at night",
    "model": "openai/gpt-image-2",
    "n": 2,
    "size": "1536x1024",
    "quality": "high",
    "output_format": "jpeg",
    "make_public": true
  }'

OpenAI Model

curl -X POST https://app.ai-media-studio.com/api/v1/images/generate \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A cute robot holding a flower",
    "model": "fal-ai/gpt-image-1.5",
    "size": "1792x1024",
    "quality": "hd",
    "background": "transparent",
    "style": "vivid"
  }'
Error Codes
HTTP status codes and their meanings
Status CodeNameDescription
200
OKRequest successful
400
Bad RequestInvalid request parameters (e.g., missing prompt)
401
UnauthorizedInvalid or missing API key
402
Payment RequiredInsufficient credits in workspace
403
ForbiddenAPI key does not have required scope
429
Too Many RequestsRate limit exceeded
500
Internal Server ErrorServer error during generation
Rate Limits

API keys have configurable rate limits. The default rate limit is 60 requests per minute.

Rate limits are configured per API key. You can create multiple API keys with different rate limits for different use cases.

Tip: If you need higher rate limits, contact support or upgrade your subscription plan.

Generate images and videos with AI agents. liebhardt-io/aims-agent