API referenceEndpoints
Base URL https://api.lotusai.io.vn. All requests and responses are JSON. Every endpoint except GET /v1/models needs Authorization: Bearer <token>.
POST/v1/auth/firebasepublic
Sign in with Google/Apple through Firebase Auth, then send the Firebase ID token here. The backend verifies it with Firebase Admin and returns a session token; the user is created on first sign-in (keyed by Firebase UID).
Request
{ "id_token": "<firebase ID token>" }Response 200
{
"token": "<session_token>",
"user_id": "uuid",
"created": true
}
GET/v1/modelspublic
List active models and their credit price.
Response 200
{ "models": [
{ "slug": "flux-schnell",
"name": "Flux.1 Schnell",
"credits": 1 }
]}
POST/v1/images/jobsbearer
Create an image job. Validates input, holds credits, queues the job. One job = one image. Pass an idempotency_key so retries never double-charge.
Request
{
"model": "flux-schnell",
"prompt": "a red fox in snow",
"params": {},
"idempotency_key": "optional"
}Response 201
{ "id": "job_uuid",
"status": "queued" }
// 402 out of credits
// 429 rate-limited
// 503 daily cap reached
GET/v1/images/jobs/{id}bearer
Get a job's status. status goes queued → running → succeeded | failed. On failed, credits are refunded automatically.
Request
GET /v1/images/jobs/job_uuid
Response 200
{
"id": "job_uuid",
"status": "succeeded",
"model": "flux-schnell",
"result_urls": ["https://..."],
"error": null
}
POST/v1/images/quotebearer
Price a model and check the current balance before creating a job.
Request
{ "model": "flux-schnell" }Response 200
{ "model": "flux-schnell",
"credits": 1,
"balance": 50,
"affordable": true }
GET/v1/usagebearer
Current credit balance and usage summary.
Response 200
{ "balance": 48,
"jobs": 12,
"spent_credits": 14 }
POST/v1/billing/purchasebearer
Add credits from an Apple/Google in-app purchase. Idempotent per receipt — the same transaction never credits twice. source = apple | google.
Request
{
"source": "apple",
"transaction_id": "<from store>",
"product_id": "credits_100"
}Response 200
{ "credited": true,
"balance": 148 }
// credited:false = already applied
POST/v1/billing/subscribebearer
Activate or confirm a subscription for the signed-in user — call after a successful store purchase. Grants that plan's monthly credits, idempotent per billing period. product_id = sub_lite | sub_plus | sub_pro | sub_studio. status = active | grace | canceled | expired.
Request
{
"provider": "apple",
"original_txn_id": "<from store>",
"product_id": "sub_plus",
"period_key": "<renewal id>"
}Response 200
{ "status": "active",
"credited": true,
"balance": 698 }
// credited:false = period already granted
GET/v1/billing/subscriptionbearer
Current subscription state for the signed-in user.
Request
GET /v1/billing/subscription
Response 200
{ "subscriptions": [
{ "provider": "apple",
"product_id": "sub_plus",
"status": "active",
"current_period_end": "..." }
]}
POST/v1/webhooks/{provider}store
Store server notifications (renewals, cancellations) — called by Apple/Google, not the app. Finds the user by original_txn_id and grants the new period's credits (idempotent). provider = apple | google.
Request
// store-signed notification payload
// (Apple ASSN v2 / Google RTDN)
Response 200
{ "ok": true,
"status": "active",
"credited": true }
Error codes
| HTTP | Meaning | What the app should do |
| 400 | Invalid input / content policy / unknown product | Fix input, show a message |
| 401 | Missing / invalid / expired token | Re-authenticate |
| 402 | Not enough credits | Prompt to buy more (IAP) |
| 404 | Job not found / not yours | Ignore |
| 429 | Rate limit exceeded | Back off and retry |
| 503 | Daily spend cap reached | Try again later |