lmstudio-cli

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

LM Studio CLI

LM Studio CLI

Use this skill when the real job is operating LM Studio itself: confirming whether
lms
exists, checking whether a local or remote LM Studio server is actually running, discovering exact model IDs, deciding whether the OpenAI-compatible endpoints are enough, and wiring a downstream tool to the correct base URL and model identifier.
Do not use this as a generic local-LLM comparison skill. Route broad provider comparison or platform selection to research/survey work. Route downstream-tool-specific scanning or appsec operation to that tool's skill (for example
strix
) once LM Studio itself is verified.
当实际任务是操作LM Studio本身时使用此技能:确认
lms
是否存在、检查本地或远程LM Studio服务器是否实际运行、查找确切的模型ID、判断OpenAI兼容端点是否足够,以及将下游工具连接到正确的基础URL和模型标识符。
请勿将此作为通用本地大模型(LLM)对比技能。将宽泛的服务商对比或平台选择需求引导至调研/调查工作。在确认LM Studio本身可用后,将下游工具特定的扫描或应用安全操作引导至对应工具的技能(例如
strix
)。

When to use this skill

何时使用此技能

  • A user mentions LM Studio,
    lms
    , or an LM Studio server directly
  • You need to verify whether LM Studio is running locally or on another authorized host
  • You need the exact model IDs returned by
    /v1/models
    before wiring another tool
  • You need to choose between LM Studio's OpenAI-compatible endpoints and its native REST API
  • You need to load, inspect, or confirm models before an agent or CLI can use them
  • A downstream tool works with OpenAI-compatible endpoints, but the user needs LM Studio-specific setup help
  • A remote/headless LM Studio workflow is failing and you need a deterministic verification path
  • 用户直接提及LM Studio、
    lms
    或LM Studio服务器
  • 需要验证LM Studio是在本地运行还是在其他授权主机上运行
  • 在连接其他工具前,需要获取
    /v1/models
    返回的确切模型ID
  • 需要在LM Studio的OpenAI兼容端点与其原生REST API之间做出选择
  • 需要在代理(Agent)或CLI使用模型前,加载、检查或确认模型
  • 下游工具可与OpenAI兼容端点配合使用,但用户需要LM Studio特定的设置帮助
  • 远程/无界面LM Studio工作流失败,需要确定性的验证路径

Instructions

操作说明

Step 1: Identify the operating mode

步骤1:确定运行模式

Classify the request before touching commands:
  1. Local native CLI mode — the machine should have LM Studio installed and
    lms
    available
  2. Remote HTTP mode — you only need to test or consume an authorized LM Studio endpoint
  3. LM Studio-native management mode — the user needs model loading / listing / unload behavior that goes beyond generic OpenAI-compatible calls
  4. Downstream wiring mode — the user already has LM Studio running and needs to point another tool at it
Use the smallest mode that answers the request.
在执行命令前先对请求进行分类:
  1. 本地原生CLI模式 — 机器应已安装LM Studio且
    lms
    可用
  2. 远程HTTP模式 — 仅需测试或使用授权的LM Studio端点
  3. LM Studio原生管理模式 — 用户需要模型加载/列出/卸载操作,这些操作超出了通用OpenAI兼容调用的范围
  4. 下游配置模式 — 用户已启动LM Studio,需要将其他工具指向它
使用能满足请求的最小模式。

Step 2: Check whether local
lms
exists

步骤2:检查本地
lms
是否存在

If local CLI operation is expected, verify it first:
bash
command -v lms
lms --help
If
lms
is missing, do not hallucinate local CLI output. Continue with remote HTTP verification only if the host/endpoint is explicitly authorized.
如果需要本地CLI操作,先进行验证:
bash
command -v lms
lms --help
如果
lms
不存在,请勿虚构本地CLI输出。仅当主机/端点已明确授权时,才继续进行远程HTTP验证。

Step 3: Verify server status or endpoint reachability

步骤3:验证服务器状态或端点可达性

For local native checks:
bash
lms server status
lms server status --json --quiet
For a remote or client-style smoke test:
bash
curl -fsS http://HOST:PORT/v1/models
Optional minimal response test:
bash
curl -fsS http://HOST:PORT/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "reply with exactly OK"}],
    "temperature": 0,
    "max_tokens": 8
  }'
