local-ai-use
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLocal AI Use (route image, TTS, STT through Lemonade)
本地AI使用(通过Lemonade路由图像、TTS、STT)
This is a meta-skill. You run it once. After that, every later request that
needs image generation, text-to-speech, or speech-to-text uses the local
Lemonade Server instead of a cloud API. The
agent's own LLM keeps handling text; only the expensive multimodal calls move
on-device.
The skill does three things:
- Makes sure local Lemonade is installed and running. If no modern
CLI is found, the setup script installs the latest version of Lemonade on the user's behalf. Modern Lemonade has no
lemonadecommand — the Lemonade service (theservedaemon) auto-starts on install and is managed by the OS — so the setup script waits for the service and, if it stays down, prints the exact OS-specific command to start it (e.g.lemondon Linux).sudo systemctl start lemond - Verifies that local Lemonade is reachable.
- Drops a block into the workspace
Local AI Useso the agent reads the routing rule on every later turn, in Cursor, Claude Code, Codex, Gemini CLI, and any other agent that respectsAGENTS.md.AGENTS.md
Requires modern Lemonade (v10.1.0 or newer). Modern Lemonade unified everything under oneCLI (lemonade,lemonade status, ...) driving an always-onlemonade pullservice. This skill targets that and installs Lemonade only from the official installers (see below) — never vialemond, which is a separate, older release line. If an older/incompatiblepip install lemonade-sdkis already on the PATH (from any channel — an oldlemonade/.msior a pip install), it will shadow the modern CLI; uninstall it first (see the removal commands in Step 1a) before running this skill..deb
Models are not downloaded during setup. Each default model is pulled
lazily, on first use, by the routing rule (e.g. the first image request pulls
the image model). This keeps setup fast and avoids gigabytes of downloads the
user may never need.
这是一项元技能。只需运行一次。此后所有需要图像生成、文本转语音(TTS)或语音转文本(STT)的请求,都将使用本地Lemonade Server而非云API。Agent自身的LLM仍处理文本内容;仅昂贵的多模态调用会转移到设备端执行。
该技能实现三项功能:
- 确保本地Lemonade已安装并运行。若未找到新版CLI,设置脚本将为用户自动安装最新版本的Lemonade。新版Lemonade无
lemonade命令——Lemonade服务(serve守护进程)在安装时自动启动,并由操作系统管理——因此设置脚本会等待服务启动,若服务始终未启动,则打印特定于操作系统的启动命令(例如Linux上的lemond)。sudo systemctl start lemond - 验证本地Lemonade是否可访问。
- 在工作区的中添加
AGENTS.md块,以便Agent在后续每次交互时读取路由规则,适用于Cursor、Claude Code、Codex、Gemini CLI及任何支持Local AI Use的Agent。AGENTS.md
要求使用新版Lemonade(v10.1.0或更高版本)。新版Lemonade将所有功能统一到单个CLI下(lemonade、lemonade status等),驱动始终运行的lemonade pull服务。本技能针对此版本,且仅从官方安装程序安装Lemonade(见下文)——绝不通过lemond安装,这是独立的旧版本分支。若PATH中已存在旧版/不兼容的pip install lemonade-sdk(来自任何渠道——旧版lemonade/.msi或pip安装),它会覆盖新版CLI;请先卸载旧版本(见步骤1a中的卸载命令),再运行此技能。.deb
设置过程中不会下载模型。每个默认模型会在首次使用时通过路由规则懒加载(例如首次图像请求时拉取图像模型)。这样可保持设置速度快,避免下载用户可能永远不需要的数GB数据。
When to use this skill
使用场景
Use this skill when all of the following are true:
- The user wants local Lemonade. If it is not yet installed, the setup script installs the latest version for them automatically.
- The user accepts the default Lemonade endpoint .
http://localhost:13305 - The user wants the change to be persistent across future turns and agent restarts (the rule is written to disk).
If the user is instead embedding Lemonade as a private subprocess inside
an app installer, do not use this skill; use
instead.
local-ai-app-integration当所有以下条件满足时,使用此技能:
- 用户需要本地Lemonade。若尚未安装,设置脚本将自动为用户安装最新版本。
- 用户接受默认Lemonade端点。
http://localhost:13305 - 用户希望更改在未来交互和Agent重启后持久生效(规则将写入磁盘)。
若用户是要将Lemonade作为私有子进程嵌入应用安装程序中,请不要使用此技能;改用。
local-ai-app-integrationPrerequisites
前提条件
- OS: Windows 11 x64, Ubuntu/Debian x64, or macOS (beta).
- Lemonade: the setup script installs it if missing. It downloads and
silently installs the latest version (Windows , the Ubuntu/Debian
lemonade.msiPPA, or the macOSppa:lemonade-team/stable). The.pkgservice auto-starts after install; the script waits for it rather than launching it. On Linux/macOS the install needslemond. Passsudoif the user wants to install it themselves instead.--no-install - Disk: ~8 GB free for the three default models (SD-Turbo + Whisper-Tiny
- kokoro-v1), plus ~0.1 GB for the installer itself.
- Network: required for the install download and the first of each model. After that, every modality runs offline.
lemonade pull
- 操作系统:Windows 11 x64、Ubuntu/Debian x64或macOS(测试版)。
- Lemonade:若缺失,设置脚本将自动安装。它会下载并静默安装最新版本(Windows的、Ubuntu/Debian的
lemonade.msiPPA或macOS的ppa:lemonade-team/stable)。.pkg服务在安装后自动启动;脚本会等待服务启动而非手动启动。在Linux/macOS上安装需要lemond权限。若用户希望自行安装,可传递sudo参数。--no-install - 磁盘空间:约8GB可用空间,用于存储三个默认模型(SD-Turbo + Whisper-Tiny + kokoro-v1),加上约0.1GB的安装程序本身。
- 网络:安装下载和首次拉取每个模型时需要网络。之后,所有多模态功能均可离线运行。
The opinionated path
标准化流程
Run this checklist top to bottom. Track progress against it; do not move on
until each step verifies.
[ ] 1. Ensure Lemonade Server is installed and running (auto-install if missing)
[ ] 2. Install the routing rule into the workspace AGENTS.mdThe single command that does both steps in one shot is:
bash
python scripts/setup_local_ai.pyAlways run this script first — even if Lemonade is already installed and the
server is already running, and even before generating a single image. Writing
the routing rule into is what makes this skill complete; skipping it
because "Lemonade is already up" leaves the workspace unconfigured for future
turns. The script is safe to run in that case: it detects the running service,
skips the install, and just writes the rule.
AGENTS.mdIt auto-installs the latest version of Lemonade if no modern CLI
is found, waits for the auto-started service, then writes the rule.
The script is idempotent: re-running it on a fully configured workspace is a
no-op apart from a healthcheck. Read the sections below for what to do when
each step fails.
lemonadelemond按从上到下的顺序执行以下检查清单。跟踪进度;每一步验证通过后再进行下一步。
[ ] 1. 确保Lemonade Server已安装并运行(缺失时自动安装)
[ ] 2. 将路由规则安装到工作区的AGENTS.md中可一次性完成两步的命令是:
bash
python scripts/setup_local_ai.py请始终先运行此脚本——即使Lemonade已安装且服务已运行,甚至在生成第一张图像之前。将路由规则写入是完成此技能的关键;不要因为“Lemonade已启动”而跳过此步骤,否则工作区在未来交互中将未配置。在此情况下运行脚本是安全的:它会检测到运行中的服务,跳过安装步骤,仅写入规则。
AGENTS.md若未找到新版 CLI,它会自动安装最新版本的Lemonade,等待自动启动的服务,然后写入规则。该脚本具有幂等性:在已完全配置的工作区重新运行时,除了健康检查外不会产生任何操作。若某一步失败,请阅读以下章节了解解决方法。
lemonadelemondStep 1: ensure Lemonade Server is installed and running
步骤1:确保Lemonade Server已安装并运行
scripts/setup_local_ai.py1a. Is a modern CLI installed? Run . The check
is by capability, not by name: modern Lemonade prints
or . If instead you get an "invalid choice" / usage
error, the on is an old, incompatible build that predates the
unified CLI (v10.1.0) — do not use it. It could have come from any install
channel, so remove it based on how it was installed, then re-run this skill (or
install Lemonade manually):
lemonadelemonade statusServer is running...Server is not runninglemonadePATH| Installed via | Uninstall with |
|---|---|
Windows | |
| Ubuntu/Debian apt/PPA | |
| pip | |
macOS | Delete the installed |
Never try to drive or auto-remove it for the user.
If no is found at all, install the latest version on the user's
behalf:
lemonade| OS | Install |
|---|---|
| Windows | Download |
| Ubuntu/Debian | |
| macOS (beta) | Download the |
After a Windows install the CLI lands in and
is added to the user PATH (new shells only); the setup script probes that
directory so it works in the same run.
%LOCALAPPDATA%\lemonade_server1b. Is the service running? Check . The
service auto-starts on install — there is no in modern
Lemonade.
lemonade status --jsonlemondlemonade serve | Action |
|---|---|
| Continue to Step 2. |
| Wait a few seconds for the auto-started service (the script polls |
Only if the automatic install genuinely fails (no , no ,
download blocked) should you stop and point the user at
https://lemonade-server.ai/docs/guide/install/.
apt-getsudoThe rest of this skill assumes the endpoint is
and no API key is required (the system-wide server defaults to no auth on
loopback). If the user has set , the routing rule template
in shows where to add the header.
http://localhost:13305/api/v1LEMONADE_API_KEYtemplates/local-ai-rule.mdAuthorizationscripts/setup_local_ai.py1a. 是否已安装新版 CLI? 运行。检查依据是功能而非版本号:新版Lemonade会显示或。若返回“invalid choice”/使用错误,则PATH中的是旧版、不兼容的构建(早于统一CLI的v10.1.0)——请勿使用。它可能来自任何安装渠道,请根据安装方式卸载,然后重新运行此技能(或手动安装Lemonade):
lemonadelemonade statusServer is running...Server is not runninglemonade| 安装方式 | 卸载命令 |
|---|---|
Windows | |
| Ubuntu/Debian apt/PPA | |
| pip | |
macOS | 删除已安装的 |
请勿尝试为用户自动卸载。
若未找到任何,则为用户安装最新版本:
lemonade| 操作系统 | 安装方式 |
|---|---|
| Windows | 从最新版本下载 |
| Ubuntu/Debian | |
| macOS(测试版) | 从最新版本下载 |
Windows安装后,CLI会位于,并添加到用户PATH中(仅新shell生效);设置脚本会探测此目录,因此在同一次运行中即可生效。
%LOCALAPPDATA%\lemonade_server1b. 服务是否正在运行? 检查。服务在安装时自动启动——新版Lemonade没有命令。
lemonade status --jsonlemondlemonade serve | 操作 |
|---|---|
| 继续步骤2。 |
| 等待几秒让自动启动的服务启动(脚本会轮询 |
本技能的其余部分假设端点为且无需API密钥(系统级服务器默认在回环接口上无认证)。若用户设置了,中的路由规则模板会显示添加头的位置。
http://localhost:13305/api/v1LEMONADE_API_KEYtemplates/local-ai-rule.mdAuthorizationDefault modality models (pulled on first use, not during setup)
默认多模态模型(首次使用时拉取,非设置期间)
Setup does not download these. The installed rule pulls each one the first
time that modality is requested. They are the Lite Collection defaults from
Lemonade OmniRouter, sized to keep token-and-cost savings real on commodity
hardware:
| Modality | Model | Size | Why this default |
|---|---|---|---|
| Image generation | | ~5 GB | Single-step generation, runs on CPU and AMD iGPU/dGPU |
| Text-to-speech | | ~0.3 GB | Only TTS model Lemonade currently supports; CPU-only, low latency |
| Speech-to-text | | ~0.1 GB | Smallest Whisper; fast on CPU. Upgrade to |
To write a different model ID into the rule, pass it to the setup script. For
example, to make future image requests use SDXL:
bash
python scripts/setup_local_ai.py --image-model SDXL-TurboThat model ID is written into the installed rule and pulled on its
first use. The same pattern works for and . For
larger / higher-quality alternatives (, ,
), see the
model picker in reference.md.
AGENTS.md--tts-model--stt-modelSDXL-TurboFlux-2-Klein-4BWhisper-Large-v3-Turbo设置过程中不会下载这些模型。已安装的规则会在首次请求对应模态时拉取相应模型。它们是Lemonade OmniRouter的精简集合默认模型,大小适合在普通硬件上实现真正的令牌和成本节约:
| 模态 | 模型 | 大小 | 默认原因 |
|---|---|---|---|
| 图像生成 | | ~5 GB | 单步生成,可在CPU和AMD iGPU/dGPU上运行 |
| 文本转语音 | | ~0.3 GB | 当前Lemonade仅支持此TTS模型;仅需CPU,低延迟 |
| 语音转文本 | | ~0.1 GB | 最小的Whisper模型;在CPU上运行速度快。若更看重准确性而非延迟,可升级为 |
要在规则中写入不同的模型ID,可将其传递给设置脚本。例如,要让未来的图像请求使用SDXL:
bash
python scripts/setup_local_ai.py --image-model SDXL-Turbo该模型ID会写入已安装的规则中,并在首次使用时拉取。同样的模式适用于和。如需更大/更高质量的替代模型(、、),请参阅reference.md中的模型选择器。
AGENTS.md--tts-model--stt-modelSDXL-TurboFlux-2-Klein-4BWhisper-Large-v3-TurboStep 2: install the routing rule into AGENTS.md
步骤2:将路由规则安装到AGENTS.md中
The rule is a Markdown block stored in .
Append it to the workspace's (create the file if missing). Both
Cursor and Claude Code load automatically on every turn, so the
agent will see the rule on its next message without any further setup.
templates/local-ai-rule.mdAGENTS.mdAGENTS.mdscripts/setup_local_ai.py<!-- BEGIN amd-skills:local-ai-use -->
...rule...
<!-- END amd-skills:local-ai-use -->If you write the file by hand, keep those exact markers. The script relies
on them for idempotent updates.
If the user's agent only respects a different convention, mirror the same
block to:
- (Claude Code, project-scoped) or
CLAUDE.md(global)~/.claude/CLAUDE.md - (Cursor user/project rules)
.cursor/rules/local-ai-use.mdc - (Gemini CLI)
GEMINI.md
The rule's content is identical; only the file location changes.
规则是存储在中的Markdown块。将其追加到工作区的中(若文件缺失则创建)。Cursor和Claude Code会在每次交互时自动加载,因此Agent会在下一次消息中看到该规则,无需额外设置。
templates/local-ai-rule.mdAGENTS.mdAGENTS.mdscripts/setup_local_ai.py<!-- BEGIN amd-skills:local-ai-use -->
...rule...
<!-- END amd-skills:local-ai-use -->若手动编写文件,请保留这些精确标记。脚本依赖它们实现幂等更新。
若用户的Agent仅支持其他约定,请将相同块复制到:
- (Claude Code,项目级)或
CLAUDE.md(全局)~/.claude/CLAUDE.md - (Cursor用户/项目规则)
.cursor/rules/local-ai-use.mdc - (Gemini CLI)
GEMINI.md
规则内容完全相同;仅文件位置不同。
What changes after this skill runs
技能运行后的变化
From the next turn onward, the agent reads the rule in on every
message. The rule explicitly tells the agent:
AGENTS.md- For image generation: call on the local server. Do not call any cloud image API and do not use the built-in
POST /api/v1/images/generationstool (that path bills tokens to the cloud provider).GenerateImage - For text-to-speech: call . Do not call cloud TTS providers (OpenAI TTS, ElevenLabs, etc.).
POST /api/v1/audio/speech - For speech-to-text: call . Do not call cloud transcription providers.
POST /api/v1/audio/transcriptions - Fallback: only fall back to a cloud API after one local attempt has failed and the user has been told the local call failed. Never silently fall back; the whole point of this skill is to keep cost predictable.
The agent's own text reasoning continues to use whatever LLM Cursor / Claude
Code / Codex is configured with. This skill does not redirect chat tokens;
it only redirects the multimodal calls that would otherwise leave the
machine.
从下一次交互开始,Agent会在每次消息时读取中的规则。规则明确告知Agent:
AGENTS.md- 图像生成:调用本地服务器的接口。请勿调用任何云图像API,也不要使用内置的
POST /api/v1/images/generations工具(该路径会向云提供商支付令牌费用)。GenerateImage - 文本转语音:调用接口。请勿调用云TTS提供商(OpenAI TTS、ElevenLabs等)。
POST /api/v1/audio/speech - 语音转文本:调用接口。请勿调用云转录提供商。
POST /api/v1/audio/transcriptions - 回退机制:仅在本地尝试失败且已告知用户本地调用失败后,才回退到云API。绝不静默回退;本技能的核心目的是保持成本可预测。
Agent自身的文本推理仍使用Cursor/Claude Code/Codex配置的LLM。本技能不会重定向聊天令牌;仅重定向原本会离开设备的多模态调用。
Troubleshooting cheatsheet
故障排除速查表
| Symptom | Cause | Recovery |
|---|---|---|
| CLI not installed | Re-run |
| An old, incompatible | Uninstall it the way it was installed (see the Step 1a table: |
| | Start it via the OS service manager — |
| Image model not downloaded | |
| Download target is a bad path (out of space, no write permission, quota, read-only mount). The write error may surface only in the server log while the console keeps showing progress | Check the target and free space first: |
| Image generation is slow on CPU (~4–5 min) | sd-cpp on CPU backend | Install the GPU backend on supported AMD hardware: |
| Input is not 16 kHz mono WAV | Re-encode with |
| TTS model not downloaded | |
| 401 Unauthorized on every request | User has set | Add |
| 症状 | 原因 | 解决方法 |
|---|---|---|
| CLI未安装 | 重新运行 |
| 旧版、不兼容的 | 按安装方式卸载旧版本(见步骤1a的表格: |
| | 通过操作系统服务管理器启动—— |
| 图像模型未下载 | 运行 |
| 下载目标路径存在问题(空间不足、无写入权限、配额限制、只读挂载)。写入错误可能仅在服务器日志中显示,而控制台仍显示进度 | 首先检查目标路径和可用空间: |
| CPU上图像生成速度慢(约4-5分钟) | 使用CPU后端的sd-cpp | 在支持的AMD硬件上安装GPU后端: |
| 输入不是16kHz单声道WAV | 使用 |
| TTS模型未下载 | 运行 |
| 所有请求均返回401未授权 | 用户设置了 | 在每个请求和规则块中添加 |
Verification checklist
验证清单
Mark this skill complete only when all of the following are true:
- reports the server running on port 13305.
lemonade status --json - The workspace contains the
AGENTS.mdblock. This is required even when Lemonade was already installed and running — generating an image alone does not complete the skill.amd-skills:local-ai-use - On a follow-up turn, asking the agent to "generate an image of X"
causes it to POST to (pulling the model on first use) rather than calling a cloud tool.
http://localhost:13305/api/v1/images/generations
If any box is unchecked, the user is still paying cloud cost for at least
one modality.
仅当所有以下条件满足时,才标记此技能已完成:
- 报告服务器在端口13305上运行。
lemonade status --json - 工作区的包含
AGENTS.md块。即使Lemonade已安装并运行,这也是必需的——仅生成图像并不代表技能完成。amd-skills:local-ai-use - 在后续交互中,要求Agent“生成一张X的图像”时,它会向发送POST请求(首次使用时拉取模型),而非调用云工具。
http://localhost:13305/api/v1/images/generations
若有任何一项未勾选,用户仍会为至少一种模态支付云服务费用。
Reference
参考资料
For the full model picker, alternate-quality options, the complete endpoint
reference, the API-key flow, and the OmniRouter tool definitions you can
hand to an agent's tool-calling loop, see reference.md.
如需完整的模型选择器、替代质量选项、完整的端点参考、API密钥流程以及可传递给Agent工具调用循环的OmniRouter工具定义,请参阅reference.md。