Compare commits
2 Commits
14b800e6fb
...
7a3f14fa48
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7a3f14fa48 | ||
|
|
797e8448af |
72
ai-setup.sh
72
ai-setup.sh
@@ -1044,6 +1044,76 @@ claude --dangerously-skip-permissions --system-prompt "$SYS_PROMPT" "$@"
|
||||
KIMIEOF
|
||||
chmod +x "$BIN_DIR/ai-kimi"
|
||||
|
||||
# === ai-openrouter ===
|
||||
cat > "$BIN_DIR/ai-openrouter" << 'OPENROUTEREOF'
|
||||
#!/usr/bin/env bash
|
||||
# ai-openrouter - запуск Claude Code через OpenRouter (любые модели)
|
||||
source "$HOME/.local/bin/ai-api-helpers.sh" 2>/dev/null || true
|
||||
|
||||
key_file="$HOME/.config/ai-setup/openrouter_key"
|
||||
api_key=""
|
||||
|
||||
[ -f "$key_file" ] && api_key=$(cat "$key_file")
|
||||
|
||||
if [ -n "$api_key" ]; then
|
||||
echo -n "Проверка сохранённого OpenRouter ключа... "
|
||||
_claude_test_openai_api "https://openrouter.ai/api/v1/chat/completions" "$api_key" "openai/gpt-4o-mini"
|
||||
_handle_openai_api_response "OpenRouter" "$_CLAUDE_TEST_CODE" "$_CLAUDE_TEST_BODY" "Пополните баланс: https://openrouter.ai/settings/credits"
|
||||
ret=$_API_RET
|
||||
if [ $ret -eq 401 ]; then
|
||||
rm -f "$key_file"
|
||||
api_key=""
|
||||
elif [ $ret -eq 429 ]; then
|
||||
echo -n "Продолжить всё равно? (запросы могут не проходить) [y/N] "
|
||||
read -r _ans; case "${_ans:-N}" in [Yy]*) ;; *) exit 1 ;; esac
|
||||
elif [ $ret -ne 0 ]; then
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ -z "$api_key" ]; then
|
||||
echo "Получить ключ: https://openrouter.ai/settings/keys"
|
||||
read -r -p "Введите ваш OpenRouter API ключ: " api_key
|
||||
[ -z "$api_key" ] && { echo "Выход."; exit 1; }
|
||||
|
||||
echo -n "Проверяю ключ и баланс... "
|
||||
_claude_test_openai_api "https://openrouter.ai/api/v1/chat/completions" "$api_key" "openai/gpt-4o-mini"
|
||||
_handle_openai_api_response "OpenRouter" "$_CLAUDE_TEST_CODE" "$_CLAUDE_TEST_BODY" "Пополните баланс: https://openrouter.ai/settings/credits"
|
||||
ret=$_API_RET
|
||||
if [ $ret -eq 0 ] || [ $ret -eq 429 ]; then
|
||||
mkdir -p "$(dirname "$key_file")"
|
||||
echo "$api_key" > "$key_file"
|
||||
chmod 600 "$key_file"
|
||||
echo "Ключ сохранён."
|
||||
if [ $ret -eq 429 ]; then
|
||||
echo -n "Продолжить всё равно? (запросы могут не проходить) [y/N] "
|
||||
read -r _ans; case "${_ans:-N}" in [Yy]*) ;; *) exit 1 ;; esac
|
||||
fi
|
||||
else
|
||||
echo "Ключ НЕ сохранён."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! command -v claude &>/dev/null; then
|
||||
echo "Ошибка: Claude Code не найден. Установите через npm:"
|
||||
echo " npm install -g @anthropic-ai/claude-code"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
SYS_PROMPT=$(_build_ai_sys_prompt)
|
||||
ANTHROPIC_BASE_URL=https://openrouter.ai/api \
|
||||
ANTHROPIC_AUTH_TOKEN="$api_key" \
|
||||
ANTHROPIC_MODEL=openai/gpt-5.5 \
|
||||
ANTHROPIC_DEFAULT_OPUS_MODEL=anthropic/claude-4.8-opus \
|
||||
ANTHROPIC_DEFAULT_SONNET_MODEL=anthropic/claude-4.6-sonnet \
|
||||
ANTHROPIC_DEFAULT_HAIKU_MODEL=openai/gpt-5.5 \
|
||||
CLAUDE_CODE_SUBAGENT_MODEL=openai/gpt-5.5 \
|
||||
CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 \
|
||||
claude --dangerously-skip-permissions --system-prompt "$SYS_PROMPT" "$@"
|
||||
OPENROUTEREOF
|
||||
chmod +x "$BIN_DIR/ai-openrouter"
|
||||
|
||||
# === ai-gemini ===
|
||||
cat > "$BIN_DIR/ai-gemini" << 'GEMINIEOF'
|
||||
#!/usr/bin/env bash
|
||||
@@ -1102,6 +1172,7 @@ if [ "$USE_VLESS" -eq 1 ]; then
|
||||
sed -i 's/^exec "\$codex_bin"/exec proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" "\$codex_bin"/' "$BIN_DIR/ai-gpt"
|
||||
sed -i 's/^claude --dangerously-skip-permissions/proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" claude --dangerously-skip-permissions/' "$BIN_DIR/ai-deepseek"
|
||||
sed -i 's/^claude --dangerously-skip-permissions/proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" claude --dangerously-skip-permissions/' "$BIN_DIR/ai-kimi"
|
||||
sed -i 's/^claude --dangerously-skip-permissions/proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" claude --dangerously-skip-permissions/' "$BIN_DIR/ai-openrouter"
|
||||
sed -i 's/^\([[:space:]]*\)exec "\$agy_bin"/\1exec proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" "\$agy_bin"/' "$BIN_DIR/ai-gemini"
|
||||
sed -i 's/^exec claude/exec proxychains4 -f "\$HOME\/\.proxychains-xray\.conf" claude/' "$BIN_DIR/ai-claude"
|
||||
success "proxychains4 интегрирован"
|
||||
@@ -1123,6 +1194,7 @@ echo -e " ${CYAN}ai-claude${NC} - Оригинальный Claude Code
|
||||
echo -e " ${CYAN}ai-gpt${NC} - OpenAI Codex (нативный CLI, автоустановка)"
|
||||
echo -e " ${CYAN}ai-deepseek${NC} - DeepSeek (API ключ сохраняется)"
|
||||
echo -e " ${CYAN}ai-kimi${NC} - Kimi K2.6 (через Claude Code, API ключ сохраняется)"
|
||||
echo -e " ${CYAN}ai-openrouter${NC} - OpenRouter (через Claude Code, любые модели)"
|
||||
echo -e " ${CYAN}ai-gemini${NC} - Gemini (нативный agy CLI, автоустановка)"
|
||||
echo ""
|
||||
echo -e "${YELLOW}⚠️ Для Gemini используйте отдельный Google-аккаунт!${NC}"
|
||||
|
||||
Reference in New Issue
Block a user