> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# HTTP inference and file system

> Use ServerRpc in Laravel Copilot SDK for HTTP inference, file system operations, and network callbacks.

## HTTP inference and file system

Scope: ServerRpc (server-wide operations tied to the Client)

For an overview of RPC and the list of all RPC pages, see [RPC](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md).

```php theme={null}
use Illuminate\Http\Client\Response;
use Revolution\Copilot\Types\Rpc\ExtensionLaunchProfile;
use Revolution\Copilot\Types\Rpc\ExtensionLaunchProviderResolveRequest;
use Revolution\Copilot\Types\Rpc\ExtensionLaunchProviderResolveResult;
use Revolution\Copilot\Support\CopilotRequestContext;
use Revolution\Copilot\Support\CopilotRequestHandler;

// llmInference (experimental: hook HTTP requests to the model layer)
$client = Copilot::client([
    'request_handler' => new class extends CopilotRequestHandler
    {
        public function sendRequest(CopilotRequestContext $context, string $method, string $body): Response
        {
            $context->url = 'https://proxy.example.com/v1/chat/completions';
            $context->headers['X-Request-Source'] = ['laravel'];

            return parent::sendRequest($context, $method, $body);
        }
    },
]);

// llmInference.setProvider is sent at startup, and you receive httpRequestStart / httpRequestChunk.
// A handler that doesn't override sendRequest transparently forwards HTTP/SSE with the Laravel HTTP Client.
// When you pass a Closure, return a Response in the form fn (CopilotRequestContext $context, string $method, string $body): Response.
// request_handler is experimental. The WebSocket transport isn't supported and returns a 501-equivalent error response.

// sessionFs (register a session file system provider)
Copilot::client()->rpc()->sessionFs()->setProvider(new SessionFsSetProviderRequest(
    initialCwd: '/path/to/project',
    sessionStatePath: '.copilot/sessions',
    conventions: 'posix',
));

// Client option that resolves how to launch extensions (respond within 15 seconds)
$client = Copilot::client([
    'extensionLaunchProvider' => fn (ExtensionLaunchProviderResolveRequest $request) => new ExtensionLaunchProviderResolveResult(
        launch: new ExtensionLaunchProfile(
            executable: '/usr/bin/node',
            args: [$request->modulePath],
        ),
    ),
]);
// Return null if there's no matching launch method.
// fn (ExtensionLaunchProviderResolveRequest $request) => null

$sessions = Copilot::client()->rpc()->sessions();
```

## network (experimental: network callbacks)

`network()->setProvider()` tells the runtime about the proxy resolution and Kerberos authentication callbacks registered on the client. The `network` option on the `Client` registers them automatically, so you normally do not need to call this RPC directly. The callback fields of `NetworkSetProviderRequest` indicate that the matching handler is registered. The RPC returns no value. The runtime must support the `network.setProvider` RPC. If it does not, the client throws an exception at startup that asks you to update the runtime.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Enums\NetworkScope;
use Revolution\Copilot\Types\Rpc\NetworkSetProviderRequest;

Copilot::client()->rpc()->network()->setProvider(
    new NetworkSetProviderRequest(
        scope: NetworkScope::Runtime,
        resolveProxy: true,
        authenticateNegotiate: true,
    ),
);
```

`scope` defaults to `connection`. `runtime` also covers shared background traffic, but only one connection at a time can register with this scope.


## Related topics

- [ServerRpc overview](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/server-overview.md)
- [RPC (Remote Procedure Call)](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md)
- [HTTP requests](https://kawax.biz/en/requests.md)
- [HTTP Tests](https://kawax.biz/en/http-tests.md)
- [Laravel Folio](https://kawax.biz/en/folio.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.