PHPackages                             halilcosdu/laravel-replicate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. halilcosdu/laravel-replicate

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

halilcosdu/laravel-replicate
============================

Laravel client for Replicate predictions, files, models, trainings, and signed webhooks

v2.0.0(1mo ago)5312.5k↓22%5[3 PRs](https://github.com/halilcosdu/laravel-replicate/pulls)MITPHPPHP ^8.2CI failing

Since Apr 27Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/halilcosdu/laravel-replicate)[ Packagist](https://packagist.org/packages/halilcosdu/laravel-replicate)[ Docs](https://github.com/halilcosdu/laravel-replicate)[ Fund](https://www.buymeacoffee.com/halilcosdu5)[ RSS](/packages/halilcosdu-laravel-replicate/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (7)Dependencies (40)Versions (14)Used By (0)

Laravel Replicate
=================

[](#laravel-replicate)

[![Latest Version on Packagist](https://camo.githubusercontent.com/eb8211f78fe8200e41b394c9e9498468d63e0d8a98d358e952e55218e4a8e3d9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f68616c696c636f7364752f6c61726176656c2d7265706c69636174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-replicate)[![PHP Version](https://camo.githubusercontent.com/3deb15e823f84261d48f67ca54f81ee3bdac7698f4ef94105a8d14fa2c6b9c1e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f68616c696c636f7364752f6c61726176656c2d7265706c69636174652f7068703f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-replicate)[![License](https://camo.githubusercontent.com/6f13b35befeee111468429b2c9b248bb5273f2a976c697e56746812258f32651/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f68616c696c636f7364752f6c61726176656c2d7265706c69636174653f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/e2fff2e565e376628b4b73567933ca068bba177e124de62788fa148cfe365762/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f68616c696c636f7364752f6c61726176656c2d7265706c69636174652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/halilcosdu/laravel-replicate)

A Laravel-native client for the [Replicate HTTP API](https://replicate.com/docs/reference/http). Run community, official, and deployment models; manage models and trainings; upload files; and authenticate incoming webhooks using Laravel's familiar HTTP client and facade APIs.

Highlights
----------

[](#highlights)

- Laravel 11, 12, and 13 support, including PHP 8.5 on supported framework versions.
- Predictions for community models, official models, and deployments.
- Sync mode, prediction deadlines, filters, and cursor pagination.
- Multipart uploads and resource management through Replicate's Files API.
- HMAC-SHA256 webhook verification with timestamp and key-rotation support.
- Native `Illuminate\Http\Client\Response` results with accurate IDE return types.
- Hermetic HTTP tests, PHPStan analysis, and a full version matrix in CI.

Requirements
------------

[](#requirements)

LaravelSupported PHP versionsFramework status in 202611.x8.2–8.4Legacy compatibility; EOL12.x8.2–8.5Security-supported13.x8.3–8.5Actively supportedThe matrix follows Laravel's [official support policy](https://laravel.com/docs/13.x/releases#support-policy). The package requires PHP `^8.2`; PHP 8.5 is tested with Laravel 12 and 13. Laravel 11 is not paired with PHP 8.5 because that combination is not supported by the framework itself.

Laravel 11 reached end-of-life on March 12, 2026 and currently has upstream security advisories. Compatibility remains available for migration windows because it is an explicit target of this package, but new and internet-facing applications should use Laravel 12 or 13. Composer may report or block affected Laravel 11 dependency resolutions; do not suppress that warning in production without reviewing the advisories.

Installation
------------

[](#installation)

Install the package with Composer:

```
composer require halilcosdu/laravel-replicate
```

Laravel discovers the service provider and facade automatically. Publish the configuration only when you need to customize it:

```
php artisan vendor:publish --tag=replicate-config
```

Add your Replicate API token to `.env`:

```
REPLICATE_API_TOKEN=r8_your_token
```

The published configuration contains:

```
return [
    'api_token' => env('REPLICATE_API_TOKEN'),
    'api_url' => env('REPLICATE_API_URL', 'https://api.replicate.com/v1'),
    'webhook_secret' => env('REPLICATE_WEBHOOK_SECRET'),
    'webhook_tolerance' => (int) env('REPLICATE_WEBHOOK_TOLERANCE', 300),
];
```

Quick start
-----------

[](#quick-start)

All API methods return Laravel's HTTP client `Response`, so `throw()`, `json()`, `collect()`, `successful()`, and the other standard response helpers are available.

```
use HalilCosdu\Replicate\Facades\Replicate;

$prediction = Replicate::createOfficialModelPrediction(
    owner: 'black-forest-labs',
    name: 'flux-schnell',
    data: [
        'input' => ['prompt' => 'A quiet library floating above Istanbul'],
    ],
)->throw()->json();

$predictionId = $prediction['id'];
```

Run a versioned community model through the generic predictions endpoint:

```
$response = Replicate::createPrediction([
    'version' => 'replicate/hello-world:version-id',
    'input' => ['text' => 'Laravel'],
]);

$prediction = $response->throw()->json();
```

### Sync mode and deadlines

[](#sync-mode-and-deadlines)

Prediction creation methods accept optional request headers. `Prefer` controls how long the HTTP request waits; `Cancel-After` controls the prediction's lifetime.

```
$response = Replicate::createOfficialModelPrediction(
    'black-forest-labs',
    'flux-schnell',
    ['input' => ['prompt' => 'Minimal geometric poster']],
    ['Prefer' => 'wait=30', 'Cancel-After' => '2m'],
);

$prediction = $response->throw()->json();
```

A sync request may still return `starting` or `processing` when the wait period expires. Retrieve its latest state with:

```
$prediction = Replicate::getPrediction($predictionId)->throw()->json();
```

### Pagination and filters

[](#pagination-and-filters)

List methods accept an optional query array and pass it directly to Replicate:

```
$page = Replicate::listPredictions([
    'created_after' => now()->subDay()->toIso8601String(),
    'source' => 'web',
    'cursor' => $cursor,
])->throw()->json();
```

This is supported by `listCollections`, `listDeployments`, `listFiles`, `listModels`, `listModelExamples`, `listPredictions`, and `listTrainings`.

Files API
---------

[](#files-api)

Upload a string or readable PHP stream as multipart content. Metadata is encoded as a JSON multipart field.

```
$stream = fopen(storage_path('app/training-images.zip'), 'rb');

throw_if($stream === false, RuntimeException::class, 'Unable to open the upload.');

try {
    $file = Replicate::createFile(
        contents: $stream,
        filename: 'training-images.zip',
        contentType: 'application/zip',
        metadata: ['dataset' => 'product-photography'],
    )->throw()->json();
} finally {
    fclose($stream);
}
```

Manage uploaded resources with `listFiles()`, `getFile($id)`, `deleteFile($id)`, and `downloadFile($id, $owner, $expiry, $signature)`.

Webhook verification
--------------------

[](#webhook-verification)

Never trust a webhook payload before verifying its signature. First retrieve your signing secret once, then store it securely rather than requesting it for every delivery:

```
$secret = Replicate::defaultSecret()->throw()->json('key');
```

```
REPLICATE_WEBHOOK_SECRET=whsec_your_signing_secret
```

Verify the untouched Laravel request before processing its JSON body:

```
use HalilCosdu\Replicate\Facades\Replicate;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

Route::post('/webhooks/replicate', function (Request $request) {
    abort_unless(Replicate::verifyWebhook($request), 401);

    $prediction = $request->json()->all();

    // Persist output, dispatch a job, or continue a model pipeline...

    return response()->noContent();
});
```

`verifyWebhook()` validates the `webhook-id`, `webhook-timestamp`, and every `v1` candidate in `webhook-signature` using constant-time comparison. Requests outside the configured 300-second tolerance are rejected to reduce replay risk. You may override the secret and tolerance for a specific request:

```
$valid = Replicate::verifyWebhook($request, $secret, tolerance: 120);
```

Remember to exempt the webhook route from CSRF protection and make processing idempotent because Replicate may retry a delivery.

API reference
-------------

[](#api-reference)

### Account, discovery, and hardware

[](#account-discovery-and-hardware)

```
Replicate::account();
Replicate::search(string $query, ?int $limit = null);
Replicate::listHardware();
```

### Collections

[](#collections)

```
Replicate::listCollections(array $query = []);
Replicate::getCollection(string $slug);
```

### Deployments

[](#deployments)

```
Replicate::listDeployments(array $query = []);
Replicate::createDeployment(array $data);
Replicate::getDeployment(string $owner, string $name);
Replicate::updateDeployment(string $owner, string $name, array $data);
Replicate::deleteDeployment(string $owner, string $name);
Replicate::createDeploymentPrediction(string $owner, string $name, array $data, array $headers = []);
```

### Files

[](#files)

```
Replicate::createFile(mixed $contents, string $filename, string $contentType = 'application/octet-stream', array $metadata = []);
Replicate::listFiles(array $query = []);
Replicate::getFile(string $id);
Replicate::deleteFile(string $id);
Replicate::downloadFile(string $id, string $owner, int $expiry, string $signature);
```

### Models and versions

[](#models-and-versions)

```
Replicate::listModels(array $query = []);
Replicate::createModel(array $data);
Replicate::getModel(string $owner, string $name);
Replicate::updateModel(string $owner, string $name, array $data);
Replicate::deleteModel(string $owner, string $name);
Replicate::getModelReadme(string $owner, string $name);
Replicate::searchModels(string $query);
Replicate::listModelExamples(string $owner, string $name, array $query = []);
Replicate::listModelVersions(string $owner, string $name);
Replicate::getModelVersion(string $owner, string $name, string $version);
Replicate::deleteModelVersion(string $owner, string $name, string $version);
```

### Predictions

[](#predictions)

```
Replicate::createPrediction(array $data, array $headers = []);
Replicate::createOfficialModelPrediction(string $owner, string $name, array $data, array $headers = []);
Replicate::getPrediction(string $id);
Replicate::listPredictions(array $query = []);
Replicate::cancelPrediction(string $id);
```

The legacy `createModelPrediction($owner, $name, $version, $data, $headers)` method remains available for backward compatibility. Replicate's official-model endpoint does not accept a version path parameter, so new code should use `createOfficialModelPrediction()`.

### Trainings

[](#trainings)

```
Replicate::listTrainings(array $query = []);
Replicate::createTraining(string $owner, string $name, string $version, array $data);
Replicate::getTraining(string $id);
Replicate::cancelTraining(string $id);
```

### Webhooks

[](#webhooks)

```
Replicate::defaultSecret();
Replicate::verifyWebhook(Request $request, ?string $secret = null, ?int $tolerance = null);
```

Error handling
--------------

[](#error-handling)

The client does not hide API failures. Use Laravel's standard response helpers according to your application's needs:

```
$response = Replicate::getPrediction($predictionId);

if ($response->tooManyRequests()) {
    // Release the job using Retry-After or your own backoff policy.
}

$prediction = $response->throw()->json();
```

See Laravel's [HTTP client documentation](https://laravel.com/docs/http-client) for response inspection, retries, exceptions, and test fakes.

Testing and quality
-------------------

[](#testing-and-quality)

```
composer test
composer analyse
vendor/bin/pint --test
```

The GitHub Actions matrix covers supported Laravel 11–13 and PHP 8.2–8.5 combinations with both lowest and stable dependency sets.

Changelog
---------

[](#changelog)

See [CHANGELOG.md](CHANGELOG.md) for release notes.

Security
--------

[](#security)

Please follow [SECURITY.md](SECURITY.md) to report vulnerabilities privately.

Credits
-------

[](#credits)

- [Halil Cosdu](https://github.com/halilcosdu)
- [All contributors](https://github.com/halilcosdu/laravel-replicate/graphs/contributors)

License
-------

[](#license)

Laravel Replicate is open-source software licensed under the [MIT license](LICENSE.md).

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance83

Actively maintained with recent releases

Popularity39

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~100 days

Recently: every ~55 days

Total

9

Last Release

38d ago

Major Versions

v1.3.0 → v2.0.02026-07-11

### Community

Maintainers

![](https://www.gravatar.com/avatar/eb33d4d47ce7f6f885331f34e8ed984e57866237d54526a2e3c97bdcbb11ecbb?d=identicon)[halilcosdu](/maintainers/halilcosdu)

---

Top Contributors

[![halilcosdu](https://avatars.githubusercontent.com/u/6373017?v=4)](https://github.com/halilcosdu "halilcosdu (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (7 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (5 commits)")[![micos7](https://avatars.githubusercontent.com/u/4460809?v=4)](https://github.com/micos7 "micos7 (4 commits)")[![dimzeta](https://avatars.githubusercontent.com/u/3192298?v=4)](https://github.com/dimzeta "dimzeta (1 commits)")

---

Tags

laravelaiwebhooksapi clientreplicate

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/halilcosdu-laravel-replicate/health.svg)

```
[![Health](https://phpackages.com/badges/halilcosdu-laravel-replicate/health.svg)](https://phpackages.com/packages/halilcosdu-laravel-replicate)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)[masterix21/laravel-licensing

Laravel licensing package with polymorphic assignment to any model, activation keys, expirations/renewals, and seat control via LicenseUsage. Supports offline verification with public-key–signed tokens, a CLI to generate/rotate/revoke keys, and an extensible architecture via config and contracts.

1614.1k4](/packages/masterix21-laravel-licensing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
