はじめに · 約5分 · 検証済 2026-12-02
APIクイックスタート:3分で最初の動画を生成
Bearer hwk_live_* キーで認証し、POST https://happywanvideo.ai/api/jobs へWan 3.0またはHappyHorse 1.1の動画生成ジョブを送信して GET /api/jobs/{id} でポーリングすることで、HappyWanのリリース初日から即座に対応できる統合を構築します。
1. 統一シングルエンドポイント設計
HappyWan Videoは、Alibabaの稼働中動画生成モデル(wan-3.0、wan-3.0-pro、happyhorse-1.1)とリリース前フラッグシップ(happywan-1.0、2026年12月公開予定)を単一の正規化されたRESTインターフェースで公開しています。モデル世代ごとに異なるフィールド名(duration と duration_seconds、ratio と aspect_ratio、audio と暗黙的オーディオなど)を個別に保守する必要はなく、クライアントから POST https://happywanvideo.ai/api/jobs へ一貫したJSONペイロードを送信するだけで完結します。
すべての新規アカウントには50クレジットの無料トライアルが付与されます。curl、TypeScript、Pythonのいずれからでも、ネイティブ音声付きの480p Wan 3.0動画(5クレジット/秒)なら10秒間、720p動画(10クレジット/秒)なら5秒間の実環境レンダリングをすぐに試せます。
happywan-1.0 のリリース前保護について
2026-12-02現在、engine: "happywan-1.0" を指定して送信すると、Alibabaによる一般公開が開始されるまでは課金なしのリリース前通知(消費クレジット0)が返却されます。現在は wan-3.0、wan-3.0-pro、happyhorse-1.1 を対象に開発・テストを進め、公開当日に文字列を1つ切り替えるだけで本番移行できます。
2. Bearer APIキー(`hwk_live_*`)の発行
HappyWan Studioにサインインし、/studio/api-keys を開いてスコープ付きAPIキーを発行します。キーは hwk_live_ で始まり、生成直後に1度だけ表示され、サーバー側にはSHA-256ダイジェストのみが保存されます。以降すべてのリクエストで、標準のHTTP Authorization ヘッダーにキーを設定して送信してください。
export HAPPYWAN_API_KEY="hwk_live_your_generated_token_here"
3. 動画生成ジョブの送信と完了までのポーリング
動画生成は非同期で実行されます。POST /api/jobs が成功すると、1秒あたりの必要クレジットがアトミックに仮押さえされ、レンダリングがキューへ投入されたうえで id、status(queued または processing)、creditsCharged を含むジョブオブジェクトが返却されます。status が completed(outputUrl を参照)または failed / refunded に遷移するまで、3〜5秒間隔で GET /api/jobs/{id} をポーリングしてください。
curl -X POST https://happywanvideo.ai/api/jobs \
-H "Authorization: Bearer $HAPPYWAN_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"engine": "wan-3.0",
"mode": "text-to-video",
"prompt": "Slow 35mm tracking shot through a sunlit Tokyo record shop as vinyl sleeves flutter near an open window. Warm analog hum, soft wooden floor footsteps.",
"duration": 5,
"resolution": "480p",
"aspectRatio": "16:9",
"generateAudio": true,
"enablePromptExpansion": false
}'curl -X GET https://happywanvideo.ai/api/jobs/hwj_0123456789abcdef \ -H "Authorization: Bearer $HAPPYWAN_API_KEY"
const BASE = "https://happywanvideo.ai";
async function renderClip() {
const headers = {
Authorization: `Bearer ${process.env.HAPPYWAN_API_KEY}`,
"Content-Type": "application/json",
};
const createRes = await fetch(`${BASE}/api/jobs`, {
method: "POST",
headers,
body: JSON.stringify({
engine: "wan-3.0",
mode: "text-to-video",
prompt: "Macro slow-motion pour of iced matcha into fluted glass on travertine stone. Crisp ice clinks, quiet morning kitchen.",
duration: 5,
resolution: "720p",
aspectRatio: "9:16",
generateAudio: true,
}),
});
const created = await createRes.json();
if (!createRes.ok) throw new Error(created.error || "Job creation failed");
const jobId = created.job.id as string;
while (true) {
await new Promise((r) => setTimeout(r, 4000));
const pollRes = await fetch(`${BASE}/api/jobs/${jobId}`, { headers });
const { job } = await pollRes.json();
if (job.status === "completed") return job.outputUrl as string;
if (job.status === "failed" || job.status === "refunded") {
throw new Error(job.errorMessage || "Render failed; credits refunded.");
}
}
}