> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://fastpix.com/docs/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://fastpix.com/docs/_mcp/server.

# FastPix PHP SDK

The FastPix PHP SDK is a strongly typed PHP client for the FastPix video API. From any PHP application you can upload and manage videos, run live streams and simulcasts, create and secure playback IDs, manage playlists and signing keys, retrieve video analytics, and use in-video AI features.

\


> **Find more in the SDK reference**
>
> For all methods, runnable examples, and advanced usage, see the [FastPix PHP SDK](https://github.com/FastPix/fastpix-php) on GitHub.

\


## Before you begin

Make sure you have:

* PHP 8.2 or later
* Composer
* Internet access
* A FastPix account
* A FastPix Access Token and Secret Key, generated from the [FastPix Dashboard](https://dashboard.fastpix.com). See [Activate your account](/getting-started/activate-your-account).

FastPix uses HTTP Basic Authentication. The SDK maps your credentials as follows:

| SDK value  | FastPix credential |
| ---------- | ------------------ |
| `username` | Access Token       |
| `password` | Secret Key         |

> **Security:** Never commit your Access Token or Secret Key to source control. Use environment variables or a secure credential-management system.

Follow the steps below in order, and do not skip the verification steps. If installation, dependency loading, authentication, client initialization, or the first API request fails, fix that problem before continuing.

\


## Check your PHP version

```bash
php --version
```

The output is similar to `PHP 8.5.10 (cli) ...`. The SDK supports PHP 8.2 and later. If your version is earlier than 8.2, install a supported version before continuing.

You can also print the exact version:

```bash
php -r 'echo PHP_VERSION, PHP_EOL;'
```

\


## Check your Composer installation

The SDK uses Composer to install and manage dependencies.

```bash
composer --version
```

The expected output is similar to `Composer version 2.x.x`. If you see `command not found`, Composer is not available in your shell. Install Composer before continuing.

\


## Create a PHP project

Create a directory for your application and initialize a Composer project:

```bash
mkdir fastpix-php-demo
cd fastpix-php-demo
composer init
```

Accept the default values when prompted. When Composer asks whether to define dependencies interactively, select `no`; you add the SDK in the next step. After initialization, the project contains a `composer.json` file.

> **Note:** Do not enter `ls` at the package-name prompt. `ls` is a shell command, not a valid Composer package name.

\


## Install the FastPix SDK

```bash
composer require fastpix/sdk
```

After installation, your project contains `composer.json`, `composer.lock`, and a `vendor/` directory. The `vendor/` directory holds the installed SDK and Composer's autoloader.

\


## Verify the SDK installation

```bash
composer show fastpix/sdk
```

The output identifies the FastPix SDK package and the installed version. You can also search all installed packages:

```bash
# macOS and Linux
composer show | grep fastpix
```

```powershell
# Windows PowerShell
composer show | Select-String fastpix
```

If `fastpix/sdk` is not listed, run `composer install`, then verify again with `composer show fastpix/sdk`.

\


## Verify that PHP can load the SDK

Create a file named `verify.php`:

```php
<?php
require 'vendor/autoload.php';

use FastPix\Sdk;

echo "FastPix SDK loaded successfully" . PHP_EOL;
```

Run it:

```bash
php verify.php
```

The expected output is `FastPix SDK loaded successfully`. This confirms that PHP can execute the application, Composer's autoloader is available, and the SDK can be loaded. If it fails, confirm that PHP 8.2 or later is installed, `composer require fastpix/sdk` completed, `vendor/autoload.php` exists, and you are running the command from the project directory.

\


## Configure authentication

FastPix uses HTTP Basic Authentication, where `username` is your Access Token and `password` is your Secret Key. For local development, set these as environment variables:

```bash
# macOS and Linux
export FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
export FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"
```

```powershell
# Windows PowerShell
$env:FASTPIX_USERNAME="<YOUR_ACCESS_TOKEN>"
$env:FASTPIX_PASSWORD="<YOUR_SECRET_KEY>"
```

\


## Verify that your credentials are set

Check that the variables are set without printing their values:

```bash
# macOS and Linux
if [ -n "$FASTPIX_USERNAME" ]; then echo "Access Token: set"; else echo "Access Token: missing"; fi
if [ -n "$FASTPIX_PASSWORD" ]; then echo "Secret Key: set"; else echo "Secret Key: missing"; fi
```

```powershell
# Windows PowerShell
if ($env:FASTPIX_USERNAME) { "Access Token: set" } else { "Access Token: missing" }
if ($env:FASTPIX_PASSWORD) { "Secret Key: set" } else { "Secret Key: missing" }
```

Both should report `set`. If either is `missing`, set the corresponding environment variable before continuing.

\


## Initialize the FastPix client

Create a file named `main.php`:

```php
<?php
require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$username = getenv('FASTPIX_USERNAME');
$password = getenv('FASTPIX_PASSWORD');

if ($username === false || $username === '') {
    throw new RuntimeException('FASTPIX_USERNAME is not set');
}
if ($password === false || $password === '') {
    throw new RuntimeException('FASTPIX_PASSWORD is not set');
}

$sdk = Sdk\Fastpixsdk::builder()
    ->setSecurity(
        new Components\Security(
            username: $username,
            password: $password,
        )
    )
    ->build();

echo "FastPix client initialized" . PHP_EOL;
```

Run it:

```bash
php main.php
```

The expected output is `FastPix client initialized`. Initializing the client does not make an API request; a request happens only when you call an SDK operation such as `$sdk->inputVideo->createMedia(...)`.

\


## Make your first API request

The easiest way to verify the integration is to create media from a publicly accessible video URL. FastPix provides a sample video at `https://static.fastpix.com/fp-sample-video.mp4`.

Replace the contents of `main.php` with:

```php
<?php
require 'vendor/autoload.php';

use FastPix\Sdk;
use FastPix\Sdk\Models\Components;

$username = getenv('FASTPIX_USERNAME');
$password = getenv('FASTPIX_PASSWORD');

if ($username === false || $username === '') {
    throw new RuntimeException('FASTPIX_USERNAME is not set');
}
if ($password === false || $password === '') {
    throw new RuntimeException('FASTPIX_PASSWORD is not set');
}

$sdk = Sdk\Fastpixsdk::builder()
    ->setSecurity(
        new Components\Security(
            username: $username,
            password: $password,
        )
    )
    ->build();

try {
    $request = new Components\CreateMediaRequest(
        inputs: [
            new Components\PullVideoInput(
                url: 'https://static.fastpix.com/fp-sample-video.mp4',
            ),
        ],
        metadata: [
            'source' => 'fastpix-php-demo',
        ],
    );

    $response = $sdk->inputVideo->createMedia(request: $request);

    if ($response->statusCode >= 200 && $response->statusCode < 300) {
        $rawBody = (string) $response->rawResponse->getBody();
        $decoded = json_decode($rawBody, true);
        echo json_encode($decoded ?? $rawBody, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
    } else {
        $errorPayload = $response->defaultError ?? $response->error ?? null;
        echo json_encode($errorPayload ?? ['message' => 'No response data'], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
        exit(1);
    }
} catch (\Exception $e) {
    echo json_encode(['error' => $e->getMessage()], JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL;
    exit(1);
}
```

Run it:

```bash
php main.php
```

A successful request returns information about the newly created media asset, similar to:

```json
{
  "success": true,
  "data": {
    "id": "..."
  }
}
```

The exact fields depend on the API response and the installed SDK version.

\


## Capture the media ID

The create-media response contains the unique ID assigned to the media asset, at `data.id`:

```json
{
  "success": true,
  "data": {
    "id": "12345678-1234-1234-1234-123456789abc"
  }
}
```

Save this value for later operations:

```text
MEDIA_ID=<value returned in data.id>
```

A `media_id` is not the same as a `playback_id`. They identify different resources and are used for different operations.

\


## Verify the integration

A successful create-media request confirms that PHP is installed and supported, Composer is installed, the project is initialized, the SDK is installed and loadable, your credentials are configured, the client can authenticate, and FastPix returns a media ID.

The initial SDK integration is now complete.

\


## Resources, error handling, and reference

The SDK is generated from the FastPix API specification, so the complete and always-current reference lives in the repo and the API docs:

* **All resources, operations, error handling, and server selection**: the [FastPix PHP SDK on GitHub](https://github.com/FastPix/fastpix-php), with runnable code in the [examples](https://github.com/FastPix/fastpix-php/tree/main/examples) directory.
* **Media** (upload, manage, playback, playlists, signing keys, DRM): [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).
* **Live** (streams, simulcasts, live playback): [Live Stream API](https://fastpix.com/docs/live-stream-api/overview).
* **Video Data** (metrics, views, dimensions, errors): [Video Data API](https://fastpix.com/docs/video-data-api/overview).
* **In-video AI** (summaries, chapters, named entities, moderation): [In-Video AI](/in-video-ai/overview).

\


#### Frequently asked questions

The SDK is a strongly typed PHP wrapper around the same FastPix REST API. It handles authentication, request serialization, and response parsing for you, so you call methods like `$sdk->inputVideo->createMedia(...)` instead of building raw HTTP requests. Anything the SDK does, you can also do by calling the REST API directly. See [Make your first API request](#make-your-first-api-request).

It is a Composer package. Run `composer require fastpix/sdk` in your project, or add `fastpix/sdk` to `composer.json` and run `composer update`. See [Install the FastPix SDK](#install-the-fastpix-sdk).

FastPix uses HTTP Basic Authentication. Pass your Access Token as the `username` and your Secret Key as the `password` in `Components\Security` when building the client. See [Initialize the FastPix client](#initialize-the-fastpix-client).

Create media from a URL or a direct upload through the input-video resource on the built client, for example `$sdk->inputVideo->createMedia(...)`. See [Make your first API request](#make-your-first-api-request).

FastPix uploads are not limited by PHP's `upload_max_filesize` or `post_max_size`. When you pull from a URL, FastPix fetches the file directly, and when you upload from a device, the SDK gives you a signed URL that the file goes to directly, so the bytes never pass through your PHP process. Large multi-gigabyte files upload without changing your `php.ini`. See the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

Use the Live API resources to create and manage streams, simulcasts, and live playback IDs. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-php) and the [Live Stream API](https://fastpix.com/docs/live-stream-api/overview).

Generate playback IDs and manage signing keys and DRM configurations through the Media API resources. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-php) and the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

Create the media with a private access policy, then generate a signed playback ID so only holders of a valid token can play it. For stronger protection, enable DRM on the playback ID. You revoke access by deleting the playback ID. Handle all of this through the Media API resources. See the [Video on Demand API](https://fastpix.com/docs/video-on-demand-api/overview).

The Video Data API exposes metrics, views, dimensions, and errors for quality-of-experience monitoring. See the [Video Data API](https://fastpix.com/docs/video-data-api/overview).

Wrap calls in a `try`/`catch` block. The SDK throws a typed `APIException` that exposes the message, status code, and response body. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-php) for the error types each operation can throw.

Pass a server URL with `setServerUrl(...)` when building the client. See the [SDK reference on GitHub](https://github.com/FastPix/fastpix-php).

PHP 8.2 and later. See [Before you begin](#before-you-begin).

\


## What's next

Want to go further? Browse runnable, end-to-end samples for the FastPix PHP SDK in the [examples folder](https://github.com/FastPix/fastpix-php/tree/main/examples) of the GitHub repository.

\


## Release notes

For a complete history of releases, improvements, and fixes, see the [FastPix PHP SDK CHANGELOG on GitHub](https://github.com/FastPix/fastpix-php/blob/main/CHANGELOG.md).