PHPackages                             thehocinesaad/stability-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. thehocinesaad/stability-php

ActiveLibrary[API Development](/categories/api)

thehocinesaad/stability-php
===========================

Stability PHP is a comprehensive PHP API client designed for seamless interaction with the Stability AI API.

v0.1.0(2y ago)64.9k1MITPHPPHP ^8.0

Since Nov 16Pushed 2y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (5)Versions (2)Used By (1)

[![Stability PHP example code.](https://camo.githubusercontent.com/3b2833355646fc07e7ac08d1160cf872808a39f48cde8c358b5a83118b21e76f/68747470733a2f2f692e696d6775722e636f6d2f344176674f30392e706e67 "Stability PHP example code.")](https://camo.githubusercontent.com/3b2833355646fc07e7ac08d1160cf872808a39f48cde8c358b5a83118b21e76f/68747470733a2f2f692e696d6775722e636f6d2f344176674f30392e706e67)

Stability PHP is a PHP API client offering developers an intuitive and efficient interface to interact seamlessly with the [Stability AI API](https://platform.stability.ai/docs/api-reference "Stability AI API").

Table of Contents
-----------------

[](#table-of-contents)

- [ **Installation**](#installation)
- [**Usage**](#usage)
    - [User](#user)
        - [Account](#account)
        - [Balance](#balance)
    - [Engines](#engines)
        - [List](#list)
    - [Generations](#generations)
        - [Text to Image](#text-to-image)
        - [Image to Image](#image-to-image)
        - [Image to Image Upscale](#image-to-image-upscale)
        - [Image to Image Masking](#image-to-image-masking)
- [**License**](#license)

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

[](#installation)

You can install the package via composer:

```
composer require thehocinesaad/stability-php
```

After that, you can start using it:

```
$client = Stability::client('YOUR_API_KEY');

$response = $client->generations()->textToImage('stable-diffusion-xl-1024-v1-0', [
    'text_prompts' => [
        [
            'text' => 'A lighthouse on a cliff',
            'weight' => 0.5
        ],
    ],
    'samples' => 1,
]);

dd($response['artifacts'][0]['base64']);
// "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAM8MmNhQ..." - Image encoded in base64.
```

You can add additional HTTP headers (which the API supports) to requests:

```
$client = Stability::client(YOUR_API_KEY')
    ->withAcceptHeader('image/png')
    ->withOrganizationHeader('org-123456')
    ->withStabilityClientIdHeader('my-great-plugin')
    ->withStabilityClientVersionHeader('1.2.1');
```

Usage
-----

[](#usage)

### User

[](#user)

Manage your Stability.ai account, and view account/organization balances.

#### **`Account`**

[](#account)

Get information about the account associated with the provided API key.

- See:

```
$response = $client->user()->account();

$response['email']; // 'your@email.com'
$response['id']; // 'user-xxxxxxxxxxxxxxx'
// ...
```

---

#### **`Balance`**

[](#balance)

Get the credit balance of the account/organization associated with the API key.

- See:

```
$response = $client->user()->balance();

$response['credits']; // 1000000 😍
```

### Engines

[](#engines)

Enumerate available engines.

#### **`List`**

[](#list)

List all engines available to your organization/user.

- See:

```
$response = $client->engines()->list();
// Returns an array of available engines.

foreach ($response as $engine) {
    $engine['description']; // 'Stability-AI Stable Diffusion XL v1.0'
    $engine['id']; // 'stable-diffusion-xl-1024-v1-0'
    $engine['name']; // 'Stable Diffusion XL v1.0'
    $engine['type']; // 'PICTURE'
}
```

### Generations

[](#generations)

Generate images from text, existing images, or both.

#### **`Text to Image`**

[](#text-to-image)

Generate a new image from a text prompt.

- See:

```
$response = $client->generations()->textToImage('stable-diffusion-xl-1024-v1-0', [
    'text_prompts' => [
        [
            'text' => 'A lighthouse on a cliff',
        ],
    ],
    'cfg_scale' => 7,
    'height' => 1024,
    'width' => 1024,
    'steps' => 30,
    'samples' => 2,
]);

foreach ($response['artifacts'] as $result) {
    $result['base64']; // 'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAA...'
    $result['seed']; // 6311659811
    $result['finishReason']; // 'SUCCESS'
}
```

---

#### **`Image to Image`**

[](#image-to-image)

Modify an image based on a text prompt.

- See:

```
$response = $client->generations()->imageToImage(stable-diffusion-xl-1024-v1-0', [
    'init_image' => 'init_image.png',
    'init_image_mode' => 'IMAGE_STRENGTH',
    'image_strength' => '0.35',
    'text_prompts' => [
        [
            'text' => 'A lighthouse on a cliff',
        ],
    ],
    'cfg_scale' => 7,
    'steps' => 10,
    'samples' => 2,
]);

foreach ($response['artifacts'] as $result) {
    $result['base64']; // 'iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAA...'
    $result['seed']; // 4285698893
    $result['finishReason']; // 'SUCCESS'
}
```

---

#### **`Image to Image Upscale`**

[](#image-to-image-upscale)

Create a higher resolution version of an input image.

- See:

```
$response = $client->generations()->imageToImageUpscale('esrgan-v1-x2plus', [
    'image' => 'image.png',
    'width' => '1024',
]);

$response['artifacts'][0]['base64']; // 'iVBORw0KGgoAAAANSUhEUgAAAgAAAAIACAIAAAB7GkOtAAD...'
$response['artifacts'][0]['seed']; // 0
$response['artifacts'][0]['finishReason']; // 'SUCCESS'
```

---

#### **`Image to Image Masking`**

[](#image-to-image-masking)

Selectively modify portions of an image using a mask.

- See:

```
$response = $client->generations()->imageToImageMasking('stable-inpainting-512-v2-0', [
    'mask_source' => 'MASK_IMAGE_BLACK',
    'init_image' => 'init_image.png',
    'mask_image' => 'mask_image.png',
    'text_prompts' => [
        [
            'text' => 'A lighthouse on a cliff',
        ],
    ],
    'cfg_scale' => 7,
    'clip_guidance_preset' => 'FAST_BLUE',
    'steps' => 10,
    'samples' => 2,
]);

foreach ($response['artifacts'] as $result) {
    $result['base64']; // 'iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7...'
    $result['seed']; // 96898585
    $result['finishReason']; // 'SUCCESS'
}
```

License
-------

[](#license)

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

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 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

914d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpclientaistabilitystable diffusionstability-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/thehocinesaad-stability-php/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[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)[resend/resend-php

Resend PHP library.

574.7M21](/packages/resend-resend-php)[gemini-api-php/client

API client for Google's Gemini API

216221.4k5](/packages/gemini-api-php-client)[mozex/anthropic-laravel

Anthropic PHP for Laravel is a supercharged PHP API client that allows you to interact with the Anthropic API

71226.4k1](/packages/mozex-anthropic-laravel)[thehocinesaad/stability-laravel

Stability Laravel is a comprehensive Laravel API client designed for seamless interaction with the Stability AI API.

111.3k](/packages/thehocinesaad-stability-laravel)

PHPackages © 2026

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