Getting Started Cameras & Video Detection & Recording Automation & Events Actions Integration & Connectivity Network & Discovery AI & Remote Control MQTT Modbus ZeroMQ System & Administration Use Cases Troubleshooting About & Legal
Home / Documentation / Gemini AI Assistant
Knowledge base

Gemini AI Assistant

The Gemini AI Assistant component integrates Google's Gemini generative AI models into the Banalytics Agent. It gives operators a chat-based interface for inspecting and controlling selected Components, Tasks, and Actions through natural language commands.

Natural language control for the running agent

Gemini component connects to the Google Generative Language API, builds a system prompt from the current Banalytics topology, keeps conversation history, and executes parsed command tags returned by the model. Users can ask about component state, open video streams, start and stop exposed components, invoke action tasks, and open configuration editors from the chat UI.

API

Gemini API

The component sends user messages and selected context to the configured Gemini model through the Generative Language REST endpoint.

CTX

Agent context

The prompt is generated from Components, Tasks, and Actions that have aiControlEnabled = true.

CMD

Action execution

Model responses can include structured action tags that the server parses and executes against the engine.

External AI boundary: user messages and the generated system prompt are sent to the Gemini API. Do not place passwords, API keys, private URLs, personal data, or other secrets in component descriptions, custom prompt instructions, or chat messages.

Adding a Gemini assistant

01

Provide a Google Gemini API key

Configure the API key and make sure the agent has outbound HTTPS access to generativelanguage.googleapis.com. Model discovery uses the same key.

02

Select the model

The model dropdown is populated from the Google model-list endpoint. Use a fast model for frequent operator chat, and a stronger model when the prompt includes many components or requires careful reasoning.

03

Define the AI-control boundary

Enable AI control only on Components, Tasks, and Actions that the assistant is allowed to inspect or operate. Keep risky infrastructure components hidden unless the use case requires them.

04

Start manually and test

The component is not autostarted by default. Start it after verifying the API key, selected model, permissions, and prompt exposure rules.

Use cases for controlled AI access

OPS

Operator assistant

Expose selected cameras, tasks, dashboards, and action tasks so operators can ask for status, open streams, start tasks, or stop components by name.

READ

Read-only helper mode

Keep risky actions and infrastructure Things with aiControlEnabled = false, and expose only diagnostic components and safe views.

FIX

Maintenance console

Expose predefined recovery actions so the assistant can invoke approved procedures instead of receiving broad access to arbitrary low-level operations.

Useful local commands

/things

List Things locally

Returns agent state without calling Gemini. Use it to verify visibility and component names.

/tasks

List Tasks locally

Shows task state without sending a model request, useful when external AI access is slow or unavailable.

/help

Show available chat commands

Displays built-in help and keeps the diagnostic path independent from the external API.

Tuning model behavior and context size

The assistant's usefulness depends on the selected model, the exposed topology, and the quality of component descriptions. Keep the prompt focused by exposing only the components that matter for the operational scenario.

Model discovery
The model list is loaded from Google's endpoint using the configured API key.
Prompt extra
Use systemPromptExtra for site vocabulary, naming conventions, safety rules, and operator preferences.
History limit
maxHistoryMessages controls how much conversation is sent back to Gemini. Higher values increase memory use and request size.
Context refresh
Call refreshContext after changing descriptions, AI-control flags, or topology while the assistant is running.
Prompt hygiene: use component descriptions to help the assistant understand human names such as "entrance camera", but avoid secrets and sensitive operational details that should not leave the agent.

Configuration parameters

ParameterRequiredDescriptionDefault
ID
YesA unique identifier automatically generated for this component instance. Read-only.Auto
Title
YesDisplay name of the AI assistant instance inside Banalytics. GeminiThing is uniqueness-keyed by title.None
Gemini API Key
YesGoogle Gemini API key. It is entered as a password field and changing it restarts the component.None
Model
YesFully qualified model name returned by the Generative Language API, for example models/gemini-.... The models/ prefix is stripped before use. Changing the model restarts the component.From API
Max conversation history messages
YesMaximum number of conversation messages retained for model context. Allowed range is 10-500. The visible chat log retains up to 3 * maxHistoryMessages entries.50
Additional system prompt instructions
OptionalAdditional custom instructions appended to the generated system prompt. Use it for local terminology, safety constraints, and operator rules.None

Methods available through Thing call

MethodRequired inputDescriptionNotes
command
commandSends a user message to the assistant. Slash commands are handled locally; other messages are sent to Gemini.Main chat entry point
history
OptionalReturns chat history. Optional fromLine returns only entries with lineNumber > fromLine.Incremental UI polling
status
NoneReturns assistant status including whether it is alive, current model, and history size.Diagnostics
clearHistory
NoneClears both model conversation history and visible chat log, then resets line numbering.Does not change runtime state
refreshContext
NoneRebuilds the system prompt from the current Things, Tasks, and Actions topology.Does not clear history

How model output becomes agent actions

The model is instructed to emit structured tags such as [ACTION:TYPE:parameters]. GeminiThing parses supported tags and executes them server-side.

START/STOP_THING
Starts or stops a Thing by UUID.
START/STOP_TASK
Starts or stops a Task by UUID.
ACTION_TASK
Invokes an IAction task in manual-run mode.
CALL_THING
Invokes a Thing API method using uuid|method|key=value,... syntax for simple parameters.
SHOW_VIDEO
Returns a UI passthrough tag that opens a media stream.
SHOW_EDITOR
Returns UI passthrough tags for component, Thing editor, or Task editor navigation.
Permission model: restrict permission to call this Thing API to trusted users. Once parsed, a model-suggested action can start or stop exposed components and invoke exposed action tasks.

Operational notes and troubleshooting

KEY

API key or model errors

If Gemini returns an error, check API key validity, quota, outbound network access, and whether the selected model is available for the key.

HIST

History and memory use

Increasing maxHistoryMessages increases conversation context, visible chat log size, memory use, and request payload size.

AUTO

Autostart carefully

The component defaults to autostart = false and STOP_ON_FAILURE. Enable autostart only after validating API access, permissions, and exposure rules.

Related automation and AI pages

Use these pages to decide what the assistant can see, which actions it may invoke, and how operators monitor the result.

Related tasks and pages