Deploying an Open-Source AI Assistant on Ubuntu 24.04 with a Domestic LLM API: A Practical Guide
This guide walks through deploying an open-source AI assistant framework on Ubuntu 24.04 LTS and connecting it to a cloud-based large language model (LLM) API that offers free trial credits. The setup separates conversational logic and tool invocation (handled locally by the Node.js-based framework) from language understanding and generation (handled by the cloud API), eliminating the need for GPU hardware. You will learn how to install Node.js via nvm, globally install and configure the assistant CLI, set up the custom LLM provider securely, enable safe remote access through SSH port forwarding, and perform basic performance troubleshooting. No GPU is required; a standard cloud server or virtual machine is sufficient.
1. Solution Overview and Applicable Scenarios
Deploying an open-source AI assistant framework on a private server and integrating it with a cloud-based large language model (LLM) service has become a common path for developers and enterprises building internal intelligent applications. The core advantage of this approach is the decoupling of responsibilities: the local framework handles dialogue logic and tool-calling capabilities, while the cloud LLM API provides language understanding and generation. This separation maintains data-handling flexibility and significantly lowers the hardware barrier compared to training a custom LLM from scratch.
This article uses Ubuntu 24.04 LTS as the runtime environment and demonstrates how to connect an open-source AI assistant framework built on the Node.js ecosystem to a domestic LLM service platform that provides conversational model APIs with free trial quotas. The entire process requires no expensive GPU resources—a standard cloud server or virtual machine can run it smoothly.
2. Prerequisites and System Requirements
Before starting, ensure the following prerequisites are met:
- Operating System – A server with Ubuntu 24.04 installed. It is recommended to operate as the root user for the initial setup; for production environments, create a regular user with sudo privileges for subsequent operations.
- Model Service Credentials – Register on the target LLM provider’s open platform and create an API key (typically prefixed with a specific string). The platform usually grants new users a free quota sufficient for personal development and testing.
- Local Terminal – Your local computer must be able to connect to the server via SSH. Windows users can use PowerShell or Windows Terminal; macOS/Linux users can use the built-in terminal.
- Package Management – Ensure the server has outbound internet access to download and install required packages.
3. Setting Up the Node.js Runtime
The AI assistant framework is built on Node.js, so the first task is to prepare a reliable and suitably versioned Node.js runtime. The default Node.js version in Ubuntu 24.04’s repositories is often outdated and not suitable for direct use. The recommended method is to install Node.js via nvm (Node Version Manager), which allows multiple versions to coexist and enables quick switching, greatly simplifying future upgrades and maintenance.
Installation steps:
# Download and execute the nvm installation scriptcurl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash# Load nvm into the current shellsource ~/.bashrc# Install Node.js 22 LTS (long-term maintenance, good stability and compatibility)nvm install 22# Set Node.js 22 as the default versionnvm alias default 22# Verify the installation (should output v22.x.x)node --version
Technical Note: Choosing an LTS (Long Term Support) version is for production stability. LTS releases receive years of security patches and bug fixes, avoiding instability caused by chasing new features.
4. Installing and Initializing the AI Assistant Framework
4.1 Global Installation
Once the Node.js environment is ready, install the AI assistant framework globally via the npm package manager. A global installation allows the command-line tool to be recognized from any path without switching to a specific directory.
npm install -g open-source-ai-cli@latest
4.2 Common Installation Issues
During installation, you may encounter the following typical problems:
- ENOTEMPTY Error – This indicates the installation directory is not empty, usually due to leftover files from a previous incomplete uninstall. Clean up manually and reinstall:
rm -rf /usr/lib/node_modules/open-source-ai-clinpm cache clean --forcenpm install -g open-source-ai-cli@latest
- Deprecated Warnings – npm may output several deprecated warnings while installing dependencies. This usually means that some indirect dependency packages have newer releases, but it does not affect the normal installation or operation of the framework. These can be safely ignored.
After installation, verify the version:
open-source-ai-cli --version
If the terminal returns a version string like 2026.3.2, the installation is successful.
5. Configuring the Domestic LLM Integration
5.1 Using the Interactive Configuration Wizard
Most modern CLI tools provide an interactive configuration interface to reduce user setup effort. Launch the configuration wizard:
open-source-ai-cli config
Follow the wizard prompts to perform the following:
- Choose to add a custom model provider – In the provider options, select “Custom Provider” to enter third-party service information that is not predefined.
- Set a provider name – Use a recognizable name, e.g.,
llm-service. - Enter the API endpoint – Provide the API endpoint provided by the target LLM platform. This is the unified entry point for all requests. Double-check the Base URL path from the provider’s official documentation, ensuring the version number is not omitted.
- Enter the API key – Paste the previously obtained key string. The key is the sole credential for authentication and usage metering. Store it securely; never commit it to a public code repository.
5.2 Key Configuration Points
The accuracy of the connection configuration directly determines whether subsequent calls succeed. Pay close attention to the following:
- Model Identifier – Some providers offer multiple models under the same API endpoint. You must specify the model identifier to be used, e.g., a lightweight conversation model name. If unsure, consult the provider’s documentation for the model list.
- Context Length and Parameters – The configuration interface may provide advanced parameters such as maximum tokens and temperature. For everyday Q&A scenarios, keep the defaults; for long-text analysis, consider raising the maximum token limit.
- Proxy Settings – If the server operates in a restricted network environment, add HTTP proxy information to the configuration file; otherwise, requests may time out.
6. Secure Access via SSH Port Forwarding
After deployment, the framework’s web management interface listens on the server’s loopback address (127.0.0.1) on a specific port (e.g., port 3000). To access this interface securely from a local browser, SSH port forwarding is recommended rather than opening the port on the firewall. The key benefits are: the communication is encrypted through an SSH tunnel, and no server port is exposed externally, reducing the risk of scanning attacks.
Execute the following command on your local terminal (replace user@your_server_ip with the actual credentials):
ssh -N -L 3000:127.0.0.1:3000 user@your_server_ip
Command breakdown:
-N– Do not execute a remote command; only establish the tunnel.-L 3000:127.0.0.1:3000– Forward local port 3000 traffic to remote port 3000.
Keep this terminal window open, then open your local browser and visit http://127.0.0.1:3000 to see the framework’s web chat interface. From any network environment, you can now securely call your private AI service over SSH.
7. Starting the Service and Functional Verification
7.1 Foreground Run and Background Daemonization
During debugging, run the service in the foreground to observe logs:
open-source-ai-cli serve
Once functionality is confirmed, use a process supervisor such as systemd or pm2 to keep the service running in the background, ensuring it restarts automatically after server reboots and captures crash logs.
7.2 Testing Dialogue
Submit a test question in the web interface, for example: “Briefly introduce the main features of Ubuntu 24.04.” If the configuration is correct, the model will return a real-time answer. Simultaneously, check the server terminal logs to confirm there are no errors and that the response time is reasonable.
8. Performance Optimization and Troubleshooting
| Symptom | Possible Cause | Solution |
|---|---|---|
| Request timeout or 502 error | Server cannot reach the internet or DNS resolution fails | Check network connectivity; configure proxy environment variables |
| 401 Unauthorized | Incorrect or expired API key | Regenerate the key and update the configuration |
| Irrelevant model responses | Wrong model identifier selected | Review the documentation and verify the model name string |
| Cannot access the web interface locally | SSH tunnel interrupted or port occupied | Kill residual ssh processes and use a different local port |
| High memory usage | Framework cache grows too quickly | Adjust Node.js memory limit (NODE_OPTIONS=--max-old-space-size) |
9. Summary and Next Steps
You have now completed the deployment of a fully functional private AI assistant. With this architecture, you have moved away from dependence on specific commercial chat software while retaining the top-tier language capabilities of a cloud LLM, achieving a balanced trade-off between data privacy and invocation cost.
Possible future extensions:
- Integrate External Tools – The framework supports a plugin mechanism. Write plugins to let the model retrieve real-time weather, execute code, or query databases, transforming it from “conversation” to “action.”
- Multi-Model Strategy – Configure multiple model providers and use routing rules to automatically select different models for different tasks, balancing cost and effectiveness.
- Authentication and Audit – If multiple users access the service, add identity authentication at the reverse proxy layer and log calls for usage auditing.
In the rapidly evolving era of large models, mastering local deployment and API integration skills will help you quickly apply AI capabilities in various business scenarios. We hope this tutorial proves useful, and we encourage you to combine the documentation and logs to continuously refine your setup during deployment.
