Created
March 20, 2026 16:10
-
-
Save Incipiens/9f70ce27d9fa4c39bca9fafcb6ef2753 to your computer and use it in GitHub Desktop.
This is my script that I use for launching an instance of Claude Code using my local LLM, and it was written for an XDA article. Save it, edit the IP and port, and mark as executable to use.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # lcc - Local Claude Code launcher | |
| # Points Claude Code at a local LLM served by llama.cpp on your GB10 device | |
| # | |
| # Usage: | |
| # lcc <modelname> — launch Claude Code with the specified model | |
| # lcc <modelname> [args] — pass additional arguments to claude | |
| # lcc — show help/launch with model if one is available | |
| # | |
| # Prerequisites: | |
| # - Claude Code installed | |
| # - LLM provider with Anthropic Messages API support | |
| # - jq (for model auto-detection) | |
| # | |
| # | |
| # Configuration: change if needed: | |
| LCC_HOST="${LCC_HOST:-192.168.1.179}" # This is my server IP, you should change to your most commonly used | |
| LCC_PORT="${LCC_PORT:-8000}" | |
| LCC_BASE_URL="http://${LCC_HOST}:${LCC_PORT}" | |
| # ANSI color codes | |
| RED='\033[0;31m' | |
| GREEN='\033[0;32m' | |
| YELLOW='\033[1;33m' | |
| BLUE='\033[0;34m' | |
| MAGENTA='\033[0;35m' | |
| CYAN='\033[0;36m' | |
| WHITE='\033[1;37m' | |
| NC='\033[0m' | |
| BOLD='\033[1m' | |
| # No model argument, show help and check server | |
| if [[ -z "$1" ]]; then | |
| echo -e "${BOLD}Local Claude Code${NC} (${CYAN}GB10 @ ${LCC_HOST}:${LCC_PORT}${NC})" | |
| echo "" | |
| # Check if server is reachable | |
| if curl -sf "${LCC_BASE_URL}/health" > /dev/null 2>&1; then | |
| echo -e "${GREEN} llama-server is running${NC}" | |
| # Try to get the loaded model name from /v1/models | |
| MODEL_INFO=$(curl -sf "${LCC_BASE_URL}/v1/models" 2>/dev/null) | |
| if [[ -n "$MODEL_INFO" ]]; then | |
| # Check for jq | |
| if ! command -v jq &>/dev/null; then | |
| echo "" | |
| echo -e "${YELLOW} jq not found; install it for model auto-detection${NC}" | |
| else | |
| echo "" | |
| echo -e "${WHITE}Loaded model(s):${NC}" | |
| MODEL_COUNT=$(echo "$MODEL_INFO" | jq '.data | length') | |
| # Store models in an array | |
| MODELS=() | |
| while IFS= read -r line; do | |
| MODELS+=("$line") | |
| done < <(echo "$MODEL_INFO" | jq -r '.data[].id') | |
| # Print models with numbering | |
| for i in "${!MODELS[@]}"; do | |
| if [[ "$MODEL_COUNT" -eq 1 ]]; then | |
| echo -e " ${GREEN}${NC} ${BOLD}${MODELS[$i]}${NC}" | |
| else | |
| echo -e " ${WHITE}$((i+1)).${NC} ${MODELS[$i]}" | |
| fi | |
| done | |
| # If exactly one model, use it | |
| if [[ "$MODEL_COUNT" -eq 1 ]]; then | |
| MODEL="${MODELS[0]}" | |
| echo "" | |
| echo -e "${CYAN}Automatic model selection:${NC} Using ${BOLD}${MODEL}${NC}" | |
| echo "" | |
| echo -e "${GREEN} Launching Claude Code...${NC}" | |
| export ANTHROPIC_BASE_URL="${LCC_BASE_URL}" | |
| export ANTHROPIC_AUTH_TOKEN="local" | |
| export ANTHROPIC_API_KEY="" | |
| export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 | |
| exec claude --model "$MODEL" "$@" | |
| fi | |
| fi | |
| fi | |
| else | |
| echo -e "${RED} Cannot reach llama-server at ${LCC_BASE_URL}${NC}" | |
| echo "" | |
| echo "" | |
| echo -e "${WHITE}Make sure you're using an LLM provider that supports${NC}" | |
| echo -e " ${CYAN}the Anthropic Messages API (/v1/messages endpoint)${NC}" | |
| fi | |
| echo "" | |
| echo -e "${WHITE}Examples:${NC}" | |
| echo -e " ${GREEN}lcc qwen3-coder${NC}" | |
| echo -e " ${GREEN}lcc my-model -p${NC} # pass extra flags to claude" | |
| echo "" | |
| echo -e "${WHITE}Override host/port:${NC}" | |
| echo -e " ${CYAN}LCC_HOST=10.0.0.5 LCC_PORT=9090 lcc mymodel${NC}" | |
| exit 0 | |
| fi | |
| # Launch Claude Code with the specified model | |
| MODEL="$1" | |
| shift # remaining args pass through to claude | |
| echo -e "${GREEN}Launching${NC} ${BOLD}Claude Code${NC} ${CYAN}${LCC_HOST}:${LCC_PORT}${NC} / ${MAGENTA}${BOLD}${MODEL}${NC}" | |
| export ANTHROPIC_BASE_URL="${LCC_BASE_URL}" | |
| export ANTHROPIC_AUTH_TOKEN="local" | |
| export ANTHROPIC_API_KEY="" | |
| export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1 | |
| exec claude --model "$MODEL" "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment