Download the PHP package marceloeatworld/runpod-serverless-php without Composer
On this page you can find all versions of the php package marceloeatworld/runpod-serverless-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download marceloeatworld/runpod-serverless-php
More information about marceloeatworld/runpod-serverless-php
Files in marceloeatworld/runpod-serverless-php
Package runpod-serverless-php
Short Description A PHP client for the RunPod Serverless API
License MIT
Informations about the package runpod-serverless-php
RunPod Serverless PHP Client
1 PHP client for the RunPod Serverless API, compatible with Laravel and native PHP, built on Saloon v4.
Table of Contents
- Requirements
- Installation
- Quick Start
- Job Lifecycle
- API Reference
- Submitting Jobs
- Checking Job Status
- Streaming Results
- Cancelling Jobs
- Retrying Failed Jobs
- Endpoint Health
- Purging the Queue
- RunPodResponse
- Status Checks
- Data Accessors
- JSON Serialization
- Advanced Configuration
- Webhooks
- Execution Policies
- S3 Storage Integration
- Combining Options
- Error Handling
- Rate Limits
- Result Retention
- Laravel Integration
- Support & Security
- License
Requirements
- PHP 8.2 or higher
- Composer
Saloon v4 is installed automatically as a dependency.
Installation
Quick Start
Your API key is available at runpod.io/console/user/settings. Your endpoint ID is the alphanumeric string visible in your endpoint's URL on the RunPod dashboard.
Job Lifecycle
Every RunPod job goes through a state machine:
| Status | Description |
|---|---|
IN_QUEUE |
Waiting for an available worker |
IN_PROGRESS |
Actively being processed |
COMPLETED |
Finished successfully, output available |
FAILED |
Worker returned an error |
CANCELLED |
Manually stopped via cancel() |
TIMED_OUT |
Expired (TTL in queue or executionTimeout during processing) |
API Reference
Submitting Jobs
Async: run(array $input)
Submits a job and returns immediately. You then poll status() or use a webhook.
Payload limit: 10 MB.
Sync: runSync(array $input)
Submits a job and waits for completion. Best for fast tasks (< 90 seconds).
If the job takes longer than ~90 seconds,
runSyncreturns with statusIN_PROGRESS. You must then fall back to pollingstatus().
Payload limit: 20 MB.
Full Polling Example
Checking Job Status
status(string $jobId)
Retrieve the current state and results of a job.
Streaming Results
stream(string $jobId)
Retrieve incremental results from a streaming job. The worker must support streaming.
Streaming in RunPod is poll-based, not chunked transfer encoding. Each chunk is limited to 1 MB.
Cancelling Jobs
cancel(string $jobId)
Cancel a queued or running job.
Retrying Failed Jobs
retry(string $jobId)
Requeue a failed or timed-out job. RunPod re-uses the same job ID and original input.
Endpoint Health
health()
Get worker pool and job pipeline statistics.
Purging the Queue
purgeQueue()
Remove all pending jobs from the queue. Running jobs are not affected.
Use with caution. This is irreversible and has a strict rate limit (2 calls per 10 seconds).
RunPodResponse
Every method returns a RunPodResponse object wrapping the raw API JSON response.
Status Checks
Data Accessors
| Method | Return Type | Description |
|---|---|---|
$response->id |
?string |
Unique job identifier |
$response->status |
?string |
Current job status |
$response->data |
array |
Complete raw API response |
->getOutput() |
mixed |
Worker's output (when COMPLETED) |
->getError() |
mixed |
Error details (when FAILED) |
->getMetrics() |
?array |
Execution metrics |
->getExecutionTime() |
?int |
Active processing time in ms |
->getDelayTime() |
?int |
Time spent waiting in queue in ms |
->getWorkerId() |
?string |
ID of the worker that processed the job |
->getStream() |
?array |
Array of stream chunks (from stream()) |
JSON Serialization
RunPodResponse implements JsonSerializable, so you can pass it directly to json_encode() or return it from a Laravel controller:
Advanced Configuration
The fluent methods withWebhook(), withPolicy(), and withS3Config() configure options on the endpoint resource. They are chainable and apply to the next run() or runSync() call.
Note: These options are sticky on the resource instance. If you call
withWebhook()once, subsequentrun()calls on the same instance will continue sending that webhook. Create a new endpoint instance if you need different config.
Webhooks
Instead of polling status(), you can provide a webhook URL. RunPod will POST the complete response JSON to your URL when the job finishes.
Webhook behavior:
- RunPod POSTs the full response JSON on completion
- Your endpoint must return HTTP 200
- On failure, RunPod retries 2 more times with a 10 second delay between retries
Execution Policies
Control job timeout and priority behavior.
| Parameter | Default | Range | Description |
|---|---|---|---|
executionTimeout |
600,000 (10 min) | 5s - 7 days | Max time a job can actively run on a worker |
ttl |
86,400,000 (24h) | 10s - 7 days | Total lifespan from submission (includes queue wait) |
lowPriority |
false |
- | If true, the job won't trigger autoscaling of new workers |
executionTimeoutvsttl: TTL counts from when the job is submitted (including queue time). executionTimeout counts from when a worker starts processing the job. If TTL expires while a job is running, it's immediately removed.
S3 Storage Integration
For large payloads exceeding the 10/20 MB limits, use S3 integration to pass data via object storage.
Combining Options
All fluent methods are chainable:
Error Handling
This client uses Saloon's AlwaysThrowOnErrors trait. Any HTTP 4xx/5xx response automatically throws an exception. Connection-level errors (DNS, timeout) are also thrown.
Exception hierarchy:
Rate Limits
RunPod enforces per-endpoint rate limits:
| Endpoint | Max per 10s | Max Concurrent |
|---|---|---|
/run |
1,000 | 200 |
/runsync |
2,000 | 400 |
/status |
2,000 | 400 |
/stream |
2,000 | 400 |
/cancel |
100 | 20 |
/purge-queue |
2 | - |
Exceeding these limits returns HTTP 429. Implement exponential backoff with jitter when retrying.
Result Retention
RunPod automatically deletes job results after a retention period:
| Mode | Retention After Completion |
|---|---|
Async (run) |
30 minutes |
Sync (runSync) |
1 minute (5 minutes max) |
Fetch your results within these windows, or use webhooks to receive results immediately.
Laravel Integration
1. Configuration
Add to config/services.php:
Add to your .env:
2. Service Provider
Register as a singleton in AppServiceProvider (or a dedicated provider):
3. Usage in Controllers
4. Usage in Jobs / Queues
Support & Security
For security issues, please email [email protected].
License
MIT License - see LICENSE