Download the PHP package marceloeatworld/falai-php without Composer

On this page you can find all versions of the php package marceloeatworld/falai-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package falai-php

fal.ai PHP Client

1 PHP client for the fal.ai serverless AI platform, compatible with Laravel and native PHP, built on Saloon v4.

Requirements

Installation

Quick Start

Streaming

Models that expose a /stream endpoint (check the model page, or stream_url in its catalog metadata) push partial results as server-sent events. stream() yields each event as an array; the last event is the final result and is also returned by the generator.

Models without a /stream endpoint answer 404 (Path /stream not found). fal-ai/flux/schnell, for example, has none; fal-ai/flux/dev does.

Queue (Async Workflow)

For long-running models, use the queue to submit jobs and retrieve results later.

Status, result and cancel are addressed by application id (fal-ai/flux), not by the full endpoint id (fal-ai/flux/schnell). The client derives it automatically, so pass the same model id you submitted with. The URLs returned by submit() (statusUrl, responseUrl, cancelUrl) are also exposed on the QueuedJob DTO.

Subscribe (Submit + Auto-Poll)

Submit a job and automatically poll until it completes.

Status Streaming

Instead of polling, the queue can push status updates as server-sent events until the request completes. The last yielded status is the COMPLETED one.

Webhooks

Receive results via webhook instead of polling.

Verifying Webhook Signatures

fal.ai signs every webhook with ED25519 (X-Fal-Webhook-* headers). Verify before trusting the payload:

Public keys are fetched from the fal.ai JWKS endpoint (https://rest.fal.ai/.well-known/jwks.json) and cached per instance for 24 hours, so reuse the verifier (singleton) across requests. If a signature matches none of the cached keys, the JWKS is fetched again once to pick up rotated keys. verify() throws with a reason, isValid() returns a boolean. Timestamps more than 5 minutes away from the server clock are rejected.

Webhook payloads carry status ("OK" or "ERROR"), request_id, gateway_request_id and payload. On error an error field is added; if the output could not be serialized, payload is null and payload_error explains why. fal.ai retries deliveries that do not answer with a 2xx (redirects count as failures), so keep handlers idempotent.

File Upload

Upload local files to the fal.ai CDN for use with image-to-image models. Files above 90 MB are uploaded in 10 MB parts (multipart flow of the official clients, each part retried up to 3 times); smaller files use a single PUT.

In-memory content works too:

Both methods accept a lifecycle to control expiration and access (see below):

File Expiration and Access Control

By default generated and uploaded files stay on the CDN forever and are publicly readable (unless your account settings say otherwise). Pass an ObjectLifecycle to run(), stream(), queue->submit(), queue->subscribe(), storage->upload() or storage->uploadData() to change that per request. It is sent as the X-Fal-Object-Lifecycle-Preference header.

Private files answer 403 to anonymous requests. To read them, exchange your API key for a CDN token (POST https://rest.fal.ai/storage/auth/token?storage_type=fal-cdn-v3) and send it as Authorization: Bearer <token>, or create a signed URL from the fal.ai dashboard or Platform API.

Model Catalog

Search the fal.ai model catalog (no API key required for this endpoint, but one is always sent).

Pricing

Fetch unit prices and estimate costs (API key required).

Queue Options

Fine-tune queue behavior with named parameters.

subscribe() accepts the same options (timeout there is the client-side polling limit, use requestTimeout for the server-side deadline). run() and stream() accept timeout, noRetry, lifecycle and storeIo.

Useful response headers on run() and result(): x-fal-request-id, x-fal-billable-units, and x-fal-error-type on failures.

Custom Base URLs

Override default endpoints if needed.

Laravel Integration

Add to config/services.php:

Register in a service provider:

Use via injection:

Error Handling

The client throws Saloon exceptions on HTTP errors (4xx/5xx). Queue subscribe throws dedicated exceptions (both extend \RuntimeException) on timeouts and on jobs whose status reports an error (for example client_cancelled).

Input validation errors are not reported in the queue status: the job completes and the result endpoint answers 422 with a detail array, so result() and subscribe() throw a Saloon RequestException in that case. Catch both.

Status responses expose error and error_type (QueueStatus::$error, QueueStatus::$errorType); request-level error types include request_timeout, startup_timeout, client_cancelled, runner_server_error and internal_error.

Architecture

License

MIT

Credits


All versions of falai-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.6
saloonphp/saloon Version ^4.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package marceloeatworld/falai-php contains the following files

Loading the files please wait ...