If you want a reusable parser instead of copy-pasting curl, use
python3 scripts/check_lmstudio_endpoint.py --base-url http://HOST:PORT/v1
.
对于本地原生检查:
bash
lms server status
lms server status --json --quiet
对于远程或客户端式冒烟测试:
bash
curl -fsS http://HOST:PORT/v1/models
可选的最小响应测试:
bash
curl -fsS http://HOST:PORT/v1/chat/completions \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "MODEL_ID",
    "messages": [{"role": "user", "content": "reply with exactly OK"}],
    "temperature": 0,
    "max_tokens": 8
  }'
如果需要可复用的解析器而非复制粘贴curl命令,使用
python3 scripts/check_lmstudio_endpoint.py --base-url http://HOST:PORT/v1

Step 4: Discover exact model identifiers

步骤4:查找确切的模型标识符

Do not guess model names.
Use one of these:
bash
lms ls
lms ls --llm
lms ps --json
curl -fsS http://HOST:PORT/v1/models
If the user needs the exact loaded instance or runtime state, prefer
lms ps
or the native REST API over a generic downstream client view.
请勿猜测模型名称。
使用以下方式之一:
bash
lms ls
lms ls --llm
lms ps --json
curl -fsS http://HOST:PORT/v1/models
如果用户需要确切的已加载实例或运行时状态,优先使用
lms ps
或原生REST API,而非通用下游客户端视图。

Step 5: Escalate to LM Studio-native management only when needed

步骤5:仅在必要时升级到LM Studio原生管理

Use the native REST API or LM Studio-native commands when OpenAI compatibility is not enough:
bash
curl -fsS http://HOST:PORT/api/v1/models
curl -fsS http://HOST:PORT/api/v1/models/load \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "MODEL_KEY",
    "context_length": 262144,
    "echo_load_config": true
  }'
And locally:
bash
lms load MODEL_KEY --identifier my-model
lms ps --json
Use this path for context-length, load-state, or instance-specific questions. Do not treat every integration problem as a native-management problem if
/v1/models
and
/v1/chat/completions
already answer the user's need.
当OpenAI兼容性不足以满足需求时,使用原生REST API或LM Studio原生命令:
bash
curl -fsS http://HOST:PORT/api/v1/models
curl -fsS http://HOST:PORT/api/v1/models/load \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "MODEL_KEY",
    "context_length": 262144,
    "echo_load_config": true
  }'
本地操作:
bash
lms load MODEL_KEY --identifier my-model
lms ps --json
此路径适用于上下文长度、加载状态或实例特定问题。如果
/v1/models
/v1/chat/completions
已能满足用户需求,请勿将每个集成问题都视为原生管理问题。

Step 6: Wire downstream tools carefully

步骤6:谨慎配置下游工具

For tools that expect an OpenAI-compatible server, pass the exact model ID and base URL:
bash
export LLM_API_BASE="http://HOST:PORT/v1"
export STRIX_LLM="openai/MODEL_ID"
Some OpenAI-compatible clients still insist on an API key field even when LM Studio itself does not need a real provider key. When that happens, set the client-required dummy key only in the downstream tool's config, not as a claim about LM Studio authentication.
对于需要OpenAI兼容服务器的工具,传入确切的模型ID和基础URL:
bash
export LLM_API_BASE="http://HOST:PORT/v1"
export STRIX_LLM="openai/MODEL_ID"
部分OpenAI兼容客户端即使LM Studio本身不需要真实的服务商密钥,仍会要求填写API密钥字段。此时,仅在下游工具的配置中设置客户端所需的虚拟密钥,而非将其作为LM Studio的认证要求。

Step 7: Report the operating facts, not guesses

步骤7:报告实际情况,而非猜测

A good final report should include:
  • whether
    lms
    was present locally
  • whether the server was verified locally, remotely, or both
  • exact base URL tested
  • exact model IDs discovered
  • whether the user needed OpenAI-compatible calls only or LM Studio-native management
  • the final env/config snippet or command needed by the downstream tool
一份优质的最终报告应包含:
  • 本地是否存在
    lms
  • 服务器是在本地、远程还是两者都已验证
  • 测试的确切基础URL
  • 发现的确切模型ID
  • 用户仅需OpenAI兼容调用还是需要LM Studio原生管理
  • 下游工具所需的最终环境变量/配置片段或命令

