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

ActiveLibrary[API Development](/categories/api)

arikislam/replicate-php-client
==============================

A PHP client for the Replicate API

1.0.0(1y ago)0131MITPHPPHP ^7.4|^8.0

Since Oct 17Pushed 1y ago1 watchersCompare

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

READMEChangelogDependencies (1)Versions (2)Used By (0)

Replicate PHP Client
====================

[](#replicate-php-client)

[![Latest Stable Version](https://camo.githubusercontent.com/37740395b6f37ee3c27e42b052230cb020f33b78513d44ecc1be5e9f0be04868/68747470733a2f2f706f7365722e707567782e6f72672f6172696b69736c616d2f7265706c69636174652d7068702d636c69656e742f762f737461626c65)](https://packagist.org/packages/arikislam/replicate-php-client)[![License](https://camo.githubusercontent.com/7133afda32834318af4cfb81f399dec0bccc861d5af391586e83d467e7ab746b/68747470733a2f2f706f7365722e707567782e6f72672f6172696b69736c616d2f7265706c69636174652d7068702d636c69656e742f6c6963656e7365)](https://packagist.org/packages/arikislam/replicate-php-client)

A simple PHP client for interacting with the [Replicate API](https://replicate.com), enabling the ability to run machine learning models from your PHP applications. This library provides a clean and reusable way to interact with the API in a Laravel environment but can also be used in other PHP applications.

Features
--------

[](#features)

- Simple API client for [Replicate](https://replicate.com)
- Supports Laravel out of the box
- Uses [Guzzle HTTP client](https://github.com/guzzle/guzzle) for HTTP requests
- Allows easy integration with machine learning models using Replicate

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

[](#installation)

To install the package, simply use Composer:

```
composer require arikislam/replicate-php-client
```

### Laravel Configuration

[](#laravel-configuration)

For Laravel applications, the package will automatically register the `ReplicatePhpClientServiceProvider` and the `Replicate` alias.

You can publish the config file with:

```
php artisan vendor:publish --provider="Arikislam\ReplicatePhpClient\Providers\ReplicatePhpClientServiceProvider"
```

Usage
-----

[](#usage)

### Configuration

[](#configuration)

To use this package, you must have an API key from [Replicate](https://replicate.com).

Set up the API key in your environment file:

```
REPLICATE_API_KEY=your_api_key_here
```

### Example Request

[](#example-request)

To create an inference using the Replicate API, use the `Replicate` facade in your application as shown below:

```
use Arikislam\ReplicatePhpClient\Replicate;

$response = Replicate::createPrediction([
    'input' => [
        'prompt' => 'Test',
        'go_fast' => true,
        'num_outputs' => 1,
        'aspect_ratio' => '16:9',
        'output_format' => 'png',
        'output_quality' => 80,
        'megapixels' => '.25',
    ],
]);

// Get the prediction results
$predictionResult = $response->getResult();
```

This example demonstrates how to send a request to the Replicate API with the required parameters.

### Detailed Breakdown

[](#detailed-breakdown)

#### 1. Input

[](#1-input)

The `input` parameter specifies the model input options. In this case:

- `prompt`: The text prompt for generating the image.
- `go_fast`: A boolean indicating whether the model should prioritize speed over quality.
- `num_outputs`: The number of outputs required from the model.
- `aspect_ratio`: The aspect ratio of the output (e.g., 16:9).
- `output_format`: The format of the generated output (e.g., `png`).
- `output_quality`: The quality of the output (percentage-based, 80 means 80% quality).
- `megapixels`: Controls the megapixel size for the image (e.g., .25).

#### 2. Webhooks

[](#2-webhooks)

Although webhooks can be used to track the progress of asynchronous tasks, this package allows you to specify a `webhook` URL and `webhook_events_filter` to listen for certain events. Currently, the `webhook` parameter is set to `null` in the example for simplicity.

#### 3. API Version

[](#3-api-version)

The `version` is an identifier for the version of the Replicate API being used. You can specify which model version you are targeting by using the correct version hash.

### Response Handling

[](#response-handling)

The response from the API will contain details of the prediction, including the generated content or the status of the request. You can handle the response as follows:

```
if ($response->isSuccessful()) {
    $output = $response->getResult();
    // Do something with the output, such as saving the image or displaying it
} else {
    // Handle errors
    $errorMessage = $response->getErrorMessage();
    // Log or display the error message
}
```

Testing
-------

[](#testing)

This package includes support for unit testing. You can run tests using PHPUnit:

```
vendor/bin/phpunit
```

Advanced Usage
--------------

[](#advanced-usage)

### Custom HTTP Client

[](#custom-http-client)

You can provide your own custom HTTP client if needed by extending the Guzzle client. For example:

```
use GuzzleHttp\Client;
use Arikislam\ReplicatePhpClient\Replicate;

$client = new Client([
    'base_uri' => 'https://api.replicate.com',
    'timeout'  => 10.0,
]);

$replicate = new Replicate($client);
$response = $replicate->createPrediction([
    // input options
]);
```

### Facades in Laravel

[](#facades-in-laravel)

For Laravel users, the `Replicate` facade provides a convenient way to interact with the API. However, if you are not using Laravel, you can directly instantiate the `Replicate` class and make API requests.

Contributing
------------

[](#contributing)

Contributions are welcome! Please submit a pull request or open an issue to contribute to the development of this package.

License
-------

[](#license)

This package is licensed under the MIT License. See the [LICENSE](LICENSE) file for more information.

Author
------

[](#author)

This package is maintained by [S M Ariq Islam](mailto:arikislam321@gmail.com).

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

578d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8f15b7cee24a4396658ef4f81d4e50c3c59826c91c4a435984de3a096a03142e?d=identicon)[arikislam](/maintainers/arikislam)

---

Top Contributors

[![arikislam](https://avatars.githubusercontent.com/u/11427054?v=4)](https://github.com/arikislam "arikislam (4 commits)")

### Embed Badge

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

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

###  Alternatives

[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3731.2M42](/packages/tencentcloud-tencentcloud-sdk-php)[convertkit/convertkitapi

Kit PHP SDK for the Kit API

2167.1k1](/packages/convertkit-convertkitapi)[mapado/rest-client-sdk

Rest Client SDK for hydra API

1125.9k2](/packages/mapado-rest-client-sdk)

PHPackages © 2026

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