POST/v1/images/generations

画像を生成

OpenAI互換の画像生成。バッファリングのみで、streamとpartial_imagesは拒否されます。urlを指定しても常にb64_jsonを返すモデルがあり、GPTの画像モデルはresponse_format: urlを拒否します。

usageは、プロバイダーが報告する場合はそのプロバイダー自身のオブジェクトです。画像のレスポンスにはusage.costが含まれません。

認証: AuthorizationヘッダーにBearer形式のAPIキー

リクエストボディ

  • modelstring必須

    画像モデルのスラッグ。

  • promptstring必須

    描画する内容。

  • ninteger

    画像の枚数。

    既定値: 1
  • sizeenum

    出力サイズ。受け付けるサイズはモデルによって異なります。

    "auto""256x256""512x512""1024x1024""1536x1024""1024x1536""1792x1024""1024x1792"
  • qualityenum
    "standard""hd""low""medium""high""auto"
  • backgroundenum
    "transparent""opaque""auto"
  • output_formatenum
    "png""jpeg""webp"
  • output_compressioninteger
  • moderationenum
    "low""auto"
  • response_formatenum
    "url""b64_json"
  • styleenum
    "vivid""natural"
  • userstring

    お客様側での識別用のエンドユーザーID。転送されません。

レスポンス

  • 200

    画像。

    レスポンス
    • createdinteger
    • dataarray<object>
      data
      • b64_jsonstring
      • urlstring
      • revised_promptstring
    • backgroundstring
    • output_formatstring
    • qualitystring
    • sizestring
    • usageobject

      プロバイダーが報告する場合の、プロバイダーのusageオブジェクト。

  • 400

    不正なリクエスト。paramはフィールド名を、codeは理由(invalid_parameter、unsupported_parameter、unsupported_capability、refusal、previous_response_not_found)を示します。課金されません。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 401

    キーがないか、形式が不正か、期限切れか、取り消されています。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 402

    組織での対応が先に必要です(card_required、email_unverified、org_under_review、free_tier_requires_payment、promotion_ended)。メッセージに手順が示されます。再試行しても解決しません。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 403

    model_not_granted(GET /v1/modelsのIDを使ってください)、model_location_not_supported、またはどのルートも満たせないゼロデータ保持の要求。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 429

    insufficient_quota(クレジット不足、支出上限の超過、またはモデルに購入が必要)とpromo_credits_now(無料プロモーションの使い切り):クレジットを追加してください。メッセージに手順が示されます。rate_limit_exceeded、free_limit_reached、admission_capacity_exceeded:Retry-Afterの秒数だけ待って再試行してください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"
  • 503

    gateway_unavailable、gateway_draining、unavailable_route、deadline_exceededのいずれか。バックオフを入れて再試行し、Retry-Afterがある場合はそれに従ってください。

    レスポンス
    • errorobject
      error
      • messagestring

        問題の内容と解決方法。

      • typestring

        例:invalid_request_error、authentication_error、permission_error、rate_limit_error、insufficient_quota、api_error。

      • codestring

        安定したエラーコード。

      • paramstring | null

        該当する場合、問題のあるリクエストフィールド。

      • refusal_reasonenum

        code: refusalの場合にのみ含まれます。

        "cyber_policy""cbrn""content_policy""recitation""data_inspection""unspecified"

リクエスト

curl https://api.experientiallabs.ai/v1/images/generations \
  -H "Authorization: Bearer <YOUR_API_KEY>" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-image-1", "prompt": "A lighthouse at dusk, watercolor", "size": "1024x1024"}'

レスポンス

{
  "created": 1795132800,
  "data": [
    {
      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."
    }
  ],
  "size": "1024x1024",
  "quality": "medium",
  "output_format": "png",
  "usage": {
    "input_tokens": 12,
    "output_tokens": 1056,
    "total_tokens": 1068
  }
}

https://api.experientiallabs.ai/v1/images/generations