Quickstart
This page shows how to use OpenAPI for a basic content-creation flow.
The examples below use slides_video for a basic flow. The actual types, ratios, page counts, qualities, languages, voices, and styles still need to come from /catalog.
Get the API Key Before You Start
OpenAPI uses the user's own API key.
If you do not have one yet, go to the main site's API Key page:
- activate the API key
- copy the API key
- come back here and validate it with
GET /me
If you are integrating for end users, this step should be part of your connect flow.
Prepare
export KGP_BASE_URL="https://api.kpainter.ai/openapi/v1"export KGP_API_KEY="<your_api_key>"
import requests BASE_URL = "https://api.kpainter.ai/openapi/v1"HEADERS = { "X-KGP-Api-Key": "<your_api_key>",}
Step 1: Validate the Key
Once you have the key, validate it before creating anything:
curl -s "$KGP_BASE_URL/me" \ -H "X-KGP-Api-Key: $KGP_API_KEY"
me_response = requests.get(f"{BASE_URL}/me", headers=HEADERS, timeout=30)me_response.raise_for_status()print(me_response.json())
At minimum, confirm:
- the key is valid
- it is a user-level key that can create content
Step 2: Read the Catalog
curl -s "$KGP_BASE_URL/catalog" \ -H "X-KGP-Api-Key: $KGP_API_KEY"
catalog_response = requests.get(f"{BASE_URL}/catalog", headers=HEADERS, timeout=30)catalog_response.raise_for_status()catalog = catalog_response.json()print(catalog["content_types"])
Use it to load:
- supported content types
- per-type aspect ratio, quality, duration, and page limits
- languages, voices, and styles
Step 3: Create Content
curl -s "$KGP_BASE_URL/creations" \ -H "Content-Type: application/json" \ -H "X-KGP-Api-Key: $KGP_API_KEY" \ -d '{ "type": "slides_video", "prompt": "Explain how transformer attention works in 6 pages", "language": "en", "aspect_ratio": "16:9", "scene_count": 6 }'
create_payload = { "type": "slides_video", "prompt": "Explain how transformer attention works in 6 pages", "language": "en", "aspect_ratio": "16:9", "scene_count": 6,} create_response = requests.post( f"{BASE_URL}/creations", headers={**HEADERS, "Content-Type": "application/json"}, json=create_payload, timeout=30,)create_response.raise_for_status() creation = create_response.json()creation_id = creation["creation_id"]job_id = creation["job"]["job_id"] print({"creation_id": creation_id, "job_id": job_id})
A basic request usually contains:
typeprompt- the required type-specific fields
Step 4: Poll the Job
curl -s "$KGP_BASE_URL/creations/jobs/<job_id>" \ -H "X-KGP-Api-Key: $KGP_API_KEY"
import time while True: job_response = requests.get( f"{BASE_URL}/creations/jobs/{job_id}", headers=HEADERS, timeout=30, ) job_response.raise_for_status() job = job_response.json() print(job["status"], job.get("progress_pct"), job.get("current_step")) if job["status"] == "succeeded": break if job["status"] in {"failed", "cancelled"}: raise RuntimeError(job) time.sleep(3)
When the job succeeds, fetch the detail response.
Step 5: Read the Detail
curl -s "$KGP_BASE_URL/creations/<creation_id>" \ -H "X-KGP-Api-Key: $KGP_API_KEY"
detail_response = requests.get( f"{BASE_URL}/creations/{creation_id}", headers=HEADERS, timeout=30,)detail_response.raise_for_status()detail = detail_response.json() print(detail["main_url"])print(detail.get("artifacts", []))print(detail.get("scenes", []))
This is where you read:
main_urlartifacts[]scenes[]
Endpoints Used In This Flow
GET /meGET /catalogPOST /creationsGET /creations/jobs/{job_id}GET /creations/{creation_id}
Read Next
API Referencefor grouped endpointsAuthenticationfor key validation, errors, and security expectations- the API Key page for viewing, activating, or rotating the key
- the content-type pages for scenario-specific guidance
