AIGate

Orchestrator API

FastAPI service at https://api.aigatecloud.com. OpenAI & Claude compatible drop-in, plus a one-call Idea→Post pipeline with intent detection, multi-step DAG, retry, and fallback chains.

Overview

The orchestrator sits between your client and providers (Groq for text, Pollinations Flux for image). You send a high-level intent — "viral", "quality", "cost" — and AIGate handles model selection, prompt shaping, retries, and image caching.

Authentication

All /v1/* endpoints require an API key as a Bearer token. Generate keys in your dashboard at cp.aigatecloud.com → API Keys.

Authorization: Bearer sk-aigate-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

/demo/* endpoints accept anonymous calls but are rate-limited to 5 requests / hour / IP.

Mode selector

Pass mode instead of a model name. AIGate routes to the right Groq model (and applies fallback chains) based on the rule engine.

ModeStrategyPrimary modelUse for
speedFastllama-3.1-8b-instantQuick replies, batch, live chat
costCheapllama-3.1-8b-instantHigh-volume content, internal tools
qualityBestllama-3.3-70b-versatileHero copy, ads, public-facing
viralMulti-step DAGllama-3.3-70b-versatileSocial posts, full pipeline

Errors & credits

Credit costs (visible in credits_used field on the response):

POST /v1/chat/completions — OpenAI compatible

POST/v1/chat/completions

Drop-in replacement for OpenAI Chat Completions. Pass a mode name as model.

curl https://api.aigatecloud.com/v1/chat/completions \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "quality",
    "messages": [{"role": "user", "content": "Write a cold-email hook for fintech CFOs"}]
  }'
import openai
client = openai.OpenAI(
    api_key="sk-aigate-...",
    base_url="https://api.aigatecloud.com/v1",
)
resp = client.chat.completions.create(
    model="quality",                 # or speed / cost / viral
    messages=[{"role": "user", "content": "Write a cold-email hook"}],
)
print(resp.choices[0].message.content)
const r = await fetch('https://api.aigatecloud.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${AIGATE_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    model: 'quality',
    messages: [{ role: 'user', content: 'Write a cold-email hook' }],
  }),
});
const data = await r.json();
console.log(data.choices[0].message.content);

POST /v1/messages — Claude compatible

POST/v1/messages

Anthropic Messages API shape. Internally translates to chat.completions.

import anthropic
client = anthropic.Anthropic(
    api_key="sk-aigate-...",
    base_url="https://api.aigatecloud.com",
)
msg = client.messages.create(
    model="quality",
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
)
print(msg.content[0].text)

POST /v1/generate-post — Idea → Content

POST/v1/generate-post

Native one-call pipeline. Detects intent, runs caption + hashtags + (optional) image in parallel via the DAG planner.

Request body

FieldTypeDefaultDescription
ideastringRequired. ≤ 200 chars.
modestringviralspeed / cost / quality / viral
langstringenBCP-47 tag — caption is generated in this language
imagebooleanfalseRender an image via Pollinations Flux
include_hashtagsbooleantrueGenerate the hashtags task

Response (200)

{
  "id":              "post_a92bb3f0c8c14a9e",
  "mode":            "viral",
  "intent":          "ads",
  "caption":         "Discover serenity in every detail. Elevate...",
  "caption_model":   "llama-3.3-70b-versatile",
  "hashtags":        ["luxuryfengshui", "highendinterior", ...],
  "hashtags_model":  "llama-3.3-70b-versatile",
  "image_url":       "https://api.aigatecloud.com/img/{sha1}.jpg",
  "image_provider":  "pollinations.flux+cdn",
  "credits_used":    15
}

Example

curl https://api.aigatecloud.com/v1/generate-post \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "idea": "selling luxury fengshui homes",
    "mode": "viral",
    "image": true
  }'
Image cache: the second call with the same idea+mode returns the cached image instantly. Cache key is sha1(mode + ":" + idea.lower()).

GET /v1/models

GET/v1/models

List available modes and their human-readable labels.

curl https://api.aigatecloud.com/v1/models -H "Authorization: Bearer $AIGATE_KEY"
{
  "data": [
    {"id": "speed",   "label": "⚡ Speed",   "use": "fast"},
    {"id": "cost",    "label": "💰 Save Cost", "use": "cheap"},
    {"id": "quality", "label": "⭐ Quality", "use": "best"},
    {"id": "viral",   "label": "🔥 Viral",   "use": "multi_step"}
  ]
}

GET /img/{key}.jpg

GET/img/{sha1}.jpg

Public CDN for cached image renders. Returned by /v1/generate-post when image:true. Cache-Control: public, max-age=2592000, immutable. No auth.

POST /v1/upload — reference image upload

POST/v1/upload

multipart/form-data, field name file. Accepts jpg/png/webp up to 8 MB. Returns a stable CDN URL on api.aigatecloud.com/img/ that you can pass as reference_url or image_url to other endpoints.

curl https://api.aigatecloud.com/v1/upload \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -F "[email protected]"

# → {"key":"upload-abc...", "url":"https://api.aigatecloud.com/img/upload-abc....jpg",
#    "bytes":40208, "content_type":"image/jpeg"}

POST /v1/image-transform — text2img + img2img

POST/v1/image-transform

Generate a new image from a prompt, or transform a previously uploaded one. Cached by sha1(mode + reference + prompt).

Request body

FieldTypeDefaultDescription
promptstringRequired. ≤ 800 chars.
reference_urlstringnullOptional. Must be a /v1/upload URL — switches to img2img.
width / heightint1024Output dimensions.
modestringqualityRouting mode (currently only affects logging).

Cost: 10 credits per image. Cache hit returns instantly.

POST /v1/enhance/lowlight — brighten dark photo

POST/v1/enhance/lowlight

Recover an underexposed photo. Identity-preserving. Three intensity levels.

FieldTypeDefaultDescription
image_urlstringRequired. Must be a /v1/upload URL.
modestringbalancedlight / balanced / extreme
face_prioritybooltrueAdd "preserve natural skin texture" to prompt.
noise_reductionstringautoauto / off / high
output_resolutionint1024Max edge in px (clamped 512-2048).
curl https://api.aigatecloud.com/v1/enhance/lowlight \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://api.aigatecloud.com/img/upload-abc.jpg",
    "mode": "balanced"
  }'

POST /v1/effects/light-trails — long-exposure night photo

POST/v1/effects/light-trails

Apply long-exposure light streaks to a night scene. Works in two modes:

  • Transform (with image_url): apply trails to your photo, motion blur on lights only.
  • Generate (with prompt only): synthesize a night scene with light trails from scratch.
FieldTypeDefaultDescription
image_urlstringnullOptional. Provide for transform; omit for generate.
promptstringnullRequired when image_url is omitted. Describes the scene.
intensitystringmediumlow / medium / high
convert_to_nightboolfalseIf true and image is daytime: convert to night first, then add trails.
output_resolutionint1024Max edge in px (clamped 512-2048).
# Generate from prompt
curl https://api.aigatecloud.com/v1/effects/light-trails \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Tokyo Shibuya crosswalk at night",
    "intensity": "high"
  }'

# Transform a daytime photo
curl https://api.aigatecloud.com/v1/effects/light-trails \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://api.aigatecloud.com/img/upload-abc.jpg",
    "intensity": "medium",
    "convert_to_night": true
  }'

POST /v1/effects/cinematic-rain — rain + neon + trails

POST/v1/effects/cinematic-rain

Combo effect: rainy night + light trails + neon reflections. Three sub-presets pick the right balance for the look you want. Subjects stay sharp; motion blur applied only to lights.

FieldTypeDefaultDescription
image_urlstringnullOptional. /v1/upload URL for transform mode.
promptstringnullRequired when no image. Describes the scene.
presetstringcinematicrealistic · cinematic · cyberpunk
rain_intensitystringper presetOverride: light / medium / heavy
neon_strengthstringper presetOverride: subtle / balanced / strong
trail_lengthstringper presetOverride: short / medium / long
wet_reflectionbooltrueStrong reflections of neon + lights on wet ground.
convert_to_nightboolfalseIf transforming a daytime photo: night-ify first.
preserve_subjectbooltrueAdds guards: keep humans sharp, controlled neon, accurate reflections.
output_resolutionint1024Max edge in px (clamped 512-2048).

Preset cheat sheet

presetrainneontrailsuse for
realisticlightsubtleshortDocumentary / discreet feel
cinematicmediumbalancedmediumDefault movie-grade. Best for ads/social.
cyberpunkheavystronglongViral neon city, TikTok-ready.
# Generate from prompt
curl https://api.aigatecloud.com/v1/effects/cinematic-rain \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Tokyo Shinjuku alley",
    "preset": "cinematic"
  }'

# Transform a photo (any time of day → cinematic rainy night)
curl https://api.aigatecloud.com/v1/effects/cinematic-rain \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://api.aigatecloud.com/img/upload-abc.jpg",
    "preset": "cyberpunk",
    "convert_to_night": true
  }'

POST /v1/edit/remove — remove people / objects

POST/v1/edit/remove

Inpaint-style cleanup. Reconstructs background where unwanted elements were removed. Subject stays sharp. Works best on simple backgrounds; complex scenes get extra geometry/lighting guard prompts.

FieldTypeDefaultDescription
image_urlstringRequired. /v1/upload URL.
targetstringpeoplepeople · objects · both
background_complexitystringsimplesimple · complex (extra guards for architecture/perspective)
reconstruction_strengthstringmediumlight · medium · strong
preserve_subjectbooltrueKeep main subject sharp + identity-locked.
mask_urlstringnullOptional B&W mask (white = remove). For pro use.

POST /v1/edit/remove-background — transparent PNG

POST/v1/edit/remove-background

Cuts the subject and returns a PNG with full alpha channel. Self-hosted rembg / U2Net. Hair detail preserved. Output served at /img/{key}.png.

FieldTypeDefaultDescription
image_urlstringRequired. /v1/upload URL.
edge_refinementstringhighlow / medium / high (informational; engine fixed)
preserve_hairbooltrueUse the alpha-matting branch for fine hair strands.
output_formatstringpngAlways PNG with alpha.
output_resolutionint2048Max edge in px.
curl https://api.aigatecloud.com/v1/edit/remove-background \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{"image_url":"https://api.aigatecloud.com/img/upload-abc.jpg"}'
503 response: If you see "engine not yet provisioned", the rembg model is still being installed on the inference node. Retry after a minute.

POST /v1/portrait/studio — 5 studio styles

POST/v1/portrait/studio

Transform a casual portrait into a polished studio shot. Identity-locked.

FieldTypeDefaultDescription
image_urlstringRequired. /v1/upload URL.
stylestringcleanclean · artistic · corporate · moody · color_gel
identity_lockbooltrueAdd identity-preserve guard.
retouchstringnaturalminimal · natural · strong

Style cheat sheet

stylelookbest for
cleanSoft even studio lighting, neutral backgroundProfile photos, branding
corporateFormal attire, sharp confident lookLinkedIn, CV, business
artisticDramatic shadows, fine art moodEditorial, portfolios
moodyLow-key, dark backgroundBranding, music covers
color_gelDual-tone gel lightingModern social, ads

POST /v1/edit/face-restore — GFPGAN / CodeFormer (Replicate BYOK)

POST/v1/edit/face-restore

Restore faces in old photos, low-res images, or AI-generated portraits. With Replicate BYOK: routes to tencentarc/gfpgan or sczhou/codeformer. Without BYOK: falls back to Pollinations img2img (lower quality but free).

FieldTypeDefaultDescription
image_urlstringRequired. /v1/upload URL.
modelstringautoauto · gfpgan (old photos) · codeformer (AI faces)
weightfloat0.5CodeFormer fidelity 0-1 (0=quality, 1=identity)
upscaleint21, 2, or 4

POST /v1/edit/upscale — Topaz (Replicate BYOK) / fallback

POST/v1/edit/upscale

Pro-grade upscaling. With Replicate BYOK: topazlabs/image-upscale. Without: Pollinations Flux upscale.

FieldTypeDefaultDescription
image_urlstringRequired.
scaleint22 or 4
enhancebooltrueEnable detail enhancement.

POST /v1/edit/kontext — Flux Kontext Pro (Replicate BYOK required)

POST/v1/edit/kontext

Text-driven precise image editing via black-forest-labs/flux-kontext-pro. Best-in-class prompt following for edits like "change the shirt to blue", "remove the chair", "make it sunset".

Replicate BYOK required. Returns 402 if no key in BYOK Vault.

FieldTypeDefaultDescription
image_urlstringRequired.
promptstringRequired. ≤500 chars. Edit instruction in plain English.
curl https://api.aigatecloud.com/v1/edit/kontext \
  -H "Authorization: Bearer $AIGATE_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "image_url": "https://api.aigatecloud.com/img/upload-abc.jpg",
    "prompt": "change the background to a sunset beach, keep the person identical"
  }'

POST /demo/generate-post — public, rate-limited

POST/demo/generate-post

Try the pipeline without an API key. 5 requests / hour / IP. No image generation.

curl https://api.aigatecloud.com/demo/generate-post \
  -H "Content-Type: application/json" \
  -d '{"idea":"sell luxury watches", "mode":"viral"}'

POST /demo/compare — public, rate-limited

POST/demo/compare

Run the same idea through all 4 modes in parallel. Used by the Lab Test page.

curl https://api.aigatecloud.com/demo/compare \
  -H "Content-Type: application/json" \
  -d '{"idea":"sell luxury watches"}'

Response shape:

{
  "idea":   "sell luxury watches",
  "intent": "ads",
  "modes": [
    {"mode": "speed",   "caption": "...", "hashtags": [...], "latency_ms": 1820, ...},
    {"mode": "cost",    ...},
    {"mode": "quality", ...},
    {"mode": "viral",   ...}
  ]
}