---
author: OOMOL
author_url: https://oomol.com/ja/about/
title: 画像・動画 API 接続ガイド
description: OOMOL API key を設定し、SDK または HTTP で画像・動画モデルを呼び出し、非同期タスクとエラーを処理します。
lang: ja
canonical_url: https://oomol.com/ja/docs/image-video-api/
markdown_url: https://oomol.com/ja/docs/image-video-api.md
---

# 画像・動画 API 接続ガイド

信頼できるバックエンドから OOMOL Fusion API を使い、画像の生成・編集や動画の作成を行います。提供元ごとに対応するリクエストとレスポンスの形式を維持します。対応範囲は特定のモデルと操作に限定され、提供元のすべての API を含むものではありません。

## API key を作成する

[OOMOL Console](https://console.oomol.com/api-key) で個人 API key を作成し、バックエンドに以下の環境変数を設定します。OOMOL key を SDK の apiKey または HTTP Bearer token として使用します。例に提供元のキーを入力する必要はありません。ブラウザーのコード、公開リポジトリ、ログにキーを含めないでください。

```sh
export FUSION_API_TOKEN="<your-oomol-api-key>"
```

## 接続先を選ぶ

サービスのホストは [https://fusion-api.oomol.com](https://fusion-api.oomol.com) です。以下の完全な Base URL をバージョンのパスも含めて使用します。Connector や ProjectConnector の接続先に置き換えないでください。有料リクエストの前にモデルの提供状況と[料金](/ja/pricing/)を確認してください。

| 提供元 | Base URL |
| --- | --- |
| OpenAI Images | `https://fusion-api.oomol.com/v1/provider/openai/v1` |
| Seedream | `https://fusion-api.oomol.com/v1/provider/seedream/api/v3` |
| Seedance | `https://fusion-api.oomol.com/v1/provider/seedance/api/v3` |
| Wanx | `https://fusion-api.oomol.com/v1/provider/wanx/api/v1` |
| Kling | `https://fusion-api.oomol.com/v1/provider/kling/` |
| MiniMax | `https://fusion-api.oomol.com/v1/provider/minimax/` |

## サンプルを実行する

選んだ提供元に必要なパッケージだけをインストールします。例を example.ts に保存し、サーバー側の TypeScript 環境で実行してください。記載のバージョンはリポジトリのローカル互換性テストに対応し、すべての SDK バージョンを保証するものではありません。有効な認証情報と利用可能な接続先で実行すると、実際の生成リクエストが送信されます。

### OpenAI Images

画像生成・編集。その他の OpenAI API は対象外。

```sh
npm install openai@7.23.0
```

```ts
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: process.env.FUSION_API_TOKEN,
  baseURL: "https://fusion-api.oomol.com/v1/provider/openai/v1",
  maxRetries: 0,
  timeout: 1_080_000,
});

const result = await client.images.generate({
  model: "gpt-image-2",
  prompt: "A ceramic mug on a wooden table",
  size: "1536x864",
  quality: "medium",
});
console.log(result);
```

### Seedream

画像生成、参照画像、一部の SSE 出力。

```sh
npm install @volcengine/ark-runtime@1.0.11
```

```ts
import { ArkRuntimeClient } from "@volcengine/ark-runtime";

const client = new ArkRuntimeClient({
  apiKey: process.env.FUSION_API_TOKEN,
  baseURL: "https://fusion-api.oomol.com/v1/provider/seedream/api/v3",
  retryTimes: 0,
  timeout: 125_000,
});

const result = await client.generateImages({
  model: "doubao-seedream-5-0-260128",
  prompt: "A ceramic mug on a wooden table",
  size: "2K",
  response_format: "url",
});
console.log(result);
```

### Seedance

動画生成・タスク照会。

```sh
npm install @volcengine/ark-runtime@1.0.11
```

```ts
import { ArkRuntimeClient } from "@volcengine/ark-runtime";

const client = new ArkRuntimeClient({
  apiKey: process.env.FUSION_API_TOKEN,
  baseURL: "https://fusion-api.oomol.com/v1/provider/seedance/api/v3",
  retryTimes: 0,
  timeout: 125_000,
});

const task = await client.createContentGenerationTask({
  model: "doubao-seedance-2-0-260128",
  content: [{ type: "text", text: "A boat on the ocean" }],
  duration: 5,
  resolution: "720p",
});
const status = await client.getContentGenerationTask(task.id);
console.log(task.id, status);
```

### Wanx

動画生成・タスク照会。

```sh
npm install dashscope-sdk-official@1.26.0
```

```ts
import { Configuration, VideoSynthesis } from "dashscope-sdk-official";

const client = new VideoSynthesis(new Configuration({
  apiKey: process.env.FUSION_API_TOKEN,
  basePath: "https://fusion-api.oomol.com/v1/provider/wanx/api/v1",
}));

const task = await client.asyncCall({
  model: "wan3.0-video",
  prompt: "A boat on the ocean",
  resolution: "1080P",
  duration: 5,
});
const status = await client.fetch(task.output.task_id);
console.log(task.output.task_id, status);
```

### Kling

動画生成・タスク照会。

```sh
npm install ky@1.11.0
```

```ts
import ky from "ky";

const client = ky.create({
  prefixUrl: "https://fusion-api.oomol.com/v1/provider/kling/",
  headers: { Authorization: `Bearer ${process.env.FUSION_API_TOKEN}` },
  retry: 0,
  redirect: "error",
  timeout: 30_000,
});

const task = await client.post("text-to-video/kling-3.0-turbo", {
  json: {
    prompt: "A boat on the ocean",
    settings: { duration: 5, resolution: "720p", aspect_ratio: "16:9" },
  },
}).json<{ data: { id: string } }>();
const status = await client.get("tasks", {
  searchParams: { task_ids: task.data.id },
}).json();
console.log(task.data.id, status);
```

### MiniMax

動画生成・タスク照会。

```sh
npm install ky@1.11.0
```

```ts
import ky from "ky";

const client = ky.create({
  prefixUrl: "https://fusion-api.oomol.com/v1/provider/minimax/",
  headers: { Authorization: `Bearer ${process.env.FUSION_API_TOKEN}` },
  retry: 0,
  redirect: "error",
  timeout: 30_000,
});

const task = await client.post("v2/video_generation", {
  json: {
    model: "MiniMax-H3",
    content: [{ type: "text", text: "A boat on the ocean" }],
    duration: 5,
    resolution: "768P",
    ratio: "16:9",
  },
}).json<{ task_id: string }>();
const status = await client.get(
  `v2/query/video_generation/${encodeURIComponent(task.task_id)}`,
).json();
console.log(task.task_id, status);
```

## 動画の結果を取得する

動画の例はタスクを作成し、一度だけ照会します。返されたタスク ID を保存してください。作成成功は受付を意味し、動画の完成を意味しません。同じ OOMOL の認証情報で間隔を空けて照会し、終了状態まで待ちます。成功または失敗で照会を止め、結果やエラーを確認します。照会の失敗から生成の失敗を断定せず、進捗確認のためにタスクを再作成しないでください。

## エラーと再試行を扱う

HTTP エラーとタスクの状態を確認します。認証や残高の確認では、提供元と形式が異なるゲートウェイエラーが返る場合があります。認証失敗では OOMOL key、権限や残高エラーではアカウントと[請求情報](https://console.oomol.com/billing/recharge)、入力エラーではモデルとパラメーターを確認します。制限時は同時実行数を減らし、応答の再試行指示に従います。

作成時のタイムアウト、切断、サーバーエラーでは結果が不明な場合があります。タスク ID、リクエスト ID、エラーを保存し、可能なら既存タスクを照会します。別の有料タスクを作らないよう、生成を自動再送しないでください。OpenAI と Ark の例は SDK 再試行を無効にし、ky はリダイレクトも無効にしています。DashScope はテスト済みの設定を使用します。アプリで待機上限を設けても、期限切れを理由に再送しないでください。

## ファイル、ストリーミング、結果

アップロード、参照素材、ストリーミングの制限は提供元ごとに異なります。OpenAI の例は Images API のみで、チャットや Responses などは含みません。Seedream は一部の SSE 操作に対応し、ここでの OpenAI 画像 API は同期応答です。一部のストリームイベントを受け取っても、完了イベントを受け取ったことにはなりません。

結果のメディア URL は別のクライアントでダウンロードし、OOMOL Authorization ヘッダーを付けないでください。URL の永続性は保証されません。クライアントの切断で受付済みの生成がキャンセルされるとは限りません。未対応の操作や不明な結果は[サポート](mailto:support@oomol.com)へ、秘密情報を除きリクエスト ID やタスク ID を添えてお問い合わせください。

[画像・動画 API の概要](/ja/image-video-api/)に戻る。

## API リファレンス

[API リファレンス](https://fusion-api.oomol.com/public/docs?lang=en) · [OpenAPI JSON](https://fusion-api.oomol.com/public/openapi.json?lang=en)
