スピードスタート
このウォーキングツアーは、最小限の説明ビデオを作成します。 生産ベースのURLは:
https://api.kpainter.ai/openapi/v1
1. APIキーの準備
キーを起動してコピーする API キーページその後、サーバーサイド環境の変数に保管します。 決してブラウザコードやログに送信しないでください。
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.アカウントを確認する
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.現在の能力について読む
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"])
この回答から時間、声、テンプレート、表現スタイルを選択します。 例値を永続的な構成として扱わないでください。
4.コンテンツ作成
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位 ポール進歩
作成と編集は非同期です。 返信された作成IDを保持し、同じ結果を検索します。
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.出力の読み方
出力は、状態が完了した場合にのみ読み取るか、あるいは_usable_delivery が真実である場合にのみ読み取る:
outputs = requests.get( f"{BASE_URL}/creations/{creation_id}/outputs", headers=HEADERS, timeout=30,)outputs.raise_for_status()print(outputs.json()["outputs"])
トレートは、権限のあるURLを返します。 ストレージパスを作らないでください。
ソースファイルを追加
各ソースを POST / ファイルでアップロードし、その後 input_file_ids にファイル_id を含みます。 すべての3つの製品がアップロードされたファイルを受け入れます。 見る 創造・取り戻し 例として。
