---
title: "Server"
sidebar_label: "Server"
description: "Kotlin binding reference: Server."
---

<!-- Generated by tools/api_reference/generate_api_docs.py. Do not edit. -->

//[clika-runtime](../../../index.md)/[io.clika.modelverse](../index.md)/[Server](index.md)

# Server

[common]\
class [Server](index.md)

The server over a loaded [GenerativeModel](../GenerativeModel/index.md) ([Modelverse.serve](../Modelverse/serve.md)): the chat API (`/v1/chat/completions`, the models listing, `/health`, the web page when enabled) on its own threads. [start](start.md) listens and returns at once; [waitUntilReady](waitUntilReady.md) probes `/health`; [stop](stop.md) ends the listening and joins the server's threads; [close](close.md) stops and releases the served engine. The model stays open, the caller's, and refuses its own `close()` while a server holds it: close the server first. Several servers may serve one model. [http](http.md) is the server's own http server, borrowed, for routes and middleware of the app's beside the API's, registered before [start](start.md).

## Properties

| Name | Summary |
|---|---|
| [baseUrl](baseUrl.md) | [common]<br>val [baseUrl](baseUrl.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>`http://host:port`, the prefix of every route. |
| [deviceFaulted](deviceFaulted.md) | [common]<br>val [deviceFaulted](deviceFaulted.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True once the device the model runs on faulted under a request; the server then refuses new ones. |
| [host](host.md) | [common]<br>val [host](host.md): [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)<br>The host the server binds, as given. |
| [http](http.md) | [common]<br>val [http](http.md): [HttpServer](../../io.clika.runtime/HttpServer/index.md)<br>The http server the API is mounted on, borrowed ([HttpServer.isBorrowed](../../io.clika.runtime/HttpServer/isBorrowed.md)) for the app's own routes, groups, middleware and static files, registered before [start](start.md): once the server listens the routes are fixed, and a read here throws IllegalStateException. A route on a path the API owns ([isReservedRoute](isReservedRoute.md)) shadows the API's; the borrow is released at [stop](stop.md) and [close](close.md), so a later call on it refuses. |
| [isRunning](isRunning.md) | [common]<br>val [isRunning](isRunning.md): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True between [start](start.md) and [stop](stop.md). |
| [model](model.md) | [common]<br>val [model](model.md): [GenerativeModel](../GenerativeModel/index.md)<br>The model the server answers with. |
| [options](options.md) | [common]<br>val [options](options.md): [ServeOptions](../ServeOptions/index.md)<br>The options the server was built with. |
| [port](port.md) | [common]<br>val [port](port.md): [Int](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)<br>The bound port once started (the requested one, or the free port picked for 0); 0 before. |

## Functions

| Name | Summary |
|---|---|
| [close](close.md) | [common]<br>open fun [close](close.md)()<br>Stop, then release the served engine; the model stays open. Idempotent. |
| [isReservedRoute](isReservedRoute.md) | [common]<br>fun [isReservedRoute](isReservedRoute.md)(path: [String](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html)): [Boolean](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html)<br>True for a path the API owns (`/v1/...`, `/health`, the page); a route there shadows the API's. |
| [start](start.md) | [common]<br>fun [start](start.md)(): [Server](index.md)<br>Listen on the host and port, on the server's own threads, and return at once; a port in use throws. |
| [stop](stop.md) | [common]<br>fun [stop](stop.md)()<br>Stop listening and join the server's threads, the [http](http.md) borrow released; a no-op when not running. |
| [waitUntilReady](waitUntilReady.md) | [common]<br>fun [waitUntilReady](waitUntilReady.md)(timeoutMs: [Long](https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-long/index.html) = DEFAULT_READY_TIMEOUT_MS)<br>Block until `/health` answers, polling every POLL_MS milliseconds up to [timeoutMs](waitUntilReady.md); throws [ModelverseException](../ModelverseException/index.md) at the deadline. |