スキル一覧に戻る
arthurelgindell

lm-studio

by arthurelgindell

Arthur's AI-powered content creation toolkit: video generation, carousel creation, image generation, and automation scripts

0🍴 0📅 2026年1月15日
GitHubで見るManusで実行

SKILL.md


name: lm-studio description: This skill should be used when the user asks to "run local LLMs", "use LM Studio", "configure local AI server", "estimate VRAM requirements", "load a model locally", or needs guidance on OpenAI-compatible local API usage, model quantization selection, GPU offload configuration, MCP server integration, or headless LLM server management. Covers local AI inference, CLI automation, SDK integration, and hardware optimization. version: 1.0.0 license: MIT

LM Studio Local LLM Integration

Comprehensive integration for running AI models locally via LM Studio.

Quick Reference

Server Endpoints:

  • Base URL: http://localhost:1234/v1
  • Chat Completions: POST /v1/chat/completions
  • Embeddings: POST /v1/embeddings
  • List Models: GET /v1/models
  • Responses (Stateful): POST /v1/responses

Default Port: 1234 (configurable via --port)


API Endpoints

LM Studio provides an OpenAI-compatible HTTP server.

EndpointMethodDescription
/v1/chat/completionsPOSTGenerate chat completions (streaming supported)
/v1/embeddingsPOSTGenerate vector embeddings for RAG
/v1/modelsGETList loaded/available models with capability tags
/v1/completionsPOSTLegacy text completion endpoint
/v1/responsesPOSTStateful interactions with previous_response_id

Authentication: API key not required but some clients expect non-empty string (use "lm-studio").


CLI Commands Reference

The lms CLI enables headless operation and automation.

Server Management

# Start server with CORS enabled
lms server start --port 1234 --cors

# Stop server
lms server stop

# Check status
lms server status

Model Management

# List downloaded models
lms ls
lms ls --json  # JSON output for scripts

# List loaded models
lms ps
lms ps --json

# Download model
lms get deepseek-r1
lms get <huggingface-url>
lms get --mlx <model>  # Apple MLX optimized

# Load model with configuration
lms load <model> --ttl 300 --gpu auto --context-length 8192

# Estimate VRAM before loading
lms load --estimate-only <model>

Logging & Monitoring

# Stream server logs
lms log stream --source server

# Stream inference logs with stats
lms log stream --source model --filter input,output --stats --json

Model Configuration Parameters

Inference Parameters

ParameterTypeDescriptionRecommended
temperaturefloatRandomness (0.0-2.0)0.3 (code), 0.6 (reasoning), 0.7 (chat)
max_tokensintMaximum generation lengthTask-dependent
top_pfloatNucleus sampling threshold0.95
top_kintTop-k sampling40
ttlintAuto-unload after N seconds idle300-600

Load-Time Configuration

ParameterDescription
contextLengthContext window size (tokens)
gpu.ratioGPU offload ratio (0.0-1.0)
flashAttentionEnable Flash Attention (NVIDIA RTX)
useFp16ForKVCacheHalf-precision KV cache
evalBatchSizeTokens processed per batch

VRAM Requirements Guide

Quantization Levels

  • Q4_K_M: Best balance for consumer hardware (recommended)
  • Q8_0: Higher quality, ~2x VRAM of Q4
  • FP16/BF16: Full precision, research/workstation only

Requirements by Model Size

Model SizeQuantizationVRAM RequiredHardware
1.5B-3BQ4_K_M3-4 GBGTX 1650, RTX 3050
7B-9BQ4_K_M6-8 GBRTX 3060, 4060
13B-14BQ4/Q59-12 GBRTX 3060 Ti, 4070
30B-35BQ420-24 GBRTX 3090, 4090
70BQ440-48 GB+RTX 6000, 2x 3090

Rule: If model fits entirely in VRAM, runs fastest. Offloading to RAM is up to 30x slower.

Use scripts/check_vram.py to estimate requirements before loading.


Reasoning & Logic

DeepSeek-R1 Distillations:

  • deepseek-r1-distill-qwen-7b, deepseek-r1-distill-qwen-32b
  • Temperature: 0.5-0.7
  • No system prompt (instructions in user message)
  • Math directive: "Please reason step by step, and put your final answer within \boxed{}."

Nemotron 3 Nano:

  • nvidia/NVIDIA-Nemotron-3-Nano-30B-A3B-GGUF
  • Temperature: 1.0, Top P: 1.0
  • Use /think or /no_think control tokens

Coding & Agentic Workflows

Qwen3-Coder:

  • qwen3-coder-30b-a3b-instruct
  • Temperature: 0.3
  • Context: up to 256k tokens

