Background texture

POST /v1/images/generations

POST/v1/images/generations

テキストプロンプトから画像を生成します。OpenAI DALL-E 互換形式です。

リクエスト

ヘッダー

ヘッダー
AuthorizationBearer {api_key}
Content-Typeapplication/json

ボディ

{
  "model": "imagen-3",
  "prompt": "A futuristic city skyline at sunset, digital art",
  "n": 1,
  "size": "1024x1024",
  "response_format": "b64_json"
}

パラメーター

パラメーター必須説明
modelstringはい画像モデル ID。
promptstringはい生成したい画像のテキスト説明。
nintegerいいえ画像数。デフォルトは 1
sizestringいいえ画像サイズ。例: "1024x1024"
qualitystringいいえ"standard" または "hd"
response_formatstringいいえ"url"(デフォルト)または "b64_json"
stylestringいいえ"natural" または "vivid"

レスポンス

{
  "created": 1709123456,
  "data": [
    {
      "url": "https://storage.example.com/generated-image.png",
      "revised_prompt": "A futuristic city skyline at golden hour sunset..."
    }
  ],
  "usage": {
    "prompt_tokens": 0,
    "completion_tokens": 0,
    "total_tokens": 0
  }
}
フィールド説明
createdintegerUnix タイムスタンプ。
data[].urlstring画像 URL(response_format"url" の場合)。
data[].b64_jsonstringBase64 画像データ(response_format"b64_json" の場合)。
data[].revised_promptstringモデルが解釈したプロンプト。

ステータスコード

ステータス説明
200成功
400不正なリクエスト、またはモデルが画像生成に非対応
401認証なし
402残高不足
502上流プロバイダーエラー

curl -X POST https://api.modelmax.io/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $MODELMAX_API_KEY" \
  -d '{
    "model": "imagen-3",
    "prompt": "A watercolor painting of a mountain lake",
    "n": 1,
    "size": "1024x1024"
  }'
from openai import OpenAI

client = OpenAI(api_key="your-key", base_url="https://api.modelmax.io/v1")

response = client.images.generate(
    model="imagen-3",
    prompt="A watercolor painting of a mountain lake",
    n=1,
    size="1024x1024",
)

print(response.data[0].url)
import OpenAI from "openai";

const client = new OpenAI({ apiKey: "your-key", baseURL: "https://api.modelmax.io/v1" });

const response = await client.images.generate({
  model: "imagen-3",
  prompt: "A watercolor painting of a mountain lake",
  n: 1,
  size: "1024x1024",
});

console.log(response.data[0].url);