Examples

示例

Example 1: Local machine with LM Studio installed

示例1:已安装LM Studio的本地机器

User asks: "Is
lms
installed and what model is loaded?"
Recommended flow:
bash
command -v lms
lms server status --json --quiet
lms ps --json
用户提问:“
lms
是否已安装,当前加载了什么模型?”
推荐流程:
bash
command -v lms
lms server status --json --quiet
lms ps --json

Example 2: Remote LM Studio host for another tool

示例2:为其他工具使用的远程LM Studio主机

User asks: "Point Strix at my LM Studio box."
Recommended flow:
bash
curl -fsS http://HOST:PORT/v1/models
python3 scripts/check_lmstudio_endpoint.py --base-url http://HOST:PORT/v1
export STRIX_LLM="openai/MODEL_ID"
export LLM_API_BASE="http://HOST:PORT/v1"
用户提问:“将Strix指向我的LM Studio主机。”
推荐流程:
bash
curl -fsS http://HOST:PORT/v1/models
python3 scripts/check_lmstudio_endpoint.py --base-url http://HOST:PORT/v1
export STRIX_LLM="openai/MODEL_ID"
export LLM_API_BASE="http://HOST:PORT/v1"

Example 3: Need more than OpenAI-compatible smoke tests

示例3:需要超出OpenAI兼容冒烟测试的功能

User asks: "Load the model with a bigger context length and tell me the effective settings."
Recommended flow:
bash
curl -fsS http://HOST:PORT/api/v1/models
curl -fsS http://HOST:PORT/api/v1/models/load \
  -H 'Content-Type: application/json' \
  -d '{"model":"MODEL_KEY","context_length":262144,"echo_load_config":true}'
用户提问:“加载更大上下文长度的模型,并告诉我实际设置。”
推荐流程:
bash
curl -fsS http://HOST:PORT/api/v1/models
curl -fsS http://HOST:PORT/api/v1/models/load \
  -H 'Content-Type: application/json' \
  -d '{"model":"MODEL_KEY","context_length":262144,"echo_load_config":true}'

Example 4: Headless failure triage

示例4:无界面故障排查

User asks: "
lms server start
broke on my Linux VM. What should I check first?"
Recommended flow:
  • verify
    lms --help
  • run
    lms server status --json --quiet
  • rerun with verbose logging if needed
  • separate local daemon/server failure from downstream OpenAI-client failure before editing configs
用户提问:“我的Linux虚拟机上
lms server start
运行失败,首先应该检查什么?”
推荐流程:
  • 验证
    lms --help
  • 运行
    lms server status --json --quiet
  • 如有需要,启用详细日志重新运行
  • 在修改配置前,区分本地守护进程/服务器故障与下游OpenAI客户端故障

Best practices

最佳实践

  1. Separate local CLI availability from remote HTTP reachability; they are related but not the same fact.
  2. Use the exact model IDs returned by LM Studio instead of shortening names by hand.
  3. Prefer the OpenAI-compatible endpoints for downstream-tool wiring, and the native REST/CLI surfaces for model-management questions.
  4. When a downstream client insists on an API key field, describe it as a client compatibility quirk rather than an LM Studio requirement.
  5. Treat remote private-network hosts as sensitive; only probe endpoints the user has authorized.
  6. Escalate to load-state or context-length guidance only when the simpler
    /v1/models
    path is not enough.
  7. Keep the boundary clear:
    lmstudio-cli
    verifies and configures LM Studio itself; downstream-tool skills own what happens after the endpoint is working.
  1. 区分本地CLI可用性远程HTTP可达性;它们相关但并非同一事实。
  2. 使用LM Studio返回的确切模型ID,而非手动缩短名称。
  3. 配置下游工具时优先使用OpenAI兼容端点,处理模型管理问题时优先使用原生REST/CLI界面。
  4. 当下游客户端要求填写API密钥字段时,将其描述为客户端兼容性问题,而非LM Studio的要求。
  5. 将远程私有网络主机视为敏感内容;仅探测用户已授权的端点。
  6. 仅当更简单的
    /v1/models
    路径无法满足需求时,才提供加载状态或上下文长度相关指导。
  7. 明确边界:
    lmstudio-cli
    用于验证和配置LM Studio本身;下游工具技能负责端点可用后的操作。

References

参考资料