runapi-ai / seedream
RunAPI Seedream Composer package for PHP applications
Requires
- php: >=8.2
- runapi-ai/core: ^0.10.0
Requires (Dev)
- phpunit/phpunit: ^11.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
The Seedream PHP SDK is the Composer package for Seedream on RunAPI. Use it when your PHP application needs associative-array request bodies, task status lookup, polling helpers, file helpers, and consistent RunAPI errors.
Install
composer require runapi-ai/seedream
Quick start
<?php require __DIR__ . "/vendor/autoload.php"; use RunApi\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'], ]); $lite = $client->textToImage->create([ 'model' => 'seedream-5-lite-text-to-image', 'prompt' => 'A bright editorial photo of a modern bookstore cafe', 'aspect_ratio' => '4:3', 'output_quality' => 'basic', 'output_format' => 'jpeg', ]); $result = $client->textToImage->run([ 'model' => 'seedream-v4-text-to-image', 'prompt' => 'A serene mountain lake at dawn', ]); echo $result->images[0]->url . PHP_EOL;
Use create() to submit a task and return quickly, get() to fetch the latest task state, and run() when a script should create and poll until completion. In web request handlers, prefer create() plus webhook or later get() polling so a worker is not held open.
Returned file URLs are temporary. Download and store generated files in your own durable storage within the retention window.
All SDK exceptions inherit from RunApi\Core\Errors\RunApiException, including API, authentication, rate limit, task failure, and task timeout errors.
Seedream 5 Pro
Use seedream-5-pro-text-to-image for generation, seedream-5-pro-edit for image editing, and seedream-5-pro-layer-decomposition to separate one image into a base image and ordered transparent layers through $client->decomposeLayers.
Seedream 5.5
Use seedream-5.5-text-to-image, seedream-5.5-edit, or seedream-5.5-layer-decomposition with the existing generation, editing, and decomposition resources. Text-to-image requires aspect_ratio. Generation and editing use output_resolution (1k, 1.5k, 2k, default 2k) and background (auto, transparent, opaque, default auto). Transparent output requires PNG.
Editing accepts 1-10 JPEG, PNG, or WebP sources up to 10 MB each and defaults aspect_ratio to auto. Prompts accept 5-5000 characters. These models accept no output_quality, seed, or output_count.
Decomposition accepts one JPEG, PNG, or WebP source up to 10 MB and an optional prompt up to 2000 characters. size accepts auto, 1K, 1.5K, or 2K, default auto. max_images is an upper bound of 2-100 outputs including the base image, default 30. text_recognition defaults to false. output_format defaults to png and affects only the base image. Query usage.generated_images for the actual output count.
Links
- Model page: https://runapi.ai/models/seedream
- SDK docs: https://runapi.ai/docs/resources/sdks
- Product docs: https://runapi.ai/docs/api/seedream/text-to-image
- Pricing and rate limits: https://runapi.ai/models/seedream/4.5-text-to-image
- Full catalog: https://runapi.ai/models
- GitHub repository: https://github.com/runapi-ai/seedream-php
- Multi-language SDK repository: https://github.com/runapi-ai/seedream-sdk
License
Licensed under the Apache License, Version 2.0.