PHP code example of runapi-ai / qwen-2

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




unApi\Qwen2\Qwen2Client;

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

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

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

$result = $client->textToImage->run([
    'model' => 'qwen-2-text-to-image',
    'prompt' => 'A serene mountain lake at dawn',
]);

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