Stats
113 Downloads
Project Files
README
Advanced AI reasoning plugin that enables LM Studio to invoke Google Gemini models with automatic API key rotation, intelligent error handling, and quota management.
cd reasoning-agent npm install lms dev # For development with hot reload # OR lms push # To deploy to your LM Studio installation
key1,key2,key3
gemini-3-flash-preview)| Setting | Type | Default | Description |
|---|---|---|---|
| API Keys | string | (required) | Comma-separated Google AI API keys |
| Model Name | string | gemini-3-flash-preview | Gemini model to use |
| Max Tokens | number | 2048 | Maximum response length (100-10000) |
| Temperature | number | 0.7 | Response creativity (0-2) |
| Retry Attempts | number | 3 | Attempts per key before rotation |
| Request Timeout | number | 30000 ms | Timeout per request (1000-120000 ms) |
| Detailed Logging | boolean | false | Enable debug logging |
User: "Use the reasoning tool to analyze the implications of quantum computing on cybersecurity" LM Studio: Calls reasoning_invoke with the prompt Plugin: 1. Sends to Gemini API (key 1) 2. Gets response back 3. Formats as Markdown AI: Returns formatted reasoning to user
User: Asks AI a complex question AI: Calls reasoning_invoke ā Plugin tries key 1 Key 1: Gets 429 quota error Plugin: Automatically rotates to key 2 Key 2: Successfully returns response AI: Uses the reasoning in its answer
reasoning_invoke( prompt="Analyze this...", useThinking=true, temperature=0.3, maxTokens=4096 )
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā ā AI Calls reasoning_invoke ā āāāāāāāāāāāāāā¬āāāāāāāāāāāāāāāāāāāāā ā¼ āāāāāāāāāāāāāāāāāāā ā Key 1: Attempt ā ā Retries: 1-3 ā āāāāāāāāāā¬āāāāāāāāā ā āāāāāāāā¼āāāāāāā ā Success? ā ā YES āāā Return Response ā Quota? ā ā ā Auth? ā ā āāāāāāāā¬āāāāāāā NO ā¼ āāāāāāāāāāāāāāāāāāā ā Key 2: Attempt ā ā Retries: 1-3 ā āāāāāāāāāā¬āāāāāāāāā ā āāāāāāāā¼āāāāāāā ā Success? ā ā YES āāā Return Response āāāāāāāā¬āāāāāāā NO ā¼ āāāāāāāāāāāāāāāāāāā ā Key 3: Attempt ā ā Retries: 1-3 ā āāāāāāāāāā¬āāāāāāāāā ā āāāāāāāā¼āāāāāāā ā Success? ā ā YES āāā Return Response āāāāāāāā¬āāāāāāā NO ā¼ Return Error Message (All keys exhausted)
The plugin distinguishes between three error categories:
| Error Type | Trigger | Action |
|---|---|---|
| Quota Error | 429, rate_limit, quota exceeded | Immediately rotate to next key |
| Auth Error | 401, 403, invalid API key | Immediately rotate to next key |
| Transient Error | Network timeout, service unavailable | Retry (up to retryAttempts) |
Enable Detailed Logging in config to see:
[ReasoningAgent] Attempting request with key 1/3 (abc123***) [ReasoningAgent] Using model: gemini-3-flash-preview, temperature: 0.7, maxTokens: 2048 [ReasoningAgent] Attempt 1/3 passed: 429 quota error (Will rotate key) [ReasoningAgent] Attempting request with key 2/3 (def456***) [ReasoningAgent] Successfully generated response (1245 chars)
Check LM Studio's console/logs for these messages while running in dev mode.
Before deploying to production, verify:
curl -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-3-flash-preview:generateContent?key=YOUR_KEYnpm install in plugin directorynpm run buildreasoning-agent/ āāā manifest.json # Plugin metadata āāā package.json # Dependencies & scripts āāā tsconfig.json # TypeScript compiler config āāā .gitignore # Git ignore patterns āāā README.md # This file āāā src/ āāā index.ts # Entry point (registers config + tools) āāā config.ts # Configuration schema for LM Studio UI āāā toolsProvider.ts # Core implementation (API calls + key rotation)
npm run build
lms dev
lms push
reasoning_invokeParameters:
{ prompt: string // Required: The prompt for Gemini systemPrompt?: string // Optional: Custom system prompt useThinking?: boolean // Optional: Enable thinking (default: true) temperature?: number // Optional: Override temperature maxTokens?: number // Optional: Override max tokens }
Returns:
## Reasoning Agent Response [Gemini's response] --- **Model:** gemini-3-flash-preview | **Temperature:** 0.7 | **Max Tokens:** 2048
MIT License - Free for personal and commercial use
Found a bug? Want to improve the plugin?
For issues related to:
Future enhancements:
Version: 1.0.0
Last Updated: April 2026
LM Studio Compatibility: v0.2.28+