Welcome to Firefly
Switch language
Firefly Docsss
Last Updated: 2026-08-14 16:48:17

Service Configuration and Operations

llamapi-server is the LlamaPi server component. It detects inference platforms, loads models, manages model instances, and provides OpenAI-compatible HTTP APIs.

This chapter assumes that firefly-llamapi-server has already been installed as described in Quick Start. It focuses on service management, configuration, logging, model preloading, and troubleshooting.

Service Information

ItemValue
Debian packagefirefly-llamapi-server
systemd unitllamapi-server.service
Binary/usr/bin/llamapi-server
Default configuration/etc/llamapi-server/config.toml
Default listen address0.0.0.0:9265
Health checkGET /health

systemd starts the service in the following form:

ExecStart=/usr/bin/llamapi-server --config /etc/llamapi-server/config.toml

Manage the Service

OperationCommand
Show statussystemctl status llamapi-server
Startsudo systemctl start llamapi-server
Stopsudo systemctl stop llamapi-server
Restartsudo systemctl restart llamapi-server
Enable at bootsudo systemctl enable llamapi-server
Disable at bootsudo systemctl disable llamapi-server
Reload systemd unitssudo systemctl daemon-reload

Restart the service after changing its configuration:

sudo systemctl restart llamapi-server

View Logs

Follow logs in real time:

journalctl -u llamapi-server -f

Show logs from the current system boot:

journalctl -u llamapi-server -b

Show the latest 100 lines:

journalctl -u llamapi-server -n 100

Check the service log first when diagnosing startup, configuration parsing, platform loading, or model preloading failures.

Command-Line Options

llamapi-server supports:

OptionDescription
--host <HOST>Override the listen address
-p, --port <PORT>Override the listen port
-c, --config <CONFIG>Select a TOML configuration file
--log-level <LEVEL>Set trace, debug, info, warn, or error
-h, --helpShow help
-V, --versionShow the version, commit hash, and build time

Configuration priority, from highest to lowest, is:

  1. Command-line options.
  2. Configuration file.
  3. Built-in defaults.

The systemd service uses the configuration file. Except for temporary debugging, keep persistent settings in /etc/llamapi-server/config.toml.

Configuration File

Default path:

/etc/llamapi-server/config.toml

Basic configuration:

[server]
host = "0.0.0.0"
port = 9265
log_level = "info"

Complete example with global generation defaults and model preloading:

[server]
host = "0.0.0.0"
port = 9265
log_level = "info"
request_queue_size = 48

[defaults]
temperature = 1.0
top_p = 0.9
top_k = 1
repeat_penalty = 1.2
frequency_penalty = 0.0
presence_penalty = 0.0
max_tokens = 1024
max_context_len = 4096
stop = []
enable_thinking = false

[[models]]
model_id = "qwen3:4b@rkllm-rk3588"
model_path = "/var/lib/llamapi/models/rkllm/rk3588/qwen3-4b"
instance_count = 1
request_queue_size = 48

[models.default_params]
temperature = 0.7
top_p = 0.9
max_tokens = 1024
max_context_len = 4096
stop = []
enable_thinking = false

[server] Settings

FieldDefaultDescription
host0.0.0.0HTTP listen address
port9265HTTP listen port
log_levelinfoLog level
request_queue_size48Default waiting capacity for each model

Approximate total request capacity for a model is:

actual instance count + request_queue_size

When all instances are busy and the waiting queue is full, the llamapi-server returns HTTP 429 with error code queue_full.

[defaults] Settings

[defaults] supplies global generation defaults. A model's model.toml and [[models]].default_params can override these values.

FieldDescription
temperatureSampling temperature
top_pNucleus sampling value
top_kTop-k sampling value
repeat_penaltyRepetition penalty
frequency_penaltyFrequency penalty
presence_penaltyPresence penalty
max_tokensDefault maximum generated tokens
max_context_lenRuntime context limit
stopStop-sequence array
enable_thinkingEnable the model's thinking mode

Matching fields in an inference request override model defaults. See the API Reference.

[[models]] Settings

Each [[models]] entry defines a model group that is preloaded when the llamapi-server starts.

FieldRequiredDescription
model_idYesRuntime model ID exposed to clients
model_pathYesModel directory path
instance_countNoTarget instance count; default 1, minimum 1
request_queue_sizeNoPer-model queue capacity; uses the llamapi-server default when omitted
default_paramsNoPer-model generation defaults

The llamapi-cli can manage these entries:

llamapi enable qwen3:4b --instance 2
llamapi disable qwen3:4b

Prefer the llamapi-cli when possible so that model paths and runtime IDs are generated consistently.

Coprocessor limitation: Set instance_count to 1 for a coprocessor model. Multiple instances may cause model loading failure, coprocessor communication failure, and abnormal rknn3.service and llamapi-server.service state. See Coprocessor Communication Failure After Loading Multiple Model Instances for recovery.

Model Preloading

At startup, the llamapi-server reads and loads [[models]] entries in order.

  • A single preload failure is written to the log.
  • One failed model does not prevent the HTTP service from starting.
  • The actual number of created instances may be lower than the requested number.
  • instance_count in /v1/models is the number of instances currently able to serve requests.

Check preloading results:

curl -s http://127.0.0.1:9265/v1/models

Important response fields:

FieldDescription
idModel ID used by clients
platformInference platform
instance_countActive instance count
model_pathSource model directory
model_kindchat or embedding

Runtime Model Management

Models can also be managed while the llamapi-server is running:

OperationAPIllamapi-cli command
LoadPOST /v1/models/loadllamapi load
ResizePOST /v1/models/resizellamapi load <id> --instance <N>
UnloadPOST /v1/models/unloadllamapi unload

The llamapi-cli resolves model names, paths, and runtime IDs. Direct API calls must provide the full model path on the llamapi-server filesystem.

Health Checks

The health endpoint does not depend on any loaded model:

curl -s http://127.0.0.1:9265/health

Response:

ok

ok only means that the HTTP service is running. To check model readiness, also use:

curl -s http://127.0.0.1:9265/v1/models
curl -s http://127.0.0.1:9265/v1/platforms

Network Access and Security

The current llamapi-server:

  • Does not require API authentication.
  • Allows cross-origin requests.
  • Listens on 0.0.0.0:9265 by default.

Before exposing it to an untrusted network, restrict access with a firewall, reverse proxy, or controlled network boundary.

Troubleshooting

SymptomCheckResolution
/health cannot connectService status and portRun systemctl status llamapi-server; confirm port 9265
Service startup failsTOML parsingCheck journalctl -u llamapi-server -b for failed to parse config file
Platform is unavailableBackend runtime and hardwareVerify required runtime libraries and package contents
Model preload failsmodel_path, model.toml, model filesCheck the log for Failed to preload model
Coprocessor communication fails after loading multiple instancesWhether multiple instances were configured on a coprocessorStop loading models and follow the recovery procedure to reset the chip and restart services in order
model_not_foundLoaded state and runtime IDCall /v1/models or run llamapi ps
queue_fullBusy instances and full queueAdd instances or queue capacity, or reduce concurrency
wrong_model_typeAPI and model typeUse chat models for chat and embedding models for Embeddings
invalid_instance_countInstance count is 0Set it to 1 or greater
Listen failurePort conflictStop the process using 9265 or coordinate service ports

See FAQ and Troubleshooting for issues that span the llamapi-cli, llamapi-server, and APIs.

On this page