#Introduction
The jAI Labs API gives you one API key for the world's leading chat, image, video and music AI models — GPT, Claude, Gemini, Veo 3.1, Sora 2, Kling 3.0, Seedance, Flux, Seedream and 100+ more model options — at up to 25% less than official prices.
How the API works
- Chat models use
POST /v1/chat/completions, the same format as the OpenAI API. If your app already uses OpenAI or OpenRouter, you only change the base URL, the key and the model name. - Image, video and music models use
POST /v1/generate. Media takes time to create, so each request starts a job. You get the result by checking the job or by receiving a webhook. - One balance, pay as you go. Top up from $5. Every response tells you exactly what the call cost.
- Sub‑accounts. Building an AI app for your own customers? Create a sub‑account for each customer, give them credits from your balance and charge them your own price.
Base URL
https://api.jailabs.ai/v1#Quickstart
- Get your API key. Message us on WhatsApp or open a support ticket. Our team sets up your account and sends you your API key. Treat it like a password.
- Add credits. Top up from $5 — we share the payment options with you on WhatsApp. There is no monthly plan.
- Save your key as an environment variable so it never ends up in your code:
export JAILABS_API_KEY="jl_live_your_key_here"- Send your first chat request:
curl https://api.jailabs.ai/v1/chat/completions \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6.1-sol",
"messages": [{"role": "user", "content": "Write a tagline for a coffee shop"}]
}' from openai import OpenAI
client = OpenAI(
base_url="https://api.jailabs.ai/v1",
api_key="YOUR_JAILABS_API_KEY",
)
reply = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Write a tagline for a coffee shop"}],
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.jailabs.ai/v1",
apiKey: process.env.JAILABS_API_KEY,
});
const reply = await client.chat.completions.create({
model: "gpt-6.1-sol",
messages: [{ role: "user", content: "Write a tagline for a coffee shop" }],
});
console.log(reply.choices[0].message.content);<?php
$ch = curl_init("https://api.jailabs.ai/v1/chat/completions");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("JAILABS_API_KEY"),
"Content-Type: application/json",
],
CURLOPT_POSTFIELDS => json_encode([
"model" => "gpt-6.1-sol",
"messages" => [["role" => "user", "content" => "Write a tagline for a coffee shop"]],
]),
]);
$reply = json_decode(curl_exec($ch), true);
echo $reply["choices"][0]["message"]["content"];- Create your first video. Start a job, then check it until it is
completed:
# 1. Start the job
curl https://api.jailabs.ai/v1/generate \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "veo-3.1-fast",
"prompt": "A golden retriever running on a beach at sunset",
"duration": 5,
"aspect_ratio": "16:9"
}'
# 2. Check the job (use the id from step 1)
curl https://api.jailabs.ai/v1/jobs/job_8f2a91c4 \
-H "Authorization: Bearer $JAILABS_API_KEY"import os, time, requests
API = "https://api.jailabs.ai/v1"
HEADERS = {"Authorization": f"Bearer {os.environ['JAILABS_API_KEY']}"}
job = requests.post(f"{API}/generate", headers=HEADERS, json={
"model": "veo-3.1-fast",
"prompt": "A golden retriever running on a beach at sunset",
"duration": 5,
"aspect_ratio": "16:9",
}).json()
while job["status"] in ("queued", "processing"):
time.sleep(10)
job = requests.get(f"{API}/jobs/{job['id']}", headers=HEADERS).json()
print(job["status"], job["outputs"][0]["url"] if job["status"] == "completed" else job["error"])const API = "https://api.jailabs.ai/v1";
const headers = {
Authorization: `Bearer ${process.env.JAILABS_API_KEY}`,
"Content-Type": "application/json",
};
let job = await fetch(`${API}/generate`, {
method: "POST",
headers,
body: JSON.stringify({
model: "veo-3.1-fast",
prompt: "A golden retriever running on a beach at sunset",
duration: 5,
aspect_ratio: "16:9",
}),
}).then((r) => r.json());
while (job.status === "queued" || job.status === "processing") {
await new Promise((r) => setTimeout(r, 10000));
job = await fetch(`${API}/jobs/${job.id}`, { headers }).then((r) => r.json());
}
console.log(job.status, job.outputs?.[0]?.url ?? job.error);callback_url and let us call your server when the job is done — see Webhooks.#Authentication
Every request needs your API key in the Authorization header as a Bearer token.
Authorization: Bearer jl_live_your_key_hereKey types
| Key | Starts with | Used for |
|---|---|---|
| Main key | jl_live_ | Your own account. Can call every endpoint, including sub‑accounts and billing. |
| Sub‑account key | jl_sub_ | One of your customers. Can call models and spend only that sub‑account's credits. Cannot manage sub‑accounts. |
Keep your key safe
- Call the API from your server. Never put a key in a website, mobile app or browser extension where users can see it.
- Store keys in environment variables or a secrets manager, never in your code repository.
- If a key is exposed, message us on WhatsApp or open a support ticket. We revoke it straight away and send you a new one.
- Create separate keys for development and production so you can rotate them independently.
401 invalid_api_key. Requests with a revoked key return 401 revoked_api_key.#Pricing & credits
Your balance is held in US dollars. Each call deducts its price from your balance — there are no monthly fees and no minimum spend.
| Model type | How it is priced |
|---|---|
| Chat | Per 1 million input tokens and per 1 million output tokens |
| Image | Per image (depends on the model and resolution) |
| Video | Per second of video (depends on the model, resolution and whether audio is on) |
| Music | Per track |
Where to see prices
- Before a call:
GET /v1/modelsreturns each model's livepricing, including the official price for comparison. - After a call: every chat response and every job includes
cost_usd— the exact amount charged. - Over time:
GET /v1/usageshows your spend by day, model and sub‑account.
Billing rules
- Top up from $5 — message us on WhatsApp to add credits. Credits do not expire.
- Media jobs are charged when they complete. If a job fails or is canceled, you are not charged.
- If your balance is too low for a request, the API returns
402 insufficient_balanceand nothing is charged. - Prices on popular models are up to 25% below each maker's official price. Makers can change their prices, so always rely on the live
pricingfield.
#Chat completions
/v1/chat/completionsGenerate a reply from any chat model. The request and response use the OpenAI Chat Completions format, so the official OpenAI SDKs and most AI libraries work by changing the base URL.
Body parameters
modelstringrequiredclaude-sonnet-5.5. See Model catalog.messagesarrayrequiredrole (system, user, assistant or tool) and content. Content can be a string, or an array of parts (text and image_url) for models that accept images.max_tokensintegertemperaturenumbertop_pnumbertemperature, not both.streambooleantrue, the reply is sent as server‑sent events while it is being written. See Streaming.stopstring or arraytoolsarraytool_choicestring or objectauto, none, required, or a specific function.response_formatobject{"type": "json_object"} to get valid JSON back (supported models only).userstringResponse
The standard OpenAI chat completion object, plus cost_usd — the amount charged for this call.
Streaming
Set "stream": true to receive the reply piece by piece. Each event is a line starting with data: containing a chunk with a delta. The stream ends with data: [DONE]. The last chunk before [DONE] includes usage and cost_usd.
curl https://api.jailabs.ai/v1/chat/completions \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-5.5",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain APIs in one sentence."}
],
"max_tokens": 200
}' from openai import OpenAI
client = OpenAI(base_url="https://api.jailabs.ai/v1", api_key="YOUR_JAILABS_API_KEY")
reply = client.chat.completions.create(
model="claude-sonnet-5.5",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain APIs in one sentence."},
],
max_tokens=200,
)
print(reply.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://api.jailabs.ai/v1", apiKey: process.env.JAILABS_API_KEY });
const reply = await client.chat.completions.create({
model: "claude-sonnet-5.5",
messages: [
{ role: "system", content: "You are a helpful assistant." },
{ role: "user", content: "Explain APIs in one sentence." },
],
max_tokens: 200,
});
console.log(reply.choices[0].message.content);{
"id": "chatcmpl_5d1c0e7b",
"object": "chat.completion",
"created": 1793350000,
"model": "claude-sonnet-5.5",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "An API is a set of rules that lets one program ask another program to do something."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 21,
"total_tokens": 45
},
"cost_usd": 0.000369
}stream = client.chat.completions.create(
model="gpt-6.1-sol",
messages=[{"role": "user", "content": "Tell me a short story"}],
stream=True,
)
for chunk in stream:
if chunk.choices and chunk.choices[0].delta.content:
print(chunk.choices[0].delta.content, end="")const stream = await client.chat.completions.create({
model: "gpt-6.1-sol",
messages: [{ role: "user", content: "Tell me a short story" }],
stream: true,
});
for await (const chunk of stream) {
process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}#Generate images, video & music
/v1/generateCreate an image, a video or a music track with any media model. The request starts a job and returns straight away with status queued. Get the result from GET /v1/jobs/{id} or a webhook.
Body parameters
modelstringrequiredveo-3.1-fast, gpt-image-2, seedance-2.0. The model decides whether the job is an image, video or music job.promptstringrequirednegative_promptstringimage_urlsarray of stringsend_image_urlstringaspect_ratiostring16:9, 9:16, 1:1, 4:3, 3:4, 21:9.resolutionstring1K, 2K, 4K. Video: 480p, 720p, 1080p, 4k.durationintegeraudiobooleannintegerseedintegerlyricsstringstylestringupbeat pop, female vocals.instrumentalbooleancallback_urlstringmetadataobjectGET /v1/models/{id} lists the exact parameters and allowed values. Sending an option a model does not support returns 422 unsupported_parameter.Response
Status 202 Accepted with a job object.
# Image
curl https://api.jailabs.ai/v1/generate \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A cozy log cabin by a lake at sunrise, photo-real",
"aspect_ratio": "3:2",
"n": 2
}'
# Image-to-video
curl https://api.jailabs.ai/v1/generate \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "kling-3.0-omni",
"prompt": "The camera slowly pushes in as steam rises from the cup",
"image_urls": ["https://example.com/coffee.jpg"],
"duration": 8,
"resolution": "1080p",
"callback_url": "https://yourapp.com/webhooks/jailabs"
}' import os, requests
r = requests.post(
"https://api.jailabs.ai/v1/generate",
headers={"Authorization": f"Bearer {os.environ['JAILABS_API_KEY']}"},
json={
"model": "seedance-2.0",
"prompt": "A drone shot over a misty mountain forest at dawn",
"duration": 10,
"aspect_ratio": "16:9",
"audio": True,
"metadata": {"order_id": "A-1042"},
},
)
job = r.json()
print(job["id"], job["status"]) # job_..., queuedconst res = await fetch("https://api.jailabs.ai/v1/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.JAILABS_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "suno-v5",
prompt: "A happy birthday song for my dog Max",
style: "acoustic pop, warm male vocals",
duration: 60,
}),
});
const job = await res.json();
console.log(job.id, job.status); // job_..., queued{
"id": "job_8f2a91c4",
"object": "job",
"type": "video",
"model": "veo-3.1-fast",
"status": "queued",
"progress": 0,
"created_at": "2026-10-29T10:15:02Z",
"completed_at": null,
"estimated_cost_usd": 0.375,
"cost_usd": null,
"outputs": [],
"error": null,
"metadata": {}
}#Jobs
/v1/jobs/{id}/v1/jobs/v1/jobs/{id}/cancelEvery media request creates a job. Use these endpoints to check a job, list your jobs or cancel one that has not started.
The job object
Fields
idstringjob_.typestringimage, video or music.modelstringstatusstringqueued → processing → completed, or failed / canceled.progressintegeroutputsarrayurl, content_type and, where relevant, width, height and duration.estimated_cost_usdnumbercost_usdnumber0 if it failed or was canceled.errorobjectcode and message explaining why.subaccount_idstringmetadataobjectcreated_at / completed_atstringList jobs
GET /v1/jobs returns your most recent jobs first. Query parameters: status, type, model, subaccount_id, limit (1–100, default 20) and after (a job ID, to get the next page).
Cancel a job
POST /v1/jobs/{id}/cancel cancels a job that is still queued. Jobs that are already processing cannot be canceled. Canceled jobs are not charged.
curl https://api.jailabs.ai/v1/jobs/job_8f2a91c4 \
-H "Authorization: Bearer $JAILABS_API_KEY"job = requests.get(
"https://api.jailabs.ai/v1/jobs/job_8f2a91c4",
headers={"Authorization": f"Bearer {os.environ['JAILABS_API_KEY']}"},
).json()const job = await fetch("https://api.jailabs.ai/v1/jobs/job_8f2a91c4", {
headers: { Authorization: `Bearer ${process.env.JAILABS_API_KEY}` },
}).then((r) => r.json());{
"id": "job_8f2a91c4",
"object": "job",
"type": "video",
"model": "veo-3.1-fast",
"status": "completed",
"progress": 100,
"created_at": "2026-10-29T10:15:02Z",
"completed_at": "2026-10-29T10:16:31Z",
"estimated_cost_usd": 0.375,
"cost_usd": 0.375,
"outputs": [
{
"url": "https://cdn.jailabs.ai/outputs/job_8f2a91c4.mp4",
"content_type": "video/mp4",
"width": 1280,
"height": 720,
"duration": 5
}
],
"error": null,
"subaccount_id": null,
"metadata": {}
}#Models
/v1/models/v1/models/{id}List every model you can use, with its live price and the options it supports. Filter with ?type=chat, image, video or music.
Model fields
idstringname / providerstringtypestringchat, image, video or music.capabilitiesarraytext-to-video, image-to-video, image-edit, vision, tools.parametersobjectpricingobjectofficial_price_usd, with the unit they apply to.statusstringactive, beta or deprecated. Deprecated models show a retires_at date.curl "https://api.jailabs.ai/v1/models?type=video" \
-H "Authorization: Bearer $JAILABS_API_KEY"models = requests.get(
"https://api.jailabs.ai/v1/models",
params={"type": "video"},
headers={"Authorization": f"Bearer {os.environ['JAILABS_API_KEY']}"},
).json()["data"]const { data: models } = await fetch("https://api.jailabs.ai/v1/models?type=video", {
headers: { Authorization: `Bearer ${process.env.JAILABS_API_KEY}` },
}).then((r) => r.json());{
"object": "list",
"data": [
{
"id": "veo-3.1-fast",
"object": "model",
"name": "Veo 3.1 Fast",
"provider": "Google",
"type": "video",
"capabilities": ["text-to-video", "image-to-video"],
"parameters": {
"duration": [4, 6, 8],
"aspect_ratio": ["16:9", "9:16"],
"resolution": ["720p", "1080p"],
"audio": [true, false]
},
"pricing": {
"unit": "second",
"price_usd": 0.075,
"official_price_usd": 0.10
},
"status": "active"
}
]
}#Balance
/v1/balanceCheck how much credit you have. With a sub‑account key, this returns that sub‑account's balance.
Fields
available_usdnumberallocated_to_subaccounts_usdnumberlow_balance_alert_usdnumberbalance.low webhook, if you asked us to set one.curl https://api.jailabs.ai/v1/balance \
-H "Authorization: Bearer $JAILABS_API_KEY"{
"object": "balance",
"currency": "USD",
"available_usd": 182.40,
"allocated_to_subaccounts_usd": 65.00,
"low_balance_alert_usd": 20.00
}#Usage
/v1/usageSee what you spent and on what. Useful for your own reports and for billing your customers.
Query parameters
start_datestringrequiredYYYY-MM-DD.end_datestringrequiredYYYY-MM-DD. Up to 90 days after start_date.group_bystringday (default), model or subaccount.subaccount_idstringcurl "https://api.jailabs.ai/v1/usage?start_date=2026-10-01&end_date=2026-10-31&group_by=model" \
-H "Authorization: Bearer $JAILABS_API_KEY"{
"object": "usage",
"start_date": "2026-10-01",
"end_date": "2026-10-31",
"group_by": "model",
"data": [
{ "model": "veo-3.1-fast", "requests": 412, "cost_usd": 618.75 },
{ "model": "gpt-image-2", "requests": 2310, "cost_usd": 121.80 },
{ "model": "claude-sonnet-5.5", "requests": 15208, "cost_usd": 44.17 }
],
"total_cost_usd": 784.72
}#Sub‑accounts overview
Sub‑accounts let you build your own AI product on jAI Labs and give each of your customers their own credit balance. You buy credits at our price, give credits to your customers, and charge them whatever you like.
How it works
- Create a sub‑account for each customer when they sign up to your app. Store its
idnext to your user. - Allocate credits when your customer pays you. The amount moves from your balance into theirs.
- Make calls for that customer — either with your main key plus the
X-JAI-Subaccountheader, or with a key created for that sub‑account. - Track usage per customer with
GET /v1/usage?subaccount_id=….
402 insufficient_balance — your main balance is never touched by mistake.#Create & manage sub‑accounts
/v1/subaccounts/v1/subaccounts/v1/subaccounts/{id}/v1/subaccounts/{id}These endpoints need your main key.
Body parameters (create)
namestringrequiredexternal_idstringGET /v1/subaccounts?external_id=…spend_limit_usdnumbermetadataobjectUpdate with PATCH to change name, spend_limit_usd or metadata, or set status to suspended to block all calls from that customer (and active to allow them again).
curl https://api.jailabs.ai/v1/subaccounts \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Acme Studio",
"external_id": "user_1042",
"spend_limit_usd": 200
}' # HEADERS = {"Authorization": "Bearer YOUR_JAILABS_API_KEY"} (as in Quickstart)
sub = requests.post(
"https://api.jailabs.ai/v1/subaccounts",
headers=HEADERS,
json={"name": "Acme Studio", "external_id": "user_1042", "spend_limit_usd": 200},
).json()
print(sub["id"]) # sa_...// headers as in Quickstart
const sub = await fetch("https://api.jailabs.ai/v1/subaccounts", {
method: "POST",
headers,
body: JSON.stringify({ name: "Acme Studio", external_id: "user_1042", spend_limit_usd: 200 }),
}).then((r) => r.json());{
"id": "sa_3k9d72mf",
"object": "subaccount",
"name": "Acme Studio",
"external_id": "user_1042",
"status": "active",
"balance_usd": 0,
"spend_limit_usd": 200,
"spent_this_month_usd": 0,
"created_at": "2026-10-29T10:20:00Z",
"metadata": {}
}#Allocate credits
/v1/subaccounts/{id}/creditsMove credit from your main balance to a sub‑account, or take unused credit back.
Body parameters
amount_usdnumberrequirednotestringamount_usd, the request returns 402 insufficient_balance and nothing moves.curl https://api.jailabs.ai/v1/subaccounts/sa_3k9d72mf/credits \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "amount_usd": 25, "note": "Invoice #2291" }' requests.post(
"https://api.jailabs.ai/v1/subaccounts/sa_3k9d72mf/credits",
headers=HEADERS,
json={"amount_usd": 25, "note": "Invoice #2291"},
)await fetch("https://api.jailabs.ai/v1/subaccounts/sa_3k9d72mf/credits", {
method: "POST",
headers,
body: JSON.stringify({ amount_usd: 25, note: "Invoice #2291" }),
});{
"object": "credit_transfer",
"id": "ct_71bd02aa",
"subaccount_id": "sa_3k9d72mf",
"amount_usd": 25,
"subaccount_balance_usd": 25,
"main_balance_usd": 157.40,
"note": "Invoice #2291",
"created_at": "2026-10-29T10:22:41Z"
}#Make calls for a customer
There are two ways to charge a call to one of your customers. Use whichever fits your app.
Option 1 — Main key + header (recommended)
Keep using your main key and add the X-JAI-Subaccount header with the sub‑account ID. You keep one secret in your server and choose the customer per request.
Option 2 — A key for each sub‑account
Create a key that can only spend that sub‑account's credits:
/v1/subaccounts/{id}/keys/v1/subaccounts/{id}/keys/{key_id}The response includes the full key once — store it securely. Delete the key to stop it working.
curl https://api.jailabs.ai/v1/generate \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "X-JAI-Subaccount: sa_3k9d72mf" \
-H "Content-Type: application/json" \
-d '{ "model": "nano-banana-2.1", "prompt": "Product photo of a red sneaker on white" }' from openai import OpenAI
client = OpenAI(base_url="https://api.jailabs.ai/v1", api_key="YOUR_JAILABS_API_KEY")
reply = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "Summarise this email..."}],
extra_headers={"X-JAI-Subaccount": "sa_3k9d72mf"},
)const reply = await client.chat.completions.create(
{
model: "gpt-6-luna",
messages: [{ role: "user", content: "Summarise this email..." }],
},
{ headers: { "X-JAI-Subaccount": "sa_3k9d72mf" } },
);{
"id": "key_2b81c0",
"object": "subaccount_key",
"subaccount_id": "sa_3k9d72mf",
"name": "Acme production",
"key": "jl_sub_6Q2v...shown-only-once",
"created_at": "2026-10-29T10:25:10Z"
}#Webhooks
Instead of checking a job again and again, give us a callback_url (per request) or ask our team to set a default webhook URL for your account. We send a POST request to your URL when something happens.
Events
| Event | When |
|---|---|
job.completed | A media job finished. data is the full job object with outputs. |
job.failed | A media job failed. data is the job object with error. You are not charged. |
balance.low | Your balance (or a sub‑account's) dropped below the alert level you set. |
Check the signature
Every webhook has an X-JAI-Signature header: t=<timestamp>,v1=<signature>. The signature is an HMAC‑SHA256 of <timestamp>.<raw request body>, using your webhook secret (our team sends it to you with your API key). Reject requests with a wrong signature or a timestamp older than 5 minutes.
Respond quickly
Return any 2xx status within 10 seconds, then do the heavy work (like downloading the video) afterwards. If we don't get a 2xx, we retry up to 6 times over 24 hours. Use the event id to ignore duplicates.
{
"id": "evt_0c7e19d2",
"type": "job.completed",
"created_at": "2026-10-29T10:16:32Z",
"data": {
"id": "job_8f2a91c4",
"object": "job",
"status": "completed",
"model": "veo-3.1-fast",
"cost_usd": 0.375,
"outputs": [
{ "url": "https://cdn.jailabs.ai/outputs/job_8f2a91c4.mp4", "content_type": "video/mp4" }
],
"metadata": { "order_id": "A-1042" }
}
}import crypto from "node:crypto";
import express from "express";
const app = express();
const SECRET = process.env.JAILABS_WEBHOOK_SECRET;
app.post("/webhooks/jailabs", express.raw({ type: "application/json" }), (req, res) => {
const header = req.get("X-JAI-Signature") || "";
const { t, v1 } = Object.fromEntries(header.split(",").map((p) => p.split("=")));
const expected = crypto.createHmac("sha256", SECRET)
.update(`${t}.${req.body}`).digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(t)) < 300;
if (!fresh || !v1 || v1.length !== expected.length ||
!crypto.timingSafeEqual(Buffer.from(v1), Buffer.from(expected))) {
return res.status(400).send("Invalid signature");
}
const event = JSON.parse(req.body);
res.sendStatus(200); // reply fast, then do the work
// handle event.type / event.data here
});import hmac, hashlib, time, json, os
from flask import Flask, request, abort
app = Flask(__name__)
SECRET = os.environ["JAILABS_WEBHOOK_SECRET"].encode()
@app.post("/webhooks/jailabs")
def jailabs_webhook():
header = request.headers.get("X-JAI-Signature", "")
parts = dict(p.split("=", 1) for p in header.split(",") if "=" in p)
body = request.get_data()
expected = hmac.new(SECRET, f"{parts.get('t')}.".encode() + body, hashlib.sha256).hexdigest()
if abs(time.time() - int(parts.get("t", 0))) > 300 or not hmac.compare_digest(expected, parts.get("v1", "")):
abort(400)
event = json.loads(body)
# handle event["type"] / event["data"] here
return "", 200#Errors
The API uses normal HTTP status codes. Errors always return the same JSON shape, with a request_id you can quote to support.
| Status | Code | What it means |
|---|---|---|
| 400 | invalid_request | The request is malformed or a value is wrong. param tells you which field. |
| 401 | invalid_api_key | The key is missing, wrong or revoked. |
| 402 | insufficient_balance | Not enough credit (or the sub‑account's spend limit is reached). Nothing was charged. |
| 403 | forbidden | The key cannot do this — e.g. a sub‑account key managing sub‑accounts, or a suspended sub‑account. |
| 404 | not_found | The model, job or sub‑account does not exist. |
| 409 | idempotency_conflict | The same Idempotency-Key was used with a different request body. |
| 422 | unsupported_parameter | The model does not support an option you sent, or the value is not allowed. |
| 422 | content_policy | The model provider refused the prompt or image under its content rules. Not charged. |
| 429 | rate_limited | Too many requests. Wait for the time in the Retry-After header. |
| 500 | server_error | Something went wrong on our side. Safe to retry. |
| 503 | model_unavailable | The model provider is busy or down. Retry later or try another model. |
{
"error": {
"type": "invalid_request_error",
"code": "unsupported_parameter",
"message": "veo-3.1-fast does not support duration 12. Allowed: 4, 6, 8.",
"param": "duration",
"request_id": "req_93ab61f0"
}
}#Rate limits & retries
Default limits
| Limit | Default |
|---|---|
| Requests per minute, per key | 120 |
| Media jobs running at the same time, per account | 10 |
Every response includes X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. Need more? Contact us — we raise limits for growing apps.
Safe retries with Idempotency‑Key
Network problems happen. To retry a POST without being charged twice, send an Idempotency-Key header with a unique value (for example a UUID). If we receive the same key again within 24 hours, we return the first result instead of running the request again.
When to retry
- Retry on
429,500and503, waiting longer each time (1s, 2s, 4s, 8s…). - Don't retry on
400,401,402,403,404or422— fix the request first.
curl https://api.jailabs.ai/v1/generate \
-H "Authorization: Bearer $JAILABS_API_KEY" \
-H "Idempotency-Key: 6f1b2c3e-9a10-4b7e-8c2d-1a2b3c4d5e6f" \
-H "Content-Type: application/json" \
-d '{ "model": "flux-2-pro", "prompt": "Minimal logo of a fox" }' #Switch from OpenAI or OpenRouter
Already using OpenAI, OpenRouter or another gateway for chat? Switching takes three small changes:
| Setting | Change it to |
|---|---|
| Base URL | https://api.jailabs.ai/v1 |
| API key | Your jAI Labs key (jl_live_…) |
| Model name | A jAI Labs model ID from the catalog, e.g. gpt-6.1-sol or claude-opus-5.5 |
Everything else — messages, streaming, tools, JSON mode — works the same. For images, video and music, use /v1/generate, which gives you every media model through one request format.
from openai import OpenAI
# Before
# client = OpenAI(api_key="sk-...")
# After
client = OpenAI(
base_url="https://api.jailabs.ai/v1",
api_key="jl_live_...",
)import OpenAI from "openai";
// Before: new OpenAI({ apiKey: "sk-..." })
const client = new OpenAI({
baseURL: "https://api.jailabs.ai/v1",
apiKey: process.env.JAILABS_API_KEY,
});#No‑code tools (n8n, Make, Zapier)
You don't need to write code. Any tool with an HTTP Request step can use jAI Labs:
- Add an HTTP Request step and set the method to
POST. - Set the URL to
https://api.jailabs.ai/v1/chat/completions(text) orhttps://api.jailabs.ai/v1/generate(images, video, music). - Add a header
Authorizationwith the valueBearer YOUR_KEY, andContent-Typewithapplication/json. - Paste the JSON body from any example on this page.
- For media, add a Wait step and a second HTTP Request to
GET https://api.jailabs.ai/v1/jobs/<id>— or use a webhook trigger as yourcallback_url.
#Best practices
- Keep keys on your server. Never ship a key inside a website or mobile app.
- Use webhooks for media. They are faster and cheaper to run than polling.
- Download outputs. Output links last 7 days — copy files to your own storage.
- Handle 402 nicely. Show your users a “top up” message instead of an error.
- Set spend limits on sub‑accounts so one customer can never overspend.
- Send an Idempotency‑Key on every POST you might retry.
- Read prices from
/v1/modelsinstead of hard‑coding them — makers change prices. - Log the
request_idfrom errors. It helps our team find your request quickly.
#Model catalog
Use the Model ID in the model field of your request. Click an ID to copy it. Music and voice models (such as suno-v5) and new models are added all the time — GET /v1/models always has the full, live list with prices.
💬 Chat models 9
| Model | Model ID | Made by |
|---|---|---|
| GPT‑6.1 Sol | gpt-6.1-sol | OpenAI |
| GPT‑6 Luna | gpt-6-luna | OpenAI |
| Claude Opus 5.5 | claude-opus-5.5 | Anthropic |
| Claude Sonnet 5.5 | claude-sonnet-5.5 | Anthropic |
| Claude Haiku 5.5 | claude-haiku-5.5 | Anthropic |
| Gemini 4 Argon | gemini-4-argon | |
| DeepSeek V4.1 Flash | deepseek-v4.1-flash | DeepSeek |
| Muse Spark Open | muse-spark-open | Meta |
| Muse Wonder | muse-wonder | Meta |
🎨 Image models 24
| Model | Model ID | Made by |
|---|---|---|
| GPT Image 2.5 Sunburst | gpt-image-2.5-sunburst | OpenAI |
| GPT Image 2 | gpt-image-2 | OpenAI |
| GPT Image 1.5 | gpt-image-1.5 | OpenAI |
| 4o Image | 4o-image | OpenAI |
| Imagen 4 Ultra | imagen-4-ultra | |
| Imagen 4 Standard | imagen-4 | |
| Imagen 4 Fast | imagen-4-fast | |
| Nano Banana 2.1 | nano-banana-2.1 | |
| Flux 3 Klein | flux-3-klein | Black Forest Labs |
| Flux 2 Pro | flux-2-pro | Black Forest Labs |
| Flux 2 Flex | flux-2-flex | Black Forest Labs |
| Seedream 5 Pro | seedream-5-pro | ByteDance |
| Seedream 5 Flash | seedream-5-flash | ByteDance |
| Seedream 5.0 Lite | seedream-5-lite | ByteDance |
| Seedream 4.5 | seedream-4.5 | ByteDance |
| Seedream v4 | seedream-4 | ByteDance |
| Ideogram v3 Turbo | ideogram-v3-turbo | Ideogram |
| Ideogram v3 Balanced | ideogram-v3-balanced | Ideogram |
| Ideogram v3 Quality | ideogram-v3-quality | Ideogram |
| Qwen Image 3.0 Pro | qwen-image-3-pro | Alibaba |
| Qwen Image 3.0 | qwen-image-3 | Alibaba |
| Qwen Image 2 | qwen-image-2 | Alibaba |
| z‑image | z-image | Alibaba |
| Grok Imagine Image 2.0 | grok-imagine-image-2 | xAI |
🎬 Video models 16
| Model | Model ID | Made by |
|---|---|---|
| Veo 3.1 Quality | veo-3.1-quality | |
| Veo 3.1 Fast | veo-3.1-fast | |
| Veo 3.1 Lite | veo-3.1-lite | |
| Sora 2 | sora-2 | OpenAI |
| Kling 3.0 Omni | kling-3.0-omni | Kling |
| Seedance 2.0 | seedance-2.0 | ByteDance |
| Seedance v1 Pro | seedance-1-pro | ByteDance |
| Seedance v1 Lite | seedance-1-lite | ByteDance |
| Hailuo H3 | hailuo-h3 | MiniMax |
| Hailuo 2.3 | hailuo-2.3 | MiniMax |
| Wan 2.7 | wan-2.7 | Alibaba |
| Wan 2.2 | wan-2.2 | Alibaba |
| HappyHorse 1.1 | happyhorse-1.1 | Alibaba |
| Grok Imagine Video | grok-imagine-video | xAI |
| Runway Aleph | runway-aleph | Runway |
| PixVerse V6 | pixverse-v6 | PixVerse |
#Support
When you contact us about a failed request, include the request_id from the error response — it helps us find it straight away.
#Changelog
- OpenAI‑compatible chat completions with streaming and tools
- One
/v1/generateendpoint for image, video and music models - Jobs, webhooks and idempotent requests
- Sub‑accounts with credit allocation, spend limits and sub‑account keys
- Live model list with pricing, balance and usage reports