Skip to main content
Method: ImagesApi#imagesGenerationsPost

Example

<?php

require 'vendor/autoload.php';

use AIStats\Sdk\Api\ImagesApi;
use AIStats\Sdk\Configuration;
use AIStats\Sdk\Model\ImageGenerationRequest;

$apiKey = getenv('AI_STATS_API_KEY');
$config = Configuration::getDefaultConfiguration()
    ->setHost('https://api.ai-stats.phaseo.app/v1')
    ->setApiKey('GatewayAuth', 'Bearer ' . $apiKey);

$imagesApi = new ImagesApi(null, $config);

$request = new ImageGenerationRequest([
    'model' => 'openai/gpt-image-1',
    'prompt' => 'A lighthouse at golden hour',
    'size' => '1024x1024',
    'n' => 1,
    'response_format' => 'url'
]);

$response = $imagesApi->imagesGenerationsPost($request);
echo $response->getData()[0]->getUrl();

Key parameters

  • model (required): Image-capable model id (e.g., openai/gpt-image-1).
  • prompt (required): Text prompt.
  • n (1–10): Number of images to generate.
  • size: e.g., 1024x1024, 1024x1792, 1792x1024.
  • quality: standard or hd (model-dependent).
  • style: e.g., vivid or natural (model-dependent).
  • response_format: url or b64_json.
  • user: Optional end-user tag for safety/abuse tracking.

Returns

ImageGenerationResponse