Images
OpenAI 互換の画像生成・編集と、BytePlus ModelArk の複数参照・バッチ画像生成を提供します。
POST /v1/images/generations はテキストプロンプトから画像を作成します。OpenAI 形式のリクエストを維持しつつ、ModelArk モデルには URL ベースの画像参照とネイティブバッチ生成を追加します。
接続#
OpenAI SDK で接続する場合、base_url を https://apirouter.pleum.ai/v1 に設定してください。SDK が /v1/images/generations を付加します。
OpenAI Images generations API
import { generateImage } from "ai";
import { createPleum } from "pleumrouter-ai-sdk-provider";
const pleum = createPleum({
apiKey: "plm_xxxxxxxxxxxxxxxx",
});
const result = await generateImage({
model: pleum.imageModel("seedream-5-0-260128"),
prompt: "A red panda coding at a tiny laptop, watercolor style",
});
console.log(result.image);OpenAI Images generations API
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: "plm_xxxxxxxxxxxxxxxx",
baseURL: "https://apirouter.pleum.ai/v1",
});
const response = await openai.images.generate({
model: "seedream-5-0-260128",
prompt: "A red panda coding at a tiny laptop, watercolor style",
});
console.log(response.data[0].url);OpenAI Images generations API
from openai import OpenAI
client = OpenAI(
api_key="plm_xxxxxxxxxxxxxxxx",
base_url="https://apirouter.pleum.ai/v1",
)
response = client.images.generate(
model="seedream-5-0-260128",
prompt="A red panda coding at a tiny laptop, watercolor style",
response_format="b64_json",
)
print(response.data[0].b64_json[:80], "...")OpenAI Images generations API
curl https://apirouter.pleum.ai/v1/images/generations \
-H "Authorization: Bearer plm_xxxxxxxxxxxxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "seedream-5-0-260128",
"prompt": "A red panda coding at a tiny laptop, watercolor style",
"response_format": "b64_json"
}'OpenAI Images generations API
curl https://apirouter.pleum.ai/v1/images/edits \
-H "Authorization: Bearer plm_xxxxxxxxxxxxxxxx" \
-F "model=gpt-image-2" \
-F "prompt=Add a red hat" \
-F "image=@./source.png"リクエストボディ#
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| model | string | 任意 | 画像モデル ID。デフォルトは dall-e-3。 |
| prompt | string | 必須 | 生成する画像の説明。最大 4,000 文字。 |
| n | integer | 任意 | 要求画像数。1–15、デフォルト 1。バッチ可否はモデルごとです。 |
| size | string | null | 任意 | 出力サイズ。省略すると選択した provider のデフォルトを使用します。ModelArk のプリセットとピクセル制限は下表を確認してください。 |
| image | string | null | 任意 | images[0] の後方互換エイリアス。入力画像 URL は HTTP(S) のみです。 |
| images | string[] | 任意 | 順序付きの入力画像 URL。image エイリアスと結合・重複除去後、最大 14 参照です。 |
| response_format | string | null | 任意 | 例: url または b64_json。対応値はモデル/provider に依存します。 |
| charge_amount_krw | integer | null | 任意 | 固定 KRW 精算額。通常の API キーは利用できず、first-party 委任キーのみ可能です。 |
curl https://apirouter.pleum.ai/v1/images/generations \
-H "Authorization: Bearer $PLEUM_API_KEY" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: image-mug-001" \
-d '{
"model": "seedream-5-0-260128",
"prompt": "A red panda coding at a tiny laptop, watercolor style",
"images": ["https://example.com/style-reference.png"],
"n": 2,
"size": "2k",
"response_format": "url"
}'BytePlus ModelArk の制約#
ModelArk の参照・サイズ・バッチ制限はクレジット hold の前に検証されます。未対応の数・サイズ・n は課金なしで 400 を返します。
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| Seedream 5 / 4.5 / 4.0 | reference + batch | 任意 | 各最大 14 参照。この Seedream 系のみネイティブ n=1–15 バッチに対応し、参照と出力の合計も 15 以下である必要があります。 |
| Dola Seedream 5 Pro | reference | 任意 | 最大 10 参照、1 リクエスト 1 出力。返却サイズが 2.36MP を超えるかで価格 variant が変わる場合があります。 |
| SeedEdit 3.0 / Seedream 3.0 T2I | reference | 任意 | SeedEdit 3.0 は 1 参照を受け付けます。Seedream 3.0 T2I はテキストから画像専用で参照を受け付けません。 |
| size presets | string | 任意 | Seedream 5: 2k/3k/4k、Seedream 4.5: 2k/4k、Seedream 4.0: 1k/2k/4k。省略時、これらは ModelArk の 2048×2048 デフォルトを使用します。 |
| explicit WxH | string | 任意 | これらの Seedream は <width>x<height> も受け付けます。総画素 3,686,400–16,777,216、アスペクト比 1:16–16:1 です。 |
Idempotency-Key は任意で最大 128 文字です。同じキーと本文は 24 時間、保存済みレスポンスを再生します。同じキーで異なる本文は 422 です。レスポンス#
レスポンスは OpenAI 形式の data 配列を含みます。各成功項目には url または b64_json があり、ModelArk 項目には size も含まれる場合があります。cost は PleumRouter 拡張です。
{
"created": 1719446400,
"data": [
{
"url": "https://.../img.png",
"revised_prompt": "A red panda coding at a tiny laptop, watercolor style",
"size": "2048x2048"
}
],
"model": "seedream-5-0-260128",
"cost": {"usd": 0.04, "krw": 55, "fx_rate": 1525.0, "markup_rate": 0.0}
}課金方式#
課金は実際に成功した出力数と ModelArk が返す出力サイズ/reference variant に基づきます。部分成功のバッチでは失敗した画像は精算しません。
b64_json を要求してください。画像編集#
POST /v1/images/edits は multipart で画像を編集します。 OpenAI gpt-image-* のみ対応です。
| パラメータ | 型 | 必須 | 説明 |
|---|---|---|---|
| image | file | 必須 | 編集する元画像ファイル。 |
| prompt | string | 必須 | 編集指示テキスト。 |
| mask | file | 任意 | 任意のマスク。 |
| model | string | 任意 | デフォルトは gpt-image-2。 |
| n / size / response_format | optional | 任意 | OpenAI Images edits と同じ任意フィールド。 |
curl https://apirouter.pleum.ai/v1/images/edits \
-H "Authorization: Bearer $PLEUM_API_KEY" \
-F "model=gpt-image-2" \
-F "prompt=Add a red hat to the subject" \
-F "image=@./source.png"