Overview
The Cuppa AI API is a REST service. You submit a source (a PDF, a document, or a URL),
receive a job_id, poll its status, then download the finished video.
Generation is asynchronous because rendering a narrated video takes tens of seconds.
Supported generation types:
- PDF → video — upload a PDF (up to 50 MB).
- Document → video — send structured text plus a prompt.
- URL → video — send a public article URL to be scraped.
- Poster — generate a single-page research poster PDF.
- Video + poster — generate both from one upload.
Authentication
Protected endpoints require a Firebase ID token in the
Authorization header:
Authorization: Bearer <firebase_id_token>
Create accounts with POST /api/signup, or use Firebase Auth directly.
You can exchange the returned custom token for an ID token, then send that ID token
on every request. Requests without a valid token receive 401.
Create an account
POST/api/signup
Form fields: email, password.
curl -X POST "https://www.cuppai.top/api/signup" \
-F "email=you@example.com" \
-F "password=your-password"
Response:
{ "uid": "...", "customToken": "..." }
API keys (third-party integrations)
Create a key in the dashboard. Send it as
X-API-Key or as a Bearer token:
X-API-Key: sk_live_...
Authorization: Bearer sk_live_...
Keys are hashed at rest, can be revoked, and work on all protected endpoints.
All routes are also available under /api/v1/... (same handlers).
Rate limits & quotas
Each key defaults to 60 requests/minute and 1,000 requests/month.
Exceeding either returns 429. Both are configurable when creating the key.
Webhooks
Set webhook_url when creating a key. We POST job.completed / job.failed
to it, signed with X-Cuppa-Signature: sha256=<hmac> using the
webhook_secret returned once at creation.
{
"event": "job.completed",
"job_id": "...",
"status": "completed",
"type": "video_pdf",
"title": "...",
"video_url": "...",
"poster_url": null,
"duration_seconds": 42.1
}
Quickstart
1. Submit a PDF.
curl -X POST "https://www.cuppai.top/api/generate" \
-H "Authorization: Bearer $TOKEN" \
-F "job_id=my-job-001" \
-F "generation_mode=video" \
-F "voice=en-US-GuyNeural" \
-F "pdf_file=@lecture.pdf;type=application/pdf"
{ "status": "accepted", "job_id": "my-job-001" }
2. Poll the job.
curl "https://www.cuppai.top/api/status-no-auth/my-job-001"
{
"status": "completed",
"progress": 100,
"video_url": "https://cuppai.top/api/download/my-job-001/video",
"poster_url": "https://cuppai.top/api/download/my-job-001/poster"
}
3. Download the MP4.
curl -L "https://cuppai.top/api/download/my-job-001/video" -o video.mp4
Endpoint reference
POST/api/generate
Create a video (and/or poster) from an uploaded PDF. multipart/form-data, auth required.
| Field | Type | Description |
|---|---|---|
| job_id | string | Your client-side job identifier. |
| generation_mode | string | video, poster or both. |
| voice | string | Neural voice ID. Default en-US-GuyNeural. |
| pdf_file | file | PDF source, max 50 MB. |
Response: { "status": "accepted", "job_id": "..." }
POST/api/generate-from-doc
Create a video from structured text. JSON body, auth required.
{
"title": "Introduction to Photosynthesis",
"document_text": "Full lesson content ...",
"user_prompt": "Create a tutorial video about photosynthesis",
"max_slides": 10,
"motion": 0,
"voice": "en-US-GuyNeural"
}
max_slides, motion and voice are optional. max_slides: 0 uses the default length.
Response: { "job_id": "..." }
POST/api/generate-from-url
Scrape a public article URL and generate a video. Form field url, auth required.
curl -X POST "https://www.cuppai.top/api/generate-from-url" \
-H "Authorization: Bearer $TOKEN" \
-F "url=https://example.com/blog-post"
Response: { "job_id": "url-..." }
POST/api/generate-poster
Generate a research poster PDF. Form fields topic and optional context, auth required.
curl -X POST "https://www.cuppai.top/api/generate-poster" \
-H "Authorization: Bearer $TOKEN" \
-F "topic=Photosynthesis" \
-F "context=Grade 12 biology"
Response: { "job_id": "poster-..." }
GET/api/status/{job_id}
Authenticated job status. Returns the full job object.
GET/api/status-no-auth/{job_id}
Same payload without auth — convenient for polling from a browser or a webhook worker. Treat job IDs as unguessable; do not expose private content through them.
HTTP 200 with
{"error":"Not found"} (not 404). Always check the error
field as well as the HTTP status. The authenticated /api/status/{job_id}
endpoint returns 404 for a missing job.
GET/api/download/{job_id}/video
Download the rendered MP4 (video/mp4).
GET/api/download/{job_id}/poster
Download the generated poster PDF.
POST/api/verify-payment
Verify a Flutterwave transaction. Query params transaction_id and optional tx_ref, auth required.
Invalid or failed transactions return 400. Repeated transaction IDs are not credited twice.
POST/api/keys
Create an API key. JSON body {"name":"My backend"}. The raw key is returned once.
GET/api/keys
List your keys (name, prefix, created, last used, active). Secrets are never returned.
DELETE/api/keys/{key_id}
Revoke a key immediately.
GET/api/account
Credits, free-videos-today, plan and available credit packs.
GET/api/usage
Totals, 14-day activity and recent jobs for the authenticated account.
POST/api/create-payment
Create a Flutterwave checkout link. JSON body {"pack_id":"pro_ugx"}.
GET/api/jobs/{job_id}/signed-url
Get an expiring download URL. Query params kind=video|poster and ttl (seconds, max 86400).
GET/api/receipts
List payment receipts for the authenticated account.
GET/api/receipts/{receipt_no}
View a printable payment receipt (HTML).
GET/api/admin/stats
Admin-only platform monitoring: users, videos, jobs, revenue, API keys, recent activity.
Research paper → chat → video
Search free sources (arXiv + OpenAlex), ingest a PDF, chat with it, add notes, then generate a tutorial video.
# 1. Search
curl "https://www.cuppai.top/api/research/search?q=attention+is+all+you+need" \
-H "X-API-Key: $API_KEY"
# 2. Ingest (use pdf_url from search)
curl -X POST "https://www.cuppai.top/api/research/ingest" \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{"pdf_url":"https://arxiv.org/pdf/1706.03762","title":"Attention Is All You Need"}'
# 3. Chat
curl -X POST "https://www.cuppai.top/api/research/chat" \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{"paper_id":"...","question":"What is the main contribution?","synthesize":true}'
# 4. Save notes / corrections
curl -X POST "https://www.cuppai.top/api/research/notes" \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{"paper_id":"...","notes":"Exam focus: self-attention, positional encoding."}'
# 5. Generate tutorial video
curl -X POST "https://www.cuppai.top/api/research/generate" \
-H "X-API-Key: $API_KEY" -H "Content-Type: application/json" \
-d '{"paper_id":"...","max_slides":10,"motion":1}'
Web UI: cuppai.top/research
Job lifecycle
Poll until status is completed or failed.
| Status | Meaning |
|---|---|
| pending | Accepted and queued. |
| ai_thinking | AI is writing the scene script. |
| processing | Extracting content / preparing assets. |
| rendering | Rendering slides, narration and assembling video. |
| completed | Finished — download via the URLs in the job. |
| failed | An error occurred; see error. |
Errors & limits
| Code | Meaning |
|---|---|
| 400 | Bad request, e.g. a URL could not be scraped. |
| 401 | Missing or invalid Firebase ID token. |
| 402 | Insufficient credits / daily free video already used. |
| 404 | Job or resource not found. |
| 429 | Rate limited by the AI backend. Retry with backoff. |
Credits: video generation costs 15 credits; new accounts get three free videos per day; posters are free.
Limits: PDF uploads up to 50 MB. Generation is CPU/GPU bound, so poll every 5–10 seconds rather than hammering the API.
Code examples
Python
import requests, time
BASE = "https://www.cuppai.top"
TOKEN = "<firebase_id_token>"
H = {"Authorization": f"Bearer {TOKEN}"}
# 1. Submit a PDF
with open("lecture.pdf", "rb") as f:
r = requests.post(f"{BASE}/api/generate", headers=H, files={"pdf_file": f},
data={"job_id": "job-001", "generation_mode": "video",
"voice": "en-US-GuyNeural"})
job_id = r.json()["job_id"]
# 2. Poll
while True:
status = requests.get(f"{BASE}/api/status-no-auth/{job_id}").json()
if status["status"] in ("completed", "failed"):
break
time.sleep(5)
# 3. Download
if status["status"] == "completed":
video = requests.get(status["video_url"])
open("output.mp4", "wb").write(video.content)
Node.js
const BASE = "https://www.cuppai.top";
async function generate(formData, token) {
const res = await fetch(`${BASE}/api/generate`, {
method: "POST",
headers: { Authorization: `Bearer ${token}` },
body: formData,
});
return res.json(); // { status, job_id }
}
async function poll(jobId) {
const res = await fetch(`${BASE}/api/status-no-auth/${jobId}`);
return res.json();
}
Job status response
{
"status": "completed",
"progress": 100,
"type": "pdf",
"mode": "video",
"video_url": "https://cuppai.top/api/download/27538/video",
"poster_url": null,
"error": null
}
mode, voice and
pdf_path; document and URL jobs include title and
prompt; poster jobs expose poster_url instead of
video_url. Treat video_url/poster_url as the
authoritative links when present.
How it works
The generation pipeline:
PDF / text / URL
│
▼
Text extraction ──► AI scene script (Azure OpenAI, gpt-5-mini)
│
▼
Scene rendering ──► Beamer + TikZ diagrams, charts, formulas
│
▼
Narration ──► Neural TTS (Azure / Edge voices)
│
▼
Assembly ──► ffmpeg ──► H.264 MP4 (+ poster PDF)
Jobs are asynchronous: the API returns immediately with a job_id and a
background worker performs extraction, AI scripting, LaTeX/TikZ rendering, text-to-speech
and video assembly. This keeps requests fast and lets you build progress UIs.
Integration notes
- Store your own copy. Download the MP4 to your own storage immediately after completion; server outputs are temporary.
- Retry 429s. The AI step is rate-limited by token throughput. Retry with exponential backoff.
- Poll politely. 5–10 second intervals are enough; generation typically takes 30–120 seconds depending on length.
- Use the Moodle plugin. For LMS deployments, the open-source
mod_aitutorialplugin already integrates this API. - Need help? Contact support or email nkugwamarkwilliam@gmail.com.