Skip to main content
LocalAI docs > Add-ons > Catalogue

Services and devices

These add-ons connect a chat or a saved agent to a service or to a machine. A person adds a connection with their own account or key.

  • Gmail

    Let agents read mail, and save and send drafts with your approval.

  • Mail

    Let agents read a mailbox over IMAP and write mail over SMTP, with any provider.

  • Google Drive

    Let agents read the Drive folders you choose, and write text files if you allow it.

  • GitHub

    Let agents read repositories, issues and pull requests, and comment if you allow it.

  • Jellyfin

    Let agents search a Jellyfin library and see what is playing, and control players if you allow it.

  • Home Assistant

    At a glance Topic Detail What it adds Tools to read a smart home: find entities, read a state, look at a history. If you allow it, switch things such as a light or a thermostat, within limits you set. Needs A connection with one Home Assistant address and one long-lived access token. Ask your chats and saved agents about your smart home: find entities, read a state, look at a history, list what is unavailable. If you allow it, they can also switch things, such as a light or a thermostat. You set the limits. The add-on never operates a lock, an alarm, a garage door or a siren, whatever you choose.

  • PiKVM

    At a glance Topic Detail What it adds Tools to check a PiKVM and the machine it controls. If you allow it, press its power buttons and type on its keyboard, with a confirmation each time unless you say otherwise. Needs A connection with the device address, a user name and a password. Ask your chats and saved agents about a PiKVM (or another device that runs the kvmd API) and the machine it controls: is it on, what is the device, is the keyboard connected. If you allow it, they can also press the power buttons of that machine and type on its keyboard. A person confirms those actions unless you choose otherwise for power actions and key presses (see Not asking for some actions and Allow all), and typing and forced power actions are off until an administrator switches them on.

  • SSH

    At a glance Topic Detail What it adds Tools to run one non-interactive command on a remote machine over SSH, and to send a file to it or read a file from it. A person confirms each call by default. Needs A connection with a host, a user and a key or a password. Run commands on a remote machine from your chats and saved agents over SSH. By default a person confirms each command: the card shows the host, the user and the exact text before anything runs.

  • Kubernetes

    At a glance Topic Detail What it adds Tools to read a Kubernetes cluster, and to change it with a confirmation each time unless you say otherwise. An administrator sets a policy for each cluster. Needs A connection with a kubeconfig of one context, with its data embedded. Read and change a Kubernetes cluster from your chats and saved agents. The add-on calls the API server directly. It does not run kubectl.

Subsections of Services and devices

LocalAI docs > Add-ons > Catalogue > Services and devices

Gmail

Agents can search and read your Gmail. With your permission, they can save and send drafts, manage primary-calendar events and attendees, and create task lists and manage tasks in a selected Google Tasks list.

At a glance

TopicDetail
What it addsSearch mail, read a message or a thread, list labels and read the text of an attachment. Drafts and sends wait for your OK by default. It never deletes, trashes, labels or forwards mail.
NeedsA Google OAuth client, which an administrator saves once because LocalAI ships none. Then each person connects their own Google account.
GuideGmail in Chat apps and connections

Whatever the agent reads is sent to the chat’s model. Calendar and Tasks require the ALL connection entry, which also grants access to the whole mailbox; Gmail labels do not restrict calendar or task access.

Calendar and Tasks changes follow the connection’s write mode, including deletions. Calendar events may include a location and can be timed or all-day, including multiple days. All-day end dates are exclusive (the day after the last day). A calendar event may include attendees; the add-on requests Google attendee email notifications only when sendUpdates is explicitly all. When updating attendees, the supplied list replaces the existing list. The approval preview refuses events with more than 20 attendees or a preview too large to show. Google Tasks stores due dates without the time. None of these operations automatically schedules a Telegram reminder.

LocalAI docs > Add-ons > Catalogue > Services and devices

Mail

Agents can read a mailbox over IMAP and, if you allow it, write mail over SMTP. It works with any provider that offers both protocols.

At a glance

TopicDetail
What it addsList folders, search, read a message or a conversation, read the text of a text attachment, and send or save a plain text email. It never deletes, moves, flags or forwards mail.
NeedsA connection with the mailbox address, the username, the password (an app password if your provider offers one) and the IMAP and SMTP server names.
GuideMail in Chat apps and connections

Whatever the agent reads is sent to the chat’s model.

LocalAI docs > Add-ons > Catalogue > Services and devices

Google Drive

Agents can read the files in the Drive folders you choose.

At a glance

TopicDetail
What it addsSearch, list a folder, read the details of a file and read its text. If you allow it, create a text file, replace the text of a file, rename or move a file, and move a file to the trash. It never shares a file.
NeedsA Google OAuth client, which an administrator saves once because LocalAI ships none. Then each person connects their own Google account.
GuideGoogle Drive in Chat apps and connections
LocalAI docs > Add-ons > Catalogue > Services and devices

GitHub

Agents can read the repositories you choose: code, files, issues, pull requests and their diffs.

At a glance

TopicDetail
What it addsRead tools, and, if you allow it, comments on issues and pull requests, new issues, labels and line comments on a pull request diff. It cannot merge, delete, push code, approve or request changes.
NeedsA connection with a fine-grained personal access token and the list of repositories the agent may use.
GuideGitHub in Chat apps and connections

The add-on does not listen for @mentions on GitHub. An agent works on GitHub only when you ask it in a chat.

LocalAI docs > Add-ons > Catalogue > Services and devices

Jellyfin

Chats and saved agents can look into a Jellyfin media server.

At a glance

