メインコンテンツへスキップ
POST
/
v1
/
videos
/
generations
curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
  }'
import requests

url = "https://api.apimart.ai/v1/videos/generations"

payload = {
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/videos/generations";

const payload = {
  model: "wan2.6",
  prompt: "草原を走るかわいい猫",
  aspect_ratio: "16:9",
  resolution: "720p",
  duration: 5
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://api.apimart.ai/v1/videos/generations"

    payload := map[string]interface{}{
        "model":        "wan2.6",
        "prompt":       "草原を走るかわいい猫",
        "aspect_ratio": "16:9",
        "resolution":   "720p",
        "duration":     5,
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://api.apimart.ai/v1/videos/generations";

        String payload = """
        {
          "model": "wan2.6",
          "prompt": "草原を走るかわいい猫",
          "aspect_ratio": "16:9",
          "resolution": "720p",
          "duration": 5
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Authorization", "Bearer <token>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
<?php

$url = "https://api.apimart.ai/v1/videos/generations";

$payload = [
    "model" => "wan2.6",
    "prompt" => "草原を走るかわいい猫",
    "aspect_ratio" => "16:9",
    "resolution" => "720p",
    "duration" => 5
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
require 'net/http'
require 'json'
require 'uri'

url = URI("https://api.apimart.ai/v1/videos/generations")

payload = {
  model: "wan2.6",
  prompt: "草原を走るかわいい猫",
  aspect_ratio: "16:9",
  resolution: "720p",
  duration: 5
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = http.request(request)
puts response.body
import Foundation

let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

let payload: [String: Any] = [
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error)")
        return
    }

    if let data = data, let responseString = String(data: data, encoding: .utf8) {
        print(responseString)
    }
}

task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var url = "https://api.apimart.ai/v1/videos/generations";

        var payload = @"{
            ""model"": ""wan2.6"",
            ""prompt"": ""草原を走るかわいい猫"",
            ""aspect_ratio"": ""16:9"",
            ""resolution"": ""720p"",
            ""duration"": 5
        }";

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

        var content = new StringContent(payload, Encoding.UTF8, "application/json");
        var response = await client.PostAsync(url, content);
        var result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "リクエストパラメータが無効です",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "認証に失敗しました。APIキーを確認してください",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "残高が不足しています。チャージしてください",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 429,
    "message": "リクエストが多すぎます。しばらくしてからお試しください",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "サーバー内部エラー。しばらくしてからお試しください",
    "type": "server_error"
  }
}
curl --request POST \
  --url https://api.apimart.ai/v1/videos/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
  }'
import requests

url = "https://api.apimart.ai/v1/videos/generations"

payload = {
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
}

headers = {
    "Authorization": "Bearer <token>",
    "Content-Type": "application/json"
}

response = requests.post(url, json=payload, headers=headers)

print(response.json())
const url = "https://api.apimart.ai/v1/videos/generations";

const payload = {
  model: "wan2.6",
  prompt: "草原を走るかわいい猫",
  aspect_ratio: "16:9",
  resolution: "720p",
  duration: 5
};

const headers = {
  "Authorization": "Bearer <token>",
  "Content-Type": "application/json"
};

fetch(url, {
  method: "POST",
  headers: headers,
  body: JSON.stringify(payload)
})
  .then(response => response.json())
  .then(data => console.log(data))
  .catch(error => console.error('Error:', error));
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "io/ioutil"
    "net/http"
)

func main() {
    url := "https://api.apimart.ai/v1/videos/generations"

    payload := map[string]interface{}{
        "model":        "wan2.6",
        "prompt":       "草原を走るかわいい猫",
        "aspect_ratio": "16:9",
        "resolution":   "720p",
        "duration":     5,
    }

    jsonData, _ := json.Marshal(payload)

    req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonData))
    req.Header.Set("Authorization", "Bearer <token>")
    req.Header.Set("Content-Type", "application/json")

    client := &http.Client{}
    resp, err := client.Do(req)
    if err != nil {
        panic(err)
    }
    defer resp.Body.Close()

    body, _ := ioutil.ReadAll(resp.Body)
    fmt.Println(string(body))
}
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.net.URI;

public class Main {
    public static void main(String[] args) throws Exception {
        String url = "https://api.apimart.ai/v1/videos/generations";

        String payload = """
        {
          "model": "wan2.6",
          "prompt": "草原を走るかわいい猫",
          "aspect_ratio": "16:9",
          "resolution": "720p",
          "duration": 5
        }
        """;

        HttpClient client = HttpClient.newHttpClient();
        HttpRequest request = HttpRequest.newBuilder()
            .uri(URI.create(url))
            .header("Authorization", "Bearer <token>")
            .header("Content-Type", "application/json")
            .POST(HttpRequest.BodyPublishers.ofString(payload))
            .build();

        HttpResponse<String> response = client.send(request,
            HttpResponse.BodyHandlers.ofString());

        System.out.println(response.body());
    }
}
<?php

$url = "https://api.apimart.ai/v1/videos/generations";

$payload = [
    "model" => "wan2.6",
    "prompt" => "草原を走るかわいい猫",
    "aspect_ratio" => "16:9",
    "resolution" => "720p",
    "duration" => 5
];

$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Authorization: Bearer <token>",
    "Content-Type: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>
require 'net/http'
require 'json'
require 'uri'

url = URI("https://api.apimart.ai/v1/videos/generations")

payload = {
  model: "wan2.6",
  prompt: "草原を走るかわいい猫",
  aspect_ratio: "16:9",
  resolution: "720p",
  duration: 5
}

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Authorization"] = "Bearer <token>"
request["Content-Type"] = "application/json"
request.body = payload.to_json

response = http.request(request)
puts response.body
import Foundation

let url = URL(string: "https://api.apimart.ai/v1/videos/generations")!

let payload: [String: Any] = [
    "model": "wan2.6",
    "prompt": "草原を走るかわいい猫",
    "aspect_ratio": "16:9",
    "resolution": "720p",
    "duration": 5
]

var request = URLRequest(url: url)
request.httpMethod = "POST"
request.setValue("Bearer <token>", forHTTPHeaderField: "Authorization")
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
request.httpBody = try? JSONSerialization.data(withJSONObject: payload)

let task = URLSession.shared.dataTask(with: request) { data, response, error in
    if let error = error {
        print("Error: \(error)")
        return
    }

    if let data = data, let responseString = String(data: data, encoding: .utf8) {
        print(responseString)
    }
}

task.resume()
using System;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static async Task Main(string[] args)
    {
        var url = "https://api.apimart.ai/v1/videos/generations";

        var payload = @"{
            ""model"": ""wan2.6"",
            ""prompt"": ""草原を走るかわいい猫"",
            ""aspect_ratio"": ""16:9"",
            ""resolution"": ""720p"",
            ""duration"": 5
        }";

        using var client = new HttpClient();
        client.DefaultRequestHeaders.Add("Authorization", "Bearer <token>");

        var content = new StringContent(payload, Encoding.UTF8, "application/json");
        var response = await client.PostAsync(url, content);
        var result = await response.Content.ReadAsStringAsync();

        Console.WriteLine(result);
    }
}
{
  "code": 200,
  "data": [
    {
      "status": "submitted",
      "task_id": "task_01J9HA7JPQ9A0Z6JZ3V8M9W6PZ"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "リクエストパラメータが無効です",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "認証に失敗しました。APIキーを確認してください",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "残高が不足しています。チャージしてください",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 429,
    "message": "リクエストが多すぎます。しばらくしてからお試しください",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "サーバー内部エラー。しばらくしてからお試しください",
    "type": "server_error"
  }
}

認証

Authorization
string
必須
すべてのAPIエンドポイントでBearer Token認証が必要ですAPIキーの取得:APIキー管理ページからAPIキーを取得してくださいリクエストヘッダーに追加:
Authorization: Bearer YOUR_API_KEY

リクエストパラメータ

model
string
必須
動画生成モデル名、wan2.6 に固定
prompt
string
必須
動画の内容説明テキストから動画モードでは必須。シーン、アクション、スタイルを詳細に記述してください例:"日差しの中で伸びをするかわいい猫"
image_urls
array<url>
参照画像URL配列(1枚のみサポート)画像から動画モードでは必須。公開アクセス可能な画像URLをサポート例:["https://example.com/image.jpg"]
システムは image_urls の有無に基づいてテキストから動画または画像から動画モードを自動選択します
negative_prompt
string
ネガティブプロンプト、望まない内容を記述例:"ぼやけ, 低品質, 歪み"
aspect_ratio
string
デフォルト:"16:9"
動画のアスペクト比オプション:
  • 16:9 - 横向き(デフォルト)
  • 9:16 - 縦向き
  • 1:1 - 正方形
  • 4:3 - 横向き
  • 3:4 - 縦向き
デフォルト:16:9
画像から動画モードではこのパラメータはサポートされていません
resolution
string
デフォルト:"720p"
動画解像度オプション:
  • 720p - 標準(デフォルト)
  • 1080p - 高解像度
デフォルト:720p
480p解像度はサポートされていません
秒単位で課金されます。解像度によって料金が異なります。具体的な料金はモデルマーケットプレイスをご参照ください
duration
integer
デフォルト:"5"
動画時間(秒)サポート値:51015 秒のみデフォルト:5
seed
integer
再現可能な結果のためのランダムシード例:12345
prompt_extend
boolean
プロンプトを自動拡張するかどうか有効にすると、システムがプロンプトを自動的に最適化・充実させます
audio
boolean
オーディオを自動追加するかどうか有効にすると、システムが動画に合ったオーディオを生成します
audio_url
string
指定オーディオURLaudio パラメータより優先されます
オーディオの長さは動画の長さを超えることはできません。オーディオが動画より短い場合、動画の前半には音声がありますが、後半は無音になります。
shot_type
string
ショットタイプオプション:
  • single - シングルショット
  • multi - マルチショット
watermark
boolean
ウォーターマークを追加するかどうか
template
string
画像から動画への特殊効果モード用のエフェクトテンプレート名
エフェクトモード使用時:
  • 画像は1枚のみ必要(image_urlsで渡す)
  • プロンプトは不要(モデルはpromptフィールドを無視します)
汎用エフェクト:
  • squish - スクイッシュ
  • rotation - 回転
  • poke - つんつん
  • inflate - 風船膨張
  • dissolve - 分子拡散
  • melt - 熱波融解
  • icecream - アイスクリーム惑星
  • flying - マジック浮遊
シングルパーソンエフェクト:
  • carousel - タイムカルーセル
  • singleheart - ラブユー
  • dance1 - スウィングモーメント
  • dance2 - ダンスムーブ
その他のエフェクトについてはアリババ万相テンプレートドキュメントを参照してください

解像度とアスペクト比の組み合わせ

アスペクト比説明720p サイズ1080p サイズ
16:9横向き(デフォルト)1280×7201920×1080
9:16縦向き720×12801080×1920
1:1正方形960×9601440×1440
4:3横向き1088×8321632×1248
3:4縦向き832×10881248×1632

レスポンス

code
integer
レスポンスステータスコード、成功時は200
data
array
レスポンスデータ配列

使用シナリオ

シナリオ 1:テキストから動画(シンプルリクエスト)

{
  "model": "wan2.6",
  "prompt": "日差しの中で伸びをするかわいい猫"
}

シナリオ 2:テキストから動画(全パラメータ)

{
  "model": "wan2.6",
  "prompt": "草原を走るかわいい猫",
  "negative_prompt": "ぼやけ, 低品質, 歪み",
  "aspect_ratio": "16:9",
  "resolution": "720p",
  "duration": 5,
  "seed": 12345,
  "prompt_extend": true,
  "audio": true,
  "shot_type": "single",
  "watermark": false
}

シナリオ 3:画像から動画

{
  "model": "wan2.6",
  "prompt": "子猫が地面を走る",
  "image_urls": ["https://upload.apimart.ai/f/apimart-models-images/9998233432754770-c059992d-9b01-47d5-810d-ea0502ac9279-image_task_01KD7SSXDBCEWZ869D6PF249ZW_0.png"],
  "resolution": "1080p",
  "duration": 10
}

シナリオ 4:画像から動画(Base64画像)

{
  "model": "wan2.6",
  "prompt": "猫を立ち上がらせて歩かせる",
  "image_urls": ["data:image/png;base64,iVBORw0KGgo..."],
  "duration": 5
}

モード説明

テキストから動画 (Text-to-Video)

  • prompt パラメータが必須
  • image_urls パラメータは不要

画像から動画 (Image-to-Video)

  • image_urls パラメータが必須(1枚のみサポート)
  • prompt パラメータはオプション、期待するアクションを記述
システムはリクエストに image_urls が含まれているかどうかに基づいてモードを自動選択します
タスク結果のクエリ動画生成は非同期タスクで、送信時に task_id を返します。タスクステータス取得 エンドポイントを使用して生成の進行状況と結果をクエリしてください。