PHPackages                             marceloeatworld/replicate-php - 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. [API Development](/categories/api)
4. /
5. marceloeatworld/replicate-php

ActiveLibrary[API Development](/categories/api)

marceloeatworld/replicate-php
=============================

\#1 PHP client for the Replicate API, compatible with Laravel and native PHP, built on Saloon v4

v1.1.0(1mo ago)0644MITPHPPHP ^8.2

Since Mar 29Pushed 1mo agoCompare

[ Source](https://github.com/marceloeatworld/replicate-php)[ Packagist](https://packagist.org/packages/marceloeatworld/replicate-php)[ RSS](/packages/marceloeatworld-replicate-php/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (12)Versions (3)Used By (0)

Replicate PHP
=============

[](#replicate-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d759d59692615bd466ba378bfbba4c88c0f33d1826173e120f16df64b1ce16d6/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d617263656c6f656174776f726c642f7265706c69636174652d7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/marceloeatworld/replicate-php)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ecdabd32730701b669e353681def1b7915f4964310c263c89a3e42a82858cae5/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617263656c6f656174776f726c642f7265706c69636174652d7068702f74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/marceloeatworld/replicate-php/actions?query=workflow%3Atests+branch%3Amain)[![PHPStan](https://camo.githubusercontent.com/daab316ccd8edecf6190b4d2c9bb03991aea63aef28760c0e770385d03fe354d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d617263656c6f656174776f726c642f7265706c69636174652d7068702f666f726d6174732e796d6c3f6272616e63683d6d61696e266c6162656c3d7068707374616e267374796c653d666c61742d737175617265)](https://github.com/marceloeatworld/replicate-php/actions?query=workflow%3Aformats+branch%3Amain)

\#1 A framework-agnostic PHP client for the [Replicate API](https://replicate.com/) compatible with Laravel and native PHP, built on [Saloon v4](https://docs.saloon.dev/).

Full coverage of the Replicate HTTP API: predictions, models, deployments, trainings, files, collections, hardware, webhooks, and account.

> This package is a fork of [benbjurstrom/replicate-php](https://github.com/benbjurstrom/replicate-php) which only covered predictions. This version has been entirely rewritten with full API coverage, Saloon v4, PHP 8.2+, and typed DTOs for every endpoint.

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

[](#requirements)

- PHP 8.2+

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

[](#installation)

```
composer require marceloeatworld/replicate-php
```

Quick Start
-----------

[](#quick-start)

```
use MarceloEatWorld\Replicate\Replicate;

$replicate = new Replicate(
    apiToken: $_ENV['REPLICATE_API_TOKEN'],
);
```

### Create a prediction

[](#create-a-prediction)

```
$prediction = $replicate->predictions()->create(
    version: 'stability-ai/sdxl:c221b2b8ef527988fb59bf24a8b97c4561f1c671f73bd389f866bfb27c061316',
    input: ['prompt' => 'a photo of an astronaut riding a horse on mars'],
);

$prediction->id;     // "xyz123"
$prediction->status; // "starting"
```

### Create a prediction using an official model

[](#create-a-prediction-using-an-official-model)

```
$prediction = $replicate->models()->createPrediction(
    owner: 'meta',
    name: 'meta-llama-3-70b-instruct',
    input: ['prompt' => 'Write a haiku about PHP'],
);
```

### Synchronous predictions (wait for result)

[](#synchronous-predictions-wait-for-result)

```
$prediction = $replicate->predictions()->create(
    version: 'stability-ai/sdxl:c221b2b8ef527988fb59bf24a8b97c4561f1c671f73bd389f866bfb27c061316',
    input: ['prompt' => 'a painting of a cat'],
    wait: 60, // wait up to 60 seconds for completion
);

if ($prediction->status === 'succeeded') {
    $prediction->output; // result is ready
}
```

### Get prediction status

[](#get-prediction-status)

```
$prediction = $replicate->predictions()->get('xyz123');
$prediction->status; // "succeeded"
$prediction->output; // ["https://replicate.delivery/..."]
```

### List predictions

[](#list-predictions)

```
$list = $replicate->predictions()->list();
$list->results; // array of PredictionData
$list->next;    // cursor for next page

// Paginate
$nextPage = $replicate->predictions()->list(cursor: $list->next);
```

### Cancel a prediction

[](#cancel-a-prediction)

```
$replicate->predictions()->cancel('xyz123');
```

Webhooks
--------

[](#webhooks)

Pass webhook parameters directly to creation methods:

```
$prediction = $replicate->predictions()->create(
    version: 'owner/model:version',
    input: ['prompt' => 'hello'],
    webhook: 'https://example.com/webhook',
    webhookEventsFilter: ['completed'],
);
```

Get the webhook signing secret for verification:

```
$secret = $replicate->webhooks()->getSecret();
$secret->key; // "whsec_..."
```

Streaming
---------

[](#streaming)

```
$prediction = $replicate->predictions()->create(
    version: 'owner/model:version',
    input: ['prompt' => 'hello'],
    stream: true,
);

// If the model supports streaming, use the stream URL
$prediction->urls['stream']; // SSE endpoint URL
```

Models
------

[](#models)

```
// List public models
$models = $replicate->models()->list();

// Get a model
$model = $replicate->models()->get('stability-ai', 'sdxl');

// Create a model
$model = $replicate->models()->create(
    owner: 'your-username',
    name: 'my-model',
    hardware: 'gpu-a40-large',
    visibility: 'private',
);

// Update a model
$model = $replicate->models()->update('your-username', 'my-model', [
    'description' => 'Updated description',
]);

// Delete a model (must be private, no versions)
$replicate->models()->delete('your-username', 'my-model');
```

### Model Versions

[](#model-versions)

```
$versions = $replicate->models()->listVersions('stability-ai', 'sdxl');
$version = $replicate->models()->getVersion('stability-ai', 'sdxl', 'abc123');
$replicate->models()->deleteVersion('your-username', 'my-model', 'abc123');
```

Deployments
-----------

[](#deployments)

```
// List deployments
$deployments = $replicate->deployments()->list();

// Get a deployment
$deployment = $replicate->deployments()->get('your-username', 'my-deployment');

// Create a deployment
$deployment = $replicate->deployments()->create(
    name: 'my-deployment',
    model: 'your-username/my-model',
    version: 'abc123...',
    hardware: 'gpu-a40-large',
    minInstances: 1,
    maxInstances: 3,
);

// Update a deployment
$deployment = $replicate->deployments()->update('your-username', 'my-deployment', [
    'min_instances' => 2,
    'max_instances' => 5,
]);

// Create prediction on a deployment
$prediction = $replicate->deployments()->createPrediction(
    owner: 'your-username',
    name: 'my-deployment',
    input: ['prompt' => 'hello world'],
);

// Delete a deployment
$replicate->deployments()->delete('your-username', 'my-deployment');
```

Trainings
---------

[](#trainings)

```
// Create a training
$training = $replicate->trainings()->create(
    owner: 'stability-ai',
    name: 'sdxl',
    versionId: 'abc123...',
    destination: 'your-username/my-trained-model',
    input: ['train_data' => 'https://example.com/data.zip'],
    webhook: 'https://example.com/training-done',
);

// Get training status
$training = $replicate->trainings()->get($training->id);

// List trainings
$trainings = $replicate->trainings()->list();

// Cancel a training
$replicate->trainings()->cancel($training->id);
```

Files
-----

[](#files)

```
// Upload a file
$file = $replicate->files()->upload(
    content: file_get_contents('/path/to/image.jpg'),
    filename: 'image.jpg',
    contentType: 'image/jpeg',
);

// Get file metadata
$file = $replicate->files()->get($file->id);

// List files
$files = $replicate->files()->list();

// Delete a file
$replicate->files()->delete($file->id);
```

Collections
-----------

[](#collections)

```
// List collections
$collections = $replicate->collections()->list();

// Get a collection with its models
$collection = $replicate->collections()->get('text-to-image');
$collection->models; // array of ModelData
```

Hardware
--------

[](#hardware)

```
// List available hardware
$hardware = $replicate->hardware()->list();
// Returns array of HardwareData with name and sku
```

Account
-------

[](#account)

```
$account = $replicate->account()->get();
$account->username;
$account->type; // "user" or "organization"
```

Using with Laravel
------------------

[](#using-with-laravel)

Add your credentials to your services config:

```
// config/services.php
'replicate' => [
    'api_token' => env('REPLICATE_API_TOKEN'),
],
```

Bind in a service provider:

```
// app/Providers/AppServiceProvider.php
public function register(): void
{
    $this->app->bind(Replicate::class, fn () => new Replicate(
        apiToken: config('services.replicate.api_token'),
    ));
}
```

Use anywhere:

```
$prediction = app(Replicate::class)->predictions()->get($id);
```

Testing
-------

[](#testing)

Use Saloon's built-in mocking:

```
use Saloon\Http\Faking\MockClient;
use Saloon\Http\Faking\MockResponse;
use MarceloEatWorld\Replicate\Requests\Predictions\GetPrediction;

$mockClient = new MockClient([
    GetPrediction::class => MockResponse::make(['id' => 'xyz', 'status' => 'succeeded']),
]);

$replicate = new Replicate('test-token');
$replicate->withMockClient($mockClient);

$prediction = $replicate->predictions()->get('xyz');
$prediction->status; // "succeeded"
```

Response Data
-------------

[](#response-data)

All responses are returned as typed data objects:

DTODescription`AccountData`Account info`PredictionData`Single prediction`PredictionsData`Paginated prediction list`ModelData`Single model`ModelsData`Paginated model list`ModelVersionData`Single model version`ModelVersionsData`Paginated version list`CollectionData`Single collection with models`CollectionsData`Paginated collection list`DeploymentData`Single deployment`DeploymentsData`Paginated deployment list`TrainingData`Single training`TrainingsData`Paginated training list`FileData`Single file metadata`FilesData`Paginated file list`HardwareData`Hardware option (name + SKU)`WebhookSecretData`Webhook signing secretCredits
-------

[](#credits)

- [Marcelo Pereira](https://github.com/marceloeatworld)
- Originally forked from [benbjurstrom/replicate-php](https://github.com/benbjurstrom/replicate-php)

License
-------

[](#license)

The MIT License (MIT). See [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 57.1% of commits — single point of failure

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 ~0 days

Total

2

Last Release

50d ago

### Community

Maintainers

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

---

Top Contributors

[![marceloeatworld](https://avatars.githubusercontent.com/u/20625497?v=4)](https://github.com/marceloeatworld "marceloeatworld (8 commits)")[![benbjurstrom](https://avatars.githubusercontent.com/u/12499093?v=4)](https://github.com/benbjurstrom "benbjurstrom (6 commits)")

---

Tags

aiapi-clientlaravelmachine-learningphpreplicatesaloonphpaisaloonapi clientmachine learningreplicate

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/marceloeatworld-replicate-php/health.svg)

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

###  Alternatives

[deepseek-php/deepseek-php-client

deepseek PHP client is a robust and community-driven PHP client library for seamless integration with the Deepseek API, offering efficient access to advanced AI and data processing capabilities.

47073.9k5](/packages/deepseek-php-deepseek-php-client)[marceloeatworld/falai-php

Professional PHP client for the fal.ai serverless AI platform

105.5k](/packages/marceloeatworld-falai-php)[rubix/server

Deploy your Rubix ML models to production with scalable stand-alone inference servers.

632.3k](/packages/rubix-server)[sabatinomasala/replicate-php

PHP client for the Replicate API

3743.6k](/packages/sabatinomasala-replicate-php)[monkeylearn/monkeylearn-php

Official PHP client for the MonkeyLearn API.

51125.8k1](/packages/monkeylearn-monkeylearn-php)[softcreatr/php-mistral-ai-sdk

A powerful and easy-to-use PHP SDK for the Mistral AI API, allowing seamless integration of advanced AI-powered features into your PHP projects.

1517.9k](/packages/softcreatr-php-mistral-ai-sdk)

PHPackages © 2026

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