v1.0

API Documentation

Build integrations with the Poiiky Studio API. Generate AI videos, images, and audio programmatically. Manage models, track usage, and receive real-time webhook notifications.

Download API Docs Download OpenAPI Spec Send this file to your AI coding assistant to integrate automatically

Quick Start

Integrate the Poiiky Studio API in a few simple steps

1

Get API Key

Generate your API key from the Developer Dashboard

export POIIKY_API_KEY="pk_..."
2

Check the price

Estimate the cost before generating. Nothing is charged.

curl -X POST "https://www.poiikystudio.com/api/v1/estimate.php" \
  -H "Authorization: Bearer $POIIKY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model_id": "kling-v2", "duration": 5}'
3

Make First Request

Create your first generation. Save the returned uuid.

curl -X POST "https://www.poiikystudio.com/api/v1/generate.php" \
  -H "Authorization: Bearer $POIIKY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model_id": "kling-v2", "prompt": "A serene mountain landscape at sunset", "aspect_ratio": "16:9", "duration": 5}'
4

Get Results

Poll the status until it is final, then download output_files.

curl "https://www.poiikystudio.com/api/v1/status.php?id=GENERATION_UUID" \
  -H "Authorization: Bearer $POIIKY_API_KEY"

Generation Lifecycle

Each generation goes through these statuses:

queuedQueued → processingProcessing → succeededSucceeded failedFailed cancelledCancelled
The only status values are queued, processing, succeeded, failed, cancelled. Some image models return succeeded directly from /generate.php, so check the create response before polling.
Balance (VND) is charged when the generation is created. Cancelled generations are refunded. Failed generations refunded by the provider have is_refunded: true. Output files may expire about 24 hours after completion, so download them promptly.

Authentication

All API requests require a Bearer token in the Authorization header. Generate your API key from the Developer Dashboard.

Header format:
Authorization: Bearer YOUR_API_KEY

Keep your API key secret. Never expose it in client-side code or public repositories. If compromised, revoke it immediately and generate a new one.

Base URL

All endpoints are relative to the base URL:

https://www.poiikystudio.com/api/v1/

Rate Limits

Rate limits are enforced per API key — the same limit applies to all users (anti-spam only, not a feature restriction).

LimitValue
Requests per minute30
Max concurrent generationsUnlimited

Rate limit info is returned in response headers:

X-RateLimit-Limit: 30
X-RateLimit-Remaining: 25
X-RateLimit-Reset: 1732612800

When exceeded, the API returns 429 Too Many Requests with a Retry-After header.

Error Codes

CodeMeaningDescription
200OKRequest succeeded
400Bad RequestMissing or invalid parameters
401UnauthorizedInvalid or missing API key
402Payment RequiredInsufficient balance
404Not FoundResource does not exist
429Too Many RequestsRate limit exceeded
500Server ErrorInternal server error

All error responses follow this format:

{
  "error": true,
  "message": "Insufficient balance. Required: 5000, Available: 2000"
}
POST /api/v1/generate.php

Create a new AI generation. Charges the estimated cost from your balance immediately. The generation runs asynchronously; poll the status endpoint or use webhooks for completion.

Request Body