TopicDetail
What it addsSearch and browse libraries, read the details of an item, see what was added lately and what plays now. If you allow it, control a player, mark an item watched, set a favourite and add items to a playlist. It cannot delete anything, scan or edit the library, or manage users.
NeedsA connection with a Jellyfin API key and the server address.
GuideJellyfin in Chat apps and connections
LocalAI docs > Add-ons > Catalogue > Services and devices

Home Assistant

At a glance

TopicDetail
What it addsTools to read a smart home: find entities, read a state, look at a history. If you allow it, switch things such as a light or a thermostat, within limits you set.
NeedsA connection with one Home Assistant address and one long-lived access token.

Ask your chats and saved agents about your smart home: find entities, read a state, look at a history, list what is unavailable. If you allow it, they can also switch things, such as a light or a thermostat. You set the limits. The add-on never operates a lock, an alarm, a garage door or a siren, whatever you choose.

A chat can answer questions such as:

  • “Is the office warmer than the bedroom, and was it warmer yesterday?”
  • “Which devices are unavailable?”
  • “Turn off the lights in the living room.” (a change, see Changes)

Set it up

  1. Install the Home Assistant add-on from Find add-ons and open its page.
  2. In Home Assistant, open your profile (your name at the bottom of the sidebar), then the Security tab. Under Long-lived access tokens, choose Create token, name it (for example LocalAI) and copy it. Home Assistant shows it once. The token has the rights of the user that made it. If you can, make it with a user that sees only what you want to share.
  3. On the add-on page, choose New Home Assistant connection. Paste the token and write the address you use to open Home Assistant in a browser, for example https://homeassistant.local:8123. Press Test: the row shows the Home Assistant version if the address and the token work.
  4. Leave the write mode on Read only until you have read the limits on this page.

One connection is one home: one token and one address. For a second home, add a second connection. A chat uses the connections you enable for it in the Tools menu (see The connections of an add-on). With two or more enabled, the model names the connection in each call.

How the address is kept

LocalAI keeps the address separate from the token. Every tool takes an instance argument, and LocalAI refuses any call that names a different address, so a model can’t send the token elsewhere. The add-on talks only to that address:

  • The address is https. Plain http is accepted only for an address on your own network (a private IP address, a single-word name, or a name ending in .local, .lan, .home, .internal or .home.arpa).
  • If Home Assistant answers with a redirect, the call fails. The token is never sent to another host.
  • The token goes in the Authorization header and nowhere else. It is not in a log, an error or a result.

A self-signed certificate

The add-on checks the certificate of Home Assistant. If yours is self-signed, the Test says the certificate is not trusted. Do not turn the check off. Pin the certificate instead: copy its SHA-256 fingerprint and add it to Pinned certificates in the limits below, as host:port=fingerprint.

openssl s_client -connect homeassistant.local:8123 </dev/null 2>/dev/null \
  | openssl x509 -noout -fingerprint -sha256

The add-on then accepts that exact certificate for that exact host:port, and nothing else. When the certificate is renewed, pin the new one.

What the tools do

ToolKindWhat it does
get-configreadVersion, time zone, units, language and state of the server. No address, path or location.
list-areasreadThe areas with entity and device counts, the visible entities by domain and how many are unavailable.
search-entitiesreadEntities by words, domain, area or state, at most 50 per call, with the total.
get-statereadOne entity with its attributes.
get-historyreadThe state changes of one entity over up to 168 hours, at most 100 points, with min, max and mean for a number.
get-logbookreadThe newest 50 logbook entries of one entity over up to 168 hours.
list-servicesreadThe services the policy lets a model call, with their fields and the write tool that calls each.
call-servicewriteA quiet service: lights, switches, input booleans, media transport.
call-physical-servicewrite, always confirmedAny other allowed service: heating, blinds, scenes, scripts, notifications.

Two more tools, get-policy and set-policy, belong to the add-on page. A model never sees them.

There is no tool that renders a template, fires an event or sets a state, because each can run arbitrary logic on your server.

Everything Home Assistant returns (names, states, attributes, logbook text) was written by devices, integrations and people. Every result is marked as untrusted data, and the add-on’s skill tells the model never to follow an instruction found in one. Results are bounded: a list is cut and says so, text is cut, an attribute value is cut, and a result above the size limit is refused.

The add-on removes these from every result: entity_picture, access_token, anything with token, password or secret in its name, a value that carries a token in an address, and the location of people and devices (latitude, longitude, gps_accuracy and similar). It never returns a camera snapshot address.

Limits you set

The limits are on the add-on page, under the connections. Everyone who opens the page sees them. Only an administrator can change them. They apply to every Home Assistant connection of the server.

Services a model may call

The allowlist holds domain.service entries, or domain.* for the services of a domain. A service that is not on it is refused. The default is small:

DomainServicesClass
lightturn_on, turn_off, togglequiet
switchturn_on, turn_off, togglequiet
input_boolean* (except reload)quiet
media_playermedia_play, media_pause, media_play_pause, media_stop, media_next_track, media_previous_track, volume_up, volume_down, volume_set, volume_mutequiet
climateset_temperature, set_hvac_modeconfirmed every time
sceneturn_onconfirmed every time
scriptturn_onconfirmed every time

notify services are not on the list. Add one only if you want a model to send messages.

A script can do anything you wrote into it, and a switch can power a heater. Allow only what you would let a guest in your house do.

Never available

These cannot be allowed. The add-on refuses them when you save the limits, and again when a call is made, so a hand-edited file does not change it:

