Skip to content

feat: add ClawRouter as a provider for cost-optimized model routing#11751

Merged
RomneyDa merged 13 commits intocontinuedev:mainfrom
1bcMax:feat/clawrouter-provider
Mar 26, 2026
Merged

feat: add ClawRouter as a provider for cost-optimized model routing#11751
RomneyDa merged 13 commits intocontinuedev:mainfrom
1bcMax:feat/clawrouter-provider

Conversation

@1bcMax
Copy link
Copy Markdown
Contributor

@1bcMax 1bcMax commented Mar 23, 2026

Summary

Add ClawRouter as a new provider option in Continue. ClawRouter is an open-source LLM router that automatically selects the cheapest capable model for each request based on prompt complexity.

Why

Users frequently hit cost and provider issues with Continue (e.g., #10298 OpenRouter 402 errors, general model selection friction). ClawRouter addresses this by:

  • Automatic model selection — 15-dimension prompt complexity scoring routes simple requests to cheap models (Haiku/Flash) and complex requests to capable ones (Opus/GPT-4o)
  • 78-96% cost savings on blended inference costs
  • OpenAI-compatible API — runs locally at localhost:1337

Changes

  • packages/openai-adapters/src/apis/ClawRouter.ts — API adapter extending OpenAI
  • packages/openai-adapters/src/index.ts — Register clawrouter provider
  • packages/openai-adapters/src/types.ts — Add clawrouter to provider type union
  • gui/src/pages/AddNewModel/configs/models.ts — Add ClawRouter models (auto, free, eco)
  • gui/src/pages/AddNewModel/configs/providers.ts — Add ClawRouter provider config
  • gui/public/logos/clawrouter.png — Provider logo
  • docs/customize/model-providers/top-level/clawrouter.mdx — Documentation

Testing

  • TypeScript builds successfully
  • Provider appears in model selection UI
  • Models connect to local ClawRouter instance

Related

Closes #10843


Disclosure: I maintain ClawRouter.


Summary by cubic

Adds clawrouter as a provider for automatic, cost‑optimized model routing via a local OpenAI‑compatible API. Includes four routing tiers, UI/docs wiring, analytics headers, tests, and post‑review fixes (docs moved to /more, logo resized, examples corrected).

  • New Features

    • LLM: ClawRouter (extends OpenAI) with defaults (apiBase http://localhost:1337/v1/, model blockrun/auto), reasoning fields, edit prompt, and registration in LLMClasses.
    • API/SDK: ClawRouterApi, constructLlmApi case, AiSdk provider map; sends User-Agent: Continue/<version|IDE> and X-Continue-Provider: clawrouter.
    • Capabilities: added to templating/image autodetect; PROVIDER_TOOL_SUPPORT for routed models and common patterns; provider enums/constants updated (VS Code schema).
    • UI/docs: provider + four presets (blockrun/auto, blockrun/free, blockrun/eco, blockrun/premium), updated logo, docs at /customize/model-providers/more/clawrouter (setup, tiers, wallet/x402, switching, error handling, cost monitoring, OpenRouter comparison).
    • Tests: unit tests for ClawRouter and ClawRouterApi headers/config, plus tool support tests.
    • Merge: resolved upstream changes; preserved MiniMax + clawrouter presets.
  • Migration

    • Run npx clawrouter (serves at http://localhost:1337), then add a ClawRouter preset or set a custom apiBase.
    • Use blockrun/free without payment; fund the auto‑created wallet for blockrun/eco, blockrun/auto, and blockrun/premium.

Written for commit c108797. Summary will update on new commits.

@1bcMax 1bcMax requested a review from a team as a code owner March 23, 2026 23:32
@1bcMax 1bcMax requested review from Patrick-Erichsen and removed request for a team March 23, 2026 23:32
@dosubot dosubot bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Mar 23, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 23, 2026

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 7 files


Since this is your first cubic review, here's how it works:

  • cubic automatically reviews your code and comments on bugs and improvements
  • Teach cubic by replying to its comments. cubic learns from your replies and gets better over time
  • Add one-off context when rerunning by tagging @cubic-dev-ai with guidance or docs links (including llms.txt)
  • Ask questions if you need clarification on any suggestion

@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 23, 2026

Updated PR Summary

Why This Matters for Continue Users

Problem: Users frequently hit cost and credit issues with LLM providers:

  • Error: gpt-5-openrouter - 402 #10298 — OpenRouter 402 errors when users run out of credits
  • General model selection friction — users manually switch between cheap/expensive models

Solution: ClawRouter provides automatic, intelligent model routing:

  • 78-96% cost savings on blended inference costs
  • Zero configuration — just works out of the box
  • Quality preservation — complex tasks still go to capable models

How It Works

ClawRouter uses a 15-dimension prompt complexity scoring system:

Request Type Example Routed To
Simple "Fix this typo" Claude Haiku, Gemini Flash
Medium "Explain this function" Claude Sonnet, GPT-4o-mini
Complex "Architect this system" Claude Opus, GPT-4o

Latest Updates

  • Added User-Agent headers (User-Agent: Continue/IDE) to track Continue integration usage
  • Enhanced documentation with troubleshooting, cost monitoring, and OpenRouter comparison
  • Added ClawRouter to the providers overview page

Quick Start for Reviewers

# Terminal 1: Start ClawRouter
npx clawrouter

# Terminal 2: Test the endpoint
curl http://localhost:1337/v1/models

Happy to address any feedback!

@1bcMax 1bcMax force-pushed the feat/clawrouter-provider branch from 9b01176 to 72059f5 Compare March 23, 2026 23:46
@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 23, 2026

I have read the CLA Document and I hereby sign the CLA

@1bcMax 1bcMax force-pushed the feat/clawrouter-provider branch from 72059f5 to cf29d1f Compare March 23, 2026 23:48
@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 23, 2026

recheck

1bcMax added 4 commits March 23, 2026 23:49
ClawRouter is an open-source LLM router that automatically selects the
cheapest capable model for each request based on prompt complexity,
providing 78-96% cost savings on blended inference costs.

Changes:
- Add ClawRouterApi class extending OpenAI adapter
- Add 'clawrouter' provider to the type system
- Add ClawRouter models (auto, free, eco)
- Add ClawRouter provider config with UI setup
- Add ClawRouter logo
- Add documentation (clawrouter.mdx)

Closes continuedev#10843
- Add ClawRouter to providers overview
- Expand documentation with:
  - Model capabilities configuration
  - Multiple roles setup
  - Troubleshooting section
  - Cost monitoring
  - Comparison with OpenRouter
  - Complexity dimensions explanation
- Add ClawRouter.ts extending OpenAI base class
- Register ClawRouter in llms/index.ts
- Add 'User-Agent: Continue/IDE' header to identify Continue requests
- Add 'X-Continue-Provider: clawrouter' header for routing analytics
- Enhanced documentation with features list

This helps ClawRouter optimize routing decisions based on integration
source and enables better analytics for the Continue community.
@1bcMax 1bcMax force-pushed the feat/clawrouter-provider branch from cf29d1f to c3d983b Compare March 23, 2026 23:49
@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 23, 2026

recheck

- Add clawrouter to PROVIDER_HANDLES_TEMPLATING (autodetect.ts)
- Add clawrouter to PROVIDER_SUPPORTS_IMAGES (autodetect.ts)
- Add clawrouter tool support function (toolSupport.ts)
- Add supportsReasoningField and supportsReasoningDetailsField
- Add promptTemplates with osModelsEditPrompt
- Match OpenRouter implementation patterns
@dosubot dosubot bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Mar 23, 2026
1bcMax added 4 commits March 23, 2026 23:56
- Add clawrouter to VS Code config_schema.json provider enum
- Add ClawRouter description in config_schema.json
- Add clawrouter to docs.json navigation (top-level providers)
- Add clawrouter to AI SDK PROVIDER_MAP
- Add Wallet & Payment Setup section to clawrouter.mdx
- Document payment tiers (free/eco/auto)
- Add wallet funding instructions (Solana/Base USDC)
- Add spend control configuration
- Update VS Code schema description with wallet info
- Update provider longDescription with payment options
- Add blockrun/premium routing profile (mission-critical tasks)
- Add dual-chain wallet support docs (Base EVM + Solana)
- Add model exclusion documentation
- Update routing profiles table with savings percentages
- Update comparison table with auth/payment differences
- Total 44+ models, 4 routing tiers
- Add ClawRouter.vitest.ts (core/llm/llms)
  - Provider name verification
  - Default options validation
  - Reasoning field support
  - User-Agent header verification
  - Routing profiles acceptance

- Add ClawRouter.test.ts (openai-adapters)
  - Default apiBase
  - Custom apiBase override
  - Continue headers
  - OpenAI standard headers

- Add clawrouter tests to toolSupport.test.ts
  - blockrun/* routing profiles
  - Tool-supporting model patterns
@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 24, 2026

Additional Context: Related Issues This PR Helps Address

ClawRouter's automatic routing and fallback capabilities can help address several open issues:

Rate Limiting (429 errors)

Payment Required (402 errors)

ClawRouter uses USDC micropayments via x402 protocol — wallet-based authentication means no API key management, and automatic payment handling prevents 402 errors.

How ClawRouter Addresses These

Request → Model fails (429/402) → Automatic fallback → Next model in tier → Response

The 15-dimension routing also helps prevent these issues proactively by:

  • Distributing simple requests to cheaper/less-loaded models
  • Reserving premium API quotas for complex tasks that need them

Users experiencing these issues today can use blockrun/auto as their model to get automatic resilience.

- Add 'Switching Between Routing Profiles' section with full examples
- Add /model command tip for quick switching
- Add 'Error Handling' section comparing Continue vs ClawRouter
- Document automatic error recovery (429, 402, 500+, timeout)
- Add response header documentation for diagnostics
- Add AI-powered doctor command for troubleshooting
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file (changes from recent commits).

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="docs/customize/model-providers/top-level/clawrouter.mdx">

<violation number="1" location="docs/customize/model-providers/top-level/clawrouter.mdx:184">
P2: JSON profile-switching example is inconsistent with the section guidance because it omits the `blockrun/free` profile present in YAML.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Need to add to PROVIDER_HANDLES_TEMPLATING, PROVIDER_SUPPORTS_IMAGES, etc if applicable
    and see comments, can merge with requested changes!

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This icon is too large, could you make it a small PNG icon?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Resized to 64x64 (1.6KB), matching other provider logos in the directory.

@github-project-automation github-project-automation bot moved this from Todo to In Progress in Issues and PRs Mar 24, 2026
@RomneyDa
Copy link
Copy Markdown
Contributor

Also note merge conflicts

@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 25, 2026

@RomneyDa All requested changes addressed:

  • Docs moved to /moreclawrouter.mdx now in model-providers/more/, updated docs.json and overview.mdx references
  • Logo resized — 64x64 PNG (1.6KB), consistent with other provider logos
  • Merge conflicts resolved — rebased on latest main, kept both MiniMax and ClawRouter models
  • Provider constants — confirmed clawrouter is registered in PROVIDER_HANDLES_TEMPLATING, PROVIDER_SUPPORTS_IMAGES, and PROVIDER_TOOL_SUPPORT

Let me know if anything else needs updating!

Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The icon still looks funky although size issue is fixed, could you address?

Copy link
Copy Markdown
Contributor Author

@1bcMax 1bcMax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the logo with our official brand kit version (128x128, higher resolution). Should look clean now — let me know if it works!

Copy link
Copy Markdown
Contributor

@RomneyDa RomneyDa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@1bcMax thanks for the contribution!

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Mar 26, 2026
@RomneyDa RomneyDa merged commit becda53 into continuedev:main Mar 26, 2026
53 of 65 checks passed
@github-project-automation github-project-automation bot moved this from In Progress to Done in Issues and PRs Mar 26, 2026
@github-actions github-actions bot locked and limited conversation to collaborators Mar 26, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

lgtm This PR has been approved by a maintainer size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add ClawRouter as a provider for cost-optimized model routing

2 participants