ParameterTypeRequiredDescription
model_idstringYesAI model identifier (e.g. kling-v2)
promptstringNoText prompt. Max length depends on the model (see params[].max in model detail, e.g. 20,000 / 30,000 / 100,000)
providerstringNoProvider override
serverstringNoServer ID (e.g. sv15) or auto (default). Mapped to server_id for provider routing
aspect_ratiostringNo16:9, 9:16, 1:1, 4:3, 3:4, 21:9, auto…
durationintegerNoDuration in seconds
resolutionstringNoOutput resolution: 720p, 1080p
qualitystringNoQuality preset, e.g. standard, high
image_urlstringNoInput image for image-to-video / image editing. Use the url from /upload.php
image_urlsarrayNoMultiple input / reference images
last_frame_urlstringNoEnd frame image (first/last-frame models)
video_url / audio_urlstringNoInput video / audio
negative_promptstringNoWhat to avoid
seedintegerNoRandom seed for reproducibility
nintegerNoNumber of outputs (image models)
with_audiobooleanNoGenerate audio with video (if supported)
voicestringNoVoice ID for TTS/subtitle models
instrumentalbooleanNoInstrumental only — no vocals (music models)
languagestringNoLanguage code for TTS/subtitle models
speedstringNoReading speed for TTS/subtitle models
formatstringNoOutput format: mp3, wav (TTS models)
srtstringNoSubtitle text content (SRT format)
subtitle_file_urlstringNoSubtitle file URL (.srt/.vtt) from /upload.php
p_*variousNoModel-specific params prefixed with p_ (e.g. p_voice_id, p_language_code, p_speed)
Supported optional fields depend on the model. Read params from /model-detail.php. Only parameters declared in the model's schema are forwarded; unrecognized fields are stripped.

Code Examples

curl -X POST "https://www.poiikystudio.com/api/v1/generate.php" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model_id": "kling-v2",
    "prompt": "A serene mountain landscape at sunset",
    "aspect_ratio": "16:9",
    "duration": 5
  }'
import requests

response = requests.post(
    "https://www.poiikystudio.com/api/v1/generate.php",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "model_id": "kling-v2",
        "prompt": "A serene mountain landscape at sunset",
        "aspect_ratio": "16:9",
        "duration": 5
    }
)
data = response.json()
print(data["generation"]["uuid"])
const response = await fetch(
  "https://www.poiikystudio.com/api/v1/generate.php",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      model_id: "kling-v2",
      prompt: "A serene mountain landscape at sunset",
      aspect_ratio: "16:9",
      duration: 5
    })
  }
);
const data = await response.json();
console.log(data.generation.uuid);
$ch = curl_init("https://www.poiikystudio.com/api/v1/generate.php");
curl_setopt_array($ch, [
    CURLOPT_POST           => true,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('POIIKY_API_KEY'),
        'Content-Type: application/json',
    ],
    CURLOPT_POSTFIELDS => json_encode([
        'model_id'     => 'kling-v2',
        'prompt'       => 'A serene mountain landscape at sunset',
        'aspect_ratio' => '16:9',
        'duration'     => 5,
    ]),
]);
$data = json_decode(curl_exec($ch), true);
curl_close($ch);
echo $data['generation']['uuid'];

Response

{
  "success": true,
  "generation": {
    "id": 98765,
    "uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "model_id": "kling-v2",
    "status": "queued",
    "progress": 0,
    "cost": 5000,
    "output_type": "video",
    "created_at": "2026-11-26T10:30:00Z"
  }
}
GET /api/v1/status.php?id={uuid}

Check the current status and progress of a generation. Poll this endpoint until status is completed or failed.

Query Parameters

ParameterTypeRequiredDescription
idstringYesGeneration UUID

Code Examples

curl "https://www.poiikystudio.com/api/v1/status.php?id=gen_abc123def456" \
  -H "Authorization: Bearer YOUR_API_KEY"
response = requests.get(
    "https://www.poiikystudio.com/api/v1/status.php",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={"id": "gen_abc123def456"}
)
data = response.json()
print(data["data"]["status"], data["data"]["progress"])
const response = await fetch(
  "https://www.poiikystudio.com/api/v1/status.php?id=gen_abc123def456",
  { headers: { "Authorization": "Bearer YOUR_API_KEY" } }
);
const { data } = await response.json();
console.log(data.status, data.progress);

Response

{
  "success": true,
  "data": {
    "id": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
    "status": "succeeded",
    "progress": 100,
    "output_files": ["https://cdn.poiiky.com/outputs/video_xyz.mp4"],
    "error": null,
    "cost": 5000
  }
}
GET /api/v1/generations.php

Retrieve a paginated list of your generation history. Filter by status or output type.

Query Parameters

ParameterTypeRequiredDescription
pageintegerNoPage number (default: 1)
limitintegerNoItems per page, 1–100 (default: 20)
statusstringNoqueued, processing, succeeded, failed, cancelled
output_typestringNovideo, image, audio

