Video, images and chat, from your application.

DEVELOPER DOCUMENTATION · API v1 · API contract updated

Create a key, check the model, approve a credit quote, then submit a job and download its result. Your studio and API share one account balance. Images and videos use asynchronous jobs; non-streaming chat returns a confirmed completion or a durable job.

Check availability before you build

A model is usable only when GET /models returns available: true. Verification and private storage are required. Creating a key does not add credits. One-time credit packs are available through Stripe.

Model IDEndpointInputs / output
minimax-h3POST /videosPrompt; optional owned photo and MP4 reference. MP4 output, 4–15 seconds, 480p through the 2K provider preset.
gpt-image-2POST /images/generationsText prompt to one private PNG with provider metadata removed. 1K, 2K or 4K. Medium quality.
gpt-image-2.5POST /images/generationsText prompt to one private PNG with provider metadata removed. 1K, 2K or 4K. Medium quality.
gpt-image-2.6POST /images/generationsText prompt to one private PNG with provider metadata removed. 1K, 2K or 4K. Medium quality.
nano-banana-2.1POST /images/generationsText prompt to one private PNG with provider metadata removed. 1K, 2K or 4K. Medium quality.
deepseek-v4.1-flashPOST /chat/completionsText messages, non-streaming. Measured token usage and private JSON response.

Model IDs describe the configured gateway contract. GPT Image 2.6 uses one public model ID and one price across its managed generation routes. Other model IDs keep their fixed mapping. Backup credentials stay private; a route may change only after an explicit admission rejection. Timeouts and uncertain results are never automatically resubmitted. This service uses third-party gateways and does not claim direct vendor access. Read the processing and retention details.

Image & chat API credits

One image per request at medium quality. Availability is reported by GET /api/v1/models; a published price does not enable an unavailable model. Checkout shows the available Stripe and PayPal payment options.

Model1K / image2K / image4K / image
gpt-image-20.13 credits0.2 credits0.27 credits
gpt-image-2.50.27 credits0.33 credits0.4 credits
gpt-image-2.60.33 credits0.4 credits0.47 credits
nano-banana-2.10.27 credits0.33 credits0.4 credits

deepseek-v4.1-flash: 2.67 credits / 1M input · 10.67 credits / 1M output

Review model availability and the current generation quote before submitting.

API quickstart · Manage API keys

1. Create a server-side key

Sign in, open API keys and choose allowed models, an expiry and a monthly credit limit. Copy the secret immediately: we retain its hash and cannot display it again. Never embed it in a browser, mobile bundle or public repository.

Base URL: https://aiswaplab.com/api/v1
Authentication: Authorization: Bearer YOUR_API_KEY

2. Quote → generate → poll → download

This cURL example makes one five-second, 480p, text-only video. The example limit is 400 credits; always use the live quote. Add input-reference duration when using a reference video.

# Keep your secret in an environment variable on your server.
# AISWAPLAB_API_KEY must be a key created in your account.
BASE="https://aiswaplab.com/api/v1"

curl "$BASE/models" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY"

curl "$BASE/quotes" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
  "model": "minimax-h3",
  "prompt": "A small orange cat resting by a sunny window, slow camera push in.",
  "seconds": 5,
  "size": "864x480",
  "max_credits": 400
}'

# Only submit if the model is available and you approve the quote.
# Use a unique ID for a new task; reuse THIS ID for a network retry.
curl "$BASE/videos" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: my-video-task-0001" \
  -d '{
  "model": "minimax-h3",
  "prompt": "A small orange cat resting by a sunny window, slow camera push in.",
  "seconds": 5,
  "size": "864x480",
  "max_credits": 400
}'

# Replace JOB_ID with the actual response ID.
curl "$BASE/jobs/JOB_ID" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY"

# Download only after status=completed.
curl --fail "$BASE/jobs/JOB_ID/content" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY" \
  -o result.mp4

Python example

Requires Python 3 and requests. Save the request ID in your application’s job record before sending; the example uses a new ID for each new task.

import os, time, uuid, requests

base = "https://aiswaplab.com/api/v1"
s = requests.Session()
s.headers["Authorization"] = "Bearer " + os.environ["AISWAPLAB_API_KEY"]
payload = {
  "model": "minimax-h3",
  "prompt": "A small orange cat resting by a sunny window, slow camera push in.",
  "seconds": 5,
  "size": "864x480",
  "max_credits": 400
}

models = s.get(base + "/models", timeout=30)
models.raise_for_status()
if not any(m["id"] == payload["model"] and m["available"]
           for m in models.json()["data"]):
    raise RuntimeError("Model not available; do not submit.")
quote = s.post(base + "/quotes", json=payload, timeout=30)
quote.raise_for_status()
if quote.json()["credits"] > payload["max_credits"]:
    raise RuntimeError("Review the quote first.")

# Persist this request ID before sending. Reuse it after a timeout.
request_id = str(uuid.uuid4())
r = s.post(base + "/videos", json=payload,
           headers={"Idempotency-Key": request_id}, timeout=30)
r.raise_for_status()
job = r.json()
for _ in range(120):  # bounded polling; never resubmit a generation
    if job["status"] in ("completed", "failed", "unknown"):
        break
    time.sleep(10)
    r = s.get("https://aiswaplab.com" + job["poll_url"], timeout=300)
    r.raise_for_status()
    job = r.json()
if job["status"] != "completed":
    raise RuntimeError(f"Keep job {job['id']}: {job['status']}")