RefusedWhy
lock.*, alarm_control_panel.*They open doors and disarm alarms. A mistaken or injected request must not do that.
siren.*, valve.*, water_heater.*A noise, a flood or a burn.
camera.*It writes files and records.
cover.* on a garage door, a gate or a doorA cover that reports any other device class can be moved once you allow cover services. A cover with no device class is treated as a garage door and is never moved.
homeassistant.*It restarts or stops the server, reloads the configuration, and its turn_on and turn_off act on any entity, which would skip the domain checks.
Any reload or reload_* service, restart, stop, check_config, set_location, install, create, delete, removeThey change the configuration or the system.
hassio.*, shell_command.*, python_script.*, command_line.*, rest_command.*, mqtt.*They run programs or reach outside the home.
recorder.*, logger.*, system_log.*, backup.*, update.*They erase history, change logging, restore a backup or install an update.

You can still let a chat read what a lock reports (see below). Reading is never operating.

Entities the tools never show or touch

Excluded entities are left out of every search, state, history, logbook and area count, and no service call can name them. You can exclude by:

  • Domain. Default: lock, alarm_control_panel and camera. Remove one to let a chat read it. A lock you read is still never operated.
  • Area. The entities of the areas you list. If Home Assistant cannot answer which entities an area holds, the tools refuse instead of guessing.
  • Pattern. A regular expression matched against the whole entity ID, such as sensor\..*_bedroom.
  • Label. Entities that carry the Home Assistant label you name (default sensitive). An older Home Assistant that does not know labels cannot check it. The result then says that the label exclusion was not applied.

How many things one call switches

A call names its entities one by one. The default is 5, the highest you can set is 20. Area, device, label and all targets are not accepted: the model has to name each entity, so you see each one in the confirmation.

Changes and confirmation

A connection has a write mode, which the host enforces before the add-on is called:

ModeWhat happens
Read only (default)Both write tools are refused.
Asks you firstEach change is stored as a proposal. You see what will be switched, with each entity’s name and current state, and you confirm or cancel it.
Acts without askingA chat of yours makes a quiet change at once. Runs without you present still wait for your confirmation.

call-physical-service is always confirmed, even in the last mode. A proposal for it expires after 15 minutes, a quiet one after two hours. Changing the limits after a preview makes an old proposal stale: it is rejected and nothing is sent.

Home Assistant has no idempotency key. The add-on records an operation before it sends it and never sends one twice. If the connection breaks after the call left, the result is “unknown”, and you decide what to do.

Limits

  • Only an administrator can change the limits. Other users can read them.
  • The limits are kept in policy.json in the data folder of the add-on. If that file can’t be read, or it names a service that is never available, the tools stop working until an administrator saves the limits again. They don’t fall back to something wider.
  • The add-on runs one process for the server, so every frontend of a cluster reads the same limits.
  • It runs on Linux and macOS, like the other tool add-ons.
  • The add-on is tested against a simulated Home Assistant. Area and label questions use a fixed template call. If an area question fails on your instance, list-areas says so and the area exclusion refuses to guess.
LocalAI docs > Add-ons > Catalogue > Services and devices

PiKVM

At a glance

TopicDetail
What it addsTools to check a PiKVM and the machine it controls. If you allow it, press its power buttons and type on its keyboard, with a confirmation each time unless you say otherwise.
NeedsA connection with the device address, a user name and a password.

Ask your chats and saved agents about a PiKVM (or another device that runs the kvmd API) and the machine it controls: is it on, what is the device, is the keyboard connected. If you allow it, they can also press the power buttons of that machine and type on its keyboard. A person confirms those actions unless you choose otherwise for power actions and key presses (see Not asking for some actions and Allow all), and typing and forced power actions are off until an administrator switches them on.

A chat can answer questions such as:

  • “Is the test box on?”
  • “Power the test box on.” (a power action, see Power actions)
  • “Press Escape and F2 to enter the BIOS.” (keys, see Typing and keys)

Set it up

  1. Install the PiKVM add-on from Find add-ons and open its page.
  2. On the PiKVM, add a user for LocalAI: switch the filesystem to read-write with rw, run kvmd-htpasswd add localai, then ro. See the PiKVM authentication guide. A PiKVM has no per-user rights: every user can do everything. A dedicated user does not limit what the add-on can do, but you can remove it on its own. The limits of the add-on (below) are the only ones.
  3. Get the fingerprint of the certificate of the PiKVM (see The certificate).
  4. On the add-on page, choose New PiKVM connection. Type the user name, the password and the address, for example https://pikvm.local#sha256=<fingerprint>. Press Test: the row shows the model and the kvmd version if the address and the login work.
  5. Leave the write mode on Read only until you have read the limits on this page.

One connection is one device. For a second device, add a second connection. A chat uses the connections you enable for it in the Tools menu (see The connections of an add-on). With two or more enabled, the model names the connection in each call.

The user and the password

The connection keeps one sealed credential. In this version it holds user:password: the host splits it at the first colon, so the user name has no colon and the password may have colons. The page has a field for each and joins them. This is a v1 format: when the host gets a credential kind with named fields (a user and a password), the add-on will move to it, and you will enter the pair again.

The add-on sends the user and the password in the X-KVMD-User and X-KVMD-Passwd headers, as the PiKVM API allows, and nowhere else. They are not in a log, an error or a result. The page trims nothing for you: a password with a space at its start or end is refused.

Two-factor login (2FA) is not supported in this version. With 2FA on, the PiKVM wants the current one-time code added to the password, and the code changes every 30 seconds. A device with 2FA on answers 403 and the Test says the login was refused. 2FA is one switch for the whole PiKVM (kvmd-totp), so the device cannot have it on for the browser and off for LocalAI.

How the address is kept

LocalAI keeps the address separate from the password. Every tool takes a device argument, and LocalAI refuses any call that names a different address, so a model can’t send the password elsewhere. The add-on talks only to that address:

  • The address is https. Plain http is accepted only for an address on your own network (a private IP address, a single-word name, or a name ending in .local, .lan, .home, .internal or .home.arpa), because the login travels in headers.
  • If the device answers with a redirect, the call fails. The password is never sent to another host.
  • The add-on does not use a proxy of the environment.