Response

{
  "success": true,
  "data": [...],
  "pagination": {
    "page": 1,
    "limit": 20,
    "total": 150,
    "total_pages": 8
  }
}
POST /api/v1/cancel.php

Cancel a pending or processing generation. The charged cost is refunded to your balance.

Request Body

ParameterTypeRequiredDescription
uuidstringYesGeneration UUID to cancel

Response

{
  "success": true,
  "refunded": 5000,
  "new_balance": 45000
}
POST /api/v1/estimate.php

Get an estimated price for a generation before committing. Useful for displaying costs in your UI.

Request Body

ParameterTypeRequiredDescription
model_idstringYesAI model identifier
providerstringNoProvider override
serverstringNoServer ID or auto (default)
durationintegerNoDuration in seconds (affects pricing for video/audio)
resolutionstringNoOutput resolution (affects pricing)
aspect_ratiostringNoOutput aspect ratio
p_*variousNoModel-specific params (same as generate endpoint)

Response

{
  "success": true,
  "provider_cost": 3500,
  "sell_price": 5000,
  "original_cost": 3500,
  "discount": 0,
  "currency": "VND",
  "formatted": "5.000₫"
}
GET /api/v1/models.php

List all available AI models. Optionally filter by type.

Query Parameters

ParameterTypeRequiredDescription
typestringNovideo, image, audio

Code Examples

curl "https://www.poiikystudio.com/api/v1/models.php?type=video" \
  -H "Authorization: Bearer YOUR_API_KEY"
response = requests.get(
    "https://www.poiikystudio.com/api/v1/models.php",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    params={"type": "video"}
)
for model in response.json()["models"]:
    print(model["model_id"], model["name"])
const response = await fetch(
  "https://www.poiikystudio.com/api/v1/models.php?type=video",
  { headers: { "Authorization": "Bearer YOUR_API_KEY" } }
);
const { models } = await response.json();
models.forEach(m => console.log(m.model_id, m.name));

Response

{
  "success": true,
  "models": [
    {
      "model_id": "kling-v2",
      "name": "Kling v2.0",
      "type": "video",
      "provider": "kling",
      "sell_price": 5000,
      "supports": ["text-to-video", "image-to-video"]
    }
  ],
  "total": 24
}
GET /api/v1/model-detail.php?model_id={id}

Get detailed information about a specific model, including supported parameters, resolutions, and pricing.

Query Parameters

ParameterTypeRequiredDescription
model_idstringYesModel identifier

Response

{
  "success": true,
  "model_id": "kling-v2",
  "params": {
    "aspect_ratios": ["16:9", "9:16", "1:1"],
    "max_duration": 10,
    "resolutions": ["720p", "1080p"]
  },
  "pricing": { "base_cost": 3500 },
  "sell_price": 5000
}
POST /api/v1/upload.php

Upload a file for use with image-to-video or other generation modes. Send as multipart/form-data.

Request Body

ParameterTypeRequiredDescription
filefileYesMax 50 MB. Image: jpg, png, webp, gif · Video: mp4, mov, webm · Audio: mp3, wav, m4a
providerstringNoDefault zova
upload_to_providerstringNo1 (default) or 0

Response

{
  "success": true,
  "id": "file_xyz789",
  "url": "https://cdn.poiiky.com/uploads/file_xyz789.png",
  "mime_type": "image/png",
  "size": 2048576
}
GET /api/v1/balance.php

Get your current account balance, subscription plan, and rate limit status.

Response

{
  "success": true,
  "balance": 50000,
  "plan": { "name": "Free" },
  "rate_limit": {
    "requests_per_minute": 30,
    "concurrent": 0
  }
}
GET /api/v1/account.php

Retrieve full account information including user profile, balance, subscription plan, and usage summary.

Response

{
  "success": true,
  "user": {
    "id": 42,
    "username": "creator",
    "email": "user@example.com",
    "created_at": "2026-01-15"
  },
  "balance": 50000,
  "plan": {
    "name": "Pro",
    "expires_at": "2027-01-15"
  },
  "usage": {
    "total_generations": 1250,
    "this_month": 89
  }
}
GET /api/v1/usage.php

Get detailed usage statistics including request counts, generation totals, cost breakdown, and daily usage data.

Response

{
  "success": true,
  "summary": {
    "total_requests": 15420,
    "total_generations": 1250,
    "total_cost": 6250000
  },
  "endpoints": {
    "/generate": 1250,
    "/status": 8900,
    "/models": 520
  },
  "daily": [
    {
      "date": "2026-11-26",
      "requests": 45,
      "generations": 12,
      "cost": 60000
    }
  ]
}
GET POST PUT DELETE /api/v1/webhooks.php

Manage webhook endpoints for receiving real-time notifications about generation events.

GET List Webhooks

Returns all registered webhook endpoints for your account.

{
  "success": true,
  "webhooks": [
    {
      "id": 1,
      "url": "https://yourapp.com/webhook",
      "events": ["generation.succeeded"],
      "active": true,
      "created_at": "2026-11-20T08:00:00Z"
    }
  ]
}

POST Create Webhook

ParameterTypeRequiredDescription
urlstringYesHTTPS endpoint URL
eventsarrayYesgeneration.succeeded, generation.failed
secretstringNoCustom signing secret (auto-generated if omitted)

Code Examples

curl -X POST "https://www.poiikystudio.com/api/v1/webhooks.php" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "url": "https://yourapp.com/webhook",
    "events": ["generation.succeeded", "generation.failed"]
  }'
response = requests.post(
    "https://www.poiikystudio.com/api/v1/webhooks.php",
    headers={"Authorization": "Bearer YOUR_API_KEY"},
    json={
        "url": "https://yourapp.com/webhook",
        "events": ["generation.succeeded", "generation.failed"]
    }
)
webhook = response.json()["webhook"]
print("Secret:", webhook["secret"])
const response = await fetch(
  "https://www.poiikystudio.com/api/v1/webhooks.php",
  {
    method: "POST",
    headers: {
      "Authorization": "Bearer YOUR_API_KEY",
      "Content-Type": "application/json"
    },
    body: JSON.stringify({
      url: "https://yourapp.com/webhook",
      events: ["generation.succeeded", "generation.failed"]
    })
  }
);
const { webhook } = await response.json();
console.log("Secret:", webhook.secret);

Response

{
  "success": true,
  "webhook": {
    "id": 2,
    "url": "https://yourapp.com/webhook",
    "events": ["generation.succeeded", "generation.failed"],
    "secret": "whsec_a1b2c3d4e5f6...",
    "active": true
  }
}

PUT Update Webhook

ParameterTypeRequiredDescription
idintegerYesWebhook ID, in the query string: PUT /webhooks.php?id=123
urlstringNoNew endpoint URL
eventsarrayNoUpdated event list
is_activebooleanNoEnable or disable
descriptionstringNoLabel

DELETE Delete Webhook

ParameterTypeRequiredDescription
idintegerYesIn the query string: DELETE /webhooks.php?id=123
{
  "success": true
}

Webhooks Guide

Event Types

EventDescription
generation.succeededA generation completed successfully with output files
generation.failedA generation failed due to an error

Payload Format

Webhook payloads are sent as POST requests with Content-Type: application/json.

{
  "event": "generation.succeeded",
  "timestamp": 1732617135,
  "data": {
    "id": "gen_abc123def456",
    "model_id": "kling-v2",
    "status": "succeeded",
    "output_files": ["https://cdn.poiiky.com/outputs/video_xyz.mp4"],
    "cost": 5000
  }
}

Signature Verification

Every webhook request includes an X-Poiiky-Signature header containing an HMAC-SHA256 signature. Verify it to ensure the request is authentic.

import hmac, hashlib

def verify_signature(payload_body, signature, secret):
    expected = hmac.new(
        secret.encode(),
        payload_body,
        hashlib.sha256
    ).hexdigest()
    return hmac.compare_digest(f"sha256={expected}", signature)
