> For the complete documentation index, see [llms.txt](https://docs.degirum.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.degirum.com/pysdk/user-guide-pysdk/api-ref/server.md).

# AI Server Module

PySDK API Reference Guide. CLI launcher for the DeGirum AI server.

{% hint style="info" %}
This API Reference is based on PySDK 0.20.0.
{% endhint %}

DeGirum AI server launcher and model downloader.

{% hint style="info" %}
The functionality of this module is now exposed via PySDK CLI.
{% endhint %}

The purpose of this module is to start DeGirum AI server:

{% code overflow="wrap" %}

```
python -m degirum.server --zoo <local zoo path> [--port <server TCP port>]
```

{% endcode %}

Other Parameters:

| Name     | Type  | Description                                                                                                                                                                                                                                                                                                                                        |
| -------- | ----- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `--zoo`  | `str` | <p>Path to a local model zoo directory, containing AI models you want your AI server to serve.</p><ul><li>One possible way to fill local model zoo directory is to download models from a model zoo repo using <code>download\_models()</code> function and provide the path to the local zoo directory as <code>--zoo</code> parameter.</li></ul> |
| `--port` | `int` | <p>TCP port to bind server to.</p><ul><li>Default is 8778.</li></ul>                                                                                                                                                                                                                                                                               |

* When AI server is started, it runs indefinitely.
* If you started the server from a terminal, you may press `Enter` to shut it down.
* If you started the server headless (for example, as a service), then to shut down the server you need to kill the Python process which runs the server.

The module also exposes `download_models()` function which can be used to prepare local model zoo directory to be served by AI server:

* You first download models from the model zoo repo of your choice into some local directory of your choice by calling [degirum.server.download\_models](#degirum.server.download_models) function.
* Then you start the AI server providing the path to that local directory as `--zoo` parameter.

## degirum.server.download\_models(path, \*, url=ZooManager.\_default\_cloud\_url, token='', \*\*kwargs)

Download all models from a model zoo repo specified by the URL.

Parameters:

| Name    | Type  | Description                                                                                             | Default              |
| ------- | ----- | ------------------------------------------------------------------------------------------------------- | -------------------- |
| `path`  | `str` | Local filesystem path to store models downloaded from a model zoo repo.                                 | *required*           |
| `url`   | `str` | <p>Zoo repo URL.</p><ul><li>If not specified, then DeGirum public model zoo URL will be used.</li></ul> | `_default_cloud_url` |
| `token` | `str` | Zoo repo authorization token.                                                                           | `''`                 |

Other Parameters:

| Name           | Type  | Description                                                                                                                                                                                                                                                                                                |
| -------------- | ----- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `model_family` | `str` | <p>Model family name filter.</p><ul><li>When you pass a string, it will be used as search substring in the model name. For example, <code>"yolo"</code>, <code>"mobilenet"</code>.</li><li>You may also pass <code>re.Pattern</code>. In this case it will do regular expression pattern search.</li></ul> |
| `device`       | `str` | <p>Target inference device -- string or list of strings of device names.</p><ul><li>If passed, only models targeting the specified device(s) will be downloaded.</li></ul>                                                                                                                                 |
| `precision`    | `str` | <p>Model calculation precision -- string or list of strings of model precision labels.</p><ul><li>Possible labels: <code>"quant"</code>, <code>"float"</code>.</li></ul>                                                                                                                                   |
| `pruned`       | `str` | <p>Model density -- string or list of strings of model density labels.</p><ul><li>Possible labels: <code>"dense"</code>, <code>"pruned"</code>.</li></ul>                                                                                                                                                  |
| `runtime`      | `str` | <p>Runtime agent type -- string or list of strings of runtime agent types.</p><ul><li>Possible types: <code>"n2x"</code>, <code>"tflite"</code>, <code>"tensorrt"</code>, <code>"openvino"</code>.</li></ul>                                                                                               |
