Skip to content

Instantly share code, notes, and snippets.

@VictorXLR
Created April 27, 2026 05:12
Show Gist options
  • Select an option

  • Save VictorXLR/4f55d904e8056a8c9206a15fac61d9c8 to your computer and use it in GitHub Desktop.

Select an option

Save VictorXLR/4f55d904e8056a8c9206a15fac61d9c8 to your computer and use it in GitHub Desktop.
Claude with Qwen3.6-A3B
#!/usr/bin/env bash
# Run Claude Code against a local llama-server.
#
# Assumes you've already started llama-server yourself on $PORT (default 8080).
# llama.cpp's /v1/messages endpoint speaks the Anthropic Messages API directly,
# so Claude Code can talk to it with no proxy. (Added in llama.cpp PR #17570.)
#
# Usage:
# ./run-claude-local.sh # connect to 127.0.0.1:8080
# PORT=9090 ./run-claude-local.sh # different port
# HOST=192.168.1.5 ./run-claude-local.sh
#
# NOTE: CLAUDE_CODE_ATTRIBUTION_HEADER must be set in ~/.claude/settings.json
# (shell exports are ignored for that var when ANTHROPIC_BASE_URL is set):
# { "env": { "CLAUDE_CODE_ATTRIBUTION_HEADER": "0" } }
set -euo pipefail
PORT="${PORT:-8080}"
HOST="${HOST:-127.0.0.1}"
ALIAS="${ALIAS:-local-model}"
command -v claude >/dev/null || { echo "claude not found in PATH" >&2; exit 1; }
if ! curl -fsS "http://$HOST:$PORT/v1/models" >/dev/null 2>&1 \
&& ! curl -fsS "http://$HOST:$PORT/health" >/dev/null 2>&1; then
echo "No server responding at http://$HOST:$PORT — start llama-server first." >&2
exit 1
fi
export ANTHROPIC_BASE_URL="http://$HOST:$PORT"
export ANTHROPIC_AUTH_TOKEN="${ANTHROPIC_AUTH_TOKEN:-sk-local-dummy}"
export ANTHROPIC_MODEL="${ANTHROPIC_MODEL:-$ALIAS}"
# Route the small/fast model to the same local server so topic naming,
# summarization, and other Haiku-tier calls don't leak to api.anthropic.com.
export ANTHROPIC_SMALL_FAST_MODEL="${ANTHROPIC_SMALL_FAST_MODEL:-$ALIAS}"
# Kill telemetry/statsig/update probes that hit api.anthropic.com regardless
# of ANTHROPIC_BASE_URL and inject volatile state into requests.
export CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC=1
export DISABLE_TELEMETRY=1
export DISABLE_ERROR_REPORTING=1
export DISABLE_AUTOUPDATER=1
export DISABLE_BUG_COMMAND=1
export CLAUDE_CODE_DISABLE_BACKGROUND_TASKS=1
echo "Launching Claude Code → $ANTHROPIC_BASE_URL (model: $ANTHROPIC_MODEL)"
exec claude "$@"
{
"env": {
"CLAUDE_CODE_ATTRIBUTION_HEADER": "0"
},
"model": "opus",
"statusLine": {
"type": "command",
"command": "input=$(cat); printf \"⏰ %s | 👤 %s | 🤖 %s\" \"$(date +%H:%M:%S)\" \"$(whoami)\" \"$(echo \"$input\" | jq -r '.model.display_name')\""
},
"enabledPlugins": {
"swift-lsp@claude-plugins-official": true,
"clangd-lsp@claude-plugins-official": true,
"rust-analyzer-lsp@claude-plugins-official": true
},
"effortLevel": "medium"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment