Deploy a Self-Hosted AI Assistant Platform on Ubuntu 24.04 and Connect It to an LLM Service

    This guide walks through deploying a self-hosted AI assistant platform on an Ubuntu 24.04 server and connecting it to a cloud-based LLM service. It covers building a controlled Node.js runtime with a version manager, installing the platform globally, configuring a custom provider with an API base URL and key, and securely accessing the admin interface through an SSH tunnel. It also includes troubleshooting tips and operational practices for process management, logging, cost control, key rotation, and upgrades. The approach is vendor-neutral and can be adapted to other compatible cloud or local inference services.

    Deploy a Self-Hosted AI Assistant Platform on Ubuntu 24.04 and Connect It to an LLM Service

    Why Self-Host an AI Assistant?

    As large language models mature, more developers want a dedicated assistant that runs continuously, keeps data under their control, and is always available. Compared with using a public chat website, a self-hosted setup offers three clear advantages. First, you control the data path, so sensitive content does not pass through an untrusted third-party page. Second, the model backend is replaceable: you can use a cloud-hosted general-purpose LLM service now and switch to local inference later when conditions allow. Third, there are more ways to interact with it. Beyond the admin interface, it can usually connect to instant messaging tools and command-line environments, making it easy to embed in daily workflows.

    This article uses a server running Ubuntu 24.04 as the base environment. It explains how to deploy a self-hosted AI assistant platform with an admin interface and multi-model support, and how to connect it to a cloud-based LLM service that uses a common authentication and request format. To avoid tying the guide to a specific product, the model service is referred to throughout as a “cloud LLM service.” The connection method follows the common industry pattern of “custom provider + API base URL + key,” and the same approach works for other services that support the same protocol.

    Prerequisites and Overall Approach

    Before you start, it helps to define the architecture: browser or CLI client → encrypted tunnel → assistant platform on the server → cloud LLM service. In this chain, the server only handles orchestration and forwarding; model inference happens on the cloud service side.

    You will need:

    • An Ubuntu 24.04 server. This guide uses the root user for demonstration; in production, create a regular user and restrict direct login access.
    • An API key for a cloud LLM service, usually created in that platform’s console. It typically looks like a string with a specific prefix, and a free trial quota is generally enough for validation.
    • A local computer that can initiate an SSH connection; any operating system works.
    • A recent Node.js runtime. Because the default system repositories often ship an older version, it is recommended to install a long-term support (LTS) release through a version management tool.

    Note that the key is a highly sensitive credential. Never hardcode it into scripts or commit it to a code repository. Inject it through environment variables or a configuration file with restricted permissions.

    Step 1: Build a Controlled Runtime Environment

    Assistant platforms are typically built on the Node.js ecosystem, and the runtime version directly affects dependency compatibility. Using a version management tool instead of the system package manager lets you switch versions on demand, avoids polluting system directories, and makes future upgrades easier.

    1. # Install the version management tool
    2. curl -o- https://version-manager-install-url | bash
    3. source ~/.bashrc
    4. # Install and set the LTS version
    5. nvm install 22
    6. nvm alias default 22
    7. # Verify
    8. node --version # expected output v22.x.x
    9. npm --version

    If the server already has a suitable version installed by other means, skip this step and simply confirm the version meets the platform’s requirements. If the install script reports that the network is unreachable, check your outbound network policy or switch to an internal mirror.

    Step 2: Install the Assistant Platform

    Once the runtime is ready, install the platform globally through the package manager:

    1. npm install -g openclaw@latest
    2. openclaw --version

    Two common issues may appear during installation:

    1. A “directory not empty” error (such as ENOTEMPTY). This is usually caused by leftovers from a previous installation. Clean the global modules directory and the package manager cache, then retry:
    1. rm -rf /root/.npm-global/lib/node_modules/openclaw
    2. npm cache clean --force
    3. npm install -g openclaw@latest
    1. A large number of deprecated warnings. This is normal noise from the evolving dependency ecosystem and does not affect functionality; you can ignore it. To reduce the noise, lower the log level during installation.

    After installation, confirm that the executable path is in your PATH and check that the version output is as expected. If you are using a non-root user, pay attention to write permissions on the global install directory, and specify a separate prefix directory for user-level installation if necessary.

    Step 3: Connect the Cloud LLM Service

    The platform usually provides an interactive configuration wizard. The core is three elements: provider type, API base URL, and access key.

    1. openclaw config

    Follow the prompts to complete these choices:

    • Select “add a custom provider” to connect a service that is not in the built-in list.
    • Enter a custom name, such as zhipu or llm-cloud; it is only used as a local identifier.
    • Enter the API base URL, which is the compatible root path exposed by the service.
    • Paste the access key, which usually starts with a prefix such as sk-.
    • Specify the default model identifier, such as the name of a general-purpose chat model with long context and multimodal capabilities.

    After configuration, verify success with the platform’s connectivity check or a minimal chat request:

    1. openclaw models list
    2. openclaw chat "Introduce yourself in one sentence"

    If authentication fails, first check whether the key was copied completely and whether it contains extra spaces. If the request times out, investigate the server’s outbound network and DNS configuration. If the model is reported as not found, the model identifier does not match the provider, so adjust it according to the provider’s documentation.

    From an engineering perspective, abstracting “provider–model–key” into replaceable configuration items is a key design of this type of platform: the business side depends only on a unified chat interface, and switching the underlying service requires no changes to calling code. If you later need to compare different models in a canary test, configure multiple providers side by side and switch the default as needed.

    Step 4: Securely Access the Admin Interface

    By default, the admin interface listens on a local port on the server. Exposing it directly to the public internet creates a risk of unauthorized access. The recommended approach is to use an SSH encrypted tunnel to map the remote port to your local machine:

    1. ssh -L 8080:127.0.0.1:8080 root@your-server-ip

    Then open the corresponding local address in your browser to complete the initialization wizard, manage sessions, and view logs. The advantages of this method are that no additional firewall ports need to be opened, traffic is encrypted end to end, and the exposure disappears when you close the connection.

    If you genuinely need multi-user collaboration, place the interface behind a reverse proxy and add common protections such as transport-layer encryption, strong passwords or two-factor authentication, and rate limiting, while opening only the necessary paths.

    Advanced: Process Management and Operations

    • Process management: use the system service manager to supervise the main process, with automatic restart and startup on boot, so the process does not exit when SSH disconnects.
    • Logging and monitoring: route standard output to a logging service, and set thresholds with monitoring alerts for process liveness, API latency, and call failure rate.
    • Resources and cost: cloud models are usually billed by usage, so set usage limits and alerts to avoid waste from abnormal repeated calls.
    • Key rotation: rotate keys regularly and load them through environment variables or restricted-permission files so they do not appear in command-line history.
    • Upgrade strategy: validate a new version in a test environment first, then roll it out to production gradually, keeping the previous version for rollback.

    Quick Troubleshooting Reference

    Symptom Possible cause Suggested action
    Directory not empty error during install Leftover files Clean the modules directory and cache, then reinstall
    Command not found PATH not applied Log in again or add the path manually
    Authentication failure Wrong or expired key Regenerate and verify the prefix and spaces
    Request timeout Restricted outbound network Check security groups, DNS, and proxy settings
    UI does not open Tunnel not established Confirm local port mapping and listen address

    Summary

    This article follows a reusable path: first build a stable runtime with a version management tool, then install the self-hosted assistant platform globally, connect a cloud LLM service through the common “custom provider + API base URL + key” method, and securely access the admin interface via an SSH encrypted tunnel. It also covers operational essentials such as process management, log monitoring, cost, and security. The overall approach does not depend on any specific vendor; replacing the provider and model identifier lets you migrate to other compatible cloud or local inference services. It works well as a unified entry point for personal knowledge base Q&A, operations assistance, and automation script orchestration.