This guide shows you how to integrate LM Studio with VTChat for free, private, local AI with a beautiful GUI interface for managing your models.
- Download LM Studio → lmstudio.ai (Free)
- Install & Open → The app will guide you through setup
- Download a Model → Search tab → Search "qwen3" → Download "qwen3:1.7b"
- Start Local Server → Developer tab → Start Server
- Use in VTChat → Select "LM Studio (Beta)" models
Why LM Studio?
- 🎨 Beautiful GUI - Easy model management with visual interface
- 🖱️ One-Click Setup - No command line needed
- 💾 Smart Downloads - Handles model downloading and storage
- ⚡ Optimized - Automatically uses your GPU for faster inference
- 🔧 Advanced Controls - Fine-tune model parameters easily
- Go to lmstudio.ai
- Click "Download" and select your platform
- Install and open LM Studio
- The app will automatically detect your hardware and optimize settings
📱 Using the LM Studio App (Recommended):
- Open LM Studio → Click the "Search" tab
- Find Models → Search for popular models:
qwen3→ Download "qwen3:1.7b" (1GB, fast)llama3.2→ Download "llama3.2:3b" (2GB, good quality)gemma-2→ Download "gemma-2:2b" (1.6GB, efficient)
- Load Model → Go to "Chat" tab → Select your downloaded model
- Test Chat → Try asking "Hello!" to make sure it works
🔧 Model Recommendations by Hardware:
- 8GB RAM or less: qwen3:1.7b, gemma-2:2b
- 16GB RAM: llama3.2:3b, qwen2.5:7b
- 32GB+ RAM: llama3.3:70b, codellama:13b
📡 Using LM Studio GUI (Easy):
- Go to "Developer" tab in LM Studio
- Click "Start Server"
- Make sure "Cross-Origin-Resource-Sharing (CORS)" is ✅ enabled
- Note the server URL (usually
http://127.0.0.1:1234)
⌨️ Using Command Line (Alternative):
# Start server on default port (1234)
lms server start --cors
# Or start on custom port
lms server start --port 3000 --corsIf using a custom port or remote instance:
# .env.local
LMSTUDIO_BASE_URL=http://localhost:3000
# For development with remote LM Studio instance
ALLOW_REMOTE_LMSTUDIO=true
# For production, remote URLs are automatically allowed
NODE_ENV=productionDefault is http://127.0.0.1:1234. Remote URLs are automatically allowed in production environments.
VTChat includes these LM Studio models by default:
- Llama 3 8B (Local) - General purpose chat model
- Qwen 2.5 7B (Local) - Multilingual model with extended context
- Gemma 7B (Local) - Google's instruction-tuned model
Run the test script to verify everything works:
node apps/web/app/tests/test-lm-studio-integration.jsThe integration uses the @ai-sdk/openai-compatible provider which follows the OpenAI API standard for maximum compatibility.
- Start LM Studio server
- Load your desired model
- Select one of the "LM Studio" models from the model selector in VTChat
- Start chatting with your local model!
- Privacy: Models run entirely on your machine
- No API costs: Free to use once you have the models
- Offline: Works without internet connection
- Custom models: Use any GGUF model compatible with LM Studio
❌ Error: connect ECONNREFUSED ::1:1234
Solution: Start LM Studio server with lms server start --cors
If you're running VTChat on HTTPS (like https://vtchat.io.vn), browsers will block HTTP requests to http://localhost:1234 due to mixed content security policies.
Solutions:
- Run VTChat locally: Use
http://localhost:3000for development - Production Environment: Deploy with
NODE_ENV=productionto allow remote URLs - HTTPS Proxy: Set up a reverse proxy with SSL for LM Studio
- Tunnel Service: Use tools like ngrok to create an HTTPS tunnel
# Example with ngrok
ngrok http 1234
# Then use the HTTPS URL: https://abc123.ngrok.io
# Set: LMSTUDIO_BASE_URL=https://abc123.ngrok.io❌ Error: Model not found
Solution: Load a model in LM Studio application first
❌ Error: CORS policy
Solution: Make sure to start the server with --cors flag
❌ Error: Port 1234 already in use
Solution:
- Stop other services using port 1234, or
- Use a different port:
lms server start --port 3000 --cors - Update
LMSTUDIO_BASE_URLenvironment variable accordingly
If you want to use models with different names than the defaults, you can modify the model identifiers in the LM Studio provider configuration.
- GPU Offloading: Configure in LM Studio settings
- Context Length: Adjust based on your hardware
- Batch Size: Optimize for your system's memory
- Llama 3.1 8B Instruct - Excellent general conversation
- Qwen2.5 7B Instruct - Good multilingual support
- Mistral 7B Instruct - Fast and efficient
- CodeLlama 7B - Specialized for programming
- Qwen2.5 Coder 7B - Good code understanding
- Deepseek Coder 6.7B - Strong coding capabilities
For LM Studio specific issues, check: