AI & Agents

How to Set Up Fastio API PHP Laravel Integration

Integrating the Fastio API into a PHP Laravel application allows developers to upgrade their file storage into a smart, agent-accessible workspace. This guide explains how to configure a custom storage driver, manage authentication, and connect Ripley, the built-in RAG agent, from your PHP ecosystem.

Fastio Editorial Team 9 min read
Abstract view of an intelligent API integration dashboard displaying connected workspaces

Why Laravel Developers Need Agent-Accessible Storage

Integrating the Fastio API into a PHP Laravel application allows developers to upgrade their file storage into a smart, agent-accessible workspace. According to Kinsta, Laravel remains the most popular PHP framework for building modern enterprise web applications. Because of its wide adoption, PHP developers are often tasked with modernizing legacy applications to support new artificial intelligence features. Connecting standard object storage buckets to complex AI systems usually requires building expensive intermediate layers. Fastio offers a different approach.

Traditional cloud storage limits applications to basic put-and-get operations. A file dropped into a standard bucket sits passively until another service requests it. Fastio acts as an active intelligence layer instead. Every workspace is automatically indexed. This makes files instantly searchable by meaning without the need to configure a separate vector database.

When your application uploads user data to Fastio, human team members and large language models can interact with the content through a unified interface. Not many resources exist to guide PHP developers on integrating modern AI-agent focused storage platforms like Fastio. By shifting to an agentic workspace, developers can cut down the amount of infrastructure code they have to write and maintain.

Helpful references: Fastio Workspaces, Fastio Collaboration, and Fastio AI.

What to check before scaling Fastio API PHP Laravel integration

Before writing any PHP code, you need to establish a secure connection between your application and the Fastio ecosystem. Authenticated calls use Authorization: Bearer {api_key} against https://api.fast.io/current/. Keep the trailing slashes. Most POST bodies are application/x-www-form-urlencoded. Uploads are multipart/form-data.

Generate an API key in Settings > Devices & Agents > API Keys, or create one with POST /current/user/auth/key/. Workspace IDs are 19-digit numeric strings. Store these credentials safely within your project's .env file to prevent accidental commits to public version control repositories. Open your environment file and append the following variables:

FASTIO_API_KEY="your_secure_api_key_here"
FASTIO_WORKSPACE_ID="your_target_workspace_id"
FASTIO_BASE_URL="https://api.fast.io/current/"

Next, register these environment variables within your Laravel configuration system. Navigate to config/services.php and add a new array block for Fastio. This sets up a centralized configuration point that your application's service container can reference safely during the boot process.

return [
    // Other services...
    'fastio' => [
        'key' => env('FASTIO_API_KEY'),
        'workspace' => env('FASTIO_WORKSPACE_ID'),
        'url' => env('FASTIO_BASE_URL', 'https://api.fast.io/current/'),
    ],
];

Centralizing your configuration ensures your underlying integration code remains independent of the specific environment. When deploying your application from a local development machine to a production server, you only need to swap the environment file variables.

Building a Dedicated Fastio HTTP Client Service

Laravel provides an HTTP client built on top of Guzzle. While you could dispatch requests directly from your controllers, it is better practice to wrap external API interactions within a dedicated service class. This approach encapsulates error handling, simplifies token management, and makes your code easier to test using mocked responses.

Create a new class in your app/Services directory named FastioClient. This service acts as the bridge between your application and the Fastio API.

namespace App\Services;

use Illuminate\Support\Facades\Http;
use Illuminate\Http\Client\PendingRequest;
use Illuminate\Http\Client\RequestException;

class FastioClient
{
    protected string $apiKey;
    protected string $baseUrl;

public function __construct()
    {
        $this->apiKey = config('services.fastio.key');
        $this->baseUrl = config('services.fastio.url');
    }

/**
     * Prepares the HTTP client with required headers.
     */
    protected function request(): PendingRequest
    {
        return Http::baseUrl($this->baseUrl)
            ->withToken($this->apiKey)
            ->acceptJson()
            ->timeout(30)
            ->retry(3, 100); // Retry failed requests 3 times with a 100ms delay
    }

/**
     * Lists a folder. Use parentId "root" for the workspace root.
     */
    public function listFiles(string $workspaceId, string $parentId = 'root'): array
    {
        $response = $this->request()->get("/workspace/{$workspaceId}/storage/{$parentId}/list/");

if ($response->failed()) {
            $response->throw();
        }

return $response->json();
    }
}

