PHP code example of runapi-ai / qwen-3

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




unApi\Qwen3\Qwen3Client;

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

$editImageTask = $client->editImage->create([
    'model' => 'qwen-3-edit-image',
    'aspect_ratio' => '1:1',
    'enable_prompt_expansion' => true,
    'enable_safety_checker' => true,
    'negative_prompt' => 'sample',
    'output_format' => 'png',
    'output_resolution' => '1k',
    'prompt' => 'Make it golden hour',
    'seed' => 1,
    'source_image_urls' => ['https://cdn.runapi.ai/public/samples/image.jpg'],
]);

$task = $client->textToImage->create([
    'model' => 'qwen-3-pro-text-to-image',
    'aspect_ratio' => '1:1',
    'enable_prompt_expansion' => true,
    'enable_safety_checker' => true,
    'negative_prompt' => 'sample',
    'output_format' => 'png',
    'output_resolution' => '1k',
    'prompt' => 'A precise product render on white marble',
    'seed' => 1,
]);

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

$result = $client->textToImage->run([
    'model' => 'qwen-3-pro-text-to-image',
    'aspect_ratio' => '1:1',
    'enable_prompt_expansion' => true,
    'enable_safety_checker' => true,
    'negative_prompt' => 'sample',
    'output_format' => 'png',
    'output_resolution' => '1k',
    'prompt' => 'A serene mountain lake at dawn',
    'seed' => 1,
]);

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