Passer au contenu principal
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": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'
import requests

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

payload = {
    "model": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
}

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: "kling-video-o1",
  prompt: "Make the person in <<<image_1>>> wave at the camera",
  image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  mode: "std",
  duration: 5,
  aspect_ratio: "16:9"
};

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":        "kling-video-o1",
        "prompt":       "Make the person in <<<image_1>>> wave at the camera",
        "image_urls":   []string{"https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"},
        "mode":         "std",
        "duration":     5,
        "aspect_ratio": "16:9",
    }

    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": "kling-video-o1",
          "prompt": "Make the person in <<<image_1>>> wave at the camera",
          "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
          "mode": "std",
          "duration": 5,
          "aspect_ratio": "16:9"
        }
        """;

        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" => "kling-video-o1",
    "prompt" => "Make the person in <<<image_1>>> wave at the camera",
    "image_urls" => ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode" => "std",
    "duration" => 5,
    "aspect_ratio" => "16:9"
];

$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: "kling-video-o1",
  prompt: "Make the person in <<<image_1>>> wave at the camera",
  image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  mode: "std",
  duration: 5,
  aspect_ratio: "16:9"
}

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": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
]

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"": ""kling-video-o1"",
            ""prompt"": ""Make the person in <<<image_1>>> wave at the camera"",
            ""image_urls"": [""https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp""],
            ""mode"": ""std"",
            ""duration"": 5,
            ""aspect_ratio"": ""16:9""
        }";

        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_xxxxxxxxxx"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Invalid authentication credentials",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance. Please top up your account",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 429,
    "message": "Rate limit exceeded. Please try again later",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "Internal server error. Please try again later",
    "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": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
  }'
import requests

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

payload = {
    "model": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
}

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: "kling-video-o1",
  prompt: "Make the person in <<<image_1>>> wave at the camera",
  image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  mode: "std",
  duration: 5,
  aspect_ratio: "16:9"
};

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":        "kling-video-o1",
        "prompt":       "Make the person in <<<image_1>>> wave at the camera",
        "image_urls":   []string{"https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"},
        "mode":         "std",
        "duration":     5,
        "aspect_ratio": "16:9",
    }

    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": "kling-video-o1",
          "prompt": "Make the person in <<<image_1>>> wave at the camera",
          "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
          "mode": "std",
          "duration": 5,
          "aspect_ratio": "16:9"
        }
        """;

        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" => "kling-video-o1",
    "prompt" => "Make the person in <<<image_1>>> wave at the camera",
    "image_urls" => ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode" => "std",
    "duration" => 5,
    "aspect_ratio" => "16:9"
];

$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: "kling-video-o1",
  prompt: "Make the person in <<<image_1>>> wave at the camera",
  image_urls: ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  mode: "std",
  duration: 5,
  aspect_ratio: "16:9"
}

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": "kling-video-o1",
    "prompt": "Make the person in <<<image_1>>> wave at the camera",
    "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
    "mode": "std",
    "duration": 5,
    "aspect_ratio": "16:9"
]

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"": ""kling-video-o1"",
            ""prompt"": ""Make the person in <<<image_1>>> wave at the camera"",
            ""image_urls"": [""https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp""],
            ""mode"": ""std"",
            ""duration"": 5,
            ""aspect_ratio"": ""16:9""
        }";

        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_xxxxxxxxxx"
    }
  ]
}
{
  "error": {
    "code": 400,
    "message": "Invalid request parameters",
    "type": "invalid_request_error"
  }
}
{
  "error": {
    "code": 401,
    "message": "Invalid authentication credentials",
    "type": "authentication_error"
  }
}
{
  "error": {
    "code": 402,
    "message": "Insufficient balance. Please top up your account",
    "type": "payment_required"
  }
}
{
  "error": {
    "code": 429,
    "message": "Rate limit exceeded. Please try again later",
    "type": "rate_limit_error"
  }
}
{
  "error": {
    "code": 500,
    "message": "Internal server error. Please try again later",
    "type": "server_error"
  }
}

Autorisation

Authorization
string
requis
Tous les points de terminaison API nécessitent une authentification par Bearer TokenObtenir votre clé API :Rendez-vous sur la page de gestion des clés API pour obtenir votre clé APIAjoutez-la à l’en-tête de la requête :
Authorization: Bearer YOUR_API_KEY

Paramètres de la requête

model
string
requis
Nom du modèle de génération vidéoModèles pris en charge :
  • kling-video-o1 — Kling Video O1 (amélioré par reasoning, qualité maximale)
prompt
string
requis
Prompt textuel positifPermet de référencer les images de image_urls via la syntaxe <<<image_N>>>, où N commence à 1.Exemple : "Make the person in <<<image_1>>> wave at the camera"
Si des images sont fournies mais que le prompt ne contient aucune référence <<<image_N>>>, le système ajoute automatiquement <<<image_1>>> au début du prompt.
mode
string
défaut:"std"
Mode de générationOptions :
  • std — mode standard (720P)
  • pro — mode professionnel (1080P)