This service wrapper applies default timeout values and automatic retry logic. Network requests fail for many unpredictable reasons. Adding resilience early in your integration helps your application handle poor network conditions smoothly. If a call returns HTTP 429 with error code 1671, wait until the x-ve-limit-expires header before retrying. Folder listings are cursor-based: pass sort_by, sort_dir, page_size, and cursor, and follow pagination.has_more with pagination.next_cursor.

Uploading Documents and Managing Agent File Locks

Transferring files into an intelligent workspace requires reliable payload management. Fastio handles the background tasks of indexing and generating embeddings automatically. This leaves your application responsible only for delivering the initial binary data.

When an agent and a human user collaborate within the same workspace, managing concurrent access becomes necessary. Fastio provides file lock mechanisms to prevent race conditions. If an automated model is actively generating a document summary or writing code into a file, it can acquire an exclusive lock. You need to respect these locks in your PHP backend.

public function uploadDocument(string $workspaceId, string $filePath, string $filename)
{
    $contents = file_get_contents($filePath);
    $size = filesize($filePath);

if ($contents === false || $size === false) {
        throw new \RuntimeException("Unable to read local file.");
    }

$response = $this->request()
        ->attach('chunk', $contents, $filename)
        ->post('upload/', [
            'name' => $filename,
            'size' => $size,
            'action' => 'create',
            'instance_id' => $workspaceId,
            'folder_id' => 'root',
        ]);

return $response->json();
}

public function acquireLock(string $workspaceId, string $nodeId)
{
    $response = $this->request()
        ->post("/workspace/{$workspaceId}/storage/{$nodeId}/lock/");

return $response->successful();
}

public function heartbeatLock(string $workspaceId, string $nodeId)
{
    $response = $this->request()
        ->post("/workspace/{$workspaceId}/storage/{$nodeId}/lock/heartbeat/");

return $response->successful();
}

A successful small upload returns HTTP 201 with result, id, and new_file_id. Keep new_file_id for later reads, locks, shares, and Ripley queries. Same-name upload into the same folder overwrites in place and keeps the old content as a recoverable version. The node_id stays stable. Release a lock with DELETE /current/workspace/{workspace_id}/storage/{node_id}/lock/.

For a large file, POST the same upload/ form without chunk to receive an upload id, send each piece to POST /current/upload/{id}/chunk/?order=N&size=N, finish with POST /current/upload/{id}/complete/, then read GET /current/upload/{id}/details/?wait=60 for session.status and session.new_file_id.

In some scenarios, you can skip local I/O by using URL import. Instead of downloading a large video file from Google Drive to your Laravel server just to upload it again to Fastio, POST application/x-www-form-urlencoded fields source_url, file_name, profile_id, profile_type (workspace or share), and folder_id to https://api.fast.io/current/web_upload/. Fastio pulls the file directly from the source, saving your server bandwidth and memory.

Processing Webhooks for Reactive Agent Workflows

Laravel queues are a good place to watch workspace activity. Long-poll GET /current/activity/poll/{entityId}?wait=95&lastactivity={timestamp} waits for the next event, then your job can continue. Search the same history in the audit log with GET /current/events/search/. Coordination Rooms also emit room.message.created and room.participant.status_changed. Agents wait on those through the MCP room tool (wait, messages, post).

Add these methods to FastioClient. Raise the timeout above 95 seconds so the long-poll can finish.

public function searchEvents(): array
{
    $response = $this->request()->get('/events/search/');

if ($response->failed()) {
        $response->throw();
    }

return $response->json();
}

public function pollActivity(string $entityId, string $lastActivity): array
{
    $response = $this->request()
        ->timeout(120)
        ->get("/activity/poll/{$entityId}", [
            'wait' => 95,
            'lastactivity' => $lastActivity,
        ]);

if ($response->failed()) {
        $response->throw();
    }

return $response->json();
}

Dispatch a queued job so the HTTP worker is not blocked for the full wait. When activity returns, continue your pipeline: list the folder, start Ripley, or invite a teammate with POST /current/workspace/{workspace_id}/members/{email_or_user_id}/.

namespace App\Jobs;

use App\Services\FastioClient;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;

class WatchFastioActivity implements ShouldQueue
{
    use Dispatchable, Queueable;

public function __construct(
        public string $entityId,
        public string $lastActivity
    ) {}

public function handle(FastioClient $fastio): void
    {
        $activity = $fastio->pollActivity($this->entityId, $this->lastActivity);
    }
}

