unloadModel( )
Unloads a previously loaded model from the server.
function unloadModel(params): Promise<void>;When the last model is unloaded and no providers are active, the RPC connection is automatically closed, allowing the process to exit naturally.
Parameters
| Name | Type | Required? | Default | Description |
|---|---|---|---|---|
| params.modelId | string | ✓ | — | The unique identifier of the model to unload |
| params.clearStorage | boolean | ✗ | false | Whether to clear the storage for the model |
Returns
Promise<void> — Resolves when the model is unloaded.
Throws
| Error | When |
|---|---|
INVALID_RESPONSE_TYPE | Response type does not match expected "unloadModel" |
MODEL_UNLOAD_FAILED | The server reports unload failure |
Example
await unloadModel({ modelId: "model-123" });
// Unload and clear cached files
await unloadModel({ modelId: "model-123", clearStorage: true });