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)3743.6k↓38.2%8[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 1mo 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 85% of packages

Maintenance34

Infrequent updates — may be unmaintained

Popularity41

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity52

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

647d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1f06741753cdd2a55329d5c1eb78e86d99e4425e463753215b162197b519d3ea?d=identicon)[SabatinoMasala](/maintainers/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.

2461.7M3](/packages/php-science-textrank)[wordpress/mcp-adapter

Adapter for Abilities API, letting WordPress abilities to be used as MCP tools, resources or prompts

74855.8k1](/packages/wordpress-mcp-adapter)[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)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)[moe-mizrak/laravel-openrouter

Laravel package for OpenRouter (A unified interface for LLMs)

153107.2k2](/packages/moe-mizrak-laravel-openrouter)[myoutdeskllc/salesforce-php

salesforce library for php8+

1560.8k](/packages/myoutdeskllc-salesforce-php)

PHPackages © 2026

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