serve_model
Launch a local AI model as an OpenAI-compatible API endpoint so apps can connect through the OpenAI SDK; setup runs asynchronously—poll status until running.
Instructions
Serve a local AI model as an OpenAI-compatible endpoint.
Serving is asynchronous: the call returns immediately with the
model row in ``building`` while the daemon pulls the image and weights
off-tick; poll ``list_models`` (or ``get_service``) until it is
``running``. Lifecycle (stop / restart / delete) goes through the
existing service tools (``stop_service`` / ``restart_service`` /
``remove_service``).
An app connects to this model by declaring an ``[ai.<name>]`` binding
(provider ``ollama``, model = this model); at each launch it receives
``NERDIT_AI_<NAME>_URL/_KEY/_MODEL``, and the ``default`` binding also
sets ``OPENAI_BASE_URL/OPENAI_API_KEY/OPENAI_MODEL`` so an unmodified
OpenAI SDK reaches this endpoint with no code change.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gpus | No | GPUs to reserve for the model server; 0 (the default) is CPU inference, and allocated GPUs are shared with other workloads. The ``vllm`` backend needs at least 1 and refuses 0 with ``model.gpu_required``. | |
| name | No | Service name for the model (lowercase DNS label). Omit and the name is the backend-prefixed, sanitized model reference (``llama3.1:8b`` on ollama → ``ollama-llama3-1-8b``). | |
| model | Yes | Model reference to pull and serve, e.g. ``llama3.1:8b`` (ollama) or a Hugging Face repo id (vLLM): letters, digits, ``. - _ /`` with an optional ``:tag``. | |
| backend | No | Serving backend: ``ollama`` (CPU or GPU) or ``vllm`` (GPU-only, one model per server, weights from Hugging Face). Omit to use the daemon's configured default; an unknown name is refused with ``model.unknown_backend``. | |
| max_model_len | No | vLLM only: context-window cap in tokens (``--max-model-len``), 256 to 262144. Omit and the daemon decides: an operator flag in ``[models].vllm_extra_args``, else 4096 on a GPU under 16 GB VRAM, else vLLM's own default. Any other backend refuses it with ``model.backend_param``. | |
| idempotency_key | No | Caller-chosen key: a retry with the same key replays the first result instead of acting twice. Omit and a fresh key is minted per call, so each call acts. | |
| gpu_memory_utilization | No | vLLM only: fraction of VRAM the engine may claim (``--gpu-memory-utilization``), 0.1 to 0.95. Omit and the daemon decides: an operator flag in ``[models].vllm_extra_args``, else 0.85 on a GPU under 16 GB VRAM, else vLLM's own default. Any other backend refuses it with ``model.backend_param``. |