A lightweight, production-ready multimodal wrapper for Google Gemini with RAG, image input, JSON mode, project learning, session memory, and a clean CLI & server.
If you are using the free tier, you may encounter temporary errors such as:
429 RESOURCE_EXHAUSTEDQuota exceeded- Requests failing after several generations
This is expected behavior and not a bug in Multimodal Agent.
- Flutter code generation (widgets, screens, models)
- Unified agent for text, image, and chat interactions
- Clean CLI :
agent ask,agent image,agent chat,agent history,agent learn-project - Supports Gemini 2.5-flash , 1.5-flash , and any future model (configurable)
- Automatic retry logic with exponential backoff
- Full offline mode support (
FAKE_RESPONSE) when no API key is available - Detailed usage logging : prompt, response, and total token counts
- Local SQLite RAGStore (no cloud dependency)
- Automatic memory saving of past chats
- Project learning: let the agent read source code & architecture
- Project introspection commands:
learn-project,show-project,inspect-project
- User config stored at:
~/.multimodal_agent/config.yaml - Configure models individually:
chat_modelimage_modelembedding_model
- New CLI commands:
agent config set-model <model>agent config set-image-model <model>agent config set-embed-model <model>agent config set-key <API_KEY>
- pytest fixtures for offline/fake mode
- High test coverage rate
- Type-safe
AgentResponse - Extensible architecture
- Easy to embed into apps or scripts
pip install multimodal-agentOr local:
git clone https://github.com/horam/multimodal-agent.git
cd multimodal-agent
pip install -e .Multimodal Agent uses a single source of truth for model selection via
~/.multimodal_agent/config.yaml.
agent config showagent config set-key YOUR_KEYagent config set-model gemini-2.5-flashagent config set-image-model gemini-1.5-flashagent config set-embed-model text-embedding-004Your config file after updates:
local_learning: true
chat_model: gemini-2.5-flash
image_model: gemini-2.0-flash
embedding_model: text-embedding-004
api_key: YOUR_KEYchat_model: gemini-2.0-flash
image_model: gemini-2.0-flash
embedding_model: text-embedding-004Always ensure your configured models exist in:
https://ai.google.dev/gemini-api/docs/models
Multimodal Agent has three execution paths:
- Talks directly to Gemini
- May continue working even if the server is failing
- Best for debugging and verification
- Acts as a bridge for the VS Code extension
- Enforces request timeouts
- Returns HTTP errors (400 / 429 / 500)
- Depends on the HTTP server
- Will show errors like:
agent ask "What is the capital of France?"agent ask "What is the capital of France?" --no-ragagent ask "give me json" --jsonagent image test.jpg "describe this"agent chatYour memory DB lives at:
~/.multimodal_agent/memory.dbShow memory:
agent history showClear memory:
agent history clearSummarize memory:
agent history summaryLet the agent scan and store a project summary:
agent learn-project my_app/List learned projects:
agent list-projectsShow a specific project:
agent show-project project:my_appInspect project without saving:
agent inspect-project my_app/Until v1.0.0, the VS Code extension is available via manual install.
git clone https://github.com/horam/multimodal-agent.git
cd multimodal-agent/vscode-extension
npm install
npm run build
code --install-extension multimodal-agent-*.vsixfrom multimodal_agent.core.agent_core import MultiModalAgent
agent = MultiModalAgent()
resp = agent.ask("Explain quantum computing")
print(resp.text)
print(resp.usage)Image example:
from multimodal_agent.utils import load_image_as_part
img = load_image_as_part("cat.jpg")
resp = agent.ask_with_image("describe this", img)
print(resp.text)Start:
agent serverRuns at:
http://127.0.0.1:8000
curl -X POST http://127.0.0.1:8000/ask \
-H "Content-Type: application/json" \
-d '{"prompt": "hello"}'Response:
{
"text": "hello",
"data": null,
"usage": { "prompt_tokens": 44, "response_tokens": 3, "total_tokens": 553 }
}curl -X POST http://127.0.0.1:8000/ask_with_image \
-F "file=@test.jpg" \
-F "prompt=describe this"Failures now return:
{
"text": "Image processing failed: 429 RESOURCE_EXHAUSTED ...",
"data": null,
"usage": {},
"error": true
}Never returns text: null.
curl -X POST http://127.0.0.1:8000/generate \
-H "Content-Type: application/json" \
-d '{"prompt": "give me json", "json": true}'curl -X POST http://127.0.0.1:8000/memory/search \
-H "Content-Type: application/json" \
-d '{"query": "hello"}'Response:
{
"results": [
[0.98, { "id": 1, "content": "hello", "role": "user" }]
]
}Returns a structured project profile:
{
"status": "ok",
"project_id": "project:rope_simulation_using_flutter",
"profile": {
"package_name": "rope_simulation_using_flutter",
"architecture": {
"patterns": ["feature_first"],
"state_management": []
},
"dart_files_count": 3,
"widget_files_count": 2
}
}multimodal_agent/
core/ # Main agent logic
rag/ # SQLite vector store
cli/ # CLI commands (`agent`)
server/ # FastAPI server implementation
utils/ # helperssessions # chat sessions
chunks # tokenized fragments
embeddings # vector embeddings
projects # project profiles (v0.6.0)The agent can generate fully functional Flutter files directly inside your project.
You must run commands from within a Flutter project (containing pubspec.yaml).
Generated files are written to:
lib/widgets/
lib/screens/
lib/models/Stateless widget
agent gen widget HomeCardStateful widget
agent gen widget CoolCounter --statefulExample output
import 'package:flutter/material.dart';
class CoolCounter extends StatefulWidget {
const CoolCounter({super.key});
@override
State<CoolCounter> createState() => _CoolCounterState();
}
class _CoolCounterState extends State<CoolCounter> {
int _counter = 0;
void _incrementCounter() {
setState(() => _counter++);
}
@override
Widget build(BuildContext context) {
return Text('$_counter');
}
}agent gen screen SettingsScreenEvery screen is a StatelessWidget with:
- Scaffold
- AppBar
- Centered placeholder body
agent gen model UserProfileGenerated model includes:
- final fields
- const constructor
- copyWith
- fromJson / toJson
- toString
Example
class UserProfile {
final String name;
final int age;
const UserProfile({required this.name, required this.age});
UserProfile copyWith({String? name, int? age}) =>
UserProfile(name: name ?? this.name, age: age ?? this.age);
factory UserProfile.fromJson(Map<String, dynamic> json) =>
UserProfile(name: json['name'], age: json['age']);
Map<String, dynamic> toJson() => {'name': name, 'age': age};
}sanitize_class_name()
Input → Class Name
| Input | Output |
|---|---|
| my widget | MyWidget |
| my-widget | MyWidget |
| my_widget | MyWidget |
| 123widget | W123widget |
| my@bad#name | MyBadName |
to_snake_case() Input → snake_case
| Input | Output |
|---|---|
| MyWidget | my_widget |
| MyWidgetScreen | my_widget_screen |
| my widget | my_widget |
| my@invalid-name | myinvalid_name |
Offline Mode (No API Key)
If no API key is configured:
FAKE_RESPONSE: <your prompt>text contains JSON stringdata is None (tests enforce this)
Example:
{"message": "hello"}This is intended for CI and local testing.
Show config:
agent config showSet models:
agent config set-model gemini-2.5-flash
agent config set-image-model gemini-vision
agent config set-embed-model gemini-embed- Detects JSON, XML, HTML, code, python, kotlin, dart, js, swift …
- Pretty-prints output
- Auto-wraps in fenced code blocks
- Optional in
agent.ask(formatted=True)
make test
make coverageThis includes:
- RAG tests
- CLI tests
- JSON mode tests
- Fake mode (offline)
- Config isolation
- SQLite operations
- Code generation
Cause:
- Gemini API free-tier quota exceeded
Solution:
- Wait for quota reset (usually within 24 hours)
- Or upgrade your Gemini API plan
Cause:
- Using a deprecated or unsupported Gemini model
Solution:
- Update
chat_modelinconfig.yaml - Restart the agent server
Cause:
- Server timeout or quota exhaustion
Solution:
- Check server logs
- Prefer CLI while quota resets
-
Local LLM mode
-
Plugin architecture for custom code generators
-
Automatic quota detection
-
Model failover (Flash → Flash Lite → Local)
-
Graceful server fallback when quota is exhausted
-
Extension-side retry & clearer diagnostics
MIT License.
If you enjoy this project, ⭐ star the repo!