lm-studio-subagents
LM Studioを活用し、ローカル環境でLLM(大規模言語モデル)を動かすことで、API利用コストを抑えつつ、要約や分類などのタスクを効率的に処理したり、複数のAIを連携させたより複雑な処理を実現したりするSkill。
📜 元の英語説明(参考)
Offload tasks to local LLMs via LM Studio. Use when a user asks to run local models with LM Studio, save API costs by using local LLMs, create subagents with local models, offload summarization or classification to a local model, or use LM Studio's API for batch processing. Covers local model inference, task delegation, and cost optimization.
🇯🇵 日本人クリエイター向け解説
LM Studioを活用し、ローカル環境でLLM(大規模言語モデル)を動かすことで、API利用コストを抑えつつ、要約や分類などのタスクを効率的に処理したり、複数のAIを連携させたより複雑な処理を実現したりするSkill。
※ jpskill.com 編集部が日本のビジネス現場向けに補足した解説です。Skill本体の挙動とは独立した参考情報です。
下記のコマンドをコピーしてターミナル(Mac/Linux)または PowerShell(Windows)に貼り付けてください。 ダウンロード → 解凍 → 配置まで全自動。
mkdir -p ~/.claude/skills && cd ~/.claude/skills && curl -L -o lm-studio-subagents.zip https://jpskill.com/download/15081.zip && unzip -o lm-studio-subagents.zip && rm lm-studio-subagents.zip
$d = "$env:USERPROFILE\.claude\skills"; ni -Force -ItemType Directory $d | Out-Null; iwr https://jpskill.com/download/15081.zip -OutFile "$d\lm-studio-subagents.zip"; Expand-Archive "$d\lm-studio-subagents.zip" -DestinationPath $d -Force; ri "$d\lm-studio-subagents.zip"
完了後、Claude Code を再起動 → 普通に「動画プロンプト作って」のように話しかけるだけで自動発動します。
💾 手動でダウンロードしたい(コマンドが難しい人向け)
- 1. 下の青いボタンを押して
lm-studio-subagents.zipをダウンロード - 2. ZIPファイルをダブルクリックで解凍 →
lm-studio-subagentsフォルダができる - 3. そのフォルダを
C:\Users\あなたの名前\.claude\skills\(Win)または~/.claude/skills/(Mac)へ移動 - 4. Claude Code を再起動
⚠️ ダウンロード・利用は自己責任でお願いします。当サイトは内容・動作・安全性について責任を負いません。
🎯 このSkillでできること
下記の説明文を読むと、このSkillがあなたに何をしてくれるかが分かります。Claudeにこの分野の依頼をすると、自動で発動します。
📦 インストール方法 (3ステップ)
- 1. 上の「ダウンロード」ボタンを押して .skill ファイルを取得
- 2. ファイル名の拡張子を .skill から .zip に変えて展開(macは自動展開可)
- 3. 展開してできたフォルダを、ホームフォルダの
.claude/skills/に置く- · macOS / Linux:
~/.claude/skills/ - · Windows:
%USERPROFILE%\.claude\skills\
- · macOS / Linux:
Claude Code を再起動すれば完了。「このSkillを使って…」と話しかけなくても、関連する依頼で自動的に呼び出されます。
詳しい使い方ガイドを見る →- 最終更新
- 2026-05-18
- 取得日時
- 2026-05-18
- 同梱ファイル
- 1
📖 Skill本文(日本語訳)
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
LM Studio サブエージェント
概要
LLMタスクをLM Studioで実行されるローカルモデルにオフロードすることで、APIコストを削減し、プライバシーを維持します。LM Studioは、ローカルモデル用のOpenAI互換APIを提供し、クラウドLLM呼び出しのドロップイン代替として機能します。要約、抽出、分類、再フォーマットなどの高頻度で低複雑度のタスクにはローカルモデルを使用し、複雑な推論にはクラウドAPIを予約します。
手順
ユーザーがLM Studio経由でローカルモデルを使用したい場合、タスクを決定します。
タスクA: LM StudioをローカルAPIサーバーとしてセットアップする
-
https://lmstudio.ai/からLM Studioをダウンロードしてインストールします。 -
LM Studio UIを通じてモデルをダウンロードします(推奨される開始モデル):
lmstudio-community/Llama-3.1-8B-Instruct-GGUF(汎用)lmstudio-community/Mistral-7B-Instruct-v0.3-GGUF(高速推論)lmstudio-community/Qwen2.5-7B-Instruct-GGUF(多言語)
-
ローカルサーバーを起動します。
- LM Studioを開き、"Developer"タブに移動します。
- モデルをロードし、"Start Server"をクリックします。
- サーバーはデフォルトで
http://localhost:1234で実行されます。
-
サーバーが実行されていることを確認します。
curl http://localhost:1234/v1/models
タスクB: PythonからLM Studioを呼び出す (OpenAI互換)
from openai import OpenAI
# ローカルLM Studioサーバーを指す
client = OpenAI(
base_url="http://localhost:1234/v1",
api_key="lm-studio", # 任意の文字列で動作します
)
def ask_local(prompt: str, system: str = "You are a helpful assistant.") -> str:
response = client.chat.completions.create(
model="loaded-model", # LM Studioはこれを無視し、ロードされたモデルを使用します
messages=[
{"role": "system", "content": system},
{"role": "user", "content": prompt},
],
temperature=0.3,
max_tokens=1024,
)
return response.choices[0].message.content
# 使用例
result = ask_local("Summarize this text in 2 sentences: ...")
print(result)
タスクC: タスク固有のサブエージェントを作成する
from openai import OpenAI
client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")
class LocalSubagent:
def __init__(self, system_prompt: str, temperature: float = 0.2):
self.system_prompt = system_prompt
self.temperature = temperature
def run(self, user_input: str) -> str:
response = client.chat.completions.create(
model="loaded-model",
messages=[
{"role": "system", "content": self.system_prompt},
{"role": "user", "content": user_input},
],
temperature=self.temperature,
max_tokens=2048,
)
return response.choices[0].message.content
# 特殊化されたサブエージェントを定義する
summarizer = LocalSubagent(
system_prompt="You are a summarization expert. Produce concise 2-3 sentence summaries."
)
classifier = LocalSubagent(
system_prompt="Classify the input into one of these categories: billing, technical, general, urgent. Respond with only the category name.",
temperature=0.0,
)
extractor = LocalSubagent(
system_prompt="Extract all named entities (people, organizations, dates, amounts) from the text. Return as JSON.",
temperature=0.0,
)
# サブエージェントを使用する
summary = summarizer.run("Long document text here...")
category = classifier.run("I can't log into my account and I need to submit a report by EOD")
entities = extractor.run("John Smith signed a $50,000 contract with Acme Corp on March 15, 2025")
タスクD: ローカルモデルを使用したバッチ処理
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")
async def process_batch(items: list[str], system_prompt: str, max_concurrent: int = 4) -> list[str]:
semaphore = asyncio.Semaphore(max_concurrent)
async def process_one(text: str) -> str:
async with semaphore:
response = await client.chat.completions.create(
model="loaded-model",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": text},
],
temperature=0.2,
max_tokens=512,
)
return response.choices[0].message.content
tasks = [process_one(item) for item in items]
return await asyncio.gather(*tasks)
# 100個のドキュメントをバッチで要約する
documents = ["doc1 text...", "doc2 text...", ...] # 100個のドキュメント
summaries = asyncio.run(process_batch(
documents,
system_prompt="Summarize in 2 sentences.",
max_concurrent=2, # LM Studioはデフォルトで一度に1つのリクエストを処理します
))
タスクE: コスト比較とルーティング戦略
ローカルモデルとクラウドモデルのどちらを使用するかを決定します。
| タスク | ローカルモデル | クラウドAPI | 推奨 |
|---|---|---|---|
| 要約 | 良い | より良い | ローカル (コスト削減) |
| 分類 | 良い | 良い | ローカル (コスト削減) |
| データ抽出 | そこそこ | 良い | 単純な場合はローカル、複雑な場合はクラウド |
| コード生成 | そこそこ | より良い | クラウド |
| 複雑な推論 | 弱い | 強い | クラウド |
| 翻訳 | 良い | より良い | 一般的な言語の場合はローカル |
def smart_route(task_type: str, text: str) -> str:
"""ローカルモデルとクラウドモデルの間でタスクをルーティングします。"""
local_tasks = {"summarize", "classify", "extract_simple", "reformat"}
if task_type in local_tasks:
return ask_local(text) # 無料、ローカル推論
else:
return ask_cloud(text) # 有料、クラウドAPI
例
例1: 500件のサポートチケットをローカルで要約する
ユーザーリクエスト: "APIコストをかけずに、先月のすべてのサポートチケットを要約してください"
tickets = load_tickets_from_csv("tickets.csv")
summaries = asyncio.run(process_batch(
[t["description"] for t in tickets],
system_prompt="Summarize this support ticket in one sentence. Include the main issue and any resolution.",
max_concurrent=2,
))
# コスト: $0 (vs ~$15
(原文がここで切り詰められています) 📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
LM Studio Subagents
Overview
Offload LLM tasks to local models running in LM Studio to save API costs and maintain privacy. LM Studio provides an OpenAI-compatible API for local models, making it a drop-in replacement for cloud LLM calls. Use local models for high-volume, lower-complexity tasks like summarization, extraction, classification, and reformatting while reserving cloud APIs for complex reasoning.
Instructions
When a user wants to use local models via LM Studio, determine the task:
Task A: Set up LM Studio as a local API server
-
Download and install LM Studio from
https://lmstudio.ai/ -
Download a model through the LM Studio UI (recommended starting models):
lmstudio-community/Llama-3.1-8B-Instruct-GGUF(general purpose)lmstudio-community/Mistral-7B-Instruct-v0.3-GGUF(fast inference)lmstudio-community/Qwen2.5-7B-Instruct-GGUF(multilingual)
-
Start the local server:
- Open LM Studio, go to the "Developer" tab
- Load a model and click "Start Server"
- Server runs at
http://localhost:1234by default
-
Verify the server is running:
curl http://localhost:1234/v1/models
Task B: Call LM Studio from Python (OpenAI-compatible)
from openai import OpenAI
# Point to local LM Studio server
client = OpenAI(
base_url="http://localhost:1234/v1",
api_key="lm-studio", # Any string works
)
def ask_local(prompt: str, system: str = "You are a helpful assistant.") -> str:
response = client.chat.completions.create(
model="loaded-model", # LM Studio ignores this, uses loaded model
messages=[
{"role": "system", "content": system},
{"role": "user", "content": prompt},
],
temperature=0.3,
max_tokens=1024,
)
return response.choices[0].message.content
# Example usage
result = ask_local("Summarize this text in 2 sentences: ...")
print(result)
Task C: Create task-specific subagents
from openai import OpenAI
client = OpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")
class LocalSubagent:
def __init__(self, system_prompt: str, temperature: float = 0.2):
self.system_prompt = system_prompt
self.temperature = temperature
def run(self, user_input: str) -> str:
response = client.chat.completions.create(
model="loaded-model",
messages=[
{"role": "system", "content": self.system_prompt},
{"role": "user", "content": user_input},
],
temperature=self.temperature,
max_tokens=2048,
)
return response.choices[0].message.content
# Define specialized subagents
summarizer = LocalSubagent(
system_prompt="You are a summarization expert. Produce concise 2-3 sentence summaries."
)
classifier = LocalSubagent(
system_prompt="Classify the input into one of these categories: billing, technical, general, urgent. Respond with only the category name.",
temperature=0.0,
)
extractor = LocalSubagent(
system_prompt="Extract all named entities (people, organizations, dates, amounts) from the text. Return as JSON.",
temperature=0.0,
)
# Use the subagents
summary = summarizer.run("Long document text here...")
category = classifier.run("I can't log into my account and I need to submit a report by EOD")
entities = extractor.run("John Smith signed a $50,000 contract with Acme Corp on March 15, 2025")
Task D: Batch processing with local models
import asyncio
from openai import AsyncOpenAI
client = AsyncOpenAI(base_url="http://localhost:1234/v1", api_key="lm-studio")
async def process_batch(items: list[str], system_prompt: str, max_concurrent: int = 4) -> list[str]:
semaphore = asyncio.Semaphore(max_concurrent)
async def process_one(text: str) -> str:
async with semaphore:
response = await client.chat.completions.create(
model="loaded-model",
messages=[
{"role": "system", "content": system_prompt},
{"role": "user", "content": text},
],
temperature=0.2,
max_tokens=512,
)
return response.choices[0].message.content
tasks = [process_one(item) for item in items]
return await asyncio.gather(*tasks)
# Batch summarize 100 documents
documents = ["doc1 text...", "doc2 text...", ...] # 100 documents
summaries = asyncio.run(process_batch(
documents,
system_prompt="Summarize in 2 sentences.",
max_concurrent=2, # LM Studio handles one request at a time by default
))
Task E: Cost comparison and routing strategy
Decide when to use local vs. cloud models:
| Task | Local Model | Cloud API | Recommendation |
|---|---|---|---|
| Summarization | Good | Better | Local (save cost) |
| Classification | Good | Good | Local (save cost) |
| Data extraction | Moderate | Good | Local for simple, cloud for complex |
| Code generation | Moderate | Better | Cloud |
| Complex reasoning | Weak | Strong | Cloud |
| Translation | Good | Better | Local for common languages |
def smart_route(task_type: str, text: str) -> str:
"""Route tasks between local and cloud models."""
local_tasks = {"summarize", "classify", "extract_simple", "reformat"}
if task_type in local_tasks:
return ask_local(text) # Free, local inference
else:
return ask_cloud(text) # Paid, cloud API
Examples
Example 1: Summarize 500 support tickets locally
User request: "Summarize all our support tickets from last month without API costs"
tickets = load_tickets_from_csv("tickets.csv")
summaries = asyncio.run(process_batch(
[t["description"] for t in tickets],
system_prompt="Summarize this support ticket in one sentence. Include the main issue and any resolution.",
max_concurrent=2,
))
# Cost: $0 (vs ~$15 with GPT-4)
Example 2: Classify incoming emails
User request: "Auto-classify emails into categories using a local model"
classifier = LocalSubagent(
system_prompt="Classify this email into exactly one category: sales, support, spam, internal. Reply with only the category.",
temperature=0.0,
)
for email in emails:
category = classifier.run(email["subject"] + "\n" + email["body"])
email["category"] = category.strip().lower()
Example 3: Extract structured data from documents
User request: "Extract names, dates, and amounts from these contracts"
extractor = LocalSubagent(
system_prompt='Extract fields from the contract as JSON: {"parties": [], "date": "", "amount": "", "term": ""}',
temperature=0.0,
)
for doc in contracts:
data = extractor.run(doc["text"])
print(f"{doc['filename']}: {data}")
Guidelines
- LM Studio processes one request at a time by default. Set
max_concurrent=1-2for batch jobs. - Use quantized models (Q4_K_M or Q5_K_M) for best speed-to-quality ratio on consumer hardware.
- 8B parameter models are the sweet spot for most extraction and classification tasks.
- Set
temperature=0.0for deterministic tasks like classification and extraction. - Test local model accuracy on a sample of 20-50 items before running full batches.
- For tasks where local models underperform, fall back to cloud APIs automatically.
- Keep LM Studio running as a background service for always-on local inference.
- Monitor RAM and VRAM usage; 7B models need ~6 GB RAM (quantized) or ~16 GB (full precision).