Self-Hosted AI Assistant on Windows 11: Connecting a Local or Remote LLM

    This guide walks through setting up a self-hosted AI assistant on Windows 11 and connecting it to an external large language model. It covers hardware and runtime prerequisites, execution policy adjustments, running the installation script, initializing the workspace, and configuring model provider, base URL, API key, and model name. It also explains a three-step verification process for the chat pipeline, security hardening practices such as loopback binding, TLS via a reverse proxy, log redaction and backups, plus a quick troubleshooting table for common errors. Note that self-hosting keeps local data under your control but prompts are still sent to the model provider.

    1. Background and Core Value

    As LLM applications move from “calling a cloud API” to “building your own agent,” more developers are looking at self-hosted AI assistant options. Self-hosting means running the chat service, conversation storage, skill extensions, and orchestration logic on your own machine or cloud host, while leaving only model inference to an external model service through an API. The value comes down to three points.

    First, clear data boundaries. Conversation history, attachments, skill configuration, and logs stay on local disk by default, so sensitive content does not have to leave a controlled environment with each request. Second, replaceable models. The assistant platform is decoupled from any specific model through a standard interface, so switching models usually means changing configuration rather than business code. Third, extensible capabilities. File processing, web search, and scheduled tasks are attached as “skills” and enabled on demand.

    To be clear, self-hosting does not mean fully offline. If you use an external model API, prompts and context are still sent to the model provider, so “privacy is covered” should be read as local data staying under your control, not as request content never leaving your network. For stricter compliance requirements, a private inference option is worth evaluating.

    2. Environment and Prerequisites

    2.1 Hardware and System Baseline

    • OS: Windows 11 64-bit; Windows 10 64-bit usually works as well
    • Memory: 8GB or more recommended; 16GB if you run browser console access and local inference at the same time
    • Disk: at least 2GB free, more if you plan to cache a large number of conversations and attachments
    • Network: access to code hosting sites and model service APIs

    2.2 Runtime Dependencies

    Platforms of this kind are generally built on the Node.js ecosystem, and the mainstream requirement is Node.js 22 or later LTS. Using the official one-click script is recommended so the runtime is installed automatically and you avoid version conflicts from manual environment variable configuration. If you have multiple runtime versions installed through a version manager, confirm the active version meets the requirement:

    1. node -v
    2. npm -v

    2.3 Model Credentials

    After registering on the model service platform, go to the key management page and create an access key. The key usually starts with a specific prefix and is shown in full only once at creation, so store it safely. Follow least-privilege practice: create separate keys per environment so they can be revoked individually, and never hardcode keys in scripts. Inject them through environment variables or a local configuration file instead.

    3. Deployment Walkthrough

    3.1 Adjusting the Execution Policy

    Windows blocks unsigned scripts by default, which stops the one-click installer. Open a terminal as administrator and allow local scripts plus signed remote scripts for the current user only, avoiding the risk of opening things up globally:

    1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    Confirm when prompted. This setting affects only the current user; run Set-ExecutionPolicy -Scope CurrentUser Undefined to revert to the default.

    3.2 Running the Installation Script

    The one-click script typically pulls installation logic from a given address and runs it directly:

    1. iwr -useb <install-script-url> | iex

    Installation usually takes a few minutes while the script downloads the runtime, installs dependencies, and places the core files, so keep the window open. Reviewing a remote script locally before running it is a basic production habit:

    1. iwr -useb <install-script-url> -OutFile install.ps1
    2. Get-Content install.ps1 | Select-Object -First 50

    3.3 Verification and Initialization

    Once installation finishes, confirm the CLI entry point works, then run the initialization wizard to generate the default configuration file and working directories:

    1. openclaw --version
    2. openclaw init

    Initialization normally produces three parts: the main configuration, a skills directory, and a data directory. Point the data directory at a separate disk partition and back it up regularly with snapshot or incremental backup support so conversation data survives a system reinstall.

    4. Model Configuration

    The main configuration usually has four fields: provider, base URL, API key, and model name. For a model service with an OpenAI-style API, the configuration looks like this:

    1. model:
    2. provider: custom
    3. base_url: https://<model-api-endpoint>/v1
    4. api_key: ${MODEL_API_KEY}
    5. name: <model-name>
    6. temperature: 0.7
    7. max_tokens: 2048

    Key points:

    1. The base URL must match the model service documentation; whether the path ends with a version number directly affects whether requests succeed.
    2. Inject the API key through an environment variable to keep it out of the file in plaintext.
    3. Context length and max output must match the actual specs of the chosen model, or the request returns a parameter error.
    4. Free-tier models suit personal validation and light use, but quota policy is set by the provider, so confirm rate limits and billing rules before production use.

    Set the environment variable and restart the service to apply the configuration:

    1. $env:MODEL_API_KEY = "sk-xxxxxxxxxxxxxxxx"
    2. openclaw serve

    5. Verifying the Chat Pipeline

    After startup, the console listens on the local address by default, so open it in a browser to reach the web UI. A three-step check helps isolate problems:

    1. Connectivity: trigger a connectivity test in the settings UI to confirm the endpoint and key are valid.
    2. Single-turn chat: send a simple question and check for a normal response and reasonable time to first token.
    3. Multi-turn context: ask follow-up questions and confirm session state is maintained correctly.

    An authentication failure usually means a wrong key or an environment variable that did not take effect. A “model not found” response typically means the model name or version does not match. On timeouts, check network egress and proxy settings first.

    6. Security Hardening and Operations

    • Listening scope: bind to the loopback address by default, open it up only when LAN access is needed, and pair that with a strong password and an access token.
    • Transport security: put a reverse proxy with TLS in front before exposing the service, so keys and conversations do not travel in plaintext.
    • Privilege isolation: run the service as a standard user, grant access to the data directory as needed, and avoid keeping administrator privileges online.
    • Log governance: redact or sample prompts and responses in logs to keep sensitive information out of the logging system.
    • Observability: connect a general-purpose logging service and monitoring with alerts, and set thresholds for error rate, latency, and quota consumption.
    • Backup and upgrades: snapshot the data directory before upgrading, and validate configuration compatibility in a test environment first.

    7. Quick Troubleshooting

    Symptom Common Cause Fix
    Script blocked from running Execution policy restriction Allow it for the current user scope
    Runtime version mismatch Multiple runtime versions installed Switch to Node.js 22 or later LTS
    API authentication failure Wrong or missing key Reset the environment variable and restart
    Model not found Name or version mismatch Correct it against the provider documentation
    Console unreachable Port in use or wrong binding Check the port and listening configuration

    8. Summary

    Setting up a self-hosted AI assistant on Windows 11 is essentially assembling four layers: runtime environment, platform core, model API, and security operations. What matters is not any single command but bringing key management, data backup, access control, and observability into the initial design. With this workflow in place, developers can keep swapping and evaluating model capabilities in their own environment and build agent infrastructure that is stable, controllable, and extensible.