hass_local_openai_llm

skye-harrisApache-2.0活跃维护

把本地 OpenAI 兼容服务(llama.cpp、vLLM、Ollama 等)接入 Home Assistant,让智能家居助手用上自托管大模型做对话。

Home Assistant LLM integration for local OpenAI-compatible services (llamacpp, vllm, etc)

1.15.1发布于 2026-11-08 01:01 UTC309star +3 / 7 天50fork同步于 2026-11-11 00:00 UTC

怎么上手

由 README 提炼,执行前请确认
通过 HACS 添加自定义仓库 https://github.com/skye-harris/hass_local_openai_llm(类型 Integration),安装 Local OpenAI LLM 后重启 Home Assistant;手动安装则将 local_openai 文件夹复制到 config 目录的 custom_components 下并重启。
硬件要求按 README 说明

README 未说明具体显存或 GPU 型号要求,实际取决于所连接的推理服务器;集成本身运行在 Home Assistant 上,推理可放在本地或远程服务。

支持 Apple Silicon
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

让 Home Assistant 接入本地或云端 OpenAI 兼容 LLM 服务的自定义集成

把本地 OpenAI 兼容服务(llama.cpp、vLLM、Ollama 等)接入 Home Assistant,让智能家居助手用上自托管大模型做对话。

核心能力

  • 支持 llama.cpp、vLLM、Ollama、LM Studio 等 OpenAI 兼容服务
  • API Key 可留空,适配无需鉴权的本地推理服务器
  • 流式响应并自动剥离 响应中的 think 标签
  • 支持并行工具调用、图像输入与图像生成
  • 可裁剪对话历史、控制温度以控制上下文窗口

容易踩的坑

