PHP code example of runapi-ai / qwen-image

1. Go to this page and download the library: Download runapi-ai/qwen-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 / qwen-image example snippets




unApi\QwenImage\QwenImageClient;

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

$task = $client->textToImage->create([
    'model' => 'qwen-image-text-to-image',
    'aspect_ratio' => '1:1',
    'output_format' => 'png',
    'prompt' => 'A precise product render on white marble',
    'seed' => 1,
]);

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

$result = $client->textToImage->run([
    'model' => 'qwen-image-text-to-image',
    'aspect_ratio' => '1:1',
    'output_format' => 'png',
    'prompt' => 'A serene mountain lake at dawn',
    'seed' => 1,
]);

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