Par défaut : std
duration
integer
défaut:"5"
Durée de la vidéo (en secondes)Options : 5 ou 10Par défaut : 5
aspect_ratio
string
défaut:"16:9"
Format d’image de la vidéoOptions :
  • 16:9 — paysage
  • 9:16 — portrait
  • 1:1 — carré
Par défaut : 16:9
image_urls
array<url>
Tableau d’URL d’images pour le référencement d’imagesRéférencez les images correspondantes dans le prompt via la syntaxe <<<image_N>>> (N commence à 1)Exemple : ["https://example.png"]
  • Les URL d’images doivent être publiquement accessibles, sans protection anti-hotlink
  • En mode image-to-video, aspect_ratio peut être remplacé par le rapport réel de l’image
  • Jusqu’à deux images. Le premier élément du tableau est l’image de début, le second l’image de fin
image_with_roles
array<object>
Tableau d’images avec rôles, recommandé pour l’image-to-video.Format de chaque élément : { "url": "...", "role": "..." }
  • first_frame : première image
  • last_frame : dernière image
  • reference : image de référence
  • image_urls et image_with_roles sont mutuellement exclusifs, ne les transmettez pas en même temps.
  • Lorsque plus de 2 images sont fournies, la définition des images de début et de fin n’est pas prise en charge.
video_list
array
Liste de vidéos de référence (basée sur URL), jusqu’à 1 vidéo.Utilisez refer_type pour distinguer les types :
  • base : vidéo à éditer (par défaut)
  • feature : vidéo de référence de caractéristiques
Utilisez keep_original_sound pour contrôler la conservation ou non de l’audio d’origine :
  • no : ne pas conserver (par défaut)
  • yes : conserver le son d’origine
Format de la requête :
"video_list":[
  { "video_url": "video_url", "refer_type": "base", "keep_original_sound": "no" }
]
  • video_url ne peut pas être vide, et l’URL de la vidéo doit être accessible
  • Lorsque refer_type=base :
    • Les images de début/fin ne peuvent pas être définies
    • La vidéo de référence doit durer 3 à 10 secondes
    • La durée de la vidéo générée suit celle de la vidéo téléversée
  • Lorsque refer_type=feature et que video_url n’est pas vide :
    • image_urls ne peut contenir qu’une image de première image
  • Exigences vidéo : MP4/MOV uniquement ; durée d’au moins 3 secondes ; résolution 720–2160 px ; fréquence d’images 24–60 fps (la sortie est de 24 fps) ; taille maximale 200 Mo

Syntaxe de référence d’image

Le modèle Video O1 utilise la syntaxe <<<image_N>>> pour référencer des images dans les prompts, offrant une expérience unifiée text-to-video / image-to-video :
SyntaxeDescription
<<<image_1>>>Référence la 1re image du tableau image_urls
<<<image_2>>>Référence la 2e image du tableau image_urls
Référence automatique : si image_urls est fourni mais que le prompt ne contient aucune référence <<<image_N>>>, le système ajoute automatiquement <<<image_1>>> au début du prompt.

Réponse

code
integer
Code de statut de la réponse, 200 en cas de succès
data
array
Tableau de données de la réponse

Cas d’usage

Cas 1 : Texte vers vidéo (qualité maximale)

{
  "model": "kling-video-o1",
  "prompt": "A cinematic shot of a city skyline at golden hour",
  "mode": "pro",
  "duration": 5,
  "aspect_ratio": "16:9"
}

Cas 2 : Référence d’image (image unique)

{
  "model": "kling-video-o1",
  "prompt": "Make the person in <<<image_1>>> wave at the camera",
  "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  "mode": "pro",
  "duration": 5
}

Cas 3 : Références à plusieurs images

{
  "model": "kling-video-o1",
  "prompt": "The character in <<<image_1>>> walks toward the scene in <<<image_2>>>",
  "image_urls": [
    "https://example.com/character.jpg",
    "https://example.com/scene.jpg"
  ],
  "mode": "pro",
  "duration": 5
}

Cas 4 : Image fournie sans référence explicite (ajoutée automatiquement)

{
  "model": "kling-video-o1",
  "prompt": "The person slowly turns and smiles",
  "image_urls": ["https://upload.apimart.ai/f/models/9998230426123070-e9d6af04-cb5e-4731-8ae7-abf144cb0d29-9998230586368386-29641169-f698-4ab9-9b6d-380899e6521e-9998230593110693-c1741a3a-.webp"],
  "mode": "std",
  "duration": 5
}
Le système ajoute automatiquement <<<image_1>>> au début du prompt, ce qui équivaut à "<<<image_1>>>The person slowly turns and smiles".
Interroger les résultats de la tâcheLa génération vidéo est une tâche asynchrone qui renvoie un task_id lors de la soumission. Utilisez le point de terminaison Obtenir le statut de la tâche pour interroger la progression et les résultats.