The certificate

A PiKVM comes with a self-signed certificate. The add-on never turns verification off. Pin the certificate instead: copy its SHA-256 fingerprint and add it to the address as #sha256= and the 64 hex digits (colons are fine).

openssl s_client -connect pikvm.local:443 </dev/null 2>/dev/null \
  | openssl x509 -noout -fingerprint -sha256

The add-on then accepts that exact certificate for that exact address, and nothing else; a different certificate is refused before the password is sent. When you renew the certificate, edit the connection and pin the new one. Without a pin, a self-signed certificate is refused and the Test says the certificate is not trusted.

What the tools do

ToolKindWhat it does
get-inforeadModel, board, platform, kvmd and streamer versions, kernel and CPU temperature. No serial number, host name or network details.
get-power-statereadWhether ATX control is enabled and busy, the power LED (on or off) and whether the disk LED shows activity.
get-keyboard-statereadWhether the keyboard of the device is connected to the target, and the Caps, Num and Scroll Lock LEDs.
power-actionwrite, confirmed (you can choose Don’t ask)Press a power button: on, off or reset. The forced actions off_hard, reset_hard and long_press need a switch.
type-textwrite, confirmed (Allow all skips the card), needs the typing switchType text on the target.
send-keywrite, confirmed (you can choose Don’t ask), needs the typing switchPress keys from a short allowlist.

Two more tools, get-settings and set-settings, belong to the add-on page. A model never sees them.

Everything the device returns is marked as untrusted data, and the add-on’s skill tells the model never to follow an instruction found in a result. Results are bounded.

Changes and confirmation

All three write tools declare approval: always in the manifest. By default a person confirms every call: the mode Read only refuses them all, and Asks you first stores each as a proposal that waits for a confirmation card. For power-action and send-key you can stop being asked one by one, as described next, and Allow all stops it for all three tools (see Allow all). A proposal expires after 10 minutes (power) or 5 minutes (typing and keys).

Not asking for some actions

On the add-on page, the section Ask before acting has one choice for Power actions and one for Key presses: Ask each time (the default) or Don’t ask. There is no choice for typed text, because it can enter a password or a command; it waits for you unless the connection is on Allow all.

  • The choice is yours alone. It is saved from your own browser session, it applies to all your PiKVM connections, and no chat, agent or model can change it.
  • With Don’t ask, a chat can switch the machine off or reset it at once, with no card, and unsaved work on it is lost. If an administrator allowed the hard power actions, those run without asking too. Read the warning on the page before you choose it.
  • It holds only for your own chats and for messaging senders you paired with the bot. Senders that are only on the allowlist, senders let in because the bot accepts anyone, roles, scheduled runs and sub-agents are still asked.
  • A connection set to Read only runs nothing, whatever you choose. A connection set to Allow all runs these two tools without asking whatever you choose here.
  • Every run without asking is written to the server log and to the latest decisions of the connection, with the tool, the connection and the result. The typed text and the keys are not written.
  • The row of each connection lists which tools run without asking now.

Allow all

The write mode of a connection has a third choice, Allow all, for someone who wants the agent to act without asking. It is never the default and is never chosen for you: a new connection starts on Read only, and a connection keeps the mode it has.

With Allow all, a chat of yours runs power-action, send-key and type-text at once, with no card. Unsaved work on the machine is lost when it is switched off or reset, and typed text and key presses go to whatever has the focus, so a shell command or a password can be entered and none of it can be taken back. The page warns about it. If you want a confirmation, choose Asks you first. The per-tool choices of Ask before acting are not asked in this mode, and the row of the connection lists both tools that have a choice as running without asking.

These rules hold in every write mode, Allow all included:

  • The switches of an administrator for each device stay in force. Typing and key presses need Allow typing and key presses, the forced power actions (off_hard, reset_hard, long_press) need Allow hard power actions, and the add-on refuses a call when the switch is off. Allow all does not turn a switch on.
  • The same limits on text and keys, the stale-state check and the rule that nothing is sent twice.
  • A run without you present, such as an agent started by a trigger, still leaves a proposal that waits for a person.

The add-on notes an operation before it sends it and never sends one twice. The PiKVM API has no idempotency key. If the connection breaks after the request left, the result is “unknown”, and you decide what to do. Read the power state to see what happened.

Power actions

power-action takes one of these:

CommandWhat it sendsNeeds the hard switch
onPOST /api/atx/power?action=on (a short press of the power button)no
offPOST /api/atx/power?action=off (a short press: a soft power off)no
resetPOST /api/atx/click?button=reset (the reset button)no
off_hardPOST /api/atx/power?action=off_hard (hold the button 5 seconds or more)yes
reset_hardPOST /api/atx/power?action=reset_hard (hardware reset)yes
long_pressPOST /api/atx/click?button=power_longyes

The confirmation card shows the power state that was read just before, and what the action does. The preview reads the state again when you confirm. If the state changed, the action is rejected as stale and nothing is sent. An action that makes no sense is refused at once: on for a machine that is on, off for one that is off, a reset for one that is off. A busy device or one with ATX control turned off is refused.

Typing and keys