An AI agent can construct a workspace, fill it with intelligence-indexed files, and leave a trail in the audit log. Your queued job reads that activity and emails a human user, inviting them to take administrative control of the new environment.

Fastio features

Give Your AI Agents Persistent Storage

Connect Laravel to intelligent workspaces with the Fastio REST API, MCP tools, and built-in Ripley RAG. Built for fast api php laravel integration workflows.

Integrating the Fastio MCP Server and OpenClaw

Connecting your application backend with natural language tools opens up new capabilities. Fastio exposes 19 named-mode MCP tools (auth, user, org, workspace, share, fileshare, storage, metadata, find, upload, download, ai, comment, event, room, member, invitation, asset, how-to). Connect at https://mcp.fast.io/mcp, or https://mcp.fast.io/mcp/key with a Bearer header. Legacy SSE is https://mcp.fast.io/sse. While MCP is natively integrated into desktop clients such as Cursor and Claude Desktop, your Laravel application can upload files over REST and let agents work those same workspaces through MCP.

Developers can install the OpenClaw integration to expand these options. By executing the command clawhub install dbalve/fast-io in compatible environments, your system gains access to fourteen zero-configuration natural language tools. Instead of building custom interfaces for organizing folders or retrieving document metadata, you allow the LLM to map user intent directly to Fastio tools.

A typical tools/call looks like this:

{"jsonrpc":"2.0","id":1,"method":"tools/call",
 "params":{"name":"upload","arguments":{"action":"web-import","url":"https://example.com/report.pdf",
 "profile_type":"workspace","profile_id":"1234567890123456789"}}}

When Intelligence Mode is toggled on a workspace, all uploaded files are automatically parsed, chunked, and indexed for semantic search. Rather than maintaining a complicated PHP integration with a vector database, your Laravel server can start Ripley, the built-in RAG agent, with POST /current/workspace/{workspace_id}/ai/agent/ and send the user's question with POST /current/workspace/{workspace_id}/ai/agent/{chat_id}/message/. Agents can get a cited answer through the MCP ai tool (action ask). The platform runs Retrieval-Augmented Generation internally so your application can present the answer directly to the user.

Evidence and Implementation Metrics

Adopting an intelligent workspace architecture changes how development teams allocate their resources. Centralizing storage and AI reasoning in a single workspace reduces the overhead associated with moving data between isolated applications. Developers spend less time maintaining custom integrations when the storage layer provides native intelligence and built-in search.

Implementing semantic search used to require assembling a pipeline of text extractors, embedding generators, and distinct database engines. Unifying these systems into a single API endpoint helps engineering teams accelerate their deployment timelines. The operational savings derived from removing redundant infrastructure components make the transition to an agentic workspace a practical architectural decision.

Frequently Asked Questions

How do I use Fastio API in Laravel?

You can use the Fastio API in Laravel by using the built-in HTTP client wrapper over Guzzle. Create a dedicated service class that sends Authorization Bearer against https://api.fast.io/current/. This lets you issue GET and POST requests to workspace, upload, and activity endpoints.

What is a good storage solution for Laravel AI apps?

Fastio works well for Laravel AI applications because it offers native Intelligence Mode. Every file uploaded is automatically indexed for semantic search. This removes the need to maintain a separate vector database alongside your standard storage bucket.

Can I use Fastio as a custom Laravel storage disk?

Yes, you can register Fastio as a custom Laravel storage disk by extending the Storage facade within a Service Provider. You need to implement a custom Flysystem adapter that maps Laravel's generic storage commands to the Fastio REST API.

How does Fastio handle large file uploads in PHP?

Fastio supports chunked uploads for large media files. POST /current/upload/ without the chunk field to get an upload id, send pieces to POST /current/upload/{id}/chunk/?order=N&size=N, finish with POST /current/upload/{id}/complete/, then GET /current/upload/{id}/details/?wait=60. You can also import a remote file with POST /current/web_upload/ so the bytes never pass through Laravel.

Does Fastio support webhooks for event tracking?

Watch workspace activity with GET /current/events/search/ or long-poll GET /current/activity/poll/{entityId}?wait=95&lastactivity={timestamp}. Put that wait in a Laravel queued job so the HTTP worker is not blocked. Agents can follow the same stream with the MCP event tool.

Related Resources

Fastio features

Give Your AI Agents Persistent Storage

Connect Laravel to intelligent workspaces with the Fastio REST API, MCP tools, and built-in Ripley RAG. Built for fast api php laravel integration workflows.