Multimodal Configuration π‘ BETA
General Bots integrates with botmodelsβa Python service for multimodal AI tasksβto enable image generation, video creation, audio synthesis, and vision capabilities directly from BASIC scripts.
Architecture
βββββββββββββββ HTTPS βββββββββββββββ
β botserver β βββββββββββββΆ β botmodels β
β (Rust) β β (Python) β
βββββββββββββββ βββββββββββββββ
β β
β BASIC Keywords β AI Models
β - IMAGE β - Stable Diffusion
β - VIDEO β - Zeroscope
β - AUDIO β - TTS (OpenAI/Google) / STT (Groq/OpenAI API)
β - SEE β - BLIP2
When a BASIC script calls a multimodal keyword, botserver forwards the request to botmodels, which runs the appropriate AI model and returns the generated content.
Configuration
Add these settings to your botβs config.csv file to enable multimodal capabilities.
BotModels Service
| Key | Default | Description |
|---|---|---|
botmodels-enabled | false | Enable botmodels integration |
botmodels-host | 0.0.0.0 | Host address for botmodels service |
botmodels-port | 8085 | Port for botmodels service |
botmodels-api-key | β | API key for authentication |
botmodels-https | false | Use HTTPS for connection |
Image Generation
| Key | Default | Description |
|---|---|---|
image-generator-model | β | Path to image generation model |
image-generator-steps | 4 | Inference steps (more = higher quality, slower) |
image-generator-width | 512 | Output image width in pixels |
image-generator-height | 512 | Output image height in pixels |
image-generator-gpu-layers | 20 | Layers to offload to GPU |
image-generator-batch-size | 1 | Batch size for generation |
Video Generation
| Key | Default | Description |
|---|---|---|
video-generator-model | β | Path to video generation model |
video-generator-frames | 24 | Number of frames to generate |
video-generator-fps | 8 | Output frames per second |
video-generator-width | 320 | Output video width in pixels |
video-generator-height | 576 | Output video height in pixels |
video-generator-gpu-layers | 15 | Layers to offload to GPU |
video-generator-batch-size | 1 | Batch size for generation |
Example Configuration
key,value
botmodels-enabled,true
botmodels-host,0.0.0.0
botmodels-port,8085
botmodels-api-key,your-secret-key
botmodels-https,false
image-generator-model,../../../../data/diffusion/sd_turbo_f16.gguf
image-generator-steps,4
image-generator-width,512
image-generator-height,512
image-generator-gpu-layers,20
video-generator-model,../../../../data/diffusion/zeroscope_v2_576w
video-generator-frames,24
video-generator-fps,8
BASIC Keywords
Once configured, these keywords become available in your scripts.
IMAGE
Generate an image from a text prompt:
file = IMAGE "a sunset over mountains with purple clouds"
SEND FILE TO user, file
The keyword returns a path to the generated image file.
VIDEO
Generate a video from a text prompt:
file = VIDEO "a rocket launching into space"
SEND FILE TO user, file
Video generation is more resource-intensive than image generation. Expect longer processing times.
AUDIO
Generate speech audio from text:
file = AUDIO "Hello, welcome to our service!"
SEND FILE TO user, file
SEE
Analyze an image or video and get a description:
' Describe an image
caption = SEE "/path/to/image.jpg"
TALK caption
' Describe a video
description = SEE "/path/to/video.mp4"
TALK description
The SEE keyword uses vision models to understand visual content and return natural language descriptions.
Starting BotModels
Before using multimodal features, start the botmodels service:
cd botmodels
python -m uvicorn src.main:app --host 0.0.0.0 --port 8085
For production with HTTPS:
python -m uvicorn src.main:app \
--host 0.0.0.0 \
--port 8085 \
--ssl-keyfile key.pem \
--ssl-certfile cert.pem
Media Auto-Task (inbound media β classification β filing)
A photo or document sent to the Telegram channel becomes a filed item without any user instruction. The chain is:
- The channel stores the attachment in the botβs Drive (
inbox/β¦) and the conversation carries the[image] inbox/9f3c.jpgmarker (see Telegram Channel). - The agent passes that path to the
classify_mediatool shipped in themedia-filingtemplate, which is the only supported way to file inbound media. - The tool perceives the content according to the file extension:
DESCRIBE IMAGEfor pictures,SPEECH TO TEXTfor[voice]/[audio]notes,DESCRIBE VIDEOfor[video]andGETfor documents. Binary audio and video never reach the document text extractor, which cannot read them. - It asks the model for one word of a closed taxonomy
(
invoice,receipt,contract,identity,report,audio,video,unsorted) and moves the file tomedia/{year}/{month}/{category}/, writing a.meta.txtaudit trail next to it.
The taxonomy being closed is the safety property: a model answer that is not
one of those words degrades to unsorted, so a misclassification can never
create an arbitrary folder. Every keyword involved already exists
(DESCRIBE IMAGE, DESCRIBE VIDEO, SPEECH TO TEXT, GET, LLM, MOVE,
CREATE FILE, SPLIT, LAST, FIRST, STR, LEN, LCASE, INSTR,
TRIM, REPLACE, LEFT, TODAY).
When the vision service is unavailable
The flow degrades instead of failing. If DESCRIBE IMAGE (or the document
read) raises an error β BotModels not running, model missing, unsupported
format β the tool falls back to the caption already carried by the marker,
still applies the closed taxonomy, and files the item; the reply notes that the
content analysis was unavailable. With no caption either, the item is filed as
unsorted. Installing/preparing BotModels therefore upgrades classification
quality with no script change.
DESCRIBE IMAGE requires two conditions, and both must hold:
- the bot configuration has
botmodels-enabled,true(see Configuration), and - the service is actually reachable at the address the server uses, e.g.
BOTMODELS_HOST=http://<bot-host>:8082in the botserver unit.
Check reachability β a connection-refused (000) result is the usual cause of
a degraded classification:
curl -s -o /dev/null -w '%{http_code}\n' http://<botmodels-host>:<port>/api/health
Deploying the template
The template ships as bottemplates/bots/media-filing/media-filing.gbai/ and is
staged by POST /api/templates/deploy/{id} (the id returned by
GET /api/templates/list) into the org layout every runtime resolver keys
on:
{org}.gborg/{bot}.gbai/{bot}.gbdialog/ # scripts, incl. classify_media
{org}.gborg/{bot}.gbai/{bot}.gbot/ # PROMPT-TELEGRAM.md
{bot} is the name chosen in the Templates app (it defaults to the template
name). The templateβs inner .gbdialog/.gbot directories are renamed to the
bot name while staging, because the tool-execution, prompt and MCP resolvers
look those directories up by bot name β a bot whose dialog directory kept the
template name would load no scripts. The drive monitor then uploads the staged
tree to MinIO and registers the bot, the same mechanism bootstrap uses for the
shipped catalog.
Telegram also needs a bot token before the channel can be reached. Provide it at
deploy time through the telegram_token field of the deploy request, or later by
writing the telegram-bot-token configuration key for the bot. The key is
recognised as sensitive, so it is stored in Vault at
secret/gbo/{org_id}/{branch_id}/{bot_id} and never in the database β the value
comes from BotFather. This step is best-effort: if the bot row does not exist yet
(the drive monitor creates it after the upload), the deploy response reports
telegram.status = "pending" and the token can be written again afterwards.
BotModels API Endpoints
The botmodels service exposes these REST endpoints:
| Endpoint | Method | Description |
|---|---|---|
/api/image/generate | POST | Generate image from prompt |
/api/video/generate | POST | Generate video from prompt |
/api/speech/generate | POST | Generate speech from text |
/api/speech/totext | POST | Transcribe audio to text |
/api/vision/describe | POST | Describe an image |
/api/vision/describe_video | POST | Describe a video |
/api/vision/vqa | POST | Visual question answering |
/api/health | GET | Health check |
All endpoints except /api/health require the X-API-Key header for authentication.
Model Paths
Configure model paths relative to the botmodels service directory. Typical layout:
data/
βββ diffusion/
β βββ sd_turbo_f16.gguf # Stable Diffusion
β βββ zeroscope_v2_576w/ # Zeroscope video
βββ tts/
β βββ model.onnx # Text-to-speech
βββ vision/
βββ blip2/ # Vision model
GPU Acceleration
Both image and video generation benefit significantly from GPU acceleration. Configure GPU layers based on your hardware:
| GPU VRAM | Recommended GPU Layers |
|---|---|
| 4GB | 8-12 |
| 8GB | 15-20 |
| 12GB+ | 25-35 |
Lower GPU layers if you experience out-of-memory errors.
Troubleshooting
βBotModels is not enabledβ
Set botmodels-enabled=true in your config.csv.
Connection refused
Verify botmodels service is running and check host/port configuration. Test connectivity:
curl http://localhost:8085/api/health
Authentication failed
Ensure botmodels-api-key in config.csv matches the API_KEY environment variable in botmodels.
Model not found
Verify model paths are correct and models are downloaded to the expected locations.
Out of memory
Reduce gpu-layers or batch-size. Video generation is particularly memory-intensive.
Security Considerations
Use HTTPS in production. Set botmodels-https=true and configure SSL certificates on the botmodels service.
Use strong API keys. Generate cryptographically random keys for the botmodels-api-key setting.
Restrict network access. Limit botmodels service access to trusted hosts only.
Consider GPU isolation. Run botmodels on a dedicated GPU server if sharing resources with other services.
Performance Tips
Image generation runs fastest with SD Turbo models and 4-8 inference steps. More steps improve quality but increase generation time linearly.
Video generation is the most resource-intensive operation. Keep frame counts low (24-48) for reasonable response times.
Batch processing improves throughput when generating multiple items. Increase batch-size if you have sufficient GPU memory.
Caching generated content when appropriate. If multiple users request similar content, consider storing results.
See Also
- LLM Configuration - Language model settings
- Bot Parameters - All configuration options
- IMAGE Keyword - Image generation reference
- SEE Keyword - Vision capabilities