runapi-ai/flux-2

RunAPI Flux 2 Composer package for PHP applications

Maintainers

Package info

github.com/runapi-ai/flux-2-php

Homepage

Documentation

pkg:composer/runapi-ai/flux-2

Transparency log

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.2.0 2026-07-28 04:07 UTC

README

Packagist License

The Flux 2 PHP SDK is the Composer package for Flux 2 on RunAPI. Use it when your PHP application needs associative-array request bodies, task status lookup, polling helpers, file helpers, and consistent RunAPI errors.

Install

composer require runapi-ai/flux-2

Quick start

<?php

require __DIR__ . "/vendor/autoload.php";

use RunApi\Flux2\Flux2Client;

$client = new Flux2Client(); // reads RUNAPI_API_KEY

$task = $client->textToImage->create([
    'model' => 'flux-2-flex-text-to-image',
    'prompt' => 'A precise product render on white marble',
]);

$status = $client->textToImage->get($task->id);

$result = $client->textToImage->run([
    'model' => 'flux-2-flex-text-to-image',
    'prompt' => 'A serene mountain lake at dawn',
]);

echo $result->images[0]->url . PHP_EOL;

Use create() to submit a task and return quickly, get() to fetch the latest task state, and run() when a script should create and poll until completion. In web request handlers, prefer create() plus webhook or later get() polling so a worker is not held open.

Flux 2 Max

Use flux-2-max-text-to-image or flux-2-max-remix-image for the highest-quality tier. Max requires a concrete aspect_ratio, supports output_resolution of 1k and output_count of 1 only, and accepts exactly one public HTTP(S) source image for remix.

Returned file URLs are temporary. Download and store generated files in your own durable storage within the retention window.

All SDK exceptions inherit from RunApi\Core\Errors\RunApiException, including validation, authentication, rate limit, task failure, and task timeout errors.

Links

License

Licensed under the Apache License, Version 2.0.