AIGate / Docs
Sign in / Register →

AIGate API

One unified API to generate AI images and videos, search a curated 1,000+ asset library, and manage credits. Built for creators, developers, and automation pipelines.

Base URL: https://cp.aigatecloud.com/api/v1  ·  All responses are JSON  ·  All requests require Bearer auth

Quick start (30 seconds)

bash
# 1. Get your API key from the dashboard
# 2. Search the library
curl "https://cp.aigatecloud.com/api/v1/search?q=luxury+lifestyle&type=image" \
  -H "Authorization: Bearer sk-aigate-YOUR_API_KEY"

# 3. Generate an image
curl -X POST "https://cp.aigatecloud.com/api/v1/generate/image" \
  -H "Authorization: Bearer sk-aigate-YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt":"cinematic sunset luxury","aspect_ratio":"9:16"}'

How it works

  1. Library first — every generate request searches 1,000+ pre-made assets first. If a match is found, it's returned instantly for the base credit cost.
  2. AI generate fallback — if no library match, AIGate generates via AI (costs more credits). You're always told which happened.
  3. BYOK routing (Scale tier) — connect your own provider keys. Requests route through your account; AIGate charges only the platform fee.

Authentication

All API calls require a Bearer token in the Authorization header. Get your token from the dashboard → API Keys.

http
Authorization: Bearer sk-aigate-xxxxxxxxxxxxxxxxxxxxxxxx
🔒 Get your API key: Register free — 100 credits included, no card required.
HeaderValueRequired
AuthorizationBearer sk-aigate-...required
Content-Typeapplication/jsonrequired for POST

Credit System

Every action costs credits. Credits never expire. Even library hits cost credits — you're paying for access, routing, and storage.

Library image 10 cr
Library video 100 cr
AI-gen image 10 cr
AI-gen video 100 cr
PackCredits~Images~VideosPrice
Free100~10~1$0
Starter1,200~120~12$9 one-time
Creator4,000~400~40$29 one-time
Pro12,000~1,200~120$79 one-time
Scale35,000~3,500~350$199 one-time
💡 The response.credits_balance field in every response shows your remaining balance in real time.

Errors & Rate Limits

HTTP Codeerror fieldMeaning
401missing_api_key / invalid_api_keyMissing or wrong token
402insufficient_creditsNot enough credits — buy a pack
403video_not_includedVideo requires Starter tier or above
429rate_limitToo many requests — back off and retry
503generation_unavailableAI provider unavailable — library only
json
{
  "error": "insufficient_credits",
  "credits_needed": 10,
  "credits_balance": 3,
  "hint": "Buy a credit pack at aigatecloud.com/#pricing"
}

POST /api/v1/generate/image

POST/api/v1/generate/image

Request body: prompt, topic, aspect_ratio, force_gen...

curl -X POST /api/v1/generate/image -H "Authorization: Bearer ..." -d '{"prompt":"..."}'
🔒 Sign up free to view Sign up free →

POST /api/v1/generate/video

POST/api/v1/generate/videoStarter+

Library-first video search, AI-gen fallback. 100 credits per request.

🔒 Starter plan or above Upgrade →

GET /api/v1/me

GET/api/v1/me

Returns tier, credit balance, and feature flags.

🔒 Sign up free to view Sign up free →

BYOK — Bring Your Own Key

🔑 BYOK is available on the Scale plan ($199). Connect your own OpenAI, Runway, Luma, Pika, Kling and 8 more provider keys.
ProviderType
openai_imagesimage
runwaymlvideo
lumavideo
klingvideo
🔑 Scale plan (T3) — includes BYOK Upgrade →

Webhooks

Webhooks available on Scale plan. Receive async notifications when generation completes.

🔑 Scale plan (T3) — includes BYOK Upgrade →

Smart Routing

Advanced routing available on Scale plan.

🔑 Scale plan (T3) — includes BYOK Upgrade →

SDKs & Code Examples

A reference implementation (PHP) is available on GitHub. Use it as a starting point for your integration.

⚠️ The GitHub example uses a placeholder token that doesn't work. Register free to get a real token with 100 credits.
bash
git clone https://github.com/melyx-id/aigatecloud-api-examples
cd api-examples
cp .env.example .env
# Add your API key to .env
php examples/generate-image.php

PHP (minimal)

<?php
// AIGate — minimal PHP client
// Get your API key: https://cp.aigatecloud.com

$apiKey = getenv('AIGATE_KEY') ?: 'sk-aigate-YOUR_API_KEY';

function aigate(string $method, string $path, array $body = []): array {
    global $apiKey;
    $ch = curl_init('https://cp.aigatecloud.com/api/v1' . $path);
    curl_setopt_array($ch, [
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_CUSTOMREQUEST  => $method,
        CURLOPT_HTTPHEADER     => ['Authorization: Bearer ' . $apiKey, 'Content-Type: application/json'],
        CURLOPT_POSTFIELDS     => $body ? json_encode($body) : null,
        CURLOPT_TIMEOUT        => 30,
    ]);
    $resp = curl_exec($ch); curl_close($ch);
    return json_decode($resp, true) ?? ['error' => 'parse_error'];
}

// Search library (free)
$results = aigate('GET', '/search?topic=lifestyle&type=image&limit=3');
foreach ($results['items'] ?? [] as $item) {
    echo $item['url'] . "\n";
}

// Generate image (10 credits)
$gen = aigate('POST', '/generate/image', [
    'prompt'       => 'luxury sunset apartment golden light',
    'aspect_ratio' => '9:16',
]);
echo $gen['asset']['url'] ?? $gen['error'] ?? 'error';
echo "\nCredits left: " . ($gen['credits_balance'] ?? '?') . "\n";

JavaScript (fetch)

const AIGATE_KEY = 'sk-aigate-YOUR_API_KEY';

async function aigate(path, body = null) {
  const res = await fetch('https://cp.aigatecloud.com/api/v1' + path, {
    method: body ? 'POST' : 'GET',
    headers: {
      'Authorization': 'Bearer ' + AIGATE_KEY,
      'Content-Type': 'application/json',
    },
    body: body ? JSON.stringify(body) : undefined,
  });
  return res.json();
}

// Search library
const results = await aigate('/search?topic=lifestyle&type=image&limit=5');
console.log(results.items);

// Generate image (10 credits)
const gen = await aigate('/generate/image', {
  prompt: 'luxury lifestyle cinematic',
  aspect_ratio: '9:16',
});
console.log(gen.asset?.url, 'credits left:', gen.credits_balance);

Python

import requests

AIGATE_KEY = "sk-aigate-YOUR_API_KEY"
BASE = "https://cp.aigatecloud.com/api/v1"
headers = {"Authorization": f"Bearer {AIGATE_KEY}"}

# Search
r = requests.get(f"{BASE}/search", params={"topic":"lifestyle","type":"image"}, headers=headers)
print(r.json()["items"][0]["url"])

# Generate image (10 credits)
r = requests.post(f"{BASE}/generate/image",
    json={"prompt": "luxury apartment golden sunset", "aspect_ratio": "9:16"},
    headers={**headers, "Content-Type": "application/json"})
data = r.json()
print(data["asset"]["url"], "| credits left:", data.get("credits_balance"))