with s.get("https://aiswaplab.com" + job["content_url"],
           stream=True, timeout=90) as result:
    result.raise_for_status()
    with open("result.mp4", "wb") as f:
        for chunk in result.iter_content(65536):
            f.write(chunk)

Generate one image

Quote this payload with POST /quotes, then submit it to POST /images/generations with an Idempotency-Key. Poll the returned job and download /jobs/ID/content after completion. Check the download Content-Type for the file extension.

{
  "model": "gpt-image-2",
  "prompt": "A minimal ceramic orange cat on a pale studio background.",
  "size": "1K",
  "quality": "medium",
  "n": 1,
  "max_credits": 6
}

Use size: 1K, 2K or 4K for square 1024×1024, 2048×2048 or 4096×4096 output. Also accepted: 1536×1024 or 1024×1536 at the 1K list price. Check the live model contract before selecting a size. One image per job; medium quality only at the published rates. Image editing, masks and batches are not supported.

Non-streaming text chat

Quote the messages first with POST /quotes. The quote reserves a conservative input-token ceiling and your maximum output. Confirmed usage determines the final debit; unused credits return once. This is a limited chat protocol, with no streaming, tools or attachments, and is not a drop-in OpenAI SDK replacement.

{
  "model": "deepseek-v4.1-flash",
  "messages": [
    {
      "role": "user",
      "content": "Hello"
    }
  ],
  "max_tokens": 100,
  "stream": false,
  "max_credits": 1
}

Submit to POST /chat/completions with Bearer authentication, Content-Type application/json and an Idempotency-Key, as in the video example. A confirmed response returns HTTP 200 with choices, usage and aiswaplab.credits. HTTP 202 returns a durable job when the outcome needs confirmation: save its ID, poll that job, and do not start a replacement task. The confirmed JSON is also available through the private content endpoint. After a timeout, reuse the original idempotency key and identical payload.

Use 1–32 system, user or assistant text messages, under 12 KB combined; max_tokens is 1–4096 (default 256). stream must be false. The final debit reflects measured token usage and the same two-decimal website credit precision.

Use your own video and photo references

Upload one file at a time with POST /files. Use kind=photo for JPG, PNG or WebP (up to 8 MB), or kind=reference for a 4–15-second MP4 (up to 20 MB). Put the returned ID in input_image_id or reference_video_id when quoting and submitting H3. Files must belong to the same account and remain out of Trash.

curl "https://aiswaplab.com/api/v1/files" \
  -H "Authorization: Bearer $AISWAPLAB_API_KEY" \
  -F "kind=photo" -F "file=@portrait.png"

The server sends the owned file to the configured generation service and stores results privately. Remote input URLs are not accepted. Use only material and likenesses you have permission to process. For individually mapping two people to replacement portraits, use the studio’s person-to-photo workflow; this API does not automatically detect or map people.

Credits, limits and reliable retries

API amounts use the v4 ledger unit. One website credit equals 45 ledger credits. The generation debit rounds to the nearest 0.01 website credit (0.45 ledger credits). Send max_credits in ledger units, with up to two decimals. Get a fresh quote before submitting.

  • Quote first. A quote does not charge or reserve credits. Submission checks the current quote against max_credits and debits atomically before dispatch. A shortfall returns 402 without contacting the provider.
  • One balance. API calls and studio generations share account credits, UTC daily generation-cost limits and concurrency limits. A key’s monthly cap is an additional ceiling, not a separate balance.
  • No double charge for a network retry. Reuse the same Idempotency-Key and identical payload after a timeout. A different payload with that key returns 409. A new key means a new task and may cost credits again.
  • Uncertain is not failed. A confirmed provider rejection or failure returns credits once. unknown retains the reservation while the outcome needs reconciliation. Keep the job ID and do not create a replacement paid task automatically.
  • Polling is free of generation credits. Check about once every 10 seconds. Each key allows 30 API requests per minute. At most two active jobs per account and four across this beta; unknown jobs continue to occupy a slot. New API submissions are capped at 100 per account and 1,000 site-wide per UTC day, including confirmed failures. Replaying an existing request does not create a new submission.
  • Revocation stops new calls. It does not cancel accepted jobs. Another permitted key on the same account can retrieve them. Completed files can be managed in the studio’s private file library.

GET /usage returns the balance, this key’s current UTC calendar-month use and recent permitted jobs. Published pack prices are separate from model availability. Buy one-time credits using a payment option available at checkout: Stripe or PayPal.

Handle responses without creating duplicate jobs

StatusMeaningWhat to do
200Confirmed chat or idempotent replayInspect the response type: completion or job.
202Job acceptedSave id and poll_url, then poll.
400 / 413Invalid input or oversized requestCorrect the input before submitting.
401 / 403Key, model scope or monthly capCheck expiry, revocation, allowed models and usage.
402Not enough account creditsDo not retry until the balance is sufficient.
409Idempotency conflict, credit limit or content not readyKeep the original payload and job ID; inspect the message.
429Rate, daily budget or concurrency limitWait; honor Retry-After. Do not create a new task ID to bypass the limit.
503Generation, storage, model or price not configuredCheck GET /models and wait for service configuration.
unknown jobNo confirmed outcomeKeep the same job ID. Poll only if a provider task was obtained; contact support if it persists.

Privacy and integration boundaries

API keys and account sign-in sessions are separate. A browser cookie cannot call this API. Requests, files and downloads are account-scoped; no public result URL is created. Put API calls on your server. We do not enable browser CORS or forward your AISwapLab key upstream.

Read the privacy policy, usage guide and character versus face replacement guide. This documentation describes the API contract; it does not claim output likeness, latency or availability for untested models.