Hızlı Başlangıç
Bu yürüyüş yoluyla, Minimum Açıklama Videosu oluşturulur. Üretim üssü URL şudur:
https://api.kpainter.ai/openapi/v1
1. Bir API anahtarı hazırlayın
Anahtarınızı etkinleştirin ve kopyalayın API Anahtar Sayfa, sonra bir server-side ortamında değişken tutun. Hiçbir zaman tarayıcı kodunda veya loglarda göndermeyin.
export KPAINTER_API_KEY="<your_api_key>"export KPAINTER_BASE_URL="https://api.kpainter.ai/openapi/v1"
import requests BASE_URL = "https://api.kpainter.ai/openapi/v1"HEADERS = { "Authorization": "Bearer <your_api_key>",}
2. Hesabınızı kontrol edin
curl -s "$KPAINTER_BASE_URL/me" \ -H "Authorization: Bearer $KPAINTER_API_KEY"
me = requests.get(f"{BASE_URL}/me", headers=HEADERS, timeout=30)me.raise_for_status()print(me.json())
3. Mevcut Yetenekleri Okuyun
curl -s "$KPAINTER_BASE_URL/capabilities" \ -H "Authorization: Bearer $KPAINTER_API_KEY"
capabilities = requests.get( f"{BASE_URL}/capabilities", headers=HEADERS, timeout=30,).json()print(capabilities["products"])
Bu cevaptan uzunluk, ses, şablon ve ifade tarzını seçin. Örnek değerleri kalıcı yapılandırma olarak ele almayın.
4. İçeriği oluşturmak
curl -s "$KPAINTER_BASE_URL/creations" \ -H "Authorization: Bearer $KPAINTER_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "type": "video", "prompt": "Explain the customer escalation process to new employees", "instructions": "Use a concise professional tone and preserve source terminology", "max_credits": 300, "video": { "duration_seconds": 120, "aspect_ratio": "16:9", "language": "en" } }'
payload = { "type": "video", "prompt": "Explain the customer escalation process to new employees", "instructions": "Use a concise professional tone and preserve source terminology", "max_credits": 300, "video": { "duration_seconds": 120, "aspect_ratio": "16:9", "language": "en", },}response = requests.post( f"{BASE_URL}/creations", headers=HEADERS, json=payload, timeout=30,)response.raise_for_status()creation_id = response.json()["id"]
5. Gelişme
Tasarım ve düzenleme asinkron. Geri dönüştürülen oluşturma kimliğini tutun ve aynı sonuçları sorgulayın.
import time while True: response = requests.get( f"{BASE_URL}/creations/{creation_id}", headers=HEADERS, timeout=30, ) response.raise_for_status() creation = response.json() print( creation["status"], creation["progress_pct"], creation.get("estimated_remaining_seconds"), creation.get("estimated_credits"), ) if creation["status"] in {"ready", "failed", "paused"}: break time.sleep(5)
6. Sonuçları okuyun
Sadece durum hazır olduğunda veya has_usable_delivery doğru olduğunda çıkışları okuyun:
outputs = requests.get( f"{BASE_URL}/creations/{creation_id}/outputs", headers=HEADERS, timeout=30,)outputs.raise_for_status()print(outputs.json()["outputs"])
URL’ler yetkili olarak geri döndü. Depolama yolları oluşturmayın.
Kaynak dosyaları ekleyin
Her kaynağı POST / dosyaları ile yükleyin, sonra file_id'ini input_file_ids'e dahil edin. Üç ürün yüklenen dosyaları kabul eder. bakın Oluştur ve al Bir örnek için.
