PHPackages                             sabatinomasala/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. sabatinomasala/replicate-php

ActiveLibrary[API Development](/categories/api)

sabatinomasala/replicate-php
============================

PHP client for the Replicate API

1.2.0(1y ago)3745.4k↓84.3%8[1 issues](https://github.com/SabatinoMasala/replicate-php/issues)[1 PRs](https://github.com/SabatinoMasala/replicate-php/pulls)MITPHPPHP ^8.1

Since Jun 11Pushed 1y ago1 watchersCompare

[ Source](https://github.com/SabatinoMasala/replicate-php)[ Packagist](https://packagist.org/packages/sabatinomasala/replicate-php)[ Docs](https://github.com/SabatinoMasala/replicate-php)[ RSS](/packages/sabatinomasala-replicate-php/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

PHP client for the Replicate API
================================

[](#php-client-for-the-replicate-api)

This is a PHP client for Replicate. It lets you run models from your PHP code and do various other things on Replicate.

Credits
-------

[](#credits)

This package is based on the work of

Video
-----

[](#video)

If you're a more visual learner, you can check out this video this package is showcased:

[![Watch the video](https://camo.githubusercontent.com/6f5ef87513ef643ee8dc8fcb6e344857c0444356d3ff3e40f3ca1b5709946abf/68747470733a2f2f69332e7974696d672e636f6d2f76692f67534759765847356b63512f6d617872657364656661756c742e6a7067)](https://youtu.be/gSGYvXG5kcQ)

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

[](#installation)

You can install the package via composer:

```
composer require sabatinomasala/replicate-php
```

Getting an API token
--------------------

[](#getting-an-api-token)

You can get an API token from https://replicate.com/account/api-tokens

Creating a prediction
---------------------

[](#creating-a-prediction)

You can create a prediction as follows:

```
// Create a prediction
$prediction = $client->predictions()->create('stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc', [
    'prompt' => 'a cat wearing a cowboy hat',
]);

$id = $prediction->json('id');

// Fetch prediction
$prediction = $client->predictions()->get($id);
dd($prediction->json())
```

Running a model
---------------

[](#running-a-model)

You can run a model and wait on the output as follows:

```
$token = env('REPLICATE_TOKEN');
$client = new SabatinoMasala\Replicate\Replicate($token);
$output = $client->run('stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc', [
    'prompt' => 'a cat wearing a cowboy hat',
], function($prediction) {
    // You can log the current state of the prediction
    \Log::info('Progress', $prediction->json());
});

dd($output[0]);
```

### Chaining multiple models

[](#chaining-multiple-models)

Because 'run' returns the output of the model, you can chain multiple models together like this:

```
$output = $client->run('stability-ai/sdxl:7762fd07cf82c948538e41f63f77d685e02b063e37e496e96eefd46c929f9bdc', [
    'prompt' => 'a cat wearing a cowboy hat',
]);

$caption = $client->run('salesforce/blip:2e1dddc8621f72155f24cf2e0adbde548458d3cab9f00c0139eea840d0ac4746', [
    'task' => 'image_captioning',
    'image' => $output[0],
]);

dd($caption); // Caption: a drawing of a cat wearing a cowboy hat
```

Usage with official models
--------------------------

[](#usage-with-official-models)

Offical models, like Llama, have a different API endpoint. This client automatically switches endpoints, based on the input you give:

```
// This will do an API call to https://api.replicate.com/v1/models/meta/meta-llama-3-70b-instruct/predictions instead of https://api.replicate.com/v1/predictions
$output = $replicate->run('meta/meta-llama-3-70b-instruct', [
    'prompt' => 'I want to travel to Japan, give me an itinerary',
    'max_tokens' => 1000,
], function($prediction) {
    \Log::info($prediction->json('output'));
});
```

Credits
-------

[](#credits-1)

- Original creator of replicate-php: [sawirricardo](https://github.com/sawirricardo)
- [sabatinomasala](https://github.com/sabatinomasala)

License
-------

[](#license)

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

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 87.5% 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 ~19 days

Total

4

Last Release

693d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2678345?v=4)[Sabatino Masala](/maintainers/SabatinoMasala)[@SabatinoMasala](https://github.com/SabatinoMasala)

---

Top Contributors

[![SabatinoMasala](https://avatars.githubusercontent.com/u/2678345?v=4)](https://github.com/SabatinoMasala "SabatinoMasala (14 commits)")[![rrelmy](https://avatars.githubusercontent.com/u/442683?v=4)](https://github.com/rrelmy "rrelmy (2 commits)")

---

Tags

ailearningmachinereplicateartificialintelligencereplicate-phpSabatinoMasala

###  Code Quality

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[php-science/textrank

TextRank (automatic text summarization) for PHP.

2451.8M3](/packages/php-science-textrank)[saloonphp/laravel-plugin

The official Laravel plugin for Saloon

807.1M201](/packages/saloonphp-laravel-plugin)[myoutdeskllc/salesforce-php

salesforce library for php8+

1579.5k](/packages/myoutdeskllc-salesforce-php)[helgesverre/mistral

Laravel Client for the Mistral.ai API

5519.3k1](/packages/helgesverre-mistral)[benbjurstrom/replicate-php

A PHP client for the Replicate API

3925.3k1](/packages/benbjurstrom-replicate-php)[codebar-ag/laravel-docuware

DocuWare integration with Laravel

1123.7k](/packages/codebar-ag-laravel-docuware)

PHPackages © 2026

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