Skip to content

feat: add ClawRouter provider + fix out-of-credits dialog API key guidance#11955

Open
1bcMax wants to merge 15 commits intocontinuedev:mainfrom
1bcMax:feat/clawrouter-provider
Open

feat: add ClawRouter provider + fix out-of-credits dialog API key guidance#11955
1bcMax wants to merge 15 commits intocontinuedev:mainfrom
1bcMax:feat/clawrouter-provider

Conversation

@1bcMax
Copy link
Copy Markdown
Contributor

@1bcMax 1bcMax commented Mar 29, 2026

Summary

  • Adds ClawRouter as a new LLM provider (pay-per-call via x402 micropayments)
  • Fixes the out-of-credits dialog (issue Error: Claude Sonnet 4.5 - 402 #11952): when a user hits a 402 from continue-proxy, they now see both a "Purchase Credits" option and an "Add API key secret" button with instructions to switch to the direct anthropic provider
  • Fixes string mismatch: StreamErrorDialog now matches both the legacy "You're out of credits!" and the current "You have no credits remaining on your Continue account" strings
  • Adds a generic 402 handler in errorAnalysis for non-proxy providers (e.g. DeepSeek insufficient balance)
  • Removes auto-retry on overloaded errors (was masking failures)
  • Adds component tests for OutOfCreditsDialog and StreamErrorDialog

Test plan

  • All 77 related tests pass (errorAnalysis, OutOfCreditsDialog, StreamErrorDialog)
  • Out-of-credits dialog shows both "Purchase Credits" and "Add API key secret" buttons
  • Switching provider from continue-proxy to anthropic with own API key resolves 402
  • ClawRouter provider connects and streams via x402

Closes #11952

🤖 Generated with Claude Code


Summary by cubic

Adds clawrouter as a new provider for automatic, cost-optimized model routing (OpenAI-compatible API at http://localhost:1337/v1/). Fixes the out-of-credits flow by showing purchase and API key options and handling generic 402s, resolving the loop in #11952.

  • New Features

    • New clawrouter provider with default apiBase http://localhost:1337/v1/, routing profiles (blockrun/auto, blockrun/eco, blockrun/premium, blockrun/free), reasoning/tool support, and Continue headers.
    • Integrated across core (llms, autodetect, tool support), openai-adapters/AiSdk, VS Code schema, GUI model presets, and docs.
  • Bug Fixes

    • Out-of-credits dialog now shows both "Purchase Credits" and "Add API key secret" with guidance to switch to anthropic; matches legacy and current copy.
    • Generic 402 handling for non-proxy providers and removal of auto-retry on "overloaded" errors to avoid masking failures.
    • Added tests for OutOfCreditsDialog, StreamErrorDialog, and clawrouter adapter/class.

Written for commit 266f984. Summary will update on new commits.

1bcMax added 14 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.
- 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
- 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
- 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
When users hit a 402 from continue-proxy, the dialog previously only
offered "Purchase Credits". Now it also surfaces an "Add API key secret"
button and explains how to switch to the direct `anthropic` provider,
fixing the loop described in issue continuedev#11952.

Also adds component tests for OutOfCreditsDialog and StreamErrorDialog
covering the 402/out-of-credits routing, customErrorMessage display,
and standard status code error branches.
@1bcMax 1bcMax requested a review from a team as a code owner March 29, 2026 05:09
@1bcMax 1bcMax requested review from sestinj and removed request for a team March 29, 2026 05:09
@dosubot dosubot bot added the size:XXL This PR changes 1000+ lines, ignoring generated files. label Mar 29, 2026
@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 29, 2026

Hey @sestinj @Patrick-Erichsen — just wanted to flag that we (@1bcMax) are committed to maintaining the code we've contributed here long-term. That includes the ClawRouter provider, the error handling improvements, and any related tests.

If anything we've shipped causes issues down the line — regressions, conflicts with new features, or anything else — please tag us and we'll handle it promptly. We're here to stay as reliable contributors, not just one-time submitters. 🙏

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 21 files

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="gui/src/pages/AddNewModel/configs/models.ts">

<violation number="1" location="gui/src/pages/AddNewModel/configs/models.ts:2695">
P2: `clawrouterPremium` is incorrectly flagged as open-source despite routing to proprietary models.</violation>
</file>

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

},
icon: "clawrouter.png",
providerOptions: ["clawrouter"],
isOpenSource: true,
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Mar 29, 2026

Choose a reason for hiding this comment

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

P2: clawrouterPremium is incorrectly flagged as open-source despite routing to proprietary models.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At gui/src/pages/AddNewModel/configs/models.ts, line 2695:

<comment>`clawrouterPremium` is incorrectly flagged as open-source despite routing to proprietary models.</comment>

<file context>
@@ -2679,6 +2679,61 @@ export const models: { [key: string]: ModelPackage } = {
+    },
+    icon: "clawrouter.png",
+    providerOptions: ["clawrouter"],
+    isOpenSource: true,
+  },
+  clawrouterFree: {
</file context>
Suggested change
isOpenSource: true,
isOpenSource: false,
Fix with Cubic

@1bcMax
Copy link
Copy Markdown
Contributor Author

1bcMax commented Mar 29, 2026

Hey @RomneyDa — thanks again for merging our previous PR (#11751)! Wanted to loop you in on this follow-up as well.

We're committed to maintaining all the code we've contributed long-term — ClawRouter provider, error handling improvements, and related tests. If anything causes issues down the line, tag us and we'll handle it promptly. 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XXL This PR changes 1000+ lines, ignoring generated files.

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Error: Claude Sonnet 4.5 - 402

1 participant