AI Assistant Documentation
Overview
The AI Assistant add-on brings enterprise-grade AI to your Home Assistant instance. It provides a web-based chat interface with multi-provider AI support (Anthropic Claude, OpenAI GPT, Google Gemini, NVIDIA NIM, GitHub Models), file access capabilities, persistent memory, document analysis, and more.
The add-on integrates seamlessly with Home Assistant's Supervisor API, requiring no long-lived tokens—just your AI provider API keys.
Features
Core Features
- Streaming chat UI with real-time responses
- Multi-provider support: Anthropic, OpenAI, Google Gemini, NVIDIA NIM, GitHub Models (40+ models)
- Model switching: Change AI providers and models on-the-fly without restarting
- Persistent model selection: Your chosen agent is saved and restored after restart
- Multi-language UI: English, Italian, Spanish, French
- Home Assistant integration: Read device states, call services directly from chat
Advanced Features (Experimental)
- File Upload & Analysis (v3.3.0+): Upload PDF, DOCX, TXT, MD, YAML files for AI analysis
- Persistent Memory (v3.3.0+): AI remembers past conversations across sessions
- RAG (Retrieval-Augmented Generation) (v3.3.0+): Semantic search over uploaded documents
- File Access: Optional read/write access to
/config directory with automatic snapshots
AI Providers
Anthropic Claude
- Models: Claude 3.5 Sonnet, Haiku, Opus
- Cost: ~$3/$0.80/$15 per 1M tokens
- Setup: Get API key from console.anthropic.com
- Best for: Complex reasoning, creative tasks, long context
OpenAI
- Models: GPT-4o, GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, o1-preview, o3-mini
- Cost: $5-$20 per 1M tokens (varies by model)
- Setup: Create API key at platform.openai.com
- Best for: Balanced performance, variety of models, tools integration
Google Gemini
- Models: Gemini 2.0 Flash, Pro, Pro Vision
- Cost: Free tier available, ~$7.50 per 1M tokens (paid)
- Setup: Get API key from ai.google.dev
- Best for: Fast responses, vision capabilities, free tier users
NVIDIA NIM
- Models: NVIDIA Llama 3.1 405B, Mistral, Mixtral, etc.
- Cost: Free tier (rate-limited)
- Setup: Get API key from build.nvidia.com
- Thinking Mode: Available on supported models (opt-in)
- Best for: Open-source models, free inference, high throughput
GitHub Models
- Models: OpenAI o1-preview, o3-mini, GPT-4o, Llama, Phi, etc.
- Cost: Free for GitHub users (token limits apply)
- Setup: Use GitHub PAT (fine-grained, no special permissions needed)
- Best for: GitHub users, experimental models, free access
Installation
Add Repository:
- Settings → Add-ons & Backups → Add-on Store → ⋮ → Repositories
- Add:
https://github.com/Bobsilvio/ha-claude
Install Add-on:
- Search for "AI Assistant"
- Click AI Assistant for Home Assistant
- Click Install
Configure & Start:
- Open the Configuration tab
- Add at least one provider API key
- Click Save and Start
Configuration
Required
At least one AI provider API key is required. Choose based on:
- Anthropic API Key: Best all-rounder, most reliable
- OpenAI API Key: Variety of models, popular choice
- Google API Key: Free options available
- NVIDIA API Key: Open-source models, free tier
- GitHub Token: Free for GitHub users
Optional Features
| Setting |
Default |
Description |
language |
en |
UI language (en/it/es/fr) |
enable_file_access |
false |
Allow read/write /config files with snapshots |
enable_file_upload |
false |
Allow uploading documents (PDF, DOCX, TXT, etc.) |
enable_memory |
false |
Enable persistent conversation memory |
enable_rag |
false |
Enable RAG for document search |
nvidia_thinking_mode |
false |
Extra reasoning tokens on NVIDIA models |
colored_logs |
true |
Pretty-print add-on logs |
debug_mode |
false |
Verbose logging for troubleshooting |
timeout |
30 |
API request timeout (seconds) |
max_retries |
3 |
Retry failed requests |
log_level |
normal |
Log verbosity: normal, verbose, debug |
Using the Chat
First Launch
- Open AI Assistant from the Home Assistant sidebar
- Click the model dropdown (top left of chat area)
- Select an agent/model (e.g., "OpenAI → GPT-4o")
- Start chatting
Model Switching
- Click the model dropdown to switch providers/models instantly
- Selection is saved automatically and persists across restarts
Home Assistant Integration
Ask the AI about your smart home:
- Device states: "What's the current garage door status?"
- Services: "Turn on the living room lights"
- Automations: "Show me my evening routine automation"
The AI reads states and can trigger actions directly from chat.
File Upload (Experimental)
If enable_file_upload: true:
- Click the file upload button (orange, in input area)
- Select a document (PDF, DOCX, TXT, MD, YAML)
- Documents are auto-injected into AI context
Files are cleaned up after use. Upload limit: 10MB per file.
Persistent Memory (Experimental)
If enable_memory: true:
- AI remembers past conversations across sessions
- Memory searches by keywords and message content
- Old conversations are kept (never deleted)
- Memory is local (no cloud sync)
Document Search (RAG)
If enable_rag: true and enable_file_upload: true:
- Upload documents to build a knowledge base
- AI performs semantic search over documents
- Results automatically injected into prompts
Advanced Configuration
File Access
Requires enable_file_access: true in config.
Snapshot & Restore Mechanism:
- When you edit
/config via chat, the add-on creates an automatic backup
- If edit fails or causes issues, you can restore the last snapshot
- Snapshots are kept in
/config/.claude_backups/
Example Uses:
- Edit
configuration.yaml to add automations
- Update secrets in
secrets.yaml
- Write custom Python scripts to
python_scripts/
Logging & Debugging
Set log_level to control verbosity:
normal (default): Core messages only (clean logs)
verbose: Includes all API request/response logs
debug: Maximum detail, including internal state
Use via YAML config or environment variable LOG_LEVEL.
Troubleshooting
Chat UI doesn't load
- Verify add-on is Running (check green status in Add-ons)
- Check add-on logs for errors
- Hard-refresh browser (Ctrl+F5 / Cmd+Shift+R)
- Restart Home Assistant if persists
API errors (401, 403, 429)
- 401: API key is invalid → Check provider account and key format
- 403: Permissions issue → Verify API key has chat/inference permissions
- 429: Rate limited → Wait or upgrade to higher tier with provider
Home Assistant integration not working
- Check
/api/status endpoint (add /ha-claude/ to HA URL)
- Verify HA connection status shows
ok
- Restart add-on if status shows
error
File Upload not working
- Ensure
enable_file_upload: true andSave config
- Verify file is < 10MB
- Check supported formats: PDF, DOCX, DOC, TXT, MD, YAML, YML, ODT
- Restart add-on if issues persist
Memory feature not saving
- Ensure
enable_memory: true in config
- Check
/config/.claude_memory/ folder exists
- Restart add-on
- Check add-on logs for permission errors
Module import errors
- Example:
ModuleNotFoundError: No module named 'PyPDF2'
- Solution: Restart the add-on (dependencies are installed on start)
API Reference
The add-on exposes a REST API at /ha-claude/api/ (or direct port 5010 if not using Ingress).
Chat Endpoints
POST /api/chat/stream
- Stream-based chat API
- Request body:
{"message": "...", "conversation_id": "..." (optional)}
- Response: Server-Sent Events (SSE) with streamed tokens
GET /api/models
- List available providers and models
- Returns:
{"providers": {...}, "models": [...]}
POST /api/set_model
- Change active provider/model
- Request body:
{"provider": "openai", "model": "gpt-4o"}
- Returns:
{"success": true}
GET /api/status
- System status (HA connection, feature flags, version)
- Returns:
{"ha_connection_ok": true, "version": "3.3.0", ...}
Document Endpoints (File Upload/RAG)
POST /api/documents/upload
- Upload document for analysis
- Multipart form-data with file
- Returns:
{"success": true, "filename": "...", "pages": N}
DELETE /api/documents/{filename}
- Remove uploaded document
- Returns:
{"success": true}
GET /api/documents
- List uploaded documents
- Returns:
{"documents": [...]}
Memory Endpoints
GET /api/memory/search
- Search conversation history
- Query params:
q=<query>
- Returns:
{"results": [...]}
DELETE /api/memory/clear
- Clear all memory (use with caution!)
- Returns:
{"success": true}
For full API details, visit the /api/ endpoint directly.
Home Assistant Integration Examples
Read Device State
"What's the current temperature in the living room?"
- AI reads the temperature sensor state from HA
Call Service
"Turn off the bedroom lights"
- AI calls the
light.turn_off service on bedroom lights
Complex Automation
"Create an automation that turns on kitchen lights when motion is detected after sunset"
- AI reads existing automations and can write new ones to
configuration.yaml
Performance Tips
- Streaming: Modern models stream responses (GPT-4o, Claude 3.5) → faster perceived performance
- Model Size: Smaller models (o3-mini, Llama 3.1 70B) are faster but less capable
- Timeout Setting: Increase if using complex reasoning or long documents
- Document Size: Keep uploaded files < 5MB for best performance
- Memory Size: Limit active memory by clearing old conversations occasionally
Security Notes
- API Keys: Stored in HA configuration, never exposed to UI
- File Access: Only reads/writes under
/config directory
- Ingress: All traffic through HA Ingress by default (no direct internet exposure)
- Memory: Local only, no cloud sync
- Documents: Deleted after use, not persisted
Support
Changelog
See CHANGELOG.md for version history and updates.
1---2name: 2885-docs-283b4c903description: AI Assistant Documentation4---5# AI Assistant Documentation67## Overview89The **AI Assistant add-on** brings enterprise-grade AI to your Home Assistant instance. It provides a web-based chat interface with multi-provider AI support (Anthropic Claude, OpenAI GPT, Google Gemini, NVIDIA NIM, GitHub Models), file access capabilities, persistent memory, document analysis, and more.1011The add-on integrates seamlessly with Home Assistant's Supervisor API, requiring no long-lived tokens—just your AI provider API keys.1213## Features1415### Core Features16- **Streaming chat UI** with real-time responses17- **Multi-provider support**: Anthropic, OpenAI, Google Gemini, NVIDIA NIM, GitHub Models (40+ models)18- **Model switching**: Change AI providers and models on-the-fly without restarting19- **Persistent model selection**: Your chosen agent is saved and restored after restart20- **Multi-language UI**: English, Italian, Spanish, French21- **Home Assistant integration**: Read device states, call services directly from chat2223### Advanced Features (Experimental)24- **File Upload & Analysis** (v3.3.0+): Upload PDF, DOCX, TXT, MD, YAML files for AI analysis25- **Persistent Memory** (v3.3.0+): AI remembers past conversations across sessions26- **RAG (Retrieval-Augmented Generation)** (v3.3.0+): Semantic search over uploaded documents27- **File Access**: Optional read/write access to `/config` directory with automatic snapshots2829## AI Providers3031### Anthropic Claude32- **Models**: Claude 3.5 Sonnet, Haiku, Opus33- **Cost**: ~$3/$0.80/$15 per 1M tokens34- **Setup**: Get API key from [console.anthropic.com](https://console.anthropic.com)35- **Best for**: Complex reasoning, creative tasks, long context3637### OpenAI38- **Models**: GPT-4o, GPT-4 Turbo, GPT-4, GPT-3.5 Turbo, o1-preview, o3-mini39- **Cost**: $5-$20 per 1M tokens (varies by model)40- **Setup**: Create API key at [platform.openai.com](https://platform.openai.com)41- **Best for**: Balanced performance, variety of models, tools integration4243### Google Gemini44- **Models**: Gemini 2.0 Flash, Pro, Pro Vision45- **Cost**: Free tier available, ~$7.50 per 1M tokens (paid)46- **Setup**: Get API key from [ai.google.dev](https://ai.google.dev)47- **Best for**: Fast responses, vision capabilities, free tier users4849### NVIDIA NIM50- **Models**: NVIDIA Llama 3.1 405B, Mistral, Mixtral, etc.51- **Cost**: Free tier (rate-limited)52- **Setup**: Get API key from [build.nvidia.com](https://build.nvidia.com)53- **Thinking Mode**: Available on supported models (opt-in)54- **Best for**: Open-source models, free inference, high throughput5556### GitHub Models57- **Models**: OpenAI o1-preview, o3-mini, GPT-4o, Llama, Phi, etc.58- **Cost**: Free for GitHub users (token limits apply)59- **Setup**: Use GitHub PAT (fine-grained, no special permissions needed)60- **Best for**: GitHub users, experimental models, free access6162## Installation63641. **Add Repository**:65 - Settings → Add-ons & Backups → Add-on Store → ⋮ → Repositories66 - Add: `https://github.com/Bobsilvio/ha-claude`67682. **Install Add-on**:69 - Search for "AI Assistant"70 - Click **AI Assistant for Home Assistant**71 - Click **Install**72733. **Configure & Start**:74 - Open the **Configuration** tab75 - Add at least one provider API key76 - Click **Save** and **Start**7778## Configuration7980### Required8182At least one AI provider API key is required. Choose based on:83- **Anthropic API Key**: Best all-rounder, most reliable84- **OpenAI API Key**: Variety of models, popular choice85- **Google API Key**: Free options available86- **NVIDIA API Key**: Open-source models, free tier87- **GitHub Token**: Free for GitHub users8889### Optional Features9091| Setting | Default | Description |92|---------|---------|-------------|93| `language` | `en` | UI language (en/it/es/fr) |94| `enable_file_access` | `false` | Allow read/write `/config` files with snapshots |95| `enable_file_upload` | `false` | Allow uploading documents (PDF, DOCX, TXT, etc.) |96| `enable_memory` | `false` | Enable persistent conversation memory |97| `enable_rag` | `false` | Enable RAG for document search |98| `nvidia_thinking_mode` | `false` | Extra reasoning tokens on NVIDIA models |99| `colored_logs` | `true` | Pretty-print add-on logs |100| `debug_mode` | `false` | Verbose logging for troubleshooting |101| `timeout` | `30` | API request timeout (seconds) |102| `max_retries` | `3` | Retry failed requests |103| `log_level` | `normal` | Log verbosity: `normal`, `verbose`, `debug` |104105## Using the Chat106107### First Launch1081. Open **AI Assistant** from the Home Assistant sidebar1092. Click the **model dropdown** (top left of chat area)1103. Select an agent/model (e.g., "OpenAI → GPT-4o")1114. Start chatting112113### Model Switching114- Click the **model dropdown** to switch providers/models instantly115- Selection is **saved automatically** and persists across restarts116117### Home Assistant Integration118Ask the AI about your smart home:119- Device states: *"What's the current garage door status?"*120- Services: *"Turn on the living room lights"*121- Automations: *"Show me my evening routine automation"*122123The AI reads states and can trigger actions directly from chat.124125### File Upload (Experimental)126If `enable_file_upload: true`:1271. Click the **file upload button** (orange, in input area)1282. Select a document (PDF, DOCX, TXT, MD, YAML)1293. Documents are auto-injected into AI context130131Files are cleaned up after use. Upload limit: **10MB per file**.132133### Persistent Memory (Experimental)134If `enable_memory: true`:135- AI **remembers past conversations** across sessions136- Memory searches by keywords and message content137- Old conversations are kept (never deleted)138- Memory is local (no cloud sync)139140### Document Search (RAG)141If `enable_rag: true` and `enable_file_upload: true`:142- Upload documents to build a knowledge base143- AI performs semantic search over documents144- Results automatically injected into prompts145146## Advanced Configuration147148### File Access149Requires `enable_file_access: true` in config.150151**Snapshot & Restore Mechanism**:152- When you edit `/config` via chat, the add-on creates an automatic backup153- If edit fails or causes issues, you can restore the last snapshot154- Snapshots are kept in `/config/.claude_backups/`155156**Example Uses**:157- Edit `configuration.yaml` to add automations158- Update secrets in `secrets.yaml`159- Write custom Python scripts to `python_scripts/`160161### Logging & Debugging162163Set `log_level` to control verbosity:164165- **`normal`** (default): Core messages only (clean logs)166- **`verbose`**: Includes all API request/response logs167- **`debug`**: Maximum detail, including internal state168169Use via YAML config or environment variable `LOG_LEVEL`.170171## Troubleshooting172173### Chat UI doesn't load1741. Verify add-on is **Running** (check green status in Add-ons)1752. Check add-on logs for errors1763. Hard-refresh browser (Ctrl+F5 / Cmd+Shift+R)1774. Restart Home Assistant if persists178179### API errors (401, 403, 429)180- **401**: API key is invalid → Check provider account and key format181- **403**: Permissions issue → Verify API key has chat/inference permissions182- **429**: Rate limited → Wait or upgrade to higher tier with provider183184### Home Assistant integration not working185- Check `/api/status` endpoint (add `/ha-claude/` to HA URL)186- Verify HA connection status shows `ok`187- Restart add-on if status shows `error`188189### File Upload not working190- Ensure `enable_file_upload: true` and**Save** config191- Verify file is < 10MB192- Check supported formats: PDF, DOCX, DOC, TXT, MD, YAML, YML, ODT193- Restart add-on if issues persist194195### Memory feature not saving196- Ensure `enable_memory: true` in config197- Check `/config/.claude_memory/` folder exists198- Restart add-on199- Check add-on logs for permission errors200201### Module import errors202- Example: `ModuleNotFoundError: No module named 'PyPDF2'`203- Solution: Restart the add-on (dependencies are installed on start)204205## API Reference206207The add-on exposes a REST API at `/ha-claude/api/` (or direct port 5010 if not using Ingress).208209### Chat Endpoints210211**POST `/api/chat/stream`**212- Stream-based chat API213- Request body: `{"message": "...", "conversation_id": "..." (optional)}`214- Response: Server-Sent Events (SSE) with streamed tokens215216**GET `/api/models`**217- List available providers and models218- Returns: `{"providers": {...}, "models": [...]}`219220**POST `/api/set_model`**221- Change active provider/model222- Request body: `{"provider": "openai", "model": "gpt-4o"}`223- Returns: `{"success": true}`224225**GET `/api/status`**226- System status (HA connection, feature flags, version)227- Returns: `{"ha_connection_ok": true, "version": "3.3.0", ...}`228229### Document Endpoints (File Upload/RAG)230231**POST `/api/documents/upload`**232- Upload document for analysis233- Multipart form-data with file234- Returns: `{"success": true, "filename": "...", "pages": N}`235236**DELETE `/api/documents/{filename}`**237- Remove uploaded document238- Returns: `{"success": true}`239240**GET `/api/documents`**241- List uploaded documents242- Returns: `{"documents": [...]}`243244### Memory Endpoints245246**GET `/api/memory/search`**247- Search conversation history248- Query params: `q=<query>`249- Returns: `{"results": [...]}`250251**DELETE `/api/memory/clear`**252- Clear all memory (use with caution!)253- Returns: `{"success": true}`254255For full API details, visit the `/api/` endpoint directly.256257## Home Assistant Integration Examples258259### Read Device State260*"What's the current temperature in the living room?"*261- AI reads the temperature sensor state from HA262263### Call Service264*"Turn off the bedroom lights"*265- AI calls the `light.turn_off` service on bedroom lights266267### Complex Automation268*"Create an automation that turns on kitchen lights when motion is detected after sunset"*269- AI reads existing automations and can write new ones to `configuration.yaml`270271## Performance Tips2722731. **Streaming**: Modern models stream responses (GPT-4o, Claude 3.5) → faster perceived performance2742. **Model Size**: Smaller models (o3-mini, Llama 3.1 70B) are faster but less capable2753. **Timeout Setting**: Increase if using complex reasoning or long documents2764. **Document Size**: Keep uploaded files < 5MB for best performance2775. **Memory Size**: Limit active memory by clearing old conversations occasionally278279## Security Notes280281- **API Keys**: Stored in HA configuration, never exposed to UI282- **File Access**: Only reads/writes under `/config` directory283- **Ingress**: All traffic through HA Ingress by default (no direct internet exposure)284- **Memory**: Local only, no cloud sync285- **Documents**: Deleted after use, not persisted286287## Support288289- **Issues**: https://github.com/Bobsilvio/ha-claude/issues290- **Discussions**: https://github.com/Bobsilvio/ha-claude/discussions291- **Repository**: https://github.com/Bobsilvio/ha-claude292293## Changelog294295See [CHANGELOG.md](https://github.com/Bobsilvio/ha-claude/blob/main/addons/claude-backend/CHANGELOG.md) for version history and updates.