PHP code example of runapi-ai / z-image

1. Go to this page and download the library: Download runapi-ai/z-image library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

runapi-ai / z-image example snippets




unApi\ZImage\ZImageClient;

$client = new ZImageClient(); // reads RUNAPI_API_KEY

$task = $client->textToImage->create([
    'model' => 'z-image',
    'prompt' => 'A serene Japanese garden at sunrise',
    'aspect_ratio' => '16:9',
]);

$status = $client->textToImage->get($task->id);

$result = $client->textToImage->run([
    'model' => 'z-image',
    'prompt' => 'A serene Japanese garden at sunrise',
    'aspect_ratio' => '16:9',
]);

echo $result->images[0]->url . PHP_EOL;