type-text and send-key are off until an administrator switches on Allow typing and key presses for the device on the add-on page. Both use that one switch.

  • type-text types text through the HID print endpoint. The text is at most 200 characters by default; an administrator can set up to 1000 for a device. It has no control characters except newline and tab. The card shows the exact text, the number of characters and lines. The text is never written to a log or an error, and the result of the call does not repeat it. As defence in depth, the add-on refuses text that looks like a private key (a -----BEGIN header), a long unbroken blob of base64-like characters (80 or more), a well-known token shape (cloud access keys, source host tokens, SSH public keys) or an exported list of passwords (three or more lines such as password: ...). This is a heuristic and not a guarantee: the skill also tells the model never to type a secret the person did not dictate.
  • send-key presses up to 8 keys or chords, in order. Allowed: the letters a to z, the digits 0 to 9, up, down, left, right, enter, escape, tab, f1 to f12, and the chords ctrl+alt+delete, ctrl+c and ctrl+z. Windows and Meta chords, modifiers alone and every other key are refused. Single keys use POST /api/hid/events/send_key, chords use POST /api/hid/events/send_shortcut.

Both refuse when the keyboard of the device is not connected to the target.

Limits you set

The switches are on the add-on page, under the connections. Everyone who opens the page sees them. Only an administrator can change them. They are kept for each device address, so a switch for one PiKVM does not open another:

SwitchDefault
Allow typing and key pressesoff
Longest typed text200 characters (1 to 1000)
Allow hard power actionsoff

Only an administrator can change the switches. Other users can read them. A settings file that can’t be read leaves every switch off. They are kept in settings.json in the add-on’s data folder; the add-on runs one process for the server.

What is not supported

  • Screenshots and screen reading. The streamer snapshot is left out of this version. The screen of the target can show secrets, and a snapshot needs a way to hand an image back that this add-on does not have yet. Without it, ask the person what the screen shows.
  • Mass storage. No mounting or uploading of disk images.
  • GPIO, mouse, the HID reset, and the ATX click beyond what power-action covers.
  • Changes to the users or the configuration of the device.
  • Two-factor login. See above.
  • Windows and Meta key chords.
LocalAI docs > Add-ons > Catalogue > Services and devices

SSH

At a glance

TopicDetail
What it addsTools to run one non-interactive command on a remote machine over SSH, and to send a file to it or read a file from it. A person confirms each call by default.
NeedsA connection with a host, a user and a key or a password.

Run commands on a remote machine from your chats and saved agents over SSH. By default a person confirms each command: the card shows the host, the user and the exact text before anything runs.

A chat can answer questions such as:

  • “How full is the disk on the build server?”
  • “Show the last 50 lines of the service log.”
  • “Restart the worker.” (a change: it waits for your confirmation)

The add-on runs one non-interactive command per call. It has no terminal, no input and no environment variables chosen by the model. It has no interactive shell, no port forwarding, no agent forwarding and no jump hosts. Files move only through upload and download, one regular file at a time.

Set it up

  1. Install the SSH add-on from Find add-ons and open its page.
  2. On the machine, make a user just for LocalAI, with only the rights the task needs. A command can change or delete anything that user may touch.
  3. Make a key pair for that user and add the public key to its authorized_keys, or choose a password. A key with a passphrase is not supported.
  4. On the add-on page, choose New SSH connection. Type the host (with the port if it is not 22), the user name and the key or the password.
  5. Press Save. When no host key is trusted yet, the page reads the key the machine presents and asks whether to trust this host, with its fingerprint. Compare it with the one on the machine (ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub), then choose Trust and save. You can also press Check host key first to look at the fingerprint, and tick that you trust it. If the host cannot be reached, the page says so and offers Retry; nothing is saved until you trust the key.
  6. Press Test: the row shows the user and the system name if the login works.

One connection is one host. For a second machine, add a second connection. A chat uses the connections you enable for it in the Tools menu (see The connections of an add-on). With two or more enabled, the model names the connection in each call.

The secret

The connection keeps one sealed secret. It is either a private key in PEM or OpenSSH format, or user:password. For a password the host splits it at the first colon, so the user name has no colon and the password may have colons.

For a key, the user name is the one in the address of the connection. The page asks for the secret again when you change the user or the host, because the saved one belongs to the old ones.

The secret is never in a result, an error, a log or a preview. The add-on also removes it from command output, in whole and in pieces. It refuses a command that holds the secret, so a model cannot ask the machine to echo it or write it to a file.

How the address is kept

The connection lists one allowed address: user@host:port#sha256=<host key fingerprint>. Every tool takes a host argument. LocalAI compares it with the address on the connection before the add-on is called and refuses any other, so a model cannot send the secret to another machine. The add-on dials only that address.

The host key

The add-on trusts a host key on first use, and you approve it when you save the connection. The page reads the key without sending any secret, shows the fingerprint, and the connection stores it as a pin (the SHA-256 of the key, as ssh-keygen -l shows it).

  • The key is checked during the key exchange, before any password or key signature is sent. A machine that presents another key never sees the secret.
  • If the key changes, every call is refused with a message that names both fingerprints. A changed key can mean the machine was reinstalled, or that someone is intercepting the connection.
  • There is no tool or setting that accepts a new key for the model. Only you can trust a new key, by editing the connection on the page and checking the host key again.
  • A connection without a pin never connects.

The mode

Each connection has a mode, set on the page by you and never by a model:

ModeWhat happens to run, upload and download
OffThe write tools are refused. The connection only checks the login. A connection made through the API with no mode starts here.
Asks you firstEach call waits in your approvals. For a command the card shows the host, the user, the exact command, the time limit and the host key. For a file it shows the host, the remote path and the size, never the content. A new connection made on the page starts here.
Runs at onceThe call runs as soon as the chat makes it, with no card.

Choose Runs at once only for a host and a user where a wrong command does no harm. In that mode the model is told to say plainly which command ran. The mode is the host’s write mode of the connection (see Confirming a held write in the chat): the tool declares no approval of its own, so the connection decides. In a messaging chat, the usual rules for who may confirm apply.

Tools