Server URL 需指向完整的 OpenAI 兼容 API,通常以 /v1 结尾;Assist 工具调用建议至少 10k 上下文,且需在推理服务器端配置而非通过 API;工具调用需在推理引擎中单独开启,并行工具调用还需模型与服务端同时支持。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本1.15.1
  1. 1.15.1最新正式版2026-11-08 · 2026-11-08 01:01 UTC

    What's Changed

    Full Changelog: https://github.com/skye-harris/hass_local_openai_llm/compare/1.15.0...1.15.1

  2. 1.15.02026-11-04 · 2026-11-04 12:16 UTC
    查看更新说明

    What's Changed

    Requires HomeAssistant 2026.11 or newer

    Full Changelog: https://github.com/skye-harris/hass_local_openai_llm/compare/1.14.0...1.15.0

  3. 1.14.02026-10-25 · 2026-10-25 12:37 UTC
    查看更新说明

    What's Changed

    New Contributors

    Full Changelog: https://github.com/skye-harris/hass_local_openai_llm/compare/1.13.0...1.14.0

  4. 1.13.02026-10-10 · 2026-10-10 12:42 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/skye-harris/hass_local_openai_llm/compare/1.12.1...1.13.0

  5. 1.12.12026-10-03 · 2026-10-03 23:58 UTC
    查看更新说明

    What's Changed

    Full Changelog: https://github.com/skye-harris/hass_local_openai_llm/compare/1.12.0...1.12.1

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    Local OpenAI LLM (Custom Integration for Home Assistant)

    Allows use of generic OpenAI-compatible LLM services, such as (but not limited to):

    • DeepSeek
    • Google (Gemini)
    • llama.cpp
    • LM Studio
    • LocalAI
    • Ollama
    • OpenRouter
    • Requesty
    • Scaleway
    • vLLM

    This integration has been forked from Home Assistants OpenRouter integration, with the following changes:

    • Added server URL to the initial server configuration
    • Made the API Key optional during initial server configuration: can be left blank if your local server does not require one
    • Uses streamed LLM responses
    • Conversation Agents support TTS streaming
    • Automatically strips <think> tags from responses
    • Added support for image inputs for AI Task entities
    • Added support for reconfiguring Conversation Agents
    • Added option to trim conversation history to help stay within your context window
    • Added temperature control (conversation agent + ai task)
    • Added option to strip emojis from responses
    • Added support for parallel tool calling
    • Added experimental Retrieval Augmented Generation capability
    • Added chat template arguments support
    • Added image generation support for AI Task entities
    • Added tools support for Generate Data actions for AI Task entities
    • Added decision model support for AI Task evaluate actions
    • Emits a local_openai_llm_generation_complete event for all LLM completion requests, with usage/timings data if available

    Installation

    Install via HACS (recommended)

    Have HACS installed, this will allow you to update easily.

    Adding Tools for Assist to HACS can be using this button:
    image

    [!NOTE] If the button above doesn't work, add https://github.com/skye-harris/hass_local_openai_llm as a custom repository of type Integration in HACS.

    • Click install on the Local OpenAI LLM integration.
    • Restart Home Assistant.

    Integration Configuration

    After installation, configure the integration through Home Assistant's UI:

    1. Go to Settings → Devices & Services.
    2. Click Add Integration.
    3. Search for Local OpenAI LLM.
    4. Follow the setup wizard to configure your desired services.

    Configuration Notes

    • The Server URL must be a fully qualified URL pointing to an OpenAI-compatible API.
      • This typically ends with /v1 but may differ depending on your server configuration.
    • A Server Type configuration can be set to expose some additional options for different inference servers and providers, where they have been implemented.
    • Assist requires a fairly lengthy context for tooling and entity definitions.
      • It is strongly recommended to use at least 10k context size and to limit history length and exposed entities to avoid context overflow issues.
      • This is not configurable through OpenAI-compatible APIs, and needs to be configured with the inference server directly.
    • Tool calling must be enabled in your inference engine, eg:
    • Parallel tool calling requires support from both your model and inference server.
      • In some cases, control of this is handled by the server directly, in which case toggling this will not have any result.
    • Chat Template Arguments allow you to provide custom arguments to your model
      • Arguments are supplied as key/value pairs and provided to the chat_template_kwargs request parameter
      • Values support Jinja2 templates, in order to provide non-string and more complex data structures
      • Arguments differ per model, and not all models make use of user-provided arguments
      • See your models documentation for what arguments are available to be used
    • Request Body Parameters allow you to provide additional top-level parameters to the chat completion request body
      • Parameters are supplied as key/value pairs and merged into the request body
      • Values support Jinja2 templates, in order to provide non-string and more complex data structures
      • Internally managed parameters, and parameters with dedicated configuration options, cannot be configured here
      • Provider support differs; see your provider and model documentation for available parameters
    • AI Task entities can be configured for Text and/or Image generation capabilities
      • This capability uses the Images API spec and requires support from your chosen image generation server
      • Support has been developed and tested with StableDiffusion.cpp
    • Always continue conversation — When a voice agent finishes speaking, passes the active voice turn back to the user in order to naturally continue the conversation
      • If the user speaks, the assistant continues the conversation naturally
      • If the user stays silent, the assistant stops following up after a timeout
      • If the user says a stop keyword (e.g. "STOP") while the agent is actively speaking, the follow-up is canceled immediately (default HomeAssistant behaviour)
      • The agent is provided a stop talking tool to end the conversation via natural language request to the agent itself (while the assist satellite is listening, not speaking)
      • When disabled (default), only assistant responses ending in a question will pass the active voice turn back to the user

    All Server Types

    Custom HTTP Headers

    Add custom HTTP headers as key-value pairs to all LLM API requests. Useful for passing custom metadata or provider-specific headers:

    • Values support Jinja2 templates and have access to all default Home Assistant template variables and functions (e.g. entity states).
    • The current Conversation ID is available in the conversation_id variable.
    • All header values are coerced to strings after rendering.

    DeepSeek Cloud Configuration

    Reasoning Effort

    When the server type is set to DeepSeek Cloud, both conversation and AI task agents show a new DeepSeek Configuration section with a Reasoning Effort option. This controls the depth of reasoning when thinking is enabled.

    • High (default) — standard reasoning effort.
    • Max — maximum reasoning effort.

    When enabled, thinking content returned by the model is also fed back into the conversation as reasoning content on supported Home Assistant versions (2026.4+).

    Thinking Mode

    Controls when reasoning is enabled. Leave the option unset to disable thinking.

    • Always on — thinking remains enabled for every iteration.
    • First loop iteration only — thinking is disabled on iterations after the first (e.g., during tool-call rounds).

    llama.cpp Configuration

    When the server type is set to llama.cpp, both conversation and AI task agents show a llama.cpp Configuration section with the following options.

    Thinking Mode

    Controls when reasoning is enabled. Leave the option unset to disable thinking.

    • Always on — reasoning is enabled for every iteration of the agent loop.
    • First loop iteration only — thinking is disabled on iterations after the first (e.g., during tool-call rounds).

    Note: This option completely overrides any existing enable_thinking option in your Chat Template Arguments.

    Include prior thinking

    Controls whether thinking/reasoning content from prior conversation turns is sent back in new completion requests.

    Some reasoning models require this enabled, and others require it disabled. Check the documentation for your model if unsure.

    • Enabled (default) — prior-turn thinking_content is passed as reasoning_content in the next request, allowing the model to see its own prior reasoning.
    • Disabled — prior thinking context is stripped before sending. Use for models that reject prior reasoning context (e.g., Gemma 4).
    Slot ID

    Pins requests to a specific llama.cpp server slot for prompt-cache reuse. Leave empty to allow any slot to be used.

    Use loaded model

    When enabled, the integration prioritizes using models already resident in memory to minimize latency.

    It follows these rules:

    • Primary: Uses the configured model if it is currently loaded.
    • Fallback: If the configured model is not loaded, it selects the first loaded model that supports the required modality (e.g., image inputs). If no compatible loaded models exist, it defaults back to the configured model.

    This is ideal for users with diverse model setups who want to route tasks to whatever is currently available in memory rather than waiting for a specific model to load.

    Sampling Parameters

    These options control how llama.cpp selects tokens during text generation. Please refer to the llama.cpp documentation for further information and usage.

    ParameterDescriptionRange
    Top-PRestricts sampling to the top-p probability mass of tokens.0–1
    Min-PMinimum probability threshold for nucleus sampling, providing additional control when combined with top-p.0–1
    Top-KLimits sampling to the k highest-probability tokens.1–1000
    Repeat PenaltyPenalizes repeat sequences of tokens.-2–2
    Presence PenaltyPenalizes tokens already present in the context.-2–2
    Model naming

    llama.cpp exposes the value supplied via its --alias flag on the model object. When an alias is set it is used as the model's display name; otherwise the raw model id (typically the full model file path) is used, with the path and .gguf extension stripped for a cleaner name.


    LocalAI Configuration

    When the server type is set to LocalAI, Chat Template Arguments are sent via the OpenAI metadata request field rather than a top-level chat_template_kwargs field, as this is where LocalAI reads chat template variables from. Values are coerced to strings, per LocalAI's metadata convention.

    See LocalAI model configuration.

    vLLM Configuration

    When the server type is set to vLLM, both conversation and AI task agents show a vLLM Configuration section with the following options.

    Thinking token budget

    Caps how many tokens the model may spend on reasoning, via the thinking_token_budget request parameter. Once the budget is reached, vLLM forces the reasoning block to be closed and the model proceeds to its answer.

    • Empty (default) — no budget is sent, and the server default applies.
    • 0 — the reasoning block is closed immediately, so the model answers without thinking.
    • Any higher value — limits reasoning to that number of tokens.
    Thinking Mode

    Controls when reasoning is enabled. Leave the option unset to disable thinking.

    • Always on — reasoning is enabled for every iteration and the token budget (if set) applies to all iterations.
    • First loop iteration only — thinking is disabled on iterations after the first (e.g., during tool-call rounds).

    Requires a reasoning model and a vLLM version that supports the parameter. Refer to the vLLM reasoning outputs documentation for further information.

    When the budget is reached the reasoning block is closed with the parser's end string, which can leave the model cut off mid-thought. A wrap-up message can be added there to transition into the answer more gracefully, though this is configured on the vLLM server rather than per request:

    --reasoning-parser qwen3
    --reasoning-config '{"reasoning_start_str": "<think>", "reasoning_end_str": "\n\nTime to wrap up my reasoning and answer.</think>"}'
    

    Experimental: Date/Time Context Injection Role

    This integration supports injecting some dynamic content, presently the date and time, into the active Conversation Agent prompt when making a request. This was added as it is beneficial for the model to be grounded with this context in its role as an assistant, and was previously added to the system prompt by Home Assistant itself before later being removed due to negative effects on prompt caching and performance.

    This was previously always-on but has been extracted as an experimental configuration option as this is not a once-size-fits-all for all models. To this end I have provided a number of options so that users can try them out and select the one that works best, or disable entirely if none work well, for their chosen model.

    The available options are:

    Tool Result:

    The date and time are inserted as a Tool Call Result message to the model, before the current user message.

    As long as the model does not reject it, this is the recommended method to use and produces the most reliable results during testing.

    Assistant:

    The date and time are inserted as an additional Assistant message to the model, before the current user message.

    In cases where the Tool Call Result role method does not work for a model, this is the next recommended to test with.

    User:

    The date and time are inserted as an additional User message to the model, before the current user message.

    Recommended only where neither the System nor Assistant injection methods work for the model, but may not produce desirable results. Some models have been known to repeat the date/time back to the user without request.

    Disabled (no selection):

    If your model simply refuses to work well with any method, simply remove the value from the configuration option to disable this again.

    Decision Models

    Home Assistant 2026.11 added the ai_task.evaluate action, which asks a decision model yes/no, choice and score questions and returns probabilities rather than generated text. This integration supports decision models served through the TypeSafe-compatible /v1/systemone API, such as llama.cpp and Ollama.

    • Add one from your server's integration entry with Add decision model. This is available for the Generic and llama.cpp server types.
    • Decision models get their own AI Task entity, separate from your data and image generation entities. Select it as the default decision entity in the AI Task settings to use it without passing entity_id.
    • On llama.cpp, the model list only shows models the server reports as native decision models. A chat model prompted to classify is not a decision model, and the server will reject it.
    • Image attachments are supported when the model and server support image input. On llama.cpp this requires a multimodal projector to be loaded.
    action: ai_task.evaluate
    data:
      task_name: Check delivery
      state: "{{ states('sensor.last_delivery_message') }}"
      questions:
        delivered:
          type: noul
          instructions: Has the package been delivered?
        location:
          type: choice
          instructions: Where was the package left?
          criteria:
            front_door: At the front door or on the porch
            mailbox: Inside the mailbox
            other: Somewhere else, or the message does not say
    response_variable: delivery
    

    Experimental: Retrieval Augmented Generation (RAG) with Weaviate

    Retrieval Augmented Generation is used to pre-feed your LLM messages with related data to provide contextually relevant information to the model based on the user input message.

    This integration supports connecting your Agent to a Weaviate vector database server. Once configured, user messages to the Agent will be queried against the Weaviate database first, and the result data pre-emptively injected into the current conversation as contextual data for the Agent to utilise in their response.

    This is not a general-purpose "memory" for the Agent: content is only provided to the Agent if it matches on the current user input message to the model.

    See the Weaviate documentation for further information on Weaviate.


    Weaviate Configuration

    1. Install Weaviate locally
      1. A pre-made docker-compose.yml is provided in the weaviate directory of this repository.
        1. Upgrading an existing install: Weaviate only supports upgrading one minor version at a time. If your data was created with the previous 1.34.0 image, step through the latest patch of each minor (1.35, 1.36, 1.37, 1.38) before starting 1.39.13. See the Weaviate migration guide.
      2. Weaviate Cloud is not supported: there is no free tier available and its cheapest pricing plan isn't attractive for personal/home use, and so I don't anticipate demand for this.
    2. Reconfigure your LLM Server entity (not the Agent entity) in Home Assistant.
      1. Expand the Weaviate configuration section and fill in the details server address and API key (homeassistant if using the supplied docker-compose.yml).
    3. Optional: Reconfigure your AI Agent entities in Home Assistant.
      1. This is only needed if you wish to change the default Weaviate values on a per-agent basis:
        1. Object class name: Defaults to Homeassistant, can be changed if you want a different data store for the Agent. The integration will handle creating the required object class within Weaviate if it does not already exist.
        2. Maximum number of results to use: Defaults to 2.
        3. Result score threshold: Defaults to 0.9.
        4. Hybrid search alpha: Defaults to 0.5. Balances the hybrid result scoring between 0 (fully text-matched) and 1 (fully vectorised) matching.

    Managing Data

    Self-hosted Weaviate does not come with a front-end to manage data at all at this current point in time.

    I have included a simple NodeJS-based WebApp server within the /weaviate directory of this repository, that can be used to connect to your local Weaviate instance and view, query, and manage the data in your object class. This is also setup into the supplied docker-compose.yml and exposed on port 9090 by default.

    This tool supports the following basic functionality:

    • Connect to your server and list the available object classes.
    • View the available entry data in each class.
    • Add new entry data to a class.
    • Perform vector and hybrid searches against an object class.

    This is not a general-purpose Weaviate management tool, rather it is purpose-built specifically for use with this integration and the object classes that it creates.

    Notes

    • Only the current generations user message is queried in the database, no prior user messages are included.
    • Search results are used for the current user/assistant turns only (including multiturn tool usages), and do not carry forward to subsequent user/assistant turns.
    • Objects are stored as 2 pieces of data: the query, and the content:
      • The query is what is vectorised and the user inputs searched against.
      • The content is the main content to be provided to be fed to the LLM, along with its query text for context.
    • Useful for providing contextual information to the LLM for different types of requests, without having all of it in your prompt at all times.
    • I have performed basic testing of this with a variety of models across a few inference providers:
      • Qwen 3-VL 8B locally on llama.cpp.
      • Minimax m2.1 on OpenRouter.
      • Ministral 8B 2512 on OpenRouter.
      • GPT-5 on OpenRouter.
      • Gemma 3 27B on Scaleway.
      • Llama 3.1 8B on Scaleway.
      • GPT-OSS-120B on Scaleway.
    • A service action, local_openai.add_to_weaviate, can be used from within Home Assistant to add content to the database.

    Web Search & Additional Tools

    Looking to add some more functionality to your Home Assistant conversation agent, such as web and localised business/location search? Check out my Tools for Assist integration here!

    These tools exist as a separate integration for compatibility across the wider Home Assistant Conversation ecosystem.


    Acknowledgements

    This integration was forked from the OpenRouter integration for Home Assistant by @joostlek.


    Contributors

    I would like to thank the following people for their contributions to this project:


    Support Development

    If you find this integration useful and would like to support development, please consider buying me a coffee.

    "Buy Me A Coffee"