<?php
require_once(__DIR__ . '/vendor/autoload.php');
$apiKey = getenv('LEGNEXT_API_KEY');
// Configure API client
$config = OpenAPI\Client\Configuration::getDefaultConfiguration();
$config->setHost('https://api.legnext.ai');
$config->setApiKey('x-api-key', $apiKey);
// Create API instance
$api = new OpenAPI\Client\Api\ImageApi(
new GuzzleHttp\Client(),
$config
);
try {
// Generate image
$body = [
'text' => 'a beautiful sunset over mountains'
];
$response = $api->apiV1DiffusionPost($apiKey, $body);
echo "Job ID: " . $response->getJobId() . "\n";
echo "Status: " . $response->getStatus() . "\n";
} catch (Exception $e) {
echo "Error: " . $e->getMessage() . "\n";
}
?>