ToolKindWhat it does
get-inforeadLogs in with the pinned key and returns the host key fingerprint, uname -a and the user name.
runwriteRuns one command. Arguments: command (at most 4000 characters) and timeoutSeconds (default 30, at most 45).
uploadwriteSends one file of your files to the remote machine. Arguments: source (a path among your files), path (the remote destination), fileMode (octal, default 0644) and overwrite (default false).
downloadwriteReads one regular file from the remote machine and publishes it as a chat file. Argument: path.

run returns the exit code, standard output and standard error. Each stream is cut at 32 KiB, and a flag (stdoutTruncated, stderrTruncated) says when it was cut. A command that does not finish within the time limit gets its connection closed; the result says timedOut and holds the output so far, and the command may still run on the machine.

The limit is 45 seconds because LocalAI stops a write call after 60 seconds, and the login uses part of that.

Files

upload and download use the same connection, login and write mode as run, and they send no command that a model wrote. Each runs one fixed script on the machine with the paths as quoted arguments. Both refuse a path that is empty, longer than 1024 bytes, holds a control character or a .. segment, ends in / or starts with ~. A relative remote path is relative to the login directory. The credential is never in a path, and a file that holds it is not published.

  • upload reads its source from your files through the host (the add-on asks for the workspace.export operation, which it declares as optional). The source can also be a file that a tool published to the same chat, such as the result of download, so a file can be copied from one machine to another. A file of another chat is refused. The bytes are written to a temporary file in the destination directory, checked for size and, when the machine has sha256sum, for the SHA-256, given the mode, and moved into place. A failed or cut transfer leaves no partial file. Without overwrite, an existing path is refused. The result has the size, the SHA-256 and what was verified. The card shows the host, the remote path, the size and the SHA-256, not the content. The preview reads the file from your files to measure it, and the call is refused if the file changed after you saw the card.
  • download publishes the file as a chat file with its bytes unchanged, under a name made from the remote file name. The result has the name, the size and the SHA-256. Directories, devices, sockets, pipes and files over 16 MiB are refused with a clear message; a file is never cut. A remote file can hold secrets, so the call follows the write mode. In Asks you first the preview asks the machine for the size, with one read-only command that reads no content.

The size limit is 16 MiB in both directions, and both stop after 40 seconds of transfer.

The page also uses a third tool, scan-host-key, to read the host key for you. No model calls it.

Limits and safety

  • One command at a time per connection. A second call is refused while one runs.
  • No double runs. The add-on records a command before it sends it. If the same call repeats, LocalAI returns the recorded answer and doesn’t run it again. If the connection drops after the command started, the result is “unknown” and the add-on doesn’t send it again.
  • Output is data. Results are marked untrusted, and the skill tells the model never to follow instructions in them.
  • Errors are specific. Each of these gives its own message: the host can’t be reached, the login was refused, the host key changed, no host key is pinned, and the host wouldn’t run a command.
  • The add-on reaches any address a connection lists, including addresses on your own network and on the LocalAI machine itself. The secret of the connection is the only limit on what a command can do there.
LocalAI docs > Add-ons > Catalogue > Services and devices

Kubernetes

At a glance

TopicDetail
What it addsTools to read a Kubernetes cluster, and to change it with a confirmation each time unless you say otherwise. An administrator sets a policy for each cluster.
NeedsA connection with a kubeconfig of one context, with its data embedded.

Read and change a Kubernetes cluster from your chats and saved agents. The add-on calls the API server directly. It does not run kubectl.

A chat can answer questions such as:

  • “Why does the web pod in team-a restart?”
  • “Show the last 100 lines of the api logs.”
  • “Scale web to 3 replicas.” (a change: it waits for your confirmation)
  • “Drain node-1 for maintenance.” (a change: it waits for your confirmation)

Set it up

  1. Install the Kubernetes add-on from Find add-ons and open its page.

  2. In the cluster, make a service account for LocalAI with only the rights the task needs. The RBAC of the credential is the outer limit of everything the add-on can do.

  3. Make a kubeconfig with one context and the data embedded:

    kubectl config view --minify --flatten --context=<name>

    For a service account, make a token and use the form with the server, the CA and the token instead:

    kubectl -n <namespace> create token <service-account> --duration=720h
  4. On the add-on page, choose a new connection. Paste the kubeconfig and pick the context, or type the server URL, paste the CA and the token.

  5. Press Save. The page runs the check: it shows the server version and the RBAC rules of the credential in the default namespace, or in the first namespace the policy allows when default is not allowed.

One connection is one cluster and one context. The connection lists the cluster as https://<host>:<port>#context=<name>. The host is written in lower case, and the port is left out when it is 443. A chat uses the connections you enable for it in the Tools menu. With two or more enabled, the model names the cluster in each call.

What the kubeconfig may hold

The kubeconfig is the sealed secret of the connection, at most 16 KiB. The add-on uses only the context of the connection. It refuses a kubeconfig that:

  • runs a credential plugin (exec or auth-provider), such as the login helpers of cloud providers;
  • names a local file (certificate-authority, client-certificate, client-key, tokenFile). Embed the data with the -data fields;
  • turns off certificate checks (insecure-skip-tls-verify: true) or uses a proxy (proxy-url);
  • uses a user name and a password;
  • names a server by a loopback, link-local, unspecified or multicast IP address, such as 127.0.0.1, ::1 or 169.254.169.254, or by a cloud metadata address outside those ranges (fd00:ec2::254, 100.100.100.200), also when it is written inside a NAT64 address (64:ff9b::7f00:1). The credential would go to a service of the LocalAI host or of its network. There is no setting to allow these addresses.

