#!/usr/bin/env bash # shellcheck disable=SC2034 # variables consumed by lib/common.sh # lcclaude — launch Claude Code on Meituan LongCat's Anthropic-compatible API. # # Uses the official LongCat Anthropic-compatible endpoint: # https://api.longcat.chat/anthropic # # LongCat-2.0 is a 1.6T-param MoE model with native 1M context, built entirely # on Chinese-manufactured compute. It ranked #2 globally in Claude Code monthly # call volume on OpenRouter (behind only Claude Opus 4.8). # # Reads LONGCAT_API_KEY from the environment first, then falls back to # ~/.zshrc / ~/.bashrc / ~/.bash_profile / ~/.profile if not already exported. # # Quick start (no install needed): # chmod +x lcclaude # ./lcclaude # # Optional — make it globally available: # sudo mv lcclaude /usr/local/bin/ && sudo chmod +x /usr/local/bin/lcclaude # # Use: # lcclaude # start on LongCat-2.0 (flagship) # lcclaude fast # start on LongCat-Flash-Chat (cheaper / faster) # lcclaude think # start on LongCat-Flash-Thinking (deep reasoning) # lcclaude long # request 1M context window (native support) # lcclaude effort max # set reasoning effort (low|medium|high|xhigh|max) # lcclaude update # git pull latest from this repo # lcclaude --help # any remaining flag is forwarded to claude # # Optional env overrides: # LONGCAT_MODEL=LongCat-2.0 # main model # LONGCAT_FLASH_MODEL=LongCat-Flash-Chat # flash / haiku / subagent tier # LONGCAT_BASE_URL=https://.../anthropic # custom Anthropic-compatible base URL # LONGCAT_CTX=1048576 # max context tokens (defaults to 1M with `long`) # LONGCAT_OUTPUT=8000 # cap output tokens # LONGCAT_EFFORT=max # CLAUDE_CODE_EFFORT_LEVEL # # In-session switch: # /model LongCat-Flash-Chat # switch to the fast tier # /model LongCat-Flash-Thinking # switch to thinking tier # /model LongCat-2.0 # switch back to flagship # # Get your free API key (public beta — 500K tokens/day free): # https://longcat.chat/platform # set -euo pipefail # Resolve symlink to find the real script directory. _SELF="$0" if [ -L "$_SELF" ]; then _LINK="$(readlink "$_SELF")" case "$_LINK" in /*) _SELF="$_LINK" ;; *) _SELF="$(cd "$(dirname "$_SELF")" && pwd)/$_LINK" ;; esac fi SELF_DIR="$(cd "$(dirname "$_SELF")" && pwd)" if [ -f "$SELF_DIR/lib/common.sh" ]; then source "$SELF_DIR/lib/common.sh" elif [ -f "$SELF_DIR/../lib/common.sh" ]; then source "$SELF_DIR/../lib/common.sh" else echo "lcclaude: cannot find lib/common.sh. Reinstall or cd to repo." >&2; exit 1; fi check_version "lcclaude" "$@" PRO_MODEL="${LONGCAT_MODEL:-LongCat-2.0}" FLASH_MODEL="${LONGCAT_FLASH_MODEL:-LongCat-Flash-Chat}" THINK_MODEL="${LONGCAT_THINK_MODEL:-LongCat-Flash-Thinking}" if [ $# -gt 0 ] && [ "$1" = "update" ]; then do_update "lcclaude" "LCCLAUDE_HOME" fi API_KEY="$(resolve_api_key "LONGCAT_API_KEY")" if [ -z "$API_KEY" ]; then echo "❌ LONGCAT_API_KEY not found." >&2 echo " Add one line to ~/.zshrc or ~/.bashrc:" >&2 echo " export LONGCAT_API_KEY=lc-xxxxxxxxxxxxxxxxxx" >&2 echo " Get your free key at: https://longcat.chat/platform" >&2 exit 1 fi BASE_URL="${LONGCAT_BASE_URL:-https://api.longcat.chat/anthropic}" LONG_CTX=0 EFFORT="${LONGCAT_EFFORT:-}" MAIN_MODEL="$PRO_MODEL" while [ $# -gt 0 ]; do case "$1" in fast|flash) MAIN_MODEL="$FLASH_MODEL"; shift ;; think) MAIN_MODEL="$THINK_MODEL"; shift ;; long) LONG_CTX=1; shift ;; effort) case "${2:-}" in low|medium|high|xhigh|max) EFFORT="$2"; shift 2 ;; *) echo "lcclaude: invalid effort level '${2:-}'. Use: low medium high xhigh max" >&2; exit 1 ;; esac ;; --) shift; break ;; *) break ;; esac done # Surface the other model in the /model picker. if [ "$MAIN_MODEL" = "$PRO_MODEL" ]; then OTHER_MODEL="$FLASH_MODEL" OTHER_DESC="LongCat Flash Chat — fast / cheap tier" elif [ "$MAIN_MODEL" = "$FLASH_MODEL" ]; then OTHER_MODEL="$PRO_MODEL" OTHER_DESC="LongCat 2.0 — flagship reasoning" else OTHER_MODEL="$PRO_MODEL" OTHER_DESC="LongCat 2.0 — flagship reasoning" fi export_anthropic_base export CLAUDE_CODE_SUBAGENT_MODEL="$FLASH_MODEL" set_custom_model "$OTHER_MODEL" "$MAIN_MODEL" "$OTHER_DESC" CTX="${LONGCAT_CTX:-}" OUTPUT_CAP="${LONGCAT_OUTPUT:-}" apply_context_and_effort show_banner_and_launch "LongCat" "$@"