Download the PHP package wavespeedai/wavespeed-php without Composer
On this page you can find all versions of the php package wavespeedai/wavespeed-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download wavespeedai/wavespeed-php
More information about wavespeedai/wavespeed-php
Files in wavespeedai/wavespeed-php
Package wavespeed-php
Short Description WaveSpeed PHP Client โ Official PHP SDK for the WaveSpeed inference platform
License MIT
Homepage https://wavespeed.ai
Informations about the package wavespeed-php
WaveSpeed PHP SDK
PHP SDK for the WaveSpeed inference platform
๐ Visit wavespeed.ai โข ๐ Documentation โข ๐ฌ Issues
A port of the official WaveSpeed Python SDK
to PHP, with the same API surface and the same retry semantics. Zero runtime
dependencies โ just ext-curl and ext-json.
Requirements
- PHP 8.1 or newer
ext-curl,ext-json
Installation
API Client
Run WaveSpeed AI models with a simple API:
Authentication
Set your API key through the environment (get one at wavespeed.ai/accesskey):
Or pass it directly:
Or configure it once during bootstrap, so every client picks it up:
Options
timeout caps how long run() blocks. Left null it waits as long as the task
takes, while each individual HTTP request stays bounded by Config::TIMEOUT
(36000s by default). A local timeout never cancels the task โ see
Recovering a Task.
Sync Mode
Pass enableSyncMode: true to ask the API to wait for the result in the initial
request. If the server-side wait runs out, the SDK throws
SyncModeTimeoutException carrying the task ID and result URL โ the task keeps
processing and can be collected later.
Note: Not all models support sync mode. Check the model documentation for availability.
Handling Failure Without Exceptions
runNoThrow() reports the outcome instead of throwing, which suits queue
workers that want to record a task ID and move on:
status is processing when a sync-mode wait expired: the task is alive
server-side, so getResult($result['task_id']) will pick it up.
Recovering a Task
A local timeout does not cancel anything โ the job keeps running. Fetch its current state by id:
Retry Configuration
A submission POST is never retried automatically. It is not idempotent: if
it fails without a response, the task may already exist, and replaying it would
risk paying for the same job twice. Result-query GETs are idempotent and are
retried freely. Setting maxRetries above 0 opts into submitting a
replacement task after a confirmed transient failure.
Diagnostics
Retries are silent by default โ a library should not write to your output uninvited. Opt in with a logger:
Upload Files
Upload images, videos, or audio files. Large files stream straight from disk, so memory use stays flat:
Errors
Every exception implements WaveSpeed\Exception\WaveSpeedException, so one
catch covers the SDK without swallowing unrelated errors:
| Exception | Meaning | Retried by the SDK |
|---|---|---|
ConfigurationException |
No API key, or an unusable argument | โ |
FileNotFoundException |
Upload path missing or unreadable | โ |
SubmissionException |
The submit POST failed | Never (not idempotent) |
PredictionFailedException |
Task reached failed / cancelled / timeout |
Never (a verdict, not a hiccup) |
SyncModeTimeoutException |
Sync wait expired; task still running | Never โ poll instead |
TimeoutException |
Local wait budget ran out | Yes, at the task level |
ConnectionException |
No response obtained | Yes, for idempotent requests |
ApiException |
Any other API-level failure | Yes for 429/5xx |
Custom HTTP Transport
Client talks to the API only through the HttpClient interface, so you can
substitute your own stack (a proxy-aware handler, a shared connection pool, a
test double):
Examples
Runnable scripts live in examples/:
Local Development
The default suite never touches the network: MockHttpClient scripts the
responses and FakeClock makes polling and backoff instant.
Environment Variables
| Variable | Description |
|---|---|
WAVESPEED_API_KEY |
WaveSpeed API key |
WAVESPEED_CLIENT_NAME |
Channel-attribution name sent as the X-Client-Name header (overrides the clientName argument; defaults to wavespeed-php) |
Mapping From the Python SDK
| Python | PHP |
|---|---|
wavespeed.run(...) |
WaveSpeed::run(...) |
wavespeed.run_no_throw(...) |
WaveSpeed::runNoThrow(...) |
wavespeed.get_result(id) |
WaveSpeed::getResult($id) |
wavespeed.upload(file) |
WaveSpeed::upload($file) |
wavespeed.Client(api_key=...) |
new WaveSpeed\Client(apiKey: ...) |
wavespeed.config.api.timeout = 60 |
Config::set(Config::TIMEOUT, 60.0) |
with wavespeed.config.patch(...) |
Config::patch([...], fn () => ...) |
RuntimeError / ValueError |
Typed exceptions (see the table above) |
License
MIT
WaveSpeed AI โ AI image & video generation platform. Try it in the browser: Image generator ยท Video generator
All versions of wavespeed-php with dependencies
ext-curl Version *
ext-json Version *