const crypto = require("crypto");

function verifySignature(body, signature, secret) {
  const expected = crypto
    .createHmac("sha256", secret)
    .update(body)
    .digest("hex");
  return signature === `sha256=${expected}`;
}
function verifySignature(string $rawBody, string $signature, string $signingKey): bool
{
    $expected = 'sha256=' . hash_hmac('sha256', $rawBody, $signingKey);
    return hash_equals($expected, $signature);
}

$raw = file_get_contents('php://input');
$ok  = verifySignature($raw, $_SERVER['HTTP_X_POIIKY_SIGNATURE'] ?? '', getenv('POIIKY_WEBHOOK_SECRET'));

Retry Policy

Respond with any 2xx within 5 seconds. Redirects are not followed. Each event is delivered once (no automatic retries). After 10 consecutive failures the webhook is disabled automatically. Re-enable it with PUT /webhooks.php?id=... and {"is_active": true}. Keep polling as a fallback for important jobs.

Full Workflow Example

Complete script: create a generation, wait for the result with retries, then download the output.

import os, time, requests

API = "https://www.poiikystudio.com/api/v1/"
HEADERS = {"Authorization": "Bearer " + os.environ["POIIKY_API_KEY"]}
FINAL = {"succeeded", "failed", "cancelled"}

def call(method, path, **kw):
    for attempt in range(5):
        r = requests.request(method, API + path, headers=HEADERS, timeout=60, **kw)
        if r.status_code in (429, 500, 502, 503) and attempt < 4:
            time.sleep(min(60, 2 ** attempt * 2))
            continue
        body = r.json()
        if r.status_code >= 400 or body.get("error"):
            err = body.get("error")
            raise RuntimeError(err.get("message") if isinstance(err, dict) else body.get("message"))
        return body

# Optional: image-to-video
# up = call("POST", "upload.php", files={"file": open("photo.jpg", "rb")})

gen = call("POST", "generate.php", json={
    "model_id": "kling-v2",
    "prompt": "A serene mountain landscape at sunset",
    "aspect_ratio": "16:9",
    "duration": 5,
    # "image_url": up["url"],
})["generation"]

data = gen
while data["status"] not in FINAL:
    time.sleep(6)
    data = call("GET", "status.php", params={"id": gen["uuid"]})["data"]
    print(data["status"], data["progress"])

if data["status"] == "succeeded":
    for i, url in enumerate(data["output_files"]):
        open(f"output_{i}.mp4", "wb").write(requests.get(url).content)
else:
    print("Failed:", data.get("error"))
const API = "https://www.poiikystudio.com/api/v1/";
const AUTH = { Authorization: "Bearer " + process.env.POIIKY_API_KEY };
const FINAL = ["succeeded", "failed", "cancelled"];
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));

async function call(method, path, json) {
  for (let attempt = 0; attempt < 5; attempt++) {
    const res = await fetch(API + path, {
      method,
      headers: json ? { ...AUTH, "Content-Type": "application/json" } : AUTH,
      body: json ? JSON.stringify(json) : undefined,
    });
    if ([429, 500, 502, 503].includes(res.status) && attempt < 4) {
      await sleep(Math.min(60000, 2000 * 2 ** attempt));
      continue;
    }
    const body = await res.json();
    if (!res.ok || body.error) {
      throw new Error(typeof body.error === "object" ? body.error.message : body.message);
    }
    return body;
  }
}

const { generation } = await call("POST", "generate.php", {
  model_id: "kling-v2",
  prompt: "A serene mountain landscape at sunset",
  aspect_ratio: "16:9",
  duration: 5,
});

let data = generation;
while (!FINAL.includes(data.status)) {
  await sleep(6000);
  ({ data } = await call("GET", "status.php?id=" + generation.uuid));
  console.log(data.status, data.progress);
}
console.log(data.status === "succeeded" ? data.output_files : data.error);
$api = "https://www.poiikystudio.com/api/v1/";

