PHP code example of runapi-ai / seedream

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




unApi\Seedream\SeedreamClient;

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

$task = $client->textToImage->create([
    'model' => 'seedream-v4-text-to-image',
    'prompt' => 'A precise product render of a glass teapot on white marble',
]);

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

$edit = $client->editImage->create([
    'model' => 'seedream-v4-edit',
    'prompt' => 'Make it golden hour',
    'source_image_urls' => ['https://cdn.runapi.ai/public/samples/image.jpg'],
]);

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

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