Skip to content

Commit cd05fed

Browse files
committed
feat(anyrouter): add AnyRouter plugin (Claude + Codex, MCP, skill, migration tools)
New plugin for wiring AnyRouter (universal OpenAI-compatible LLM gateway, 150+ models / 28+ providers) into coding agents. Contents: - skills/anyrouter/SKILL.md: contract, model ids, integration patterns, migration recipes (from OpenAI / Anthropic / OpenRouter), routing, streaming, app attribution, MCP overview - commands/anyrouter-migrate.md: /anyrouter:migrate slash command for surgical migration of an existing integration - agents/anyrouter-integrator.md: specialist sub-agent - .mcp.json: remote MCP at https://anyrouter.dev/api/v1/mcp via mcp-remote - references/: frozen snapshot of 14 canonical AnyRouter docs for offline use - .claude-plugin/ and .codex-plugin/ manifests with parity - Registered in marketplace.json, .claude-plugin/marketplace.json, and .agents/plugins/marketplace.json (new "ai" / "AI" category) scripts/validate-plugins.sh: 34/34 pass.
1 parent ccba44d commit cd05fed

25 files changed

Lines changed: 2186 additions & 3 deletions

.agents/plugins/marketplace.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,18 @@
195195
"authentication": "ON_INSTALL"
196196
},
197197
"category": "Design"
198+
},
199+
{
200+
"name": "anyrouter",
201+
"source": {
202+
"source": "local",
203+
"path": "./anyrouter"
204+
},
205+
"policy": {
206+
"installation": "AVAILABLE",
207+
"authentication": "ON_INSTALL"
208+
},
209+
"category": "AI"
198210
}
199211
]
200212
}

.claude-plugin/marketplace.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,11 @@
7878
"name": "good-html",
7979
"source": "./good-html",
8080
"description": "Generate or review high-density, interactive, self-contained HTML artifacts based on Thariq Shihipar's 'Unreasonable Effectiveness of HTML' patterns."
81+
},
82+
{
83+
"name": "anyrouter",
84+
"source": "./anyrouter",
85+
"description": "Wire AnyRouter into coding agents. Universal OpenAI-compatible LLM gateway for 150+ models, migration recipes from Anthropic/OpenAI/OpenRouter, and a remote MCP server for keys and credits."
8186
}
8287
]
8388
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "anyrouter",
3+
"version": "1.0.0",
4+
"description": "Wire AnyRouter into Claude Code, Codex, Cursor, and other coding agents. Universal OpenAI-compatible router for 150+ models, with migration recipes from Anthropic, OpenAI, and OpenRouter, plus a remote MCP server for key and credit management.",
5+
"author": {
6+
"name": "duyet",
7+
"url": "https://github.com/duyet"
8+
},
9+
"homepage": "https://anyrouter.dev",
10+
"repository": "https://github.com/duyet/claude-plugins",
11+
"license": "MIT"
12+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"name": "anyrouter",
3+
"version": "1.0.0",
4+
"description": "Wire AnyRouter into Claude Code, Codex, Cursor, and other coding agents. Universal OpenAI-compatible router for 150+ models, with migration recipes from Anthropic, OpenAI, and OpenRouter, plus a remote MCP server for key and credit management.",
5+
"author": {
6+
"name": "duyet"
7+
},
8+
"skills": "./skills/",
9+
"commands": "./commands/",
10+
"agents": "./agents/",
11+
"mcp": "./.mcp.json",
12+
"interface": {
13+
"displayName": "AnyRouter",
14+
"shortDescription": "Universal OpenAI-compatible LLM router (150+ models). Migrate from Anthropic / OpenAI / OpenRouter; manage keys via MCP.",
15+
"developerName": "duyet",
16+
"category": "AI",
17+
"capabilities": [
18+
"Skill",
19+
"Command",
20+
"Agent",
21+
"MCP"
22+
],
23+
"links": {
24+
"homepage": "https://anyrouter.dev",
25+
"docs": "https://anyrouter.dev/docs",
26+
"mcp": "https://anyrouter.dev/docs/mcp"
27+
}
28+
}
29+
}

anyrouter/.mcp.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"mcpServers": {
3+
"anyrouter": {
4+
"command": "npx",
5+
"args": ["-y", "mcp-remote", "https://anyrouter.dev/api/v1/mcp"],
6+
"description": "AnyRouter MCP — list models, manage API keys, check credits, browse presets, and search conversations. Authorizes via OAuth on first use."
7+
}
8+
}
9+
}

