Receber por email
← Voltar para o catálogo

brewtools:provider-switch

Configure Claude Code alternative API providers — DeepSeek (priority), Z.ai/GLM, Qwen, MiniMax, OpenRouter. Creates shell aliases, manages API tokens, checks status. Triggers: 'provider', 'switch provider', 'alternative api', 'configure provider', 'claudeds', 'claudeglm', 'claudeqwen', 'openrouter setup', 'deepseek'.

28estrelas
Atualizado há 4 meses

Ver no GitHub ↗ Licença: NOASSERTION

Como adicionar

/plugin marketplace add kochetkov-ma/claude-brewcode

O comando exato pode variar conforme o repositório. Confira o README no GitHub.

Para o autor da skill

Cole no README do seu repo

Mostra que sua skill está catalogada na Skillteca, gera backlink e tráfego rastreável.

[![Skillteca](https://www.skillteca.com.br/api/badge/brewtools-provider-switch/svg)](https://www.skillteca.com.br/skills/brewtools-provider-switch)

Skills relacionadas

Ver todas de Automação →

Alerta por categoria

Receba novas skills de Automação toda segunda

1 email curto, só com as skills novas de Automação. 4 minutos de leitura, sem spam, cancela com 1 clique.

Você confirma o email no primeiro envio. Sem spam. Cancela com 1 clique.

Ler descrição completa

Provider Switch

Configure and switch between Claude Code alternative API providers — DeepSeek (priority), Z.ai/GLM, Qwen/DashScope, MiniMax, OpenRouter. Creates isolated shell aliases in ~/.zshrc.
DeepSeek V4 is the priority default (strongest Chinese open model, 1M context, Anthropic-compatible endpoint). Recommend it first in setup.

<instructions>

Robustness Rules (MANDATORY)

| Rule | Applies to | |------|-----------| | Every Bash call MUST end with && echo "OK ..." \|\| echo "FAILED ..." | ALL commands | | On FAILED — stop current phase, report error, DO NOT retry blindly | ALL phases | | Max 3 AskUserQuestion per phase | ALL phases | | NEVER write secrets to any file other than ~/.zshrc | ALL phases | | NEVER commit ~/.zshrc changes | ALL phases | | All comments in ~/.zshrc MUST be in ENGLISH | ALL writes |

Error Reporting

On ANY failure — before stopping — output:

SCRIPT_ERROR: <script-name or command>
PHASE: <current phase>
ACTION: <what was attempted>
SUGGESTION: <what user can try>

Phase 0: Language Selection

First interaction: Use AskUserQuestion:

Question: "Select language for this session / Выберите язык" Options:

  • "English (Recommended)"
  • "Russian / Русский"

Remember choice — all subsequent messages in selected language. Default if skipped: English.

Compatibility Flags (REQUIRED for this provider)

Alternative providers (Z.ai, MiniMax) implement Anthropic-compatible APIs but have incompatibilities that require Claude Code flags:

| Provider | Required Flags | Why | |----------|---------------|-----| | DeepSeek | None required | DeepSeek silently ignores beta/version headers; native Anthropic endpoint | | Z.ai (GLM) | CLAUDE_ENABLE_BYTE_WATCHDOG=0 + CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 | Z.ai rejects beta headers with error 1210; SSE format triggers byte watchdog | | MiniMax | CLAUDE_ENABLE_BYTE_WATCHDOG=0 + CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 | Same issues as Z.ai | | Qwen/DashScope | CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1 | Beta headers may be rejected; SSE works fine | | OpenRouter | None required | OpenRouter is an aggregator with good compatibility |

When constructing aliases (Step 6), ALWAYS include the compatibility flags from the provider's reference file.

Phase 1: Mode Detection

Skill arguments received: $ARGUMENTS

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/detect-mode.sh" "$ARGUMENTS" && echo "OK detect" || echo "FAILED detect"
STOP if FAILED — parse $ARGUMENTS manually as fallback (keyword matching).

Output format:

ARGS: [arguments received]
MODE: [detected mode]

Mode Reference

| Keyword in args | MODE | |-----------------|------| | status, check | status | | setup, configure | setup | | help, how | help | | deepseek, ds, dpsk | provider-deepseek | | glm, zai, z.ai | provider-glm | | qwen, dashscope | provider-qwen | | minimax, mini | provider-minimax | | openrouter, router | provider-openrouter | | verify, test, token | verify | | model-check, identify | model-check | | model-cehck (typo), cehck, hlpe, setuo | fuzzy match to correct mode | | (empty) | status |

Phase 2: Status Check (ALL modes)

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/check-status.sh" && echo "OK status" || echo "FAILED status"
STOP if FAILED — check ~/.zshrc manually with grep.

Parse output key=value pairs. Determine status per provider:

  • configured = ALIAS + KEY both true
  • partial = ALIAS true, KEY false
  • not configured = ALIAS false
  • active = ACTIVE_PROVIDER matches

Render status table to user:

# Provider Switch — [MODE]

## Current Status

| Provider | Alias | API Key | Model | Status |
|----------|-------|---------|-------|--------|
| DeepSeek (priority) | claudeds | DEEPSEEK_API_KEY | deepseek-v4-pro | ... |
| Z.ai / GLM | claudeglm | ZAI_API_KEY | glm-5.1 | ... |
| Qwen | claudeqwen | DASHSCOPE_API_KEY | qwen3.6-plus[1m] | ... |
| MiniMax | claudeminimax | MINIMAX_API_KEY | minimax-m2.7 | ... |
| OpenRouter | claudeor | OPENROUTER_API_KEY | (user-selected) | ... |

## How to Use
Run `claudeds` — sets env vars and launches Claude in one command (recommended default).
To return to Anthropic subscription: open a new terminal and run `claude`.

Auto-setup Logic (MODE = status only)

After rendering the status table, count configured providers (status = configured or active):

  • Zero configured → automatically proceed to Phase 3 (setup). Tell the user: "No providers configured yet. Starting setup..."
  • At least one configured → STOP here with status table. User will re-run with specific mode if needed.

If MODE = help — GOTO Phase 6.

Phase 3: Provider Selection

If MODE = setup (no specific provider):

Use AskUserQuestion:

Question: "Which providers do you want to configure?" Options:

  • "DeepSeek V4 (deepseek-v4-pro, 1M context, priority - Recommended)"
  • "Z.ai / GLM (glm-5.1, free models available)"
  • "Qwen / DashScope (qwen3.6-plus, 1M context)"
  • "MiniMax (minimax-m2.7, cheapest)"
  • "OpenRouter (aggregator, any model)"
  • "All providers"

If MODE = provider-\<name\> — skip to Phase 4 for that provider only.

Phase 4: Provider Configuration

For each selected provider, execute this sequence:

Step 1: Load Reference

Read the provider reference file using Read tool:

  • DeepSeek: references/deepseek.md
  • Z.ai/GLM: references/zai-glm.md
  • Qwen: references/qwen-dashscope.md
  • MiniMax: references/minimax.md
  • OpenRouter: references/openrouter.md

Also read references/common.md for shared alias structure (first time only).

Step 2: Initialize Section

Ensure the provider aliases section exists in ~/.zshrc:

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/write-alias.sh" init && echo "OK init" || echo "FAILED init"
STOP if FAILED — cannot write to ~/.zshrc.

Step 3: API Key

Check if key already set (from Phase 2 status output: KEY_ZAI, KEY_DASHSCOPE, KEY_MINIMAX, KEY_OPENROUTER).

If missing — Use AskUserQuestion:

Question: "Enter your <PROVIDER_NAME> API key (from <dashboard-url>):"

Qwen-specific callout: Before asking for the Qwen key, read references/qwen-dashscope.md section "## How to Get API Key" and show the user the step-by-step instructions. Warn that the key MUST be created in the Singapore region — other regions return 403. Valid format: sk-... (~40 chars). After receiving the key, validate format: if it starts with sk-ws- or is longer than 100 chars, warn the user it's likely from the wrong region and ask to regenerate.

Then write:

EXECUTE using Bash tool:

bash "${CLAUDE_SKILL_DIR}/scripts/write-alias.sh" set-key "KEY_VAR_NAME" "KEY_VALUE" && echo "OK set-key" || echo "FAILED set-key"

Replace KEY_VAR_NAME with: DEEPSEEK_API_KEY, ZAI_API_KEY, DASHSCOPE_API_KEY, MINIMAX_API_KEY, or OPENROUTER_API_KEY.

STOP if FAILED — report error.

Step 4: Model Selection (OpenRouter only)

If provider is OpenRouter, read references/openrouter-models.md for available models.

Use AskUserQuestion — pick ONE model (same model for all three roles):

Question: "Select model for OpenRouter:" Options:

  • "qwen/qwen3.6-plus[1m] — 1M context, top coding (Recommended)"
  • "z-ai/glm-5.1 — #1 SWE-bench Pro, 200K"
  • "qwen/qwen3-coder:free — free, 262K, code-focused"
  • "Custom (I will specify model ID)"

The selected model is set as OPUS, SONNET, and HAIKU simultaneously.

If "Custom": ask user for model ID, then VALIDATE it against OpenRouter API using the script from references/openrouter-models.md (## Model Validation section). If NOT_FOUND — show fuzzy suggestions from the API and re-ask. Max 2 retries, then fall back to default.

Step 5: Alias Name

Suggest a default alias name and let user customize via AskUserQuestion:

| Provider | Default name | |----------|-------------|

Compartilhar X LinkedIn