function poiiky(string $method, string $url, ?array $json = null): array
{
    $headers = ['Authorization: Bearer ' . getenv('POIIKY_API_KEY')];
    $ch = curl_init($url);
    $opts = [CURLOPT_CUSTOMREQUEST => $method, CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 60];
    if ($json !== null) {
        $headers[] = 'Content-Type: application/json';
        $opts[CURLOPT_POSTFIELDS] = json_encode($json);
    }
    $opts[CURLOPT_HTTPHEADER] = $headers;
    curl_setopt_array($ch, $opts);
    $body = json_decode((string) curl_exec($ch), true) ?: [];
    $code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($code >= 400 || !empty($body['error'])) {
        throw new RuntimeException(is_array($body['error'] ?? null) ? $body['error']['message'] : ($body['message'] ?? "HTTP $code"));
    }
    return $body;
}

$gen = poiiky('POST', $api . 'generate.php', [
    'model_id'     => 'kling-v2',
    'prompt'       => 'A serene mountain landscape at sunset',
    'aspect_ratio' => '16:9',
    'duration'     => 5,
])['generation'];

$data = $gen;
while (!in_array($data['status'], ['succeeded', 'failed', 'cancelled'], true)) {
    sleep(6);
    $data = poiiky('GET', $api . 'status.php?id=' . urlencode($gen['uuid']))['data'];
}

if ($data['status'] === 'succeeded') {
    foreach ($data['output_files'] as $i => $url) {
        file_put_contents("output_$i.mp4", fopen($url, 'r'));
    }
} else {
    echo 'Failed: ' . $data['error'];
}
Image-to-video: upload the image with /upload.php first, then pass the returned url as image_url.

Best Practices

Polling Strategy

  • Start polling 3–5 seconds after creating
  • Use 5–10 second intervals for video, 2–3 seconds for images
  • Apply exponential backoff on errors
  • Stop polling when status is succeeded, failed or cancelled
  • Use webhooks in production, with polling as a fallback

Error Handling

  • Always check the HTTP status code before reading the body
  • Retry automatically on 429 and 5xx
  • Do not retry 400 or 401
  • Exponential backoff: 2s, 4s, 8s, max 60s
  • Log every error for debugging
Do not blindly retry /generate.php after a network timeout. The first request may have succeeded and a retry would charge you twice. Check /generations.php first.

File Upload Tips

  • Compress images before uploading (max 50 MB)
  • Formats: JPEG, PNG, WebP, GIF; MP4, MOV, WebM; MP3, WAV, M4A
  • Upload once, then reuse the returned URL in generate requests
  • Reference images should match the output aspect ratio

Security

  • Keep the API key on your server in an environment variable
  • Verify webhook signatures with a constant-time comparison
  • Use HTTPS webhook URLs

FAQ

Video: usually MP4. Image: PNG/JPEG/WebP. Audio: MP3/WAV. Check the file extension in output_files.
Images: seconds to about 1 minute. Video: usually 1–10 minutes depending on the model, duration and load.
Cancelled generations are refunded. Failed generations refunded by the provider return to your balance and show is_refunded: true.
30 requests per minute per API key. Concurrent generations are unlimited. Polling counts toward the request limit.
Not yet. Use the examples on this page, or download the documentation and give it to your AI coding assistant to generate a client for your language.
No. Each event is sent once. A webhook is disabled after 10 consecutive failures. Keep polling as a fallback.
No. Call it from your backend so your API key stays secret.

Complete API Documentation Package

Download the complete documentation to send to your AI coding assistant or development team.

Includes:
  • OpenAPI specification (YAML)
  • Complete code examples
  • Step-by-step integration guide
  • Every endpoint, parameter and response
  • Webhooks and signature verification
  • Best practices and error handling
Download API Docs Download OpenAPI Spec Send this file to your AI coding assistant to integrate automatically

Changelog

Track API updates and changes.

VersionDateChanges
v1.02026-11-27Initial public release: generations, models, uploads, account, webhooks
Download API Docs