GLM-4.7:

  • zai-org/GLM-4.7
  • Excellent for web page generation and multi-step tool use

Vision (Multimodal)

Qwen2.5-VL/Qwen3-VL:

  • qwen2.5-vl-7b-instruct, qwen3-vl-8b-instruct
  • Set image resize bounds to 2048px minimum

LFM2.5-VL:

  • LiquidAI/LFM2.5-VL-1.6B
  • Optimized for edge devices and laptops

MCP Server Configuration

LM Studio acts as an MCP Host, connecting to external tool servers.

Configuration File: ~/.lmstudio/mcp.json

Remote Server Example

{
  "mcpServers": {
    "hf-mcp-server": {
      "url": "https://huggingface.co/mcp",
      "headers": {
        "Authorization": "Bearer <YOUR_HF_TOKEN>"
      }
    }
  }
}

Local Server Example

{
  "mcpServers": {
    "sandbox": {
      "command": "sandbox-server-stdio",
      "args": []
    },
    "my-local-server": {
      "url": "http://localhost:8000"
    }
  }
}

Tool Choice Options:

  • "auto": Model decides whether to call tools
  • "required": Force tool usage
  • "none": Disable tools

Python/OpenAI Client Integration

from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:1234/v1",
    api_key="lm-studio"  # Placeholder required by some clients
)

completion = client.chat.completions.create(
    model="qwen2.5-7b-instruct",
    messages=[{"role": "user", "content": "Hello!"}],
    temperature=0.7,
    max_tokens=2048
)

print(completion.choices[0].message.content)

With Streaming

stream = client.chat.completions.create(
    model="deepseek-r1-distill-qwen-7b",
    messages=[{"role": "user", "content": "Explain quantum computing"}],
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="")

TypeScript SDK Usage

import { LMStudioClient } from "@lmstudio/sdk";

const client = new LMStudioClient();

// Load model with configuration
const model = await client.llm.load("qwen2.5-7b-instruct", {
  config: {
    contextLength: 8192,
    gpu: { ratio: 1.0 },
    flashAttention: true,
    useFp16ForKVCache: true
  }
});

// Run inference
const response = await model.respond([
  { role: "user", content: "Write a Python function to sort a list" }
]);

Framework Integration

LangChain

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    base_url="http://localhost:1234/v1",
    api_key="lm-studio",
    model="qwen2.5-7b-instruct"
)

AutoGen

config_list = [
    {
        "model": "qwen2.5-7b-instruct",
        "base_url": "http://localhost:1234/v1",
        "api_key": "lm-studio"
    }
]

assistant = autogen.AssistantAgent(
    name="Assistant",
    llm_config={"config_list": config_list}
)

System Requirements

macOS (Apple Silicon):

  • M1/M2/M3/M4 chip required (Intel not supported)
  • macOS 13.4+ (14.0+ for MLX backend)
  • 16GB+ unified memory recommended

Windows:

  • x64 with AVX2 or ARM64 (Snapdragon X Elite)
  • 16GB+ RAM, 4GB+ dedicated VRAM minimum
  • NVIDIA RTX preferred (CUDA 12.8), AMD via ROCm

Linux:

  • Ubuntu 20.04+ (AppImage)
  • x64 with AVX2, 16GB+ RAM, 8GB+ VRAM

Performance Optimization

  1. Enable Flash Attention for NVIDIA RTX GPUs
  2. Use Q4_K_M quantization for best speed/quality balance
  3. Set appropriate context length (smaller = faster, less VRAM)
  4. Enable FP16 KV Cache to reduce memory usage
  5. Configure Idle TTL for automatic resource cleanup
  6. Use speculative decoding with draft models for 2-3x speedup

Speculative Decoding Example

{
  "model": "deepseek-r1-distill-qwen-7b",
  "draft_model": "deepseek-r1-distill-qwen-0.5b",
  "messages": [...]
}

Bundled Resources

  • scripts/check_vram.py - Estimate VRAM requirements
  • scripts/server_health.py - Monitor server status
  • scripts/model_benchmark.py - Performance testing
  • references/integration-patterns.md - RAG, multi-model, IDE integration examples

スコア

総合スコア

50/100

リポジトリの品質指標に基づく評価

SKILL.md

SKILL.mdファイルが含まれている

+20
LICENSE

ライセンスが設定されている

0/10
説明文

100文字以上の説明がある

+10
人気

GitHub Stars 100以上

0/15
最近の活動

3ヶ月以内に更新がある

0/10
フォーク

10回以上フォークされている

0/5
Issue管理

オープンIssueが50未満

+5
言語

プログラミング言語が設定されている

+5
タグ

1つ以上のタグが設定されている

0/5

レビュー

💬

レビュー機能は近日公開予定です