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

# Local models (Azure ML)

> Use ServerRpc in Laravel Copilot SDK to work with local models such as Azure ML deployments.

## Local models (Azure ML)

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 Revolution\Copilot\Enums\AzureMlRegistry;
use Revolution\Copilot\Types\Rpc\AzureMlAcquireFamilyRequest;
use Revolution\Copilot\Types\Rpc\AzureMlCancelRequest;
use Revolution\Copilot\Types\Rpc\AzureMlCatalogRequest;
use Revolution\Copilot\Types\Rpc\AzureMlDiscardRequest;
use Revolution\Copilot\Types\Rpc\AzureMlDownloadRequest;
use Revolution\Copilot\Types\Rpc\AzureMlLatestRequest;
use Revolution\Copilot\Types\Rpc\AzureMlReleaseFamilyRequest;
use Revolution\Copilot\Types\Rpc\AzureMlResolveRequest;
use Revolution\Copilot\Types\Rpc\AzureMlStatusRequest;

// Azure ML local model management (experimental)
$azureMl = Copilot::client()->rpc()->azureMl();
$hardware = $azureMl->hardware();
// gpuMemory is null where it can't be measured
$gpuMemory = $hardware->gpuMemory;
$catalog = $azureMl->catalog(new AzureMlCatalogRequest(includeDev: false));
$latest = $azureMl->latest(new AzureMlLatestRequest(
    registry: AzureMlRegistry::AzureMl,
    name: 'phi',
));
$resolved = $azureMl->resolve(new AzureMlResolveRequest(
    registry: AzureMlRegistry::AzureMl,
    name: $latest->name,
    version: $latest->version,
));

// requestId and leaseId are bound to this SDK connection, so don't reuse them with another Client
$lease = $azureMl->acquireFamily(new AzureMlAcquireFamilyRequest(
    registry: AzureMlRegistry::AzureMl,
    name: $latest->name,
));

try {
    $download = $azureMl->download(new AzureMlDownloadRequest(
        requestId: 'download-1',
        registry: AzureMlRegistry::AzureMl,
        name: $latest->name,
        version: $latest->version,
        destination: 'models/phi/'.$latest->version,
        leaseId: $lease->leaseId,
    ));
} finally {
    $azureMl->releaseFamily(new AzureMlReleaseFamilyRequest(
        leaseId: $lease->leaseId,
        registry: AzureMlRegistry::AzureMl,
        name: $latest->name,
    ));
}

// download() waits until completion. To check progress or cancel while it runs,
// call from another Fiber or similar using the same connection's $azureMl
// $status = $azureMl->status(new AzureMlStatusRequest(requestId: 'download-1'));
// $cancelled = $azureMl->cancel(new AzureMlCancelRequest(requestId: 'download-1'));
// The bool from cancel() indicates the cancel request was accepted; confirm cleanup completion via download()

// Delete an inactive version
$azureMl->discard(new AzureMlDiscardRequest(destination: 'models/phi/previous-version'));

// The resolve() and download() types have no dedicated field for signed URLs
// download() has no timeout by default. To specify seconds, pass them as the second argument
// registration() runs upsert/remove/restore with the leaseId of the same family
// Check kind/path/detail in the result, and before for compensation
```


## Related topics

- [RPC (Remote Procedure Call)](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc.md)
- [ServerRpc overview](https://kawax.biz/en/packages/laravel-copilot-sdk/rpc/server-overview.md)
- [Models](https://kawax.biz/en/packages/laravel-copilot-sdk/models.md)
- [Custom providers](https://kawax.biz/en/packages/laravel-copilot-sdk/custom-providers.md)
- [Eloquent Observers and Model Events](https://kawax.biz/en/advanced/eloquent-observers.md)


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