A host name can resolve to such an address too: localhost, a DNS record that points at 127.0.0.1 or at a metadata address, or a form that only the system resolver reads as an address, such as 2130706433. So the add-on also checks the address of every connection after the name is resolved, and refuses the same addresses. It connects directly: it does not use HTTP_PROXY, HTTPS_PROXY or another proxy setting of the LocalAI host. The WebSocket connection of exec cannot use that check, so the add-on resolves the name and checks its addresses just before exec connects; a name whose DNS answer changes in that short time can still pass, and the SPDY fallback of exec is checked when it connects.

For a local cluster made by kind, do not use the kubeconfig that names 127.0.0.1 or localhost. When LocalAI runs in a container on the kind Docker network, use kind get kubeconfig --internal, which names the server by its container (https://<cluster>-control-plane:6443). Otherwise, set networking.apiServerAddress in the kind configuration to an address of the host that is not loopback, such as its LAN address, and use the kubeconfig that kind writes. The certificate of the API server covers that address.

The add-on never reads a file on the LocalAI host because a kubeconfig names it. The kubeconfig is never in a result, an error, a log or a preview.

What the tools do

ToolKindWhat it does
listreadA table of one kind: name, namespace, status, age and columns of the kind. At most 500 rows.
getreadOne object as YAML, without managed fields.
describereadA summary of one object, the related objects and the newest events.
logsreadThe newest lines of a container, cut at 32 KiB.
eventsreadEvents, newest first, for a namespace or one object.
topreadCPU and memory use of nodes or pods. Needs metrics-server.
api-resourcesreadThe kinds the cluster serves, including custom resources.
checkreadThe server version and the RBAC rules of the credential in a namespace.
scalewriteSet the replicas of a Deployment, StatefulSet or ReplicaSet.
rollout-restartwriteRestart the pods of a Deployment, StatefulSet or DaemonSet.
rollout-undowriteRoll a Deployment back to the previous revision or a named one.
delete-podwriteDelete one pod.
cordon, uncordonwriteMark a node unschedulable or schedulable.
drainwriteCordon a node and evict its pods through the Eviction API, so PodDisruptionBudgets hold.
applywriteServer-side apply of one namespaced object, with field manager localai-kubernetes.
patchwriteA strategic merge, merge or JSON patch of one namespaced object.
execwriteRun one command in a container, with no terminal and no input. Off by default.

Everything the cluster returns is data, and every result says so. A model must not follow instructions it finds in a log, a label or an event.

Changes and confirmation

Every write tool declares approval: always. By default a person confirms every call: the card shows what will change. For apply and patch the card shows a diff of the live object against the result of a server-side dry run (dryRun=All). The API server runs its defaults, validation and admission for the dry run, so the diff is what the write will really do.

When you confirm, the add-on checks the call again. If the object or the policy changed after the card was made, nothing is written and the result says the preview is stale.

Not asking for some tools

On the add-on page, the section for approvals has one choice for each write tool: ask each time (the default) or always run. The choice is your own user setting. No chat, agent or model can change it.

  • It holds only for your own chats. Triggers, jobs, sub-agents and messaging senders that are not paired with you are still asked.
  • A call that runs without a card goes through the same checks and the same policy. For apply and patch the result still carries the diff.
  • The write mode Allow all of a connection lifts the confirmation of every write tool for your own chats.

The policy

An administrator sets a policy for each cluster on the add-on page. The add-on checks it on every call, confirmed or not. Skipping a confirmation never widens what a call can touch.

RuleBuilt-in defaultWhat it does
namespaces*The namespaces the tools may read and change. A namespaced call outside the list is refused. A list across all namespaces returns only the allowed ones, whatever the selectors say. check also stays inside the list.
writeToolsnoneThe write tools that work. A disabled tool is still offered to the model and answers that the policy disabled it.
readSecretValuesonWhen on, the tools show Secret values to the model. When off, they hide them. See Secret values for what hiding covers and what it does not.

The policy of a cluster is keyed by its server URL, written one way: the host in lower case without trailing dots, an IP address in its canonical form (2001:0db8::0001 is 2001:db8::1, and ::ffff:10.0.0.1 is 10.0.0.1), the port read as a number and left out when it is 443 (:0443 is left out too), and no trailing slash. A server URL with a query or a fragment, even an empty one (a bare ? or #), is refused. A host name in Unicode is not converted to its punycode form (xn--): the two forms of one name are two keys, so write the server the same way in every kubeconfig. Every context and every connection of one server share one policy, so renaming a context in the kubeconfig, or writing :443, does not change which policy applies.

The add-on does not resolve names to match policies. Another name for the same API server, such as a second DNS name or its IP address instead of its name, is another key, and it gets the default policy. So set a strict default policy (few namespaces, no write, Secret values hidden) and give each cluster its own policy, rather than a broad default.

A cluster with no policy of its own uses the default policy. Out of the box the default allows reads in every namespace, Secret values included, and no write: the page shows such a cluster as “Not configured: writes are off” until an administrator saves a policy for it. An administrator can also change the default policy itself: choose Default for clusters with no policy in the cluster list.

Cluster-scoped objects are always readable. The only cluster-scoped writes are cordon, uncordon and drain of a node. apply and patch of a cluster-scoped kind (a Namespace, a ClusterRole, a CustomResourceDefinition) are refused.

A refusal names its rule, for example refused by the connection policy (namespaces).

The policy is kept in policy.json in the data folder of the add-on. If that file cannot be read, every cluster gets no namespace, no write, and Secret values hidden, until an administrator saves a policy again. The damaged file may have held any policy, so this is the only policy that is never broader than one an administrator set. Cluster-scoped objects, such as nodes, stay readable, as under every policy. The page keeps working, so an administrator can repair the file there.

The next save keeps the damaged file aside as policy.json.damaged-<time> and starts a new file. That new file stores the same no-namespace policy as its default policy, and holds only the policy that was saved. Every other cluster keeps the no-namespace policy until an administrator enters its policy again; the old policies are in the file kept aside. A save that names only some rules takes the others from the no-namespace policy, so it must name the namespaces.

Policies saved by an earlier build were keyed by server and context, or by a server written another way. They move to the key of their server by themselves; an entry already under that key wins. When two entries of one server had different policies, neither applies: the page lists them, the server gets the no-namespace policy (no namespace, no write, Secret values hidden) rather than the default policy, which may be broader than both, and saving a policy for that server removes them. The page shows such a server, and every cluster under a no-namespace default policy, as “No namespace: reads and writes are off”. An entry whose key is not a server the add-on accepts (for example a loopback address) never applies. The page lists it on its own, and the next save removes it.

With several frontends, the add-on runs on the add-on owner, and every frontend sends its tool calls there. So there is one policy file, on the instance that runs the add-on owner.

Secret values

The model sees Secret values unless an administrator turns readSecretValues off, for one cluster or in the default policy. A value the model reads goes to the model and stays in the chat history.

With readSecretValues off, “hidden” means that the read tools (get, describe, list) and the diffs and results of the write tools do not show a value:

  • A Secret shows its keys, its type and the length of each value, never the value. Its last-applied-configuration annotation is removed, and its other annotations show only their length, except kubernetes.io/service-account.name and kubernetes.io/service-account.uid.
  • An environment variable whose name holds TOKEN, PASSWORD, SECRET or KEY (in any case) shows *** instead of an inline value. This covers every container list (containers, initContainers, ephemeralContainers) at any depth of any object: pods, the pod templates of Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs and the jobTemplate of CronJobs, and custom resources that use the same field names. A secretKeyRef stays visible: it names a Secret and a key, and holds no value.
  • The diff of apply or patch marks a Secret key, a Secret annotation or a hidden environment value that the write changes as (new value), without the value.
  • A json patch of any kind may not use copy, move or test, and may not name an env list or a place under one. On a Secret it may also not name data, stringData or the whole object. Those operations could copy a value to a place that is shown, rename an environment variable so that its value shows, or answer yes or no about a value. Use a merge or strategic patch.
  • apply may not set a Secret key under data or stringData that the live Secret already has, a Secret annotation that the live Secret already has and that is masked, the kubectl.kubernetes.io/last-applied-configuration annotation of a Secret, or the inline value of an environment variable with a secret-looking name that the live object already has (matched by container list, container name and variable name). The add-on applies without force, so when another field manager owns the value, a wrong value comes back as a conflict and the right one does not. Leave those values out of the manifest, change them with a merge or strategic patch that replaces the whole value, or ask an administrator. A new Secret, and new keys and annotations of an existing one, can still be applied.
  • While values are hidden, an apply to an object that exists carries the resourceVersion the add-on read for that check, unless the manifest names one. So if another writer changes the object between the check and the write, the apply fails with a 409 conflict whatever the manifest holds; apply again.
  • An API error about a Secret keeps only its status code and reason, because the API server can quote a value in the message.

“Hidden” does not cover:

  • the args and command of a container, environment values whose name does not look secret, and other fields of custom resources;
  • what a workload shows. A pod that a chat creates with apply can mount a Secret or print it, and its logs then show the value. exec output is not filtered: a command can print a Secret that the container holds;
  • what the cluster itself puts in events or in the status of an object;
  • the diff of a merge or strategic patch that sets a hidden value. It says “no change” when the new value equals the live one and (new value) when it differs, so a chat that may patch can test a guess of a value, one guess per preview. Leave patch off for a cluster where that matters: with patch off and the apply checks above, the write tools give no way to test a guess.

To keep a chat from reading Secret values through a workload as well, turn readSecretValues off and leave apply, patch and exec off for that cluster, or limit the RBAC of the credential. Out of the box every write tool is off.

Errors

API errors keep their status, reason and message, so the model can act on them. The message, and the reason a drain could not evict a pod, are quoted and marked as data, not instructions, because an admission webhook can write any text there. An error about a Secret keeps only its status and reason while the policy hides Secret values. A 403 says the RBAC of the credential does not allow the call; a 401 says the cluster refused the credential. scale tries once more after a 409 conflict: it writes with the resourceVersion it read, so another writer that came first makes it fail instead of being overwritten. Nothing else is retried. A server-side apply does not force ownership: a conflict with another field manager comes back as an error.

Limits

  • The kubeconfig is at most 16 KiB, with one context and embedded data. No credential plugins and no file references.
  • One drain call ends within 50 seconds, checks included, because LocalAI stops a write after 60 seconds. It evicts at most 50 pods, starts no eviction in the last 5 seconds, and waits for the evicted pods to go at most timeoutSeconds (at most 45). The result lists pending pods (evicted, not gone yet) and remaining pods (not evicted yet); a second call continues, and the node is already cordoned. An error after the cordon ends the call with a partial result and an error field, not with an error that says nothing changed. A 429 from API Priority and Fairness is reported as throttling, not as a PodDisruptionBudget; after one, the drain waits the Retry-After of the server (1 to 2 seconds) before the next eviction, and stops evicting when that wait would not fit in the 50 seconds.
  • exec runs for at most 45 seconds and its output is not filtered. One exec runs per pod at a time.
  • No cluster-scoped apply or patch, no port forwarding, no interactive exec or attach, no file copy, no Helm and no watches.
  • top needs the metrics.k8s.io API (metrics-server).
  • A read ends within 28 seconds, because LocalAI stops a read after 30. A list across many allowed namespaces reads them one by one; when the time runs out it returns what it read with partial: true and the namespaces in notRead.
  • describe of a Deployment reads at most 100 of its replica sets, by the labels of its selector, and at most 20 of its pods.