anyrouter/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2026 duyet
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

anyrouter/README.md

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# AnyRouter Plugin
2+
3+
Wire [AnyRouter](https://anyrouter.dev) — a universal, OpenAI-compatible LLM gateway for 150+ models across 28+ providers — into Claude Code, Codex, Cursor, and any other coding agent that accepts a custom base URL.
4+
5+
This plugin ships as both a **Claude Code plugin** (`.claude-plugin/`) and a **Codex plugin** (`.codex-plugin/`), and bundles a remote **MCP server** for key and credit management.
6+
7+
## What you get
8+
9+
- **`anyrouter` skill** — discoverable knowledge for the agent: contract, model ids, integration patterns, migration recipes (from Anthropic, OpenAI, OpenRouter), routing, streaming, app attribution.
10+
- **`/anyrouter:migrate` command** — interactive migration of an existing LLM integration to AnyRouter.
11+
- **`anyrouter-integrator` agent** — sub-agent that performs surgical migrations on demand.
12+
- **MCP server** — remote MCP at `https://anyrouter.dev/api/v1/mcp` for `list_models`, `get_credits`, `list_keys`, `create_key`, `revoke_key`, `list_presets`, `list_conversations`.
13+
- **`references/`** — a frozen snapshot of the AnyRouter docs (quickstart, dashboard, migration guides, MCP, routing, app attribution) so the agent can answer offline.
14+
15+
## Install
16+
17+
### Claude Code
18+
19+
```bash
20+
/plugin marketplace add duyet/claude-plugins
21+
/plugin install anyrouter@duyet-claude-plugins
22+
```
23+
24+
Then set your key:
25+
26+
```bash
27+
export ANYROUTER_API_KEY="sk-ar-..."
28+
```
29+
30+
(Get one at https://anyrouter.dev/dashboard/keys.)
31+
32+
### Codex
33+
34+
The plugin's `.codex-plugin/plugin.json` declares Skill, Command, Agent, and MCP capabilities. Install via your Codex plugin loader the same way you install other plugins from `duyet/claude-plugins`.
35+
36+
### MCP only
37+
38+
If you only want the AnyRouter MCP server in another client (Claude Desktop, Cursor, Claude Code CLI, OpenCode), point it at `https://anyrouter.dev/api/v1/mcp` — full per-client setup is in [`references/mcp.md`](references/mcp.md).
39+
40+
## Quick usage
41+
42+
After installing, the agent will load the `anyrouter` skill on its own when you say things like:
43+
44+
- "Add AnyRouter to this project."
45+
- "Migrate this from OpenAI to AnyRouter."
46+
- "Move my OpenRouter calls to AnyRouter."
47+
- "Point Claude Code at AnyRouter."
48+
- "List my AnyRouter API keys." (uses MCP)
49+
- "How much credit do I have left?" (uses MCP)
50+
51+
You can also invoke the slash command directly:
52+
53+
```
54+
/anyrouter:migrate
55+
```
56+
57+
## Contract
58+
59+
| Setting | Value |
60+
| --- | --- |
61+
| Base URL | `https://anyrouter.dev/api/v1` |
62+
| API key env | `ANYROUTER_API_KEY` (prefix `sk-ar-`) |
63+
| Model id format | `provider/model` |
64+
| Default model | `openai/gpt-5.4-mini` |
65+
| Anthropic-native base | `https://anyrouter.dev/api` (for `/messages`) |
66+
| MCP endpoint | `https://anyrouter.dev/api/v1/mcp` |
67+
68+
## Reference snapshot
69+
70+
The `references/` directory contains the canonical AnyRouter docs at the time the plugin was published. Live docs always win — fetch fresh content from https://anyrouter.dev/docs for any current question.
71+
72+
| Topic | File |
73+
| --- | --- |
74+
| Quickstart | `references/getting-started_quickstart.md` |
75+
| Dashboard tour | `references/guides_dashboard-tour.md` |
76+
| Claude Code | `references/guides_claude-code.md` |
77+
| Hermes Agent | `references/guides_hermes-agent.md` |
78+
| OpenClaw | `references/guides_openclaw.md` |
79+
| AI agent integration | `references/guides_ai-agent-integration.md` |
80+
| Streaming | `references/guides_streaming.md` |
81+
| Migrate from OpenAI | `references/guides_migrate-from-openai.md` |
82+
| Migrate from Anthropic | `references/guides_migrate-from-anthropic.md` |
83+
| Migrate from OpenRouter | `references/guides_migrate-from-openrouter.md` |
84+
| App attribution | `references/features_app-attribution.md` |
85+
| Smart routing | `references/features_routing.md` |
86+
| MCP server | `references/mcp.md` |
87+
| MCP API reference | `references/api-reference_mcp.md` |
88+
89+
## License
90+
91+
MIT. See [LICENSE](LICENSE).
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
name: anyrouter-integrator
3+
description: Specialist for wiring AnyRouter into an existing codebase. Use proactively when the task is "add AnyRouter", "migrate to AnyRouter", "swap LLM provider for AnyRouter", "point our agent at AnyRouter", or any equivalent. Has full context on the AnyRouter contract, model ids, routing, and MCP.
4+
tools: Read, Edit, Write, Glob, Grep, Bash
5+
---
6+
7+
# AnyRouter Integrator
8+
9+
You wire AnyRouter into projects. Load the `anyrouter` skill, then work as follows.
10+
11+
## Contract (memorize)
12+
13+
- Base URL: `https://anyrouter.dev/api/v1`
14+
- Anthropic-native base: `https://anyrouter.dev/api` (for `/messages`)
15+
- Key env: `ANYROUTER_API_KEY`, prefix `sk-ar-`
16+
- Model id format: `provider/model`
17+
- Default model: `openai/gpt-5.4-mini`
18+
- MCP endpoint: `https://anyrouter.dev/api/v1/mcp`
19+
20+
## Operating rules
21+
22+
1. **Read before write.** Always `Grep` for existing LLM clients, base URLs, and env vars first. Reuse what's there; don't add a parallel client.
23+
2. **Surgical edits only.** Change base URL, key, and model id. Leave everything else — including streaming flags, error handling, and feature flags — untouched.
24+
3. **Never inline a literal key.** Always go through env.
25+
4. **Model id mapping.** Convert bare ids:
26+
- `gpt-4o-mini``openai/gpt-5.4-mini`
27+
- `gpt-4o``openai/gpt-5.4`
28+
- `claude-3-5-sonnet-*``anthropic/claude-sonnet-4.6`
29+
- `claude-3-5-haiku-*``anthropic/claude-haiku-4.5`
30+
- Unknown bare ids → leave the existing slug and add a `// TODO(anyrouter): pick a current model id from https://anyrouter.dev/models` comment.
31+
5. **Streaming preserved.** If the original code streams, the migrated code streams.
32+
6. **Smoke test before declaring done.** Hit `/chat/completions` once with a 20-token prompt and report the result.
33+
7. **Speak plainly about failures.** If something didn't migrate cleanly, say so.
34+
35+
## When to consider the Anthropic-native path
36+
37+
If the project depends on Anthropic SDK features that the OpenAI-compatible endpoint can't replicate (e.g. specific tool-use block shapes, system message handling that breaks under `/chat/completions`), keep the Anthropic SDK and set `ANTHROPIC_BASE_URL=https://anyrouter.dev/api`. Otherwise prefer unifying on `/chat/completions`.
38+
39+
## Default deliverables
40+
41+
For every migration, leave behind:
42+
43+
- Updated client construction (one place, env-driven).
44+
- Updated model ids.
45+
- `.env.example` entry for `ANYROUTER_API_KEY`.
46+
- Smoke test (or run-and-report if a test harness exists).
47+
- Short summary listing files changed, TODOs left, and the smoke-test outcome.
48+
49+
## When to hand back
50+
51+
Hand back to the user (don't keep guessing) when:
52+
53+
- The project uses a private SDK that doesn't accept a custom base URL.
54+
- Provider-specific request shapes (e.g. non-standard tool blocks) need a product decision.
55+
- Env-loading is non-obvious (custom secret manager, infra-defined env, etc.).
56+
- Smoke test fails for a reason that isn't "bad key".
57+
58+
State clearly what you need from the user.
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
---
2+
description: Migrate the current project's LLM integration to AnyRouter. Detect existing OpenAI / Anthropic / OpenRouter usage, swap base URL + key + model ids, preserve behavior, and add a smoke test.
3+
---
4+
5+
# /anyrouter:migrate
6+
7+
You are migrating this project to **AnyRouter** — a universal OpenAI-compatible LLM gateway at `https://anyrouter.dev/api/v1`. Read the `anyrouter` skill before doing anything; it has the contract, model-id rules, and migration recipes.
8+
9+
## Step 1 — Detect the current integration
10+
11+
Search the repo for any of these signals and report what you find before changing anything:
12+
13+
- Imports: `from openai import`, `import OpenAI`, `import Anthropic`, `from anthropic`, `import openrouter`.
14+
- Base URLs: `api.openai.com`, `api.anthropic.com`, `openrouter.ai/api/v1`.
15+
- Env vars: `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, `OPENROUTER_API_KEY`, `ANTHROPIC_BASE_URL`, `OPENAI_BASE_URL`.
16+
- Model ids: bare `gpt-*`, bare `claude-*`, `provider/model` slugs.
17+
- SDK instances: `new OpenAI({...})`, `OpenAI(base_url=...)`, `Anthropic({...})`.
18+
19+
Output a short table: file, line, current value, what it becomes.
20+
21+
## Step 2 — Confirm the plan with the user
22+
23+
Before editing, ask the user:
24+
25+
1. Which key env var should the migrated code read — `ANYROUTER_API_KEY` (default) or an existing project name?
26+
2. Should `anthropic/*` calls keep the `/messages` endpoint (Anthropic-native) or move to `/chat/completions` (unified)?
27+
3. Pin a single model, read from env, or keep per-call overrides?
28+
4. Should `X-AnyRouter-Title / -Source / -Version` headers be added for attribution?
29+
30+
Do not invent answers. If the user says "you decide", default to: `ANYROUTER_API_KEY`, `/chat/completions` for everything, model from `ANYROUTER_MODEL ?? "openai/gpt-5.4-mini"`, attribution headers on.
31+
32+
## Step 3 — Edit minimally
33+
34+
Apply the exact rules from the skill:
35+
36+
- Base URL → `https://anyrouter.dev/api/v1` (or `https://anyrouter.dev/api` for Anthropic-native).
37+
- Key → `process.env.ANYROUTER_API_KEY` (or chosen env var). Never inline a literal.
38+
- Model ids → `provider/model`. Map common bare ids:
39+
- `gpt-4o-mini``openai/gpt-5.4-mini`
40+
- `gpt-4o``openai/gpt-5.4`
41+
- `claude-3-5-sonnet-*``anthropic/claude-sonnet-4.6`
42+
- `claude-3-5-haiku-*``anthropic/claude-haiku-4.5`
43+
- When uncertain, leave the existing id and add a TODO so the user can pick a current model from https://anyrouter.dev/models.
44+
- Reuse the existing LLM client module if one exists. Do **not** add a new one in parallel.
45+
- Keep request/response shapes, streaming behavior, and error handling identical.
46+
47+
Touch only what you must. Don't refactor unrelated code.
48+
49+
## Step 4 — Update `.env.example` and docs
50+
51+
- Add `ANYROUTER_API_KEY=` to `.env.example`.
52+
- If a README mentions `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` / `OPENROUTER_API_KEY`, replace those mentions with `ANYROUTER_API_KEY` and link to https://anyrouter.dev/docs/getting-started/quickstart.
53+
54+
## Step 5 — Smoke test
55+
56+
Add (or update) a smoke test that exercises one short prompt end-to-end. Prefer the project's existing test framework; otherwise drop a one-shot script:
57+
58+
```bash
59+
curl https://anyrouter.dev/api/v1/chat/completions \
60+
-H "Authorization: Bearer $ANYROUTER_API_KEY" \
61+
-H "Content-Type: application/json" \
62+
-d '{"model":"openai/gpt-5.4-mini","messages":[{"role":"user","content":"Reply with: anyrouter-ok"}],"max_tokens":20}'
63+
```
64+
65+
Run it. If it fails, do not declare the migration done — diagnose and fix.
66+
67+
## Step 6 — Summary
68+
69+
Report back:
70+
71+
- Files changed (count + paths).
72+
- Bare model ids that were left as TODO for the user.
73+
- Whether streaming, tool-use, and error paths were re-verified.
74+
- The smoke test result.
75+
76+
If anything was skipped, **say so explicitly**. Don't hide uncertainty.

0 commit comments

Comments
 (0)