# Muse 实操教程:任意公开API包装成Muse能用的连接器
**作者**: Ryan
**日期**: 2026-10-27T04:18:07.000Z
**来源**: [https://x.com/7998l201/status/2114934644852273446](https://x.com/7998l201/status/2114934644852273446)
---

> 参考来源:Grok Bot 「tinkabot」(作者 lauren)——把 API 包装成插件:先看数据形状、最小脚手架、本地验证,再交付使用。
> 本篇结论:Muse 能完整跑通。 2026-10-25 已把 OpenRouter 模型 API 包成本机自定义连接器,三条命令全部对真实 API 跑通;本站此前已用同一规范建成汇率连接器(Frankfurter),方法可复用。
# 你能得到什么
一个属于你的“小工具”:某个 API 从此变成 Muse 随时能调用的能力——你说人话,它自己去调接口拿真数据,而不是每次临时拼凑、或者凭记忆编数字。本篇以 OpenRouter 模型目录为例(免 key、适合练手),方法适用于一切有文档的公开 API。
# 先理解:连接器由三件套组成
1. connector.yaml:登记这个连接器是谁、连哪个域名、要不要鉴权;
2. CONNECTOR.md:给 Muse 看的说明书——有哪些命令、什么口径、什么注意事项;
3. 助手脚本(bin/ 下):真正干活的程序,把 API 包成几个简单子命令。
这套结构的好处是:脚本负责稳定执行,说明书负责让 Muse 每次都用对口径——数字类任务最怕口径漂移,这套结构就是治这个的。
# 手把手步骤
第 1 步:选 API,先看数据形状。对 Muse 说(可照抄):
> “我想把 OpenRouter 的模型列表 API 包成连接器。先别写代码:去拉一次它的公开接口,把返回的数据形状给我看——有哪些字段、价格字段长什么样、怎么判断支不支持工具调用。”
先看形状再动手,能避免写完才发现字段对不上。实跑确认:该接口免 key 返回全量模型 JSON,价格在 pricing 字段下,工具支持看 supported_parameters。

第 2 步:让它按三件套建成最小版本。
> “按本站自定义连接器的规范建成它:助手脚本先给三个子命令——list 列全部、search 按关键词过滤、free 只看真免费(口径:输入输出单价都为 0)。说明书里把口径和限制写清。”
顺序记牢:数据形状优先、最小脚手架、本地实跑验证——顺序反了都会返工。

第 3 步:真跑验收(这一步不许跳)。让 Muse 当场执行三条命令并把原始输出给你看。实跑结果:
- list → 467 个模型;
- search llama → 13 个命中;
- free → 20 个(与《Muse 实操教程:找出“真免费且支持工具调用”的模型,并每天盯住名单变化》里用独立脚本筛出的数字一致,两条路径互相印证)。
数字能对上、命令能复跑,才算建成;只写完文件没跑过的连接器等于半成品。

第 4 步:之后的使用方式。建成后你不需要记命令。直接说人话:“查一下 OpenRouter 现在有多少免费模型”“搜一下带 llama 的模型”,Muse 会自己走连接器。口径已经写死在说明书里,不会今天一个标准明天一个标准。

# 实跑记录(证据)
- 连接器落盘位置:~/workspace/custom-connectors/custom.openrouter/(yaml + 说明书 + bin/models.py 三件套齐全)。
- 免费口径与《Muse 实操教程:找出“真免费且支持工具调用”的模型,并每天盯住名单变化》一致:单价双零;两个独立实现(筛选脚本 vs 连接器)在同一时点给出相同数字(467 总数 / 20 免费)。
- 本连接器只做只读目录查询,不做模型推理——推理调用需要 API key,是另一个连接器的事,说明书中已注明。
- 产物形态是本机自定义连接器:装在本机、随说随调,自用为主,不走插件市场发布。
# 常见问题
- 要鉴权的 API 也能包吗? 能。密钥必须由你本人在官方页面获取并走安全录入,连接器只记录“密钥从哪取”,绝不把明文写进文件或说明书。
- 包一个 API 大概多久? 文档齐全、免 key 的公开 API,一次会话内可建成并验完;要鉴权、分页复杂或返回结构脏的,要多留清洗与试错时间。
- 包完会不会很快失效? 对方改接口就会失效。验收习惯能救命:每次用之前让 Muse 先跑一条探活命令,失败了先修连接器再谈业务。

# 边界
- 只包你有权使用的 API;对方条款禁止自动访问的,不要包。
- 连接器给的是“能调通”的能力,不保证对方数据的准确性——关键数字仍要按来源核对。
# 附:实跑实例
## 1. connector.yaml(全文)
```
provider: openrouter
name: OpenRouter Models
hosts:
- openrouter.ai
auth: none
description: 无密钥公开模型目录 API(OpenRouter),列出全部模型、按关键词过滤、只看真免费模型(输入输出价格均为 0)。
```
## 2. CONNECTOR.md 要点
- 无需注册、无需 API key、无需凭证录入:目录接口公开只读;真正调用模型推理才需要 key,本连接器不做推理。
- Helper 为 bin/models.py(Python 标准库实现,无第三方依赖),已通过语法检查并完成真实调用验证(2026-10-25)。
- 三个子命令:list 列全部;search --q <关键词> 按 id / name 过滤(不分大小写);free 只看真免费。
- 免费判定口径写死:pricing.prompt == 0 且 pricing.completion == 0——真免费,不是限时试用价。
- 每个模型的输出字段:id、name、context_length、pricing_per_1m(由按 token 单价换算为每百万 token 美元价,便于横向比较)。
- 目录是动态的:模型上下架与免费名单每天都可能变,引用数量时必须注明查询日期。
- “免费”指单价为 0;免费模型通常有速率限制(如每日请求数),目录接口不返回该信息,实际调用前看模型页说明。
- 接口只读、无写操作,无审批点。
## 3. 三条命令的真实输出(附录生成时点复跑)
> 说明:以下输出为本附录生成时点(2026-10-26)当场复跑 bin/models.py 的真实结果。目录是动态数据,数字可能与正文 2026-10-25 时点(467 / 13 / 20)不同,属正常现象;本次复跑恰好仍为 467 / 13 / 20。
## 命令一:list(列出全部模型)
```
{
"count": 467,
"models": [
{
"id": "moonshotai/kimi-k3.1-pro",
"name": "MoonshotAI: Kimi K3.1 Pro",
"context_length": 1048576,
"pricing_per_1m": {
"prompt": 2.0,
"completion": 10.0
}
},
{
"id": "recursive/flint-v1.0:free",
"name": "Recursive: Flint (free)",
"context_length": 262144,
"pricing_per_1m": {
"prompt": 0.0,
"completion": 0.0
}
},
{
"id": "minimax/minimax-m3.1-flash",
"name": "MiniMax: MiniMax M3.1 Flash",
"context_length": 1048576,
"pricing_per_1m": {
"prompt": 0.15,
> ……(list 输出共 467 条,此处仅示开头部分;完整输出为当场复跑的真实结果,结构与上方一致。search 与 free 两条命令的完整输出见下。)
#### 命令二:search --q llama(按关键词过滤)
```
json { "query": "llama", "count": 13, "models": [ { "id": "meta-llama/llama-guard-4-12b", "name": "Meta: Llama Guard 4 12B", "contextlength": 163840, "pricingper1m": { "prompt": 0.18, "completion": 0.18 } }, { "id": "meta-llama/llama-4-maverick", "name": "Meta: Llama 4 Maverick", "contextlength": 524288, "pricingper1m": { "prompt": 0.1875, "completion": 0.6525 } }, { "id": "meta-llama/llama-4-scout", "name": "Meta: Llama 4 Scout", "contextlength": 1310720, "pricingper1m": { "prompt": 0.1, "completion": 0.3 } }, { "id": "aion-labs/aion-rp-llama-3.1-8b", "name": "AionLabs: Aion-RP 1.0 (8B)", "contextlength": 32768, "pricingper1m": { "prompt": 0.8, "completion": 1.6 } }, { "id": "meta-llama/llama-3.3-70b-instruct", "name": "Meta: Llama 3.3 70B Instruct", "contextlength": 131072, "pricingper1m": { "prompt": 0.1, "completion": 0.32 } }, { "id": "meta-llama/llama-3.2-1b-instruct", "name": "Meta: Llama 3.2 1B Instruct", "contextlength": 60000, "pricingper1m": { "prompt": 0.027, "completion": 0.201 } }, { "id": "meta-llama/llama-3.2-3b-instruct", "name": "Meta: Llama 3.2 3B Instruct", "contextlength": 131072, "pricingper1m": { "prompt": 0.05, "completion": 0.33 } }, { "id": "sao10k/l3.1-euryale-70b", "name": "Sao10K: Llama 3.1 Euryale 70B v2.2", "contextlength": 131072, "pricingper1m": { "prompt": 0.85, "completion": 0.85 } }, { "id": "nousresearch/hermes-3-llama-3.1-70b", "name": "Nous: Hermes 3 70B Instruct", "contextlength": 131072, "pricingper1m": { "prompt": 0.7, "completion": 0.7 } }, { "id": "nousresearch/hermes-3-llama-3.1-405b", "name": "Nous: Hermes 3 405B Instruct", "contextlength": 131072, "pricingper1m": { "prompt": 1.0, "completion": 1.0 } }, { "id": "sao10k/l3-lunaris-8b", "name": "Sao10K: Llama 3 8B Lunaris", "contextlength": 8192, "pricingper1m": { "prompt": 0.04, "completion": 0.05 } }, { "id": "meta-llama/llama-3.1-70b-instruct", "name": "Meta: Llama 3.1 70B Instruct", "contextlength": 131072, "pricingper1m": { "prompt": 0.4, "completion": 0.4 } }, { "id": "meta-llama/llama-3.1-8b-instruct", "name": "Meta: Llama 3.1 8B Instruct", "contextlength": 131072, "pricingper_1m": { "prompt": 0.05, "completion": 0.08 } } ] }
```
#### 命令三:free(只看真免费模型)
```
json { "count": 20, "models": [ { "id": "recursive/flint-v1.0:free", "name": "Recursive: Flint (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "xingchen-agi/xing4.0-29b-a4b:free", "name": "XingChen: Xing4.0 29B A4B (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3.5-super-vl:free", "name": "NVIDIA: Nemotron 3.5 Super VL (free)", "contextlength": 1000000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "dots-studio/dots-3-note-preview:free", "name": "Dots Studio: Dots3-Note Preview (free)", "contextlength": 512000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "liquid/lfm-2.5-2.6b:free", "name": "LiquidAI: LFM2.5-2.6B (free)", "contextlength": 65536, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3.5-lightning:free", "name": "NVIDIA: Nemotron 3.5 Lightning (free)", "contextlength": 1000000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "thinkingmachines/inkling-small:free", "name": "Thinking Machines: Inkling Small (free)", "contextlength": 1048576, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "poolside/laguna-s-2.1:free", "name": "Poolside: Laguna S 2.1 (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "thinkingmachines/inkling:free", "name": "Thinking Machines: Inkling (free)", "contextlength": 1048576, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "poolside/laguna-xs-2.1:free", "name": "Poolside: Laguna XS 2.1 (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "cohere/north-mini-code:free", "name": "Cohere: North Mini Code (free)", "contextlength": 256000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3.5-content-safety:free", "name": "NVIDIA: Nemotron 3.5 Content Safety (free)", "contextlength": 128000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3-ultra-550b-a55b:free", "name": "NVIDIA: Nemotron 3 Ultra (free)", "contextlength": 1000000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3-nano-omni-30b-a3b-reasoning:free", "name": "NVIDIA: Nemotron 3 Nano Omni (free)", "contextlength": 256000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "google/gemma-4-26b-a4b-it:free", "name": "Google: Gemma 4 26B A4B (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "google/gemma-4-31b-it:free", "name": "Google: Gemma 4 31B (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "google/lyria-3-pro-preview", "name": "Google: Lyria 3 Pro Preview", "contextlength": 1048576, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "google/lyria-3-clip-preview", "name": "Google: Lyria 3 Clip Preview", "contextlength": 1048576, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "nvidia/nemotron-3-super-120b-a12b:free", "name": "NVIDIA: Nemotron 3 Super (free)", "contextlength": 262144, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } }, { "id": "openrouter/free", "name": "Free Models Router", "contextlength": 200000, "pricingper1m": { "prompt": 0.0, "completion": 0.0 } } ] } ` 还没有注册好Muse ,不想折腾注册的朋友,可以直接安排!Muse 成品号、还有Muse 邀请码助力,详情请查看我的置顶帖;
## 相关链接
- [Ryan](https://x.com/7998l201)
- [@7998l201](https://x.com/7998l201)
- [5.1K](https://x.com/7998l201/status/2114934644852273446/analytics)
- [Upgrade to Plus](https://x.com/i/premium_sign_up)
- [12:18 PM · Oct 27, 2026](https://x.com/7998l201/status/2114934644852273446)
- [5,144 Views](https://x.com/7998l201/status/2114934644852273446/analytics)
---
*导出时间: 2026/10/27 18:17:58*