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

    This guide walks through building a self-hosted AI assistant on Windows 11, covering resource planning, API key setup, installation, model connection, troubleshooting, and hardening. It explains how self-hosting keeps interaction, session data, and permissions under your control while model inference still runs on remote services. You will find the exact PowerShell commands, configuration steps, and security defaults needed to get a working local console.

    1. Why Choose a Self-Hosted AI Assistant

    As public cloud LLM services keep evolving quickly, more developers are paying attention to control. The core value of a self-hosted AI assistant is not replacing cloud LLMs, but bringing the interaction entry point, session data, skill extensions, and permission boundaries back into your local or owned environment. Storing data entirely locally means sensitive conversations never have to leave your internal network; freely switching models means avoiding lock-in to a single vendor; extensible skills mean capabilities such as file processing, web retrieval, and scheduled tasks can be assembled on demand; and a well-structured web console lowers the barrier for non-engineers.

    It is worth stressing that self-hosted does not mean offline-capable. Model inference usually still calls external services; the difference is that you control the calling relationship. The sensible architecture is therefore: local handles orchestration, storage, and display, while remote handles inference compute. Understanding this split is the foundation for every configuration decision that follows.

    2. Preparation: Eliminate Uncertainty Early

    2.1 Environment and Resource Assessment

    • OS: Windows 11 64-bit; Windows 10 64-bit usually works too.
    • Memory: 8GB or more recommended. If you run a browser console, an editor, and local services at the same time, 16GB is more stable.
    • Disk: reserve at least 2GB, 5GB recommended in practice, for runtime dependencies, logs, and session cache.
    • Network: installation requires access to code hosting and package sources; if access is restricted, prepare a usable mirror channel in advance.

    The point of resource assessment is to avoid “installs fine, runs badly.” The local service itself has a small footprint; real memory pressure usually comes from browser tabs and concurrent sessions.

    2.2 Obtain Model Access Keys

    A self-hosted platform needs an inference backend. The common approach is to register an account on any model service platform that exposes an OpenAI-style API, go to the key management page, and create a key. Keys usually start with the sk- prefix and are shown in full only once at creation, so they must be stored safely. If you use a model service from Baidu AI Cloud, the key is created in the same way from the access credential management entry in its console, following the least-privilege principle.

    On free tiers: policies differ widely across platforms and change frequently, so “free forever” should not be treated as an architectural assumption. Always check the current billing and rate limit documentation before production use.

    2.3 Open a Terminal as Administrator

    Press Win + X and choose “Terminal (Admin)” or “Windows PowerShell (Admin)”, then confirm in the User Account Control prompt. Administrator rights are only needed during installation; use standard privileges for daily operation to reduce the attack surface.

    3. Key Actions During Installation

    3.1 Configure the Script Execution Policy

    Windows restricts script execution by default, so loosen it for the current user only:

    1. Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    Type Y to confirm. The tradeoff with RemoteSigned is that locally created scripts can run, while scripts from the network must carry a trusted signature, which is far safer than Unrestricted. Never use Bypass as a long-term setting.

    3.2 Use the Official Install Script

    Mainstream self-hosted assistant projects generally provide a one-click script that automatically deploys the runtime (such as Node.js 22 or newer) and core files:

    1. iwr -useb <official install script URL> | iex

    If the official source is slow or drops, you can switch to a community-maintained mirror URL; the command form is identical. Installation takes about 3–10 minutes, so do not close the window. Security advice: before running it, open the script URL in a browser and read it through to confirm there is no suspicious downloading or writing behavior. This is a habit you must build for the iwr | iex pattern.

    3.3 Verify the Installation

    1. openclaw --version
    2. openclaw doctor

    The first command confirms the version number; the second runs an environment self-check (runtime version, port usage, configuration integrity). Once both pass, move on to configuration.

    4. Connect the Model: Turn a Key into Usable Capability

    4.1 Initialization and Key Storage

    1. openclaw init
    2. openclaw config set model.provider openai-compatible
    3. openclaw config set model.baseUrl <service URL>
    4. openclaw config set model.apiKey "$env:MODEL_API_KEY"

    A safer approach is to put the key in a user-level environment variable rather than a plaintext config file:

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

    If the config file is under version control, always exclude it with .gitignore so credentials do not leak with the code.

    4.2 Choose a Model and Parameters

    Taking a generic “lightweight fast model” as an example, prefer low-latency variants for everyday Q&A and summarization, and switch to larger models for complex reasoning. Key parameters usually include temperature, max tokens, and timeout. It is advisable to run an A/B comparison in the console with a fixed set of questions first, then lock in the defaults.

    4.3 Start and Access

    1. openclaw serve --host 127.0.0.1 --port 3000

    Open the local address in a browser to see the console. Binding only to the loopback address and not exposing the port externally is the most important security default for local deployment.

    5. Common Issues and Troubleshooting

    • Script execution blocked: confirm the execution policy scope is the current user, and check whether group policy overrides it.
    • Runtime version mismatch: verify with node -v, and switch versions via a version management tool if needed.
    • Key authentication failure: distinguish three cases: wrong key, exhausted quota, and mismatched address; check the return code first, then the logs.
    • Port conflict: switch to a high port, or use Get-NetTCPConnection to locate the process holding it.
    • Garbled Chinese text: set the terminal encoding to UTF-8 and use UTF-8 response headers consistently in the console.

    6. Hardening for Stable Operation

    Bring in logging, monitoring, and alerting early; local services need rotation and retention policies too. Back up session data to object storage regularly. Follow least privilege for skill extensions, and restrict file reads and writes to designated directories. When sharing externally, always place the service behind a reverse proxy with authentication enabled. If you need elastic compute and unified operations, deploy the orchestration layer on a container platform and route model calls to a cloud vendor’s model service category, achieving a compromise of “local control plus cloud elasticity.”

    At this point you have completed the full loop from environment assessment and installation to model integration and hardening, giving you an AI assistant foundation that keeps data local and extends capabilities on demand.