Self-Hosted AI Assistant on Windows 11: Setup and Multi-Model Integration

    This guide walks through building a self-hosted AI assistant on Windows 11 and connecting it to cloud-hosted models. It explains why self-hosting the runtime (rather than the model) matters for data boundaries, model replaceability, and extensibility, then covers prerequisites, an execution-policy adjustment, reviewing and running the install script, verification with the doctor command, API key handling, provider configuration, startup checks, common troubleshooting, and long-term operations around security, cost, and observability.

    1. Why Self-Host an AI Assistant

    Over the past two years, the model-as-an-API delivery pattern has matured. Even so, keeping both the “calling capability” and the “runtime environment” under your own control still has clear engineering value. The core benefits of a self-hosted setup come down to three points.

    First, clear data boundaries. Conversation history, uploaded documents, and retrieval caches all land on local disk, and you decide whether anything leaves the machine and which fields are sent. When handling internal material or customer information, this is often a hard compliance requirement.

    Second, replaceable models. Once the assistant layer is decoupled from the model layer, switching providers, switching parameter sizes, or trading off “cheap and fast” against “stronger reasoning” is a matter of editing configuration rather than rewriting business logic.

    Third, extensible capabilities. Skills such as file parsing, web retrieval, scheduled tasks, and message notifications are mounted as plugins, so the main flow stays stable and extensions do not intrude on core code.

    One clarification: self-hosting does not mean running inference locally. The vast majority of personal devices cannot absorb the inference cost of models in the tens-of-billions-of-parameters range, so the realistic approach is to self-host the runtime while sending inference to a cloud API. Everything that follows assumes this premise.

    2. Prerequisites and Risk Assessment

    Confirming the environment variables up front saves most of the troubleshooting time later.

    • OS: Windows 11 64-bit. Windows 10 64-bit usually works too, but some dependencies require newer kernel features.
    • Memory: 8GB or more recommended. With a browser, an editor, and the assistant process running at once, 16GB is noticeably more stable.
    • Disk: 2GB or more free. Runtime dependencies and skill packages are downloaded at runtime, so first launch takes more space than the installer itself.
    • Network: the install script pulls files from a code hosting site, so prepare a mirror or proxy in advance if access is unreliable.
    • Permissions: an administrator-level terminal is required for installation and first-time configuration.

    An easily overlooked point: the default Windows script execution policy blocks remote scripts. This is not an installation failure but a security mechanism working as intended. Understanding that matters more than blindly disabling every protection.

    3. Installation Walkthrough

    3.1 Adjust the Script Execution Policy

    Open a terminal as administrator (choose the administrator terminal from the Win + X menu) and check the current policy:

    1. Get-ExecutionPolicy -List

    Then set the current user’s policy to allow signed remote scripts:

    1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    Scope CurrentUser means the change affects only your account and leaves machine-wide settings untouched, which is the lowest-risk option. Confirm when prompted. Keeping Bypass or Unrestricted in place long term is not recommended.

    3.2 Review and Run the Install Script

    A one-click install script essentially downloads code and executes it immediately, so download it locally and read it first:

    1. Invoke-WebRequest -Uri "https://<install-source-url>/install.ps1" -OutFile "$env:TEMP\install.ps1"
    2. Get-Content "$env:TEMP\install.ps1" | Select-Object -First 60

    Confirm it does three things: checks the OS version, installs the Node.js 22 or newer runtime, and writes core files into the user directory while registering a startup entry. Once it looks right, run it:

    1. & "$env:TEMP\install.ps1"

    If the official source is slow or drops the connection, switching to a mirror is the usual fix; a more robust option is configuring a proxy for the terminal alone rather than changing system-wide network settings. Installation normally takes 3 to 10 minutes. Keep the window open, since interrupting midway tends to leave a half-installed state.

    3.3 Verify the Installation

    After installation, check the runtime and the main program in order:

    1. node -v
    2. npm -v
    3. openclaw --version
    4. openclaw doctor

    The value of a doctor-style subcommand is that it reports port usage, configuration file syntax, and dependency integrity item by item, which beats guessing after a failed start. If node -v reports that the command does not exist, the runtime was not added to PATH; opening a new terminal resolves most cases.

    4. Connecting a Cloud Model: Using a Free Tier as an Example

    4.1 Obtain an API Key

    Register an account on the model provider’s open platform, go to the key management page, and create a key: a string starting with sk-. Three reminders: the key is shown in full only once at creation, so store it in a password manager immediately; use one key per project so it can be revoked per project; free tier policies change, so treat the current platform documentation as authoritative for quotas and rate limits instead of hard-coding assumptions.

    4.2 Configure the Model Provider

    Most self-hosted assistants use a three-part configuration of provider, model name, and key. Edit the configuration file in your user directory:

    1. {
    2. "providers": {
    3. "default": {
    4. "baseUrl": "https://<provider-endpoint>/v1",
    5. "apiKey": "${env:MODEL_API_KEY}",
    6. "models": ["<flash-class-model-id>"]
    7. }
    8. },
    9. "agent": {
    10. "model": "<flash-class-model-id>",
    11. "temperature": 0.7,
    12. "maxTokens": 4096
    13. }
    14. }

    Two engineering habits are worth fixing in place. First, inject the key through an environment variable instead of writing it in plaintext in the configuration file:

    1. [Environment]::SetEnvironmentVariable("MODEL_API_KEY", "sk-your-key", "User")

    Second, prefer a lightweight model labeled flash, lite, or mini as the default tier, and keep long-context and strong-reasoning models as on-demand switches. Latency and cost for everyday question answering are determined mainly by the default tier.

    4.3 Start and Self-Check

    1. openclaw start
    2. openclaw status

    Then open the local console address and send a minimal request in the chat window, confirming three things: a reply comes back, the reply language is correct, and the console shows the latency and token usage for this call. The third is the most important, since it is the basis for cost accounting and rate limiting later.

    5. Common Failures and How to Locate Them

    • Script blocked: confirm the effective scope of the execution policy is CurrentUser and that the terminal runs as administrator.
    • Port in use: find the process with Get-NetTCPConnection -LocalPort <port>; changing the port in configuration is safer than force-killing the process.
    • API 401: the key is wrong or expired, so verify it on its own with a minimal request first.
    • API 429: rate limit hit, so lower concurrency or add a request queue with backoff retries at the assistant layer.
    • Garbled Chinese: switch the terminal encoding to UTF-8 and save configuration files as UTF-8 without BOM.
    • Slow startup: the first run warms up dependencies, so read the logs rather than declaring failure outright.

    6. Long-Term Operations: Security, Cost, and Observability

    On security, keep keys only in environment variables or a key management service, and keep configuration files and log directories out of any code repository; the console listens on the loopback address by default, and if LAN access is needed, add a reverse proxy and authentication rather than exposing an unauthenticated port to the public internet.

    On cost, set token limits per session and a daily call cap, and make high-consumption skills such as web retrieval and file parsing explicitly triggered rather than enabled by default.

    On observability, ship runtime logs to a local log service, configure monitoring and alerts for disk usage and error rates, and back up the configuration and skill directories weekly while keeping one rollback-able version. With these three in place, the environment moves from “it runs” to “dependable long term.”

    If you are running in a cloud environment, you can host keys in a key management service, deliver logs to a log service, and run scheduled tasks on a function compute or container platform, keeping only the console and configuration locally. That preserves data control